-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Text; | ||
using System.Text; | ||
|
||
namespace WeihanLi.EntityFramework.SourceGenerator; | ||
|
||
[Generator] | ||
Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
|
||
public class EFRepositorySourceGenerator : IIncrementalGenerator | ||
public sealed class EFRepositorySourceGenerator : IIncrementalGenerator | ||
Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
|
||
{ | ||
public void Initialize(IncrementalGeneratorInitializationContext context) | ||
{ | ||
|
@@ -28,7 +28,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) | |
{ | ||
var (dbContextDeclaration, templates) = source; | ||
var dbContextName = dbContextDeclaration!.Identifier.Text; | ||
var repositoryNamespace = dbContextDeclaration!.Parent!.GetNamespace(); | ||
var repositoryNamespace = dbContextDeclaration.Parent!.GetNamespace(); | ||
var generatedCode = GenerateRepositoryCode(dbContextName, repositoryNamespace, templates); | ||
Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs GitHub Actions / build
|
||
spc.AddSource($"{dbContextName}Repository.g.cs", SourceText.From(generatedCode, Encoding.UTF8)); | ||
}); | ||
|