Skip to content

Commit

Permalink
Add C# source generator for docopt text files (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Sep 13, 2021
1 parent fe4c9e6 commit a8bcd5e
Show file tree
Hide file tree
Showing 62 changed files with 2,573 additions and 116 deletions.
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
<LangVersion>9</LangVersion>
<Nullable>warnings</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!--
> [CS8785] warning is emitted if a source generator failed to produce output
> due to an exception and there are no generated files. Since the warning
> is easy to miss among errors from missing sources it's useful to promote
> it to an error.
Credit:
- Andrey Dyatlov
- https://github.com/TessenR/BestPracticesSourceGeneratorsDemo
- b8be40f0e153f46ccc79682397680be1b2649b6d
-->
<MSBuildWarningsAsErrors>CS8785</MSBuildWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
156 changes: 156 additions & 0 deletions DocoptNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocoptNet.CodeGeneration", "src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.csproj", "{37D45A51-EB3E-4D6D-9943-EF2F3967343C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SourceGenerator", "SourceGenerator", "{99846126-1D88-42CC-897C-ACEA7C2DBB2B}"
ProjectSection(SolutionItems) = preProject
eg\SourceGenerator\Directory.Build.props = eg\SourceGenerator\Directory.Build.props
eg\SourceGenerator\Directory.Build.targets = eg\SourceGenerator\Directory.Build.targets
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NavalFate", "eg\SourceGenerator\NavalFate\NavalFate.csproj", "{E41419E5-251C-4093-ADDE-77EF694964E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArgumentsExample", "eg\SourceGenerator\ArgumentsExample\ArgumentsExample.csproj", "{99A5B165-A15E-4CE1-B68E-E0992F4478D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorExample", "eg\SourceGenerator\CalculatorExample\CalculatorExample.csproj", "{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CountedExample", "eg\SourceGenerator\CountedExample\CountedExample.csproj", "{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OddEvenExample", "eg\SourceGenerator\OddEvenExample\OddEvenExample.csproj", "{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OptionsExample", "eg\SourceGenerator\OptionsExample\OptionsExample.csproj", "{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OptionsShortcutExample", "eg\SourceGenerator\OptionsShortcutExample\OptionsShortcutExample.csproj", "{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickExample", "eg\SourceGenerator\QuickExample\QuickExample.csproj", "{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocoptNet.Playground", "src\DocoptNet.Playground\DocoptNet.Playground.csproj", "{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Git", "eg\SourceGenerator\Git\Git.csproj", "{63B571D9-DA1B-4209-B4E2-59F0AC529E06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -95,6 +121,114 @@ Global
{5A641DFB-CB1A-4044-AF52-554CC8904449}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5A641DFB-CB1A-4044-AF52-554CC8904449}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5A641DFB-CB1A-4044-AF52-554CC8904449}.Release|x86.ActiveCfg = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|x86.ActiveCfg = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Debug|x86.Build.0 = Debug|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|Any CPU.Build.0 = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|x86.ActiveCfg = Release|Any CPU
{37D45A51-EB3E-4D6D-9943-EF2F3967343C}.Release|x86.Build.0 = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Debug|x86.Build.0 = Debug|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|Any CPU.Build.0 = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|x86.ActiveCfg = Release|Any CPU
{E41419E5-251C-4093-ADDE-77EF694964E3}.Release|x86.Build.0 = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Debug|x86.Build.0 = Debug|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|Any CPU.Build.0 = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|x86.ActiveCfg = Release|Any CPU
{99A5B165-A15E-4CE1-B68E-E0992F4478D9}.Release|x86.Build.0 = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|x86.ActiveCfg = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Debug|x86.Build.0 = Debug|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|Any CPU.Build.0 = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|x86.ActiveCfg = Release|Any CPU
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E}.Release|x86.Build.0 = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|x86.ActiveCfg = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Debug|x86.Build.0 = Debug|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|Any CPU.Build.0 = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|x86.ActiveCfg = Release|Any CPU
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18}.Release|x86.Build.0 = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|x86.ActiveCfg = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Debug|x86.Build.0 = Debug|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|Any CPU.Build.0 = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|x86.ActiveCfg = Release|Any CPU
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B}.Release|x86.Build.0 = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|x86.ActiveCfg = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Debug|x86.Build.0 = Debug|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|Any CPU.Build.0 = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|x86.ActiveCfg = Release|Any CPU
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE}.Release|x86.Build.0 = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|x86.ActiveCfg = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Debug|x86.Build.0 = Debug|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|Any CPU.Build.0 = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|x86.ActiveCfg = Release|Any CPU
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74}.Release|x86.Build.0 = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|x86.ActiveCfg = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Debug|x86.Build.0 = Debug|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|Any CPU.Build.0 = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|x86.ActiveCfg = Release|Any CPU
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D}.Release|x86.Build.0 = Release|Any CPU
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
Expand All @@ -107,12 +241,34 @@ Global
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Release|x86.ActiveCfg = Release|Any CPU
{93595D4E-5AE9-4714-AC8B-1FB24D68A15C}.Release|x86.Build.0 = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|x86.ActiveCfg = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Debug|x86.Build.0 = Debug|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|Any CPU.Build.0 = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|x86.ActiveCfg = Release|Any CPU
{63B571D9-DA1B-4209-B4E2-59F0AC529E06}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2B454F8B-D702-4281-80DF-367142007B0C} = {AE631D61-6BE6-438F-A535-955BB9A0218F}
{99846126-1D88-42CC-897C-ACEA7C2DBB2B} = {AE631D61-6BE6-438F-A535-955BB9A0218F}
{E41419E5-251C-4093-ADDE-77EF694964E3} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{99A5B165-A15E-4CE1-B68E-E0992F4478D9} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{8BCB1D8B-0233-48C5-B5C6-6E3EDB566D3E} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{962D6BAB-A7DE-41BC-9E91-567A6EEE4C18} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{E4EB11FF-6FD7-42F5-A5CD-2C7C2B52568B} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{6C3733DD-C7BD-47C7-BF9A-691A3D0ACCCE} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{21E4EA57-6291-4C58-BFC4-CA8ACF48DB74} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{86843F8B-9B83-4985-9E68-77F9ACF4DA2D} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
{63B571D9-DA1B-4209-B4E2-59F0AC529E06} = {99846126-1D88-42CC-897C-ACEA7C2DBB2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3DEED27A-6D3F-4F2E-A5D5-1F71648F2413}
Expand Down
14 changes: 14 additions & 0 deletions eg/SourceGenerator/ArgumentsExample/ArgumentsExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<Import Project="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.targets" />

</Project>
36 changes: 36 additions & 0 deletions eg/SourceGenerator/ArgumentsExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using DocoptNet.Generated;
using ArgumentsExample;

ProgramArguments arguments;

try
{
arguments = ProgramArguments.Apply(args);
}
catch (DocoptExitException e)
{
Console.WriteLine(e.Message);
return e.ErrorCode;
}
catch (DocoptInputErrorException e)
{
Console.Error.WriteLine(e);
return 0xbd;
}

foreach (var (name, value) in arguments)
Console.WriteLine($"{name} = {value}");

Console.WriteLine($@"{{
Help = {arguments.OptHelp },
V = {arguments.OptV },
Q = {arguments.OptQ },
R = {arguments.OptR },
Left = {arguments.OptLeft },
Right = {arguments.OptRight },
Correction = {arguments.ArgCorrection},
File = [{string.Join(", ", arguments.ArgFile)}],
}}");

return 0;
17 changes: 17 additions & 0 deletions eg/SourceGenerator/ArgumentsExample/Program.docopt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Usage: ArgumentsExample [-vqrh] [FILE] ...
ArgumentsExample (--left | --right) CORRECTION FILE

Process FILE and optionally apply correction to either left-hand side or
right-hand side.

Arguments:
FILE optional input file
CORRECTION correction angle, needs FILE, --left or --right to be present

Options:
-h --help
-v verbose mode
-q quiet mode
-r make report
--left use left-hand side
--right use right-hand side
14 changes: 14 additions & 0 deletions eg/SourceGenerator/CalculatorExample/CalculatorExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<Import Project="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.targets" />

</Project>
36 changes: 36 additions & 0 deletions eg/SourceGenerator/CalculatorExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using DocoptNet.Generated;
using CalculatorExample;

ProgramArguments arguments;

try
{
arguments = ProgramArguments.Apply(args);
}
catch (DocoptExitException e)
{
Console.WriteLine(e.Message);
return e.ErrorCode;
}
catch (DocoptInputErrorException e)
{
Console.Error.WriteLine(e);
return 0xbd;
}

foreach (var (name, value) in arguments)
Console.WriteLine($"{name} = {value}");

Console.WriteLine($@"{{
Help = {arguments.OptHelp },
+ = {arguments.CmdPlus },
- = {arguments.CmdMinus },
* = {arguments.CmdStar },
/ = {arguments.CmdSlash },
Function = {arguments.ArgFunction},
Comma = {arguments.CmdComma },
Value = [{string.Join(", ", arguments.ArgValue)}],
}}");

return 0;
14 changes: 14 additions & 0 deletions eg/SourceGenerator/CalculatorExample/Program.docopt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Not a serious example.

Usage:
calculator_example.py <value> ( ( + | - | * | / ) <value> )...
calculator_example.py <function> <value> [( , <value> )]...
calculator_example.py (-h | --help)

Examples:
calculator_example.py 1 + 2 + 3 + 4 + 5
calculator_example.py 1 + 2 '*' 3 / 4 - 5 # note quotes around '*'
calculator_example.py sum 10 , 20 , 30 , 40

Options:
-h, --help
14 changes: 14 additions & 0 deletions eg/SourceGenerator/CountedExample/CountedExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<Import Project="..\..\..\src\DocoptNet.CodeGeneration\DocoptNet.CodeGeneration.targets" />

</Project>
33 changes: 33 additions & 0 deletions eg/SourceGenerator/CountedExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using DocoptNet.Generated;
using CountedExample;

ProgramArguments arguments;

try
{
arguments = ProgramArguments.Apply(args);
}
catch (DocoptExitException e)
{
Console.WriteLine(e.Message);
return e.ErrorCode;
}
catch (DocoptInputErrorException e)
{
Console.Error.WriteLine(e);
return 0xbd;
}

foreach (var (name, value) in arguments)
Console.WriteLine($"{name} = {value}");

Console.WriteLine($@"{{
Help = {arguments.OptHelp },
V = {arguments.OptV },
Go = {arguments.CmdGo },
File = [{string.Join(", ", arguments.ArgFile)}],
Path = {arguments.OptPath },
}}");

return 0;
Loading

0 comments on commit a8bcd5e

Please sign in to comment.