-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove base class name from generated parameter names and static fa…
…ctory method names. See docs about static factory methods. - version of generators package to 4.0, because generated Match parameter and static method names may change
- Loading branch information
Showing
35 changed files
with
1,762 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
....StandardMinLangVersion/FunicularSwitch.Generators.Consumer.StandardMinLangVersion.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net4.8</TargetFramework> | ||
<LangVersion>9.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> | ||
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath> | ||
<RootNamespace>StandardMinLangVersion</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!--Don't include the output from a previous source generator execution into future runs; the */** trick here ensures that there's | ||
at least one subdirectory, which is our key that it's coming from a source generator as opposed to something that is coming from | ||
some other tool.--> | ||
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/*/**/*.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\FunicularSwitch.Generators\FunicularSwitch.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
</ItemGroup> | ||
|
||
</Project> |
60 changes: 60 additions & 0 deletions
60
...d/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/Attributes.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace FunicularSwitch.Generators | ||
{ | ||
[AttributeUsage(AttributeTargets.Enum)] | ||
sealed class ExtendedEnumAttribute : Attribute | ||
{ | ||
public EnumCaseOrder CaseOrder { get; set; } = EnumCaseOrder.AsDeclared; | ||
public ExtensionAccessibility Accessibility { get; set; } = ExtensionAccessibility.Public; | ||
} | ||
|
||
enum EnumCaseOrder | ||
{ | ||
Alphabetic, | ||
AsDeclared | ||
} | ||
|
||
/// <summary> | ||
/// Generate match methods for all enums defined in assembly that contains AssemblySpecifier. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] | ||
class ExtendEnumsAttribute : Attribute | ||
{ | ||
public Type AssemblySpecifier { get; } | ||
public EnumCaseOrder CaseOrder { get; set; } = EnumCaseOrder.AsDeclared; | ||
public ExtensionAccessibility Accessibility { get; set; } = ExtensionAccessibility.Public; | ||
|
||
public ExtendEnumsAttribute() => AssemblySpecifier = typeof(ExtendEnumsAttribute); | ||
|
||
public ExtendEnumsAttribute(Type assemblySpecifier) | ||
{ | ||
AssemblySpecifier = assemblySpecifier; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Generate match methods for Type. Must be enum. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] | ||
class ExtendEnumAttribute : Attribute | ||
{ | ||
public Type Type { get; } | ||
|
||
public EnumCaseOrder CaseOrder { get; set; } = EnumCaseOrder.AsDeclared; | ||
|
||
public ExtensionAccessibility Accessibility { get; set; } = ExtensionAccessibility.Public; | ||
|
||
public ExtendEnumAttribute(Type type) | ||
{ | ||
Type = type; | ||
} | ||
} | ||
|
||
enum ExtensionAccessibility | ||
{ | ||
Internal, | ||
Public | ||
} | ||
} |
Oops, something went wrong.