-
-
Notifications
You must be signed in to change notification settings - Fork 267
Add doc for OwningComponentBase to bit Boilerplate (#11768) #11767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| public class AutoInjectSourceGenerator : ISourceGenerator | ||
| { | ||
| private static int counter; | ||
| private static readonly DiagnosticDescriptor NonPartialClassError = new DiagnosticDescriptor(id: "BITGEN001", | ||
|
Check warning on line 17 in src/SourceGenerators/Bit.SourceGenerators/AutoInject/AutoInjectSourceGenerator.cs
|
||
| title: "The class needs to be partial", | ||
| messageFormat: "{0} is not partial. The AutoInject attribute needs to be used only in partial classes.", | ||
| category: "Bit.SourceGenerators", | ||
|
|
@@ -82,48 +82,6 @@ | |
|
|
||
| private static string? GenerateSource(INamedTypeSymbol? attributeSymbol, INamedTypeSymbol? classSymbol, IReadOnlyCollection<ISymbol> eligibleMembers) | ||
| { | ||
| AutoInjectClassType env = FigureOutTypeOfEnvironment(classSymbol); | ||
| return env switch | ||
| { | ||
| AutoInjectClassType.NormalClass => AutoInjectNormalClassHandler.Generate(attributeSymbol, classSymbol, eligibleMembers), | ||
| AutoInjectClassType.RazorComponent => AutoInjectRazorComponentHandler.Generate(classSymbol, eligibleMembers), | ||
| _ => string.Empty | ||
| }; | ||
| } | ||
|
|
||
| private static AutoInjectClassType FigureOutTypeOfEnvironment(INamedTypeSymbol? @class) | ||
| { | ||
| if (@class is null) | ||
| throw new ArgumentNullException(nameof(@class)); | ||
|
|
||
| if (IsClassIsRazorComponent(@class)) | ||
| return AutoInjectClassType.RazorComponent; | ||
| else | ||
| return AutoInjectClassType.NormalClass; | ||
| } | ||
|
|
||
| private static bool IsClassIsRazorComponent(INamedTypeSymbol @class) | ||
| { | ||
| bool isInheritIComponent = @class.AllInterfaces.Any(o => o.ToDisplayString() == "Microsoft.AspNetCore.Components.IComponent"); | ||
|
|
||
| if (isInheritIComponent) | ||
| return true; | ||
|
|
||
| var classFilePaths = @class.Locations | ||
| .Where(o => o.SourceTree is not null) | ||
| .Select(o => o.SourceTree?.FilePath) | ||
| .ToList(); | ||
|
|
||
| string razorFileName = $"{@class.Name}.razor"; | ||
|
|
||
| foreach (var path in classFilePaths) | ||
| { | ||
| string directoryPath = Path.GetDirectoryName(path) ?? string.Empty; | ||
| string filePath = Path.Combine(directoryPath, razorFileName); | ||
| if (File.Exists(filePath)) | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| return AutoInjectNormalClassHandler.Generate(attributeSymbol, classSymbol, eligibleMembers); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.