Skip to content

Commit 6558b68

Browse files
authored
feat: add initial Generators and Interceptors (#8)
1 parent 0e21f1f commit 6558b68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+975
-78
lines changed

source/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<PropertyGroup>
17-
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
17+
<!--<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>-->
1818
</PropertyGroup>
1919

2020
<PropertyGroup Condition="'$(Configuration)'=='Debug'">

source/examples/Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

9+
<PropertyGroup>
10+
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);FlashOWare.Generated</InterceptorsPreviewNamespaces>
11+
</PropertyGroup>
12+
913
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace FlashOWare.Enumerations;
2+
3+
internal static class EnumerationExamples
4+
{
5+
internal static void Run()
6+
{
7+
Console.WriteLine($"{nameof(Enum.GetName)}: {Enum.GetName(StringComparison.OrdinalIgnoreCase)}");
8+
Console.WriteLine($"{nameof(Enum.IsDefined)}: {Enum.IsDefined(StringComparison.OrdinalIgnoreCase)}");
9+
}
10+
}

source/examples/FlashOWare.Generators.Example/Examples/MyExample.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using FlashOWare.Examples;
1+
using FlashOWare.Enumerations;
22

33
Console.WriteLine("Hello, World!");
4+
Console.WriteLine();
45

5-
MyExample.Write();
6+
EnumerationExamples.Run();

source/gen/.globalconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
is_global = true
2+
3+
# CA1064: Exceptions should be public
4+
dotnet_diagnostic.CA1064.severity = none
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FlashOWare.Attributes;
2+
3+
internal static class AttributeNames
4+
{
5+
public const string EnumGetName = "FlashOWare.Generators.GeneratedEnumGetNameAttribute`1";
6+
public const string EnumIsDefined = "FlashOWare.Generators.GeneratedEnumIsDefinedAttribute`1";
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FlashOWare.CodeAnalysis;
2+
3+
internal static class CompilationExtensions
4+
{
5+
internal static string GetInterceptorFilePath(Compilation compilation, SyntaxTree tree)
6+
{
7+
return compilation.Options.SourceReferenceResolver?.NormalizePath(tree.FilePath, baseFilePath: null) ?? tree.FilePath;
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FlashOWare.CodeAnalysis;
2+
3+
internal static class Formatting
4+
{
5+
internal static SymbolDisplayFormat Default { get; } = SymbolDisplayFormat.FullyQualifiedFormat
6+
.WithMemberOptions(SymbolDisplayMemberOptions.IncludeContainingType);
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FlashOWare.CodeAnalysis;
2+
3+
internal static class SyntaxTreeExtensions
4+
{
5+
internal static string GetInterceptorFilePath(this SyntaxTree tree, Compilation compilation)
6+
{
7+
return compilation.Options.SourceReferenceResolver?.NormalizePath(tree.FilePath, baseFilePath: null) ?? tree.FilePath;
8+
}
9+
}

0 commit comments

Comments
 (0)