-
-
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.
* General code improvements * Update dependencies
- Loading branch information
1 parent
38a0801
commit fd5d13c
Showing
15 changed files
with
252 additions
and
108 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,86 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Immediate.Handlers.Analyzers; | ||
|
||
internal static class ITypeSymbolExtensions | ||
{ | ||
public static bool IsBehaviorsAttribute(this ITypeSymbol? typeSymbol) => | ||
typeSymbol is | ||
{ | ||
Name: "BehaviorsAttribute", | ||
ContainingNamespace: | ||
{ | ||
Name: "Shared", | ||
ContainingNamespace: | ||
{ | ||
Name: "Handlers", | ||
ContainingNamespace: | ||
{ | ||
Name: "Immediate", | ||
ContainingNamespace.IsGlobalNamespace: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
public static bool IsRenderModeAttribute(this ITypeSymbol? typeSymbol) => | ||
typeSymbol is | ||
{ | ||
Name: "RenderModeAttribute", | ||
ContainingNamespace: | ||
{ | ||
Name: "Shared", | ||
ContainingNamespace: | ||
{ | ||
Name: "Handlers", | ||
ContainingNamespace: | ||
{ | ||
Name: "Immediate", | ||
ContainingNamespace.IsGlobalNamespace: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
public static bool IsRenderMode(this ITypeSymbol? typeSymbol) => | ||
typeSymbol is | ||
{ | ||
Name: "RenderMode", | ||
ContainingNamespace: | ||
{ | ||
Name: "Shared", | ||
ContainingNamespace: | ||
{ | ||
Name: "Handlers", | ||
ContainingNamespace: | ||
{ | ||
Name: "Immediate", | ||
ContainingNamespace.IsGlobalNamespace: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
public static bool IsBehavior2(this ITypeSymbol typeSymbol) => | ||
typeSymbol is | ||
{ | ||
MetadataName: "Behavior`2", | ||
ContainingNamespace: | ||
{ | ||
Name: "Shared", | ||
ContainingNamespace: | ||
{ | ||
Name: "Handlers", | ||
ContainingNamespace: | ||
{ | ||
Name: "Immediate", | ||
ContainingNamespace.IsGlobalNamespace: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
public static bool ImplementsBehavior(this INamedTypeSymbol typeSymbol) => | ||
typeSymbol.IsBehavior2() | ||
|| (typeSymbol.BaseType is not null && ImplementsBehavior(typeSymbol.BaseType.OriginalDefinition)); | ||
} |
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
78 changes: 78 additions & 0 deletions
78
src/Immediate.Handlers.Generators/ITypeSymbolExtensions.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,78 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Immediate.Handlers.Generators; | ||
|
||
internal static class ITypeSymbolExtensions | ||
{ | ||
public static bool IsBehavior2(this ITypeSymbol typeSymbol) => | ||
typeSymbol is | ||
{ | ||
MetadataName: "Behavior`2", | ||
ContainingNamespace: | ||
{ | ||
Name: "Shared", | ||
ContainingNamespace: | ||
{ | ||
Name: "Handlers", | ||
ContainingNamespace: | ||
{ | ||
Name: "Immediate", | ||
ContainingNamespace.IsGlobalNamespace: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
public static bool ImplementsBehavior(this INamedTypeSymbol typeSymbol) => | ||
typeSymbol.IsBehavior2() | ||
|| (typeSymbol.BaseType is not null && ImplementsBehavior(typeSymbol.BaseType.OriginalDefinition)); | ||
|
||
public static bool IsValueTask1(this ITypeSymbol typeSymbol) => | ||
typeSymbol is INamedTypeSymbol | ||
{ | ||
MetadataName: "ValueTask`1", | ||
ContainingNamespace: | ||
{ | ||
Name: "Tasks", | ||
ContainingNamespace: | ||
{ | ||
Name: "Threading", | ||
ContainingNamespace: | ||
{ | ||
Name: "System", | ||
ContainingNamespace.IsGlobalNamespace: true | ||
} | ||
} | ||
} | ||
}; | ||
|
||
public static bool IsValueTask(this ITypeSymbol typeSymbol) => | ||
typeSymbol is INamedTypeSymbol | ||
{ | ||
Name: "ValueTask", | ||
ContainingNamespace: | ||
{ | ||
Name: "Tasks", | ||
ContainingNamespace: | ||
{ | ||
Name: "Threading", | ||
ContainingNamespace: | ||
{ | ||
Name: "System", | ||
ContainingNamespace.IsGlobalNamespace: true | ||
} | ||
} | ||
} | ||
}; | ||
|
||
public static bool IsIEquatable1(this ITypeSymbol typeSymbol) => | ||
typeSymbol is INamedTypeSymbol | ||
{ | ||
MetadataName: "IEquatable`1", | ||
ContainingNamespace: | ||
{ | ||
Name: "System", | ||
ContainingNamespace.IsGlobalNamespace: true | ||
}, | ||
}; | ||
} |
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
Oops, something went wrong.