-
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.
Merge pull request #9 from futurum-dev/feature/improvements-to-Module…
…-and-Startable Improvements to Modules and Startables
- Loading branch information
Showing
15 changed files
with
217 additions
and
84 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
37 changes: 37 additions & 0 deletions
37
...Futurum.Microsoft.Extensions.DependencyInjection.Generator/ModuleNonVoidReturnAnalyzer.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,37 @@ | ||
using System.Collections.Immutable; | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
namespace Futurum.Microsoft.Extensions.DependencyInjection.Generator; | ||
|
||
[DiagnosticAnalyzer(LanguageNames.CSharp)] | ||
public class ModuleNonVoidReturnAnalyzer : DiagnosticAnalyzer | ||
{ | ||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } | ||
= ImmutableArray.Create(DiagnosticDescriptors.ModuleNonVoidReturn); | ||
|
||
public override void Initialize(AnalysisContext context) | ||
{ | ||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); | ||
context.EnableConcurrentExecution(); | ||
|
||
context.RegisterSymbolAction(Execute, SymbolKind.Method); | ||
} | ||
|
||
private static void Execute(SymbolAnalysisContext context) | ||
{ | ||
if (context.Symbol is not IMethodSymbol methodSymbol) | ||
return; | ||
|
||
if (!Diagnostics.Module.HasAttribute(methodSymbol)) | ||
return; | ||
|
||
var diagnostics = Diagnostics.Module.NonVoidReturn.Check(methodSymbol); | ||
|
||
foreach (var diagnostic in diagnostics) | ||
{ | ||
context.ReportDiagnostic(diagnostic); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...rum.Microsoft.Extensions.DependencyInjection.Generator/StartableNonAsyncMethodAnalyzer.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,37 @@ | ||
using System.Collections.Immutable; | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
namespace Futurum.Microsoft.Extensions.DependencyInjection.Generator; | ||
|
||
[DiagnosticAnalyzer(LanguageNames.CSharp)] | ||
public class StartableNonAsyncMethodAnalyzer : DiagnosticAnalyzer | ||
{ | ||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } | ||
= ImmutableArray.Create(DiagnosticDescriptors.StartableNonAsyncMethod); | ||
|
||
public override void Initialize(AnalysisContext context) | ||
{ | ||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); | ||
context.EnableConcurrentExecution(); | ||
|
||
context.RegisterSymbolAction(Execute, SymbolKind.Method); | ||
} | ||
|
||
private static void Execute(SymbolAnalysisContext context) | ||
{ | ||
if (context.Symbol is not IMethodSymbol methodSymbol) | ||
return; | ||
|
||
if (!Diagnostics.Startable.HasAttribute(methodSymbol)) | ||
return; | ||
|
||
var diagnostics = Diagnostics.Startable.StartableNonAsyncMethod.Check(methodSymbol); | ||
|
||
foreach (var diagnostic in diagnostics) | ||
{ | ||
context.ReportDiagnostic(diagnostic); | ||
} | ||
} | ||
} |
Oops, something went wrong.