Skip to content

Commit

Permalink
fix xml doc
Browse files Browse the repository at this point in the history
  • Loading branch information
EngRajabi committed Mar 19, 2024
1 parent bfe0a7f commit 95ab4ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
23 changes: 13 additions & 10 deletions Supernova.Enum.Generators/EnumSourceGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Supernova.Enum.Generators.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Supernova.Enum.Generators;

Expand All @@ -24,13 +24,16 @@ public void Execute(GeneratorExecutionContext context)
// Debugger.Launch();
// }
//#endif
context.AddSource($"{SourceGeneratorHelper.AttributeName}Attribute.g.cs", SourceText.From($@"using System;
context.AddSource($"{SourceGeneratorHelper.AttributeName}Attribute.g.cs", SourceText.From($@"
using System;
using System.CodeDom.Compiler;
namespace {SourceGeneratorHelper.NameSpace}
{{
/// <summary>
/// An attribute that marks enums for which extension methods are to be generated.
/// </summary>
[AttributeUsage(AttributeTargets.Enum)]
[GeneratedCodeAttribute(""Supernova.Enum.Generators"", null)]
public sealed class {SourceGeneratorHelper.AttributeName}Attribute : Attribute
{{
}}
Expand Down Expand Up @@ -93,13 +96,13 @@ public sealed class {SourceGeneratorHelper.AttributeName}Attribute : Attribute
namedArgument.Value.Value?.ToString() is { } displayName)
{
enumDisplayNames.Add(member.Name, displayName);
}
}
if (namedArgument.Key.Equals("Description", StringComparison.OrdinalIgnoreCase) &&
namedArgument.Value.Value?.ToString() is { } description)
{
enumDescriptions.Add(member.Name, description);
}

}
}
}
Expand All @@ -117,10 +120,10 @@ namespace {SourceGeneratorHelper.NameSpace}

//DisplayNames Dictionary
DisplayNamesDictionary(sourceBuilder, symbol, e, enumDisplayNames);

//DisplayDescriptions Dictionary
DisplayDescriptionsDictionary(sourceBuilder, symbol, e, enumDescriptions);

//ToStringFast
ToStringFast(sourceBuilder, symbol, e);

Expand Down
17 changes: 0 additions & 17 deletions Supernova.Enum.Generators/SourceGeneratorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

public static class SourceGeneratorHelper
{
private const string Header = @"//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Supernova source generator
// Do not change this file !!
// </auto-generated>
//------------------------------------------------------------------------------
using System;
";

public const string NameSpace = "EnumFastToStringGenerated";
public const string AttributeName = "EnumGenerator";
public const string ExtensionMethodNameToString = "ToStringFast";
Expand All @@ -23,12 +14,4 @@ public static class SourceGeneratorHelper
public const string PropertyDisplayNamesDictionary = "DisplayNamesDictionary";
public const string PropertyDisplayDescriptionsDictionary = "DisplayDescriptionsDictionary";

public const string Attribute = Header + $@"
namespace {NameSpace};
[AttributeUsage(AttributeTargets.Enum)]
public sealed class {AttributeName}Attribute : System.Attribute
{{
}}";
}

0 comments on commit 95ab4ef

Please sign in to comment.