Skip to content

Commit

Permalink
Use KiotaVersion.Current()
Browse files Browse the repository at this point in the history
Use `KiotaVersion.Current()` instead of reflection to render the version for `[GeneratedCode]` to address feedback.
  • Loading branch information
martincostello committed Jul 2, 2024
1 parent 7e2c01c commit 10532fc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Kiota.Builder.Writers.CSharp;
public class CodeClassDeclarationWriter : BaseElementWriter<ClassDeclaration, CSharpConventionService>
{
public static string AutoGenerationHeader => "// <auto-generated/>";
public static string GeneratedCodeAttribute { get; } = $"[global::System.CodeDom.Compiler.GeneratedCode(\"Kiota\", \"{typeof(CodeClassDeclarationWriter).Assembly.GetName().Version}\")]";
public static string GeneratedCodeAttribute { get; } = $"[global::System.CodeDom.Compiler.GeneratedCode(\"Kiota\", \"{Kiota.Generated.KiotaVersion.Current()}\")]";
public CodeClassDeclarationWriter(CSharpConventionService conventionService) : base(conventionService) { }
public override void WriteCodeElement(ClassDeclaration codeElement, LanguageWriter writer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/CSharp/CodeEnumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Kiota.Builder.Writers.CSharp;
public class CodeEnumWriter : BaseElementWriter<CodeEnum, CSharpConventionService>
{
public static string AutoGenerationHeader => "// <auto-generated/>";
public static string GeneratedCodeAttribute { get; } = $"[global::System.CodeDom.Compiler.GeneratedCode(\"Kiota\", \"{typeof(CodeClassDeclarationWriter).Assembly.GetName().Version}\")]";
public static string GeneratedCodeAttribute { get; } = $"[global::System.CodeDom.Compiler.GeneratedCode(\"Kiota\", \"{Kiota.Generated.KiotaVersion.Current()}\")]";
public CodeEnumWriter(CSharpConventionService conventionService) : base(conventionService) { }
public override void WriteCodeElement(CodeEnum codeElement, LanguageWriter writer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void WritesGeneratedCodeAttribute()
{
codeElementWriter.WriteCodeElement(parentClass.StartBlock, writer);
var result = tw.ToString();
var pattern = @"\s+\[global::System\.CodeDom\.Compiler\.GeneratedCode\(""Kiota"", ""[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+""\)\]";
var pattern = @"\s+\[global::System\.CodeDom\.Compiler\.GeneratedCode\(""Kiota"", ""[0-9]+\.[0-9]+\.[0-9]+\""\)\]";
Assert.Matches(pattern, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void WritesGeneratedCodeAttribute()
currentEnum.AddOption(new CodeEnumOption { Name = "option2" });
writer.Write(currentEnum);
var result = tw.ToString();
var pattern = @"\s+\[global::System\.CodeDom\.Compiler\.GeneratedCode\(""Kiota"", ""[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+""\)\]";
var pattern = @"\s+\[global::System\.CodeDom\.Compiler\.GeneratedCode\(""Kiota"", ""[0-9]+\.[0-9]+\.[0-9]+\""\)\]";
Assert.Matches(pattern, result);
}
}

0 comments on commit 10532fc

Please sign in to comment.