Skip to content

Commit

Permalink
Merge pull request #36 from Cysharp/hadashiA/remove-unused
Browse files Browse the repository at this point in the history
Remove an unused class
  • Loading branch information
hadashiA authored Sep 28, 2023
2 parents 41a364b + ecc63a4 commit 4e1d81d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 90 deletions.
72 changes: 0 additions & 72 deletions src/UnitGenerator/CodeTemplate.Partial.cs

This file was deleted.

29 changes: 11 additions & 18 deletions src/UnitGenerator/SourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,17 @@ public void Execute(GeneratorExecutionContext context)
var typeSymbol = context.Compilation.GetSemanticModel(type.SyntaxTree).GetDeclaredSymbol(type);
if (typeSymbol == null) throw new Exception("can not get typeSymbol.");

var template = new CodeTemplate
{
Name = typeSymbol.Name,
Namespace = typeSymbol.ContainingNamespace.IsGlobalNamespace ? null : typeSymbol.ContainingNamespace.ToDisplayString(),
Type = prop.Type.ToString(),
Options = prop.Options,
ToStringFormat = prop.ToStringFormat
};

var text = GenerateType(typeSymbol, prop);
if (template.Namespace == null)
{
context.AddSource($"{template.Name}.Generated.cs", text);
}
else
{
context.AddSource($"{template.Namespace}.{template.Name}.Generated.cs", text);
}
var source = GenerateType(typeSymbol, prop);

var ns = typeSymbol.ContainingNamespace.IsGlobalNamespace
? null
: typeSymbol.ContainingNamespace.ToDisplayString();

var filename = ns == null
? $"{typeSymbol.Name}.g.cs"
: $"{ns}.{typeSymbol.Name}.g.cs";

context.AddSource(filename, source);
}
}
catch (Exception ex)
Expand Down

0 comments on commit 4e1d81d

Please sign in to comment.