-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: apply incremental source generator best practises
* the attributes are now always in the Tuxedo namespace, but performance is improved 99x
- Loading branch information
Showing
24 changed files
with
238 additions
and
192 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#if NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0 || NETCOREAPP3_1 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 | ||
|
||
using System.ComponentModel; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// Reserved to be used by the compiler for tracking metadata. | ||
/// This class should not be used by developers in source code. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit { } | ||
|
||
#endif |
12 changes: 12 additions & 0 deletions
12
Tuxedo.SourceGenerator/Extensions/CompilationExtensions.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,12 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Tuxedo.SourceGenerator.Extensions; | ||
|
||
internal static class CompilationExtensions | ||
{ | ||
public static bool HasRefinedTypeAttribute(this Compilation compilation) | ||
{ | ||
var typeSymbol = compilation.GetTypeByMetadataName("Tuxedo.RefinedTypeAttribute"); | ||
return typeSymbol != null; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
Tuxedo.SourceGenerator/Generators/RefinementSourceGenerator.RefinedTypeDetails.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,21 @@ | ||
using Tuxedo.SourceGenerator.Extensions; | ||
|
||
namespace Tuxedo.SourceGenerator; | ||
|
||
public sealed partial class RefinementSourceGenerator | ||
{ | ||
private readonly record struct RefinedTypeDetails( | ||
string? Namespace, | ||
string? Predicate, | ||
string? FailureMessage, | ||
string? AccessModifier, | ||
string? Generics, | ||
string? GenericConstraints, | ||
string? RawType, | ||
string? RefinedType, | ||
string? AlternativeType | ||
) | ||
{ | ||
public string? RefinedTypeXmlSafeName => (RefinedType + Generics).EscapeXml(); | ||
} | ||
} |
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
24 changes: 0 additions & 24 deletions
24
Tuxedo.SourceGenerator/Generators/RefinementSourceGenerator.ViewModel.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.