Skip to content

Commit

Permalink
build fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Oct 27, 2023
1 parent 5ca4fa1 commit ddfd0f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Annotations\MUnique.OpenMU.Annotations.csproj" />
<ProjectReference Include="..\..\DataModel\MUnique.OpenMU.DataModel.csproj" />
</ItemGroup>
</Project>
9 changes: 6 additions & 3 deletions src/SourceGenerators/CloneableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace MUnique.OpenMU.SourceGenerators;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using MUnique.OpenMU.Annotations;

/// <summary>
/// A <see cref="ISourceGenerator"/> which implements <see cref="ICloneable{}"/>
Expand All @@ -18,6 +17,10 @@ namespace MUnique.OpenMU.SourceGenerators;
[Generator]
public class CloneableGenerator : ISourceGenerator
{
private const string CloneableAttributeFullName = "MUnique.OpenMU.Annotations.CloneableAttribute";

private const string CloneableAttributeName = "CloneableAttribute";

/// <inheritdoc />
public void Initialize(GeneratorInitializationContext context)
{
Expand All @@ -27,7 +30,7 @@ public void Initialize(GeneratorInitializationContext context)
/// <inheritdoc />
public void Execute(GeneratorExecutionContext context)
{
var attributeSymbol = context.Compilation.GetTypeByMetadataName(typeof(CloneableAttribute).FullName);
var attributeSymbol = context.Compilation.GetTypeByMetadataName(CloneableAttributeFullName);

var classWithAttributes = context.Compilation.SyntaxTrees.Where(st => st.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>()
.Any(p => p.DescendantNodes().OfType<AttributeSyntax>().Any()));
Expand Down Expand Up @@ -80,7 +83,7 @@ private StringBuilder GeneratePartialClass(ClassDeclarationSyntax annotatedClass
var sb = new StringBuilder();
var className = annotatedClass.Identifier.Text;
var ns = declaredClassSymbol.ContainingNamespace?.ToString() ?? string.Empty;
var isInheritedClonable = declaredClassSymbol.BaseType?.GetAttributes().Any(a => a.AttributeClass?.Name == nameof(CloneableAttribute)) ?? false;
var isInheritedClonable = declaredClassSymbol.BaseType?.GetAttributes().Any(a => a.AttributeClass?.Name == CloneableAttributeName) ?? false;

sb.AppendLine($"""
namespace {ns};
Expand Down
11 changes: 2 additions & 9 deletions src/SourceGenerators/MUnique.OpenMU.SourceGenerators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable;CS4014;VSTHRD110;VSTHRD100</WarningsAsErrors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,11 +21,4 @@
</PackageReference>
</ItemGroup>


<ItemGroup>
<Reference Include="MUnique.OpenMU.Annotations">
<HintPath>$(SolutionDir)\Annotations\bin\$(Configuration)\MUnique.OpenMU.Annotations.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

0 comments on commit ddfd0f8

Please sign in to comment.