Skip to content

Commit

Permalink
add generator to sln and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Dec 20, 2024
1 parent 3e24057 commit 00c9833
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions WeihanLi.EntityFramework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeihanLi.EntityFramework.Te
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A1756F80-F25E-4ADC-A079-048FFCA5DBA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeihanLi.EntityFramework.SourceGenerator", "src\WeihanLi.EntityFramework.SourceGenerator\WeihanLi.EntityFramework.SourceGenerator.csproj", "{010A98BE-1871-4E6F-8129-7A1C44C73423}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -61,6 +63,18 @@ Global
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x64.Build.0 = Release|Any CPU
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x86.ActiveCfg = Release|Any CPU
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x86.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|Any CPU.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x64.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x64.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x86.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x86.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|Any CPU.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|Any CPU.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x64.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x64.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x86.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -69,6 +83,7 @@ Global
{0BB1C3F3-50C6-4924-894C-0A9A7BA4E54A} = {40B7673F-5ACD-42E4-AE04-6C3AEEBC8546}
{0E013C55-6D52-4B68-B188-460B97DB1E48} = {46AED92E-94FC-409A-9CFB-C9CD4E59717D}
{9DF6D464-63A7-487C-9763-4A212ADDFC4B} = {A1756F80-F25E-4ADC-A079-048FFCA5DBA6}
{010A98BE-1871-4E6F-8129-7A1C44C73423} = {40B7673F-5ACD-42E4-AE04-6C3AEEBC8546}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {201A8B4F-A16D-44B7-BB29-F9B9CFC2A467}
Expand Down
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

View workflow job for this annotation

GitHub Actions / build

This compiler extension should not be implemented in an assembly with target framework '.NET 8.0'. References to other target frameworks will cause the compiler to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1041.md)

Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

This compiler extension should not be implemented in an assembly with target framework '.NET 8.0'. References to other target frameworks will cause the compiler to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1041.md)

Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

This compiler extension should not be implemented in an assembly with target framework '.NET 8.0'. References to other target frameworks will cause the compiler to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1041.md)

Check warning on line 9 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

This compiler extension should not be implemented in an assembly with target framework '.NET 8.0'. References to other target frameworks will cause the compiler to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1041.md)
public class EFRepositorySourceGenerator : IIncrementalGenerator
public sealed class EFRepositorySourceGenerator : IIncrementalGenerator

Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'WeihanLi.EntityFramework.SourceGenerator.EFRepositorySourceGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'

Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'WeihanLi.EntityFramework.SourceGenerator.EFRepositorySourceGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'

Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'WeihanLi.EntityFramework.SourceGenerator.EFRepositorySourceGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'

Check warning on line 10 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'WeihanLi.EntityFramework.SourceGenerator.EFRepositorySourceGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
Expand All @@ -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

View workflow job for this annotation

GitHub Actions / build

Argument of type 'ImmutableArray<string?>' cannot be used for parameter 'templates' of type 'ImmutableArray<string>' in 'string EFRepositorySourceGenerator.GenerateRepositoryCode(string dbContextName, string repositoryNamespace, ImmutableArray<string> templates)' due to differences in the nullability of reference types.

Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Argument of type 'ImmutableArray<string?>' cannot be used for parameter 'templates' of type 'ImmutableArray<string>' in 'string EFRepositorySourceGenerator.GenerateRepositoryCode(string dbContextName, string repositoryNamespace, ImmutableArray<string> templates)' due to differences in the nullability of reference types.

Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Argument of type 'ImmutableArray<string?>' cannot be used for parameter 'templates' of type 'ImmutableArray<string>' in 'string EFRepositorySourceGenerator.GenerateRepositoryCode(string dbContextName, string repositoryNamespace, ImmutableArray<string> templates)' due to differences in the nullability of reference types.

Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Argument of type 'ImmutableArray<string?>' cannot be used for parameter 'templates' of type 'ImmutableArray<string>' in 'string EFRepositorySourceGenerator.GenerateRepositoryCode(string dbContextName, string repositoryNamespace, ImmutableArray<string> templates)' due to differences in the nullability of reference types.

Check warning on line 32 in src/WeihanLi.EntityFramework.SourceGenerator/EFRepositorySourceGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Argument of type 'ImmutableArray<string?>' cannot be used for parameter 'templates' of type 'ImmutableArray<string>' in 'string EFRepositorySourceGenerator.GenerateRepositoryCode(string dbContextName, string repositoryNamespace, ImmutableArray<string> templates)' due to differences in the nullability of reference types.
spc.AddSource($"{dbContextName}Repository.g.cs", SourceText.From(generatedCode, Encoding.UTF8));
});
Expand Down

0 comments on commit 00c9833

Please sign in to comment.