diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..1998cb4 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,30 @@ +name: .NET + +on: + push: + branches: + - "main" + - "develop" + pull_request: + branches: + - "main" + - "develop" + +jobs: + build: + + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml new file mode 100644 index 0000000..065fb28 --- /dev/null +++ b/.github/workflows/nuget.yml @@ -0,0 +1,26 @@ +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + build: + + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - run: | + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + git branch --remote --contains | grep origin/main + - run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV + - run: dotnet build --configuration Release /p:Version=${VERSION} + - run: dotnet test --configuration Release /p:Version=${VERSION} --no-build + - run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output . + - run: dotnet nuget push Podimo.ConstEmbed.${VERSION}.nupkg --source https://nuget.pkg.github.com/podimo/index.json --api-key ${GITHUB_TOKEN} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf9356e --- /dev/null +++ b/.gitignore @@ -0,0 +1,341 @@ +**/.DS_Store +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..5219208 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,12 @@ + + + + 10 + enable + true + + CS8785 + false + + + \ No newline at end of file diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..3b521e9 --- /dev/null +++ b/Justfile @@ -0,0 +1,25 @@ +# https://github.com/casey/just + +# Print generated types and their constants. +print-types: + dotnet run --nologo --verbosity=quiet --project examples/Podimo.ExampleConsoleApp + +# Print generated code. +print-code: + dotnet run --nologo --verbosity=quiet --project examples/Podimo.ExampleCodeGeneration + +# Run the tests. +test: + dotnet test --nologo --verbosity=quiet + +# List the contents of the generated nupkg. N.B.: Requires bash. +inspect: + #!/usr/bin/env bash + set -euo pipefail + my_tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'my_tmp_dir') # 1. Create temporary directory + dotnet pack --nologo --verbosity=quiet --output "${my_tmp_dir}" # 2. Put packages into directory + for x in "${my_tmp_dir}"/*.nupkg; do # 3. Iterate through all packages + mv -- "$x" "$x.zip" # 4. Set zip extension on packages + unzip -l "$x.zip" # 5. Use unzip to list the files + done + rm -rf "${my_tmp_dir}" # 6. Remove the directory diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..2d87a36 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Podimo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Podimo.ConstEmbed.sln b/Podimo.ConstEmbed.sln new file mode 100644 index 0000000..f745fdd --- /dev/null +++ b/Podimo.ConstEmbed.sln @@ -0,0 +1,69 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30323.103 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6C1DD0C1-2B34-4711-A19B-0D13F5CB369D}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + Justfile = Justfile + README.md = README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1FA07F37-FAFC-4A11-B0D7-FBEC5117B1E5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Podimo.ConstEmbed", "src\Podimo.ConstEmbed\Podimo.ConstEmbed.csproj", "{0D5EB089-BF2E-4168-B6FC-6F206E54C42F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E161277B-6B8D-4B2A-A83D-46CEBDE4EAC8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Podimo.ConstEmbedTests", "tests\Podimo.ConstEmbedTests\Podimo.ConstEmbedTests.csproj", "{5C5F32E7-D33A-420F-98BE-E269E75748B4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{F529D587-9BB8-4974-ABC1-0AD347F2CFAD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Podimo.ExampleConsoleApp", "examples\Podimo.ExampleConsoleApp\Podimo.ExampleConsoleApp.csproj", "{53E30252-5907-4AA5-8C0F-D98D5DBC07BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Podimo.ExampleCodeGeneration", "examples\Podimo.ExampleCodeGeneration\Podimo.ExampleCodeGeneration.csproj", "{490EAEC0-CBD0-4BED-BCBB-D6B566FA7970}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Podimo.ConstEmbedTestHelpers", "tests\Podimo.ConstEmbedTestHelpers\Podimo.ConstEmbedTestHelpers.csproj", "{A842477D-29BF-412F-BCA2-660EA7E54E82}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0D5EB089-BF2E-4168-B6FC-6F206E54C42F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D5EB089-BF2E-4168-B6FC-6F206E54C42F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D5EB089-BF2E-4168-B6FC-6F206E54C42F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D5EB089-BF2E-4168-B6FC-6F206E54C42F}.Release|Any CPU.Build.0 = Release|Any CPU + {5C5F32E7-D33A-420F-98BE-E269E75748B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C5F32E7-D33A-420F-98BE-E269E75748B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C5F32E7-D33A-420F-98BE-E269E75748B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C5F32E7-D33A-420F-98BE-E269E75748B4}.Release|Any CPU.Build.0 = Release|Any CPU + {53E30252-5907-4AA5-8C0F-D98D5DBC07BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53E30252-5907-4AA5-8C0F-D98D5DBC07BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53E30252-5907-4AA5-8C0F-D98D5DBC07BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53E30252-5907-4AA5-8C0F-D98D5DBC07BA}.Release|Any CPU.Build.0 = Release|Any CPU + {490EAEC0-CBD0-4BED-BCBB-D6B566FA7970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {490EAEC0-CBD0-4BED-BCBB-D6B566FA7970}.Debug|Any CPU.Build.0 = Debug|Any CPU + {490EAEC0-CBD0-4BED-BCBB-D6B566FA7970}.Release|Any CPU.ActiveCfg = Release|Any CPU + {490EAEC0-CBD0-4BED-BCBB-D6B566FA7970}.Release|Any CPU.Build.0 = Release|Any CPU + {A842477D-29BF-412F-BCA2-660EA7E54E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A842477D-29BF-412F-BCA2-660EA7E54E82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A842477D-29BF-412F-BCA2-660EA7E54E82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A842477D-29BF-412F-BCA2-660EA7E54E82}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E72B357-9E1E-43B5-9868-8D2B74CB2AF0} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0D5EB089-BF2E-4168-B6FC-6F206E54C42F} = {1FA07F37-FAFC-4A11-B0D7-FBEC5117B1E5} + {5C5F32E7-D33A-420F-98BE-E269E75748B4} = {E161277B-6B8D-4B2A-A83D-46CEBDE4EAC8} + {53E30252-5907-4AA5-8C0F-D98D5DBC07BA} = {F529D587-9BB8-4974-ABC1-0AD347F2CFAD} + {490EAEC0-CBD0-4BED-BCBB-D6B566FA7970} = {F529D587-9BB8-4974-ABC1-0AD347F2CFAD} + {A842477D-29BF-412F-BCA2-660EA7E54E82} = {E161277B-6B8D-4B2A-A83D-46CEBDE4EAC8} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index 66e584e..cefdec1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ # Podimo.ConstEmbed +This project is a [Source Generator](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) which generates constant strings from files at compile-time. + +## Using + +We use project files to control the generation of constants. +You can see how these are used in [Podimo.ExampleConsoleApp](examples/Podimo.ExampleConsoleApp/Podimo.ExampleConsoleApp.csproj). + +## License + +See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT). diff --git a/examples/Podimo.ExampleCodeGeneration/Podimo.ExampleCodeGeneration.csproj b/examples/Podimo.ExampleCodeGeneration/Podimo.ExampleCodeGeneration.csproj new file mode 100644 index 0000000..2852552 --- /dev/null +++ b/examples/Podimo.ExampleCodeGeneration/Podimo.ExampleCodeGeneration.csproj @@ -0,0 +1,23 @@ + + + + Exe + net6.0 + + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/examples/Podimo.ExampleCodeGeneration/Program.cs b/examples/Podimo.ExampleCodeGeneration/Program.cs new file mode 100644 index 0000000..da30294 --- /dev/null +++ b/examples/Podimo.ExampleCodeGeneration/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Podimo.ConstEmbedTestHelpers; + +var textOptions = new Dictionary +{ + [new TestAdditionalText("Text1", "content1")] = new TestAnalyzerConfigOptions( + new Dictionary + { + ["build_metadata.AdditionalFiles.ConstEmbed"] = "Text1", + }.ToImmutableDictionary() + ), + [new TestAdditionalText("Text2", "content2")] = TestAnalyzerConfigOptions.Empty, +}; + +var (diagnostics, output) = OutputGenerator.GetGeneratedOutput( + TestAnalyzerConfigOptions.Empty, + textOptions +); + +if (diagnostics.Length > 0) +{ + Console.WriteLine("Diagnostics:"); + foreach (var diagnostic in diagnostics) + { + Console.WriteLine(" " + diagnostic); + } + + Console.WriteLine(); + Console.WriteLine("Output:"); +} + +Console.WriteLine(output); \ No newline at end of file diff --git a/examples/Podimo.ExampleConsoleApp/Podimo.ExampleConsoleApp.csproj b/examples/Podimo.ExampleConsoleApp/Podimo.ExampleConsoleApp.csproj new file mode 100644 index 0000000..37652ac --- /dev/null +++ b/examples/Podimo.ExampleConsoleApp/Podimo.ExampleConsoleApp.csproj @@ -0,0 +1,39 @@ + + + + Exe + net6.0 + true + + false + + + + + + + + + + Podimo.ExampleConsoleApp.Generated + + public + + + + + + + + + + + + + + + + + + + diff --git a/examples/Podimo.ExampleConsoleApp/Program.cs b/examples/Podimo.ExampleConsoleApp/Program.cs new file mode 100644 index 0000000..def4da8 --- /dev/null +++ b/examples/Podimo.ExampleConsoleApp/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Linq; +using System.Reflection; + +// Enumerate all the generated types and constants, printing their names out to STDOUT. + +Console.WriteLine("Enumerating types..."); +var types = AppDomain.CurrentDomain + .GetAssemblies() + .SelectMany(t => t.GetTypes()) + .Where(t => t.IsClass && t.Namespace == "Podimo.ExampleConsoleApp.Generated") + .ToArray(); + +Console.WriteLine($"Number of types found: {types.Length}"); + +foreach (var t in types) +{ + Console.WriteLine( + $"{t.FullName} ({(t.Attributes & (TypeAttributes.Public | TypeAttributes.NotPublic)).ToString()})" + ); + var members = t.GetMembers(bindingAttr: BindingFlags.Static | BindingFlags.Public); + foreach (var member in members) + { + Console.WriteLine($"{t.FullName}.{member.Name}"); + } +} \ No newline at end of file diff --git a/examples/Podimo.ExampleConsoleApp/SQL/SELECT.sql b/examples/Podimo.ExampleConsoleApp/SQL/SELECT.sql new file mode 100644 index 0000000..a4000f4 --- /dev/null +++ b/examples/Podimo.ExampleConsoleApp/SQL/SELECT.sql @@ -0,0 +1,3 @@ +SELECT * +FROM some.table +WHERE val = "Example" \ No newline at end of file diff --git a/examples/Podimo.ExampleConsoleApp/YAML/KeyVal.yaml b/examples/Podimo.ExampleConsoleApp/YAML/KeyVal.yaml new file mode 100644 index 0000000..14231c4 --- /dev/null +++ b/examples/Podimo.ExampleConsoleApp/YAML/KeyVal.yaml @@ -0,0 +1 @@ +Key: Val \ No newline at end of file diff --git a/examples/Podimo.ExampleConsoleApp/YAML/List.yaml b/examples/Podimo.ExampleConsoleApp/YAML/List.yaml new file mode 100644 index 0000000..b4135da --- /dev/null +++ b/examples/Podimo.ExampleConsoleApp/YAML/List.yaml @@ -0,0 +1,3 @@ +- One +- Two +- Three \ No newline at end of file diff --git a/src/Podimo.ConstEmbed/AnalyzerReleases.Shipped.md b/src/Podimo.ConstEmbed/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Podimo.ConstEmbed/AnalyzerReleases.Unshipped.md b/src/Podimo.ConstEmbed/AnalyzerReleases.Unshipped.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Podimo.ConstEmbed/ConstEmbedGenerator.cs b/src/Podimo.ConstEmbed/ConstEmbedGenerator.cs new file mode 100644 index 0000000..cdc4569 --- /dev/null +++ b/src/Podimo.ConstEmbed/ConstEmbedGenerator.cs @@ -0,0 +1,53 @@ +using System.IO; +using System.Linq; +using Microsoft.CodeAnalysis; + +namespace Podimo.ConstEmbed; + +[Generator] +public class ConstEmbedGenerator : IIncrementalGenerator +{ + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var globalOptions = context.AnalyzerConfigOptionsProvider.Select(static (provider, _) => + ( + Namespace: provider.GetGlobalOptionOrDefault("ConstEmbedNamespace", "Podimo.ConstEmbed"), + Visibility: provider.GetGlobalOptionOrDefault("ConstEmbedVisibility", "internal") + )); + + var additionalFiles = + context.AdditionalTextsProvider + .Combine(context.AnalyzerConfigOptionsProvider) + .Select(static (pair, token) => + { + var @class = pair.Right.GetAdditionalFileMetadata(pair.Left, "ConstEmbed"); + return (Class: @class, File: pair.Left); + }) + .Where(static pair => pair.Class is not null); + + var combined = additionalFiles.Combine(globalOptions); + + context.RegisterSourceOutput(combined, static (spc, pair) => + { + var @namespace = pair.Right.Namespace; + var visibility = pair.Right.Visibility; + var @class = pair.Left.Class; + var file = pair.Left.File; + var filename = Path.GetFileNameWithoutExtension(file.Path); + var escapedContent = file + .GetText()? + .ToString()? + .Replace("\"", "\"\""); + + spc.AddSource( + hintName: $"{@class}.{filename}.g.cs", + source: $@"namespace {@namespace} +{{ + {visibility} static partial class {@class} + {{ + public const string {filename} = @""{escapedContent}""; + }} +}}"); + }); + } +} \ No newline at end of file diff --git a/src/Podimo.ConstEmbed/Podimo.ConstEmbed.csproj b/src/Podimo.ConstEmbed/Podimo.ConstEmbed.csproj new file mode 100644 index 0000000..435d150 --- /dev/null +++ b/src/Podimo.ConstEmbed/Podimo.ConstEmbed.csproj @@ -0,0 +1,51 @@ + + + + netstandard2.0 + true + + NU5128 + + false + + + + Podimo.ConstEmbed + Source Generators;Source Generator;Incremental;Embedding;Constants;Constant;Const + 1.0.0 + Podimo + Podimo + git + https://github.com/podimo/Podimo.ConstEmbed + Podimo.ConstEmbed - Compile-time file embedding as string constants. + + A source generator that turns additional files into file constants in a generated namespace. + This is an alternative approach to embedding files in C# source manually, + or loading them manually as embedded resources via reflection. + With ConstEmbed, you will never have to see a runtime error because you mistyped the name, + as the constants are evaluated at compile-time. + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/src/Podimo.ConstEmbed/ProviderExtensions.cs b/src/Podimo.ConstEmbed/ProviderExtensions.cs new file mode 100644 index 0000000..b8d9305 --- /dev/null +++ b/src/Podimo.ConstEmbed/ProviderExtensions.cs @@ -0,0 +1,30 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Podimo.ConstEmbed; + +public static class ProviderExtensions +{ + public static string GetGlobalOptionOrDefault( + this AnalyzerConfigOptionsProvider provider, + string name, + string @default) + { + provider.GlobalOptions.TryGetValue($"build_property.{name}", out var value); + + return value ?? @default; + } + + public static string? GetAdditionalFileMetadata( + this AnalyzerConfigOptionsProvider provider, + AdditionalText file, + string name) + { + provider.GetOptions(file) + .TryGetValue( + $"build_metadata.AdditionalFiles.{name}", + out var value + ); + return value; + } +} \ No newline at end of file diff --git a/src/Podimo.ConstEmbed/build/Podimo.ConstEmbed.props b/src/Podimo.ConstEmbed/build/Podimo.ConstEmbed.props new file mode 100644 index 0000000..7445555 --- /dev/null +++ b/src/Podimo.ConstEmbed/build/Podimo.ConstEmbed.props @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/tests/Podimo.ConstEmbedTestHelpers/OutputGenerator.cs b/tests/Podimo.ConstEmbedTestHelpers/OutputGenerator.cs new file mode 100644 index 0000000..67f3ef7 --- /dev/null +++ b/tests/Podimo.ConstEmbedTestHelpers/OutputGenerator.cs @@ -0,0 +1,45 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; +using Podimo.ConstEmbed; + +namespace Podimo.ConstEmbedTestHelpers; + +public static class OutputGenerator +{ + public static (ImmutableArray, string) GetGeneratedOutput( + AnalyzerConfigOptions globalOptions, + Dictionary textOptions + ) + { + var compilation = CSharpCompilation.Create( + assemblyName: null, + options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) + ); + + var diagnostics = compilation.GetDiagnostics(); + + if (diagnostics.Any()) + { + return (diagnostics, ""); + } + + var generator = new ConstEmbedGenerator(); + + CSharpGeneratorDriver + .Create(generator) + .AddAdditionalTexts(textOptions.Keys.ToImmutableArray()) + .WithUpdatedAnalyzerConfigOptions(newOptions: new TestAnalyzerConfigOptionsProvider( + globalOptions: globalOptions, + textOptions: textOptions + )) + .RunGeneratorsAndUpdateCompilation( + compilation, + out var outputCompilation, + out var generateDiagnostics + ); + + return (generateDiagnostics, outputCompilation.SyntaxTrees.Last().ToString()); + } +} \ No newline at end of file diff --git a/tests/Podimo.ConstEmbedTestHelpers/Podimo.ConstEmbedTestHelpers.csproj b/tests/Podimo.ConstEmbedTestHelpers/Podimo.ConstEmbedTestHelpers.csproj new file mode 100644 index 0000000..35190f4 --- /dev/null +++ b/tests/Podimo.ConstEmbedTestHelpers/Podimo.ConstEmbedTestHelpers.csproj @@ -0,0 +1,20 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + diff --git a/tests/Podimo.ConstEmbedTestHelpers/TestAdditionalText.cs b/tests/Podimo.ConstEmbedTestHelpers/TestAdditionalText.cs new file mode 100644 index 0000000..013a6de --- /dev/null +++ b/tests/Podimo.ConstEmbedTestHelpers/TestAdditionalText.cs @@ -0,0 +1,21 @@ +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; + +namespace Podimo.ConstEmbedTestHelpers; + +public class TestAdditionalText : AdditionalText +{ + private readonly SourceText _content; + + public TestAdditionalText(string path, string content) + { + if (content == null) throw new ArgumentNullException(nameof(content)); + Path = path ?? throw new ArgumentNullException(nameof(path)); + _content = SourceText.From(content, Encoding.UTF8); + } + + public override string Path { get; } + + public override SourceText GetText(CancellationToken cancellationToken = default) => _content; +} \ No newline at end of file diff --git a/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptions.cs b/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptions.cs new file mode 100644 index 0000000..a293388 --- /dev/null +++ b/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptions.cs @@ -0,0 +1,21 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Podimo.ConstEmbedTestHelpers; + +public class TestAnalyzerConfigOptions : AnalyzerConfigOptions +{ + private readonly IImmutableDictionary _options; + + public TestAnalyzerConfigOptions(IImmutableDictionary options) + { + _options = options ?? throw new ArgumentNullException(nameof(options)); + } + + public static TestAnalyzerConfigOptions Empty => new(ImmutableDictionary.Empty); + + public override bool TryGetValue(string key, out string value) + { + return _options.TryGetValue(key, out value!); + } +} \ No newline at end of file diff --git a/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptionsProvider.cs b/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptionsProvider.cs new file mode 100644 index 0000000..f531a82 --- /dev/null +++ b/tests/Podimo.ConstEmbedTestHelpers/TestAnalyzerConfigOptionsProvider.cs @@ -0,0 +1,32 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Podimo.ConstEmbedTestHelpers; + +public class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider +{ + private readonly ImmutableDictionary _textOptions; + + public TestAnalyzerConfigOptionsProvider(AnalyzerConfigOptions globalOptions, + IEnumerable> textOptions) + { + GlobalOptions = globalOptions ?? throw new ArgumentNullException(nameof(globalOptions)); + _textOptions = textOptions?.ToImmutableDictionary() ?? throw new ArgumentNullException(nameof(textOptions)); + } + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) + { + throw new NotSupportedException("GetOptions for SyntaxTree not supported."); + } + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) + { + if (_textOptions.TryGetValue(textFile, out var options)) + return options; + + return TestAnalyzerConfigOptions.Empty; + } + + public override AnalyzerConfigOptions GlobalOptions { get; } +} \ No newline at end of file diff --git a/tests/Podimo.ConstEmbedTests/Podimo.ConstEmbedTests.csproj b/tests/Podimo.ConstEmbedTests/Podimo.ConstEmbedTests.csproj new file mode 100644 index 0000000..3090226 --- /dev/null +++ b/tests/Podimo.ConstEmbedTests/Podimo.ConstEmbedTests.csproj @@ -0,0 +1,35 @@ + + + + net6.0 + + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/tests/Podimo.ConstEmbedTests/Tests.cs b/tests/Podimo.ConstEmbedTests/Tests.cs new file mode 100644 index 0000000..364db48 --- /dev/null +++ b/tests/Podimo.ConstEmbedTests/Tests.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Podimo.ConstEmbedTestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Podimo.ConstEmbedTests +{ + public class Tests + { + private readonly ITestOutputHelper _output; + + public Tests(ITestOutputHelper output) + { + _output = output; + } + + [Fact] + public void ConstEmbedGenerator_ProducesExpectedFile_WithDefaults() + { + var globalOptions = TestAnalyzerConfigOptions.Empty; + var textOptions = new Dictionary + { + [new TestAdditionalText("Text1", "content1")] = new TestAnalyzerConfigOptions( + new Dictionary + { + ["build_metadata.AdditionalFiles.ConstEmbed"] = "Text1", + }.ToImmutableDictionary()), + [new TestAdditionalText("Text2", "content2")] = TestAnalyzerConfigOptions.Empty, + }; + + var (diagnostics, output) = OutputGenerator.GetGeneratedOutput( + globalOptions, + textOptions + ); + + _output.WriteLine(output); + + Assert.Empty(diagnostics); + Assert.Contains("namespace Podimo.ConstEmbed", output); + Assert.Contains("internal", output); + Assert.Contains("Text1", output); + Assert.Contains("content1", output); + Assert.DoesNotContain("Text2", output); + Assert.DoesNotContain("content2", output); + } + + [Fact] + public void ConstEmbedGenerator_ProducesExpectedNamespaceAndVisibility_WithGlobalOptionsSet() + { + var globalOptions = new TestAnalyzerConfigOptions(new Dictionary + { + ["build_property.ConstEmbedNamespace"] = "Different.Namespace", + ["build_property.ConstEmbedVisibility"] = "public", + }.ToImmutableDictionary()); + + var textOptions = new Dictionary + { + [new TestAdditionalText("Text1", "content1")] = new TestAnalyzerConfigOptions( + new Dictionary + { + ["build_metadata.AdditionalFiles.ConstEmbed"] = "Text1", + }.ToImmutableDictionary()), + [new TestAdditionalText("Text2", "content2")] = TestAnalyzerConfigOptions.Empty, + }; + + var (diagnostics, output) = OutputGenerator.GetGeneratedOutput( + globalOptions, + textOptions + ); + + _output.WriteLine(output); + + Assert.Empty(diagnostics); + Assert.Contains("namespace Different.Namespace", output); + Assert.Contains("public", output); + Assert.Contains("Text1", output); + Assert.Contains("content1", output); + Assert.DoesNotContain("Text2", output); + Assert.DoesNotContain("content2", output); + } + } +} \ No newline at end of file