The project was using a newer version of Microsoft.CodeAnalysis.CSharp
This commit is contained in:
JacobTech 2023-06-04 15:52:06 -04:00
parent 84af952300
commit dd05aca370
2 changed files with 8 additions and 5 deletions

View File

@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>true</IncludeBuildOutput>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Title>Server Database Source Generator</Title>
<Authors>JacobTech</Authors>
</PropertyGroup>
@ -16,7 +16,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
</ItemGroup>
<ItemGroup>

View File

@ -59,12 +59,14 @@ public class TableRowGenerator : ISourceGenerator
this.CloseClass(generatedClass);
context.AddSource($"{declaredClass.Identifier}_{relatedClass.Type.Name}.g.cs", SourceText.From(generatedClass.ToString(), Encoding.UTF8));
//context.AddSource($"{declaredClass.Identifier}_{relatedClass.Type.Name}_goooddddd.g.cs", SourceText.From(generatedClass.ToString().Replace("partial ", "").Replace(declaredClass.Identifier.ToString(), declaredClass.Identifier.ToString() + "GODDD"), Encoding.UTF8));
}
}
}
catch (Exception e)
{
context.AddSource("teste.g.cs", SourceText.From(@$"using System;
context.AddSource("teste.g.cs", SourceText.From(@$"// <auto-generated/>
using System;
namespace ServerDatabase.SourceGenerator.Generated
{{
public class bobe
@ -81,13 +83,14 @@ namespace ServerDatabase.SourceGenerator.Generated
string bad = prop.Type.ToString();
bad = bad.Replace("ServerDatabase.TableColumn<", "");
bad = bad.Remove(bad.LastIndexOf('>'));
builder.AppendLine($" public {bad} {prop.Name} {{ get; set; }}");
builder.AppendLine($" public {bad} {prop.Name} {{ get; set; }}");
}
private StringBuilder GenerateClass(string n, ClassDeclarationSyntax og)
{
StringBuilder sb = new StringBuilder();
sb.Append(@$"using System;
sb.Append(@$"// <auto-generated/>
using System;
namespace {n}
{{