Skip to content

Commit

Permalink
chore: code linting
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Oct 7, 2024
1 parent d6ed68b commit 8360b57
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/generated/KiotaVersionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
{
var projectDirectory = Path.GetDirectoryName(compilation.SyntaxTrees.First().FilePath);

var version = "unknown";
try
{
XmlDocument csproj = new XmlDocument();
projectDirectory = Path.Combine(projectDirectory, "..", "..", "..", "..", "Directory.Build.props");
csproj.Load(projectDirectory);
version = csproj.GetElementsByTagName("VersionPrefix")[0].InnerText;
}
catch(Exception e)
{
throw new FileNotFoundException($"KiotaVersionGenerator expanded in an invalid project, missing 'Directory.Build.props' file in the following directory {projectDirectory}", e);
}

string source = $@"// <auto-generated/>
var version = csproj.GetElementsByTagName("VersionPrefix")[0].InnerText;
string source = $@"// <auto-generated/>
namespace Microsoft.Kiota.Http.Generated
{{
/// <summary>
Expand All @@ -49,8 +42,13 @@ public static string Current()
}}
";

// Add the source code to the compilation
spc.AddSource($"KiotaVersion.g.cs", SourceText.From(source, Encoding.UTF8));
// Add the source code to the compilation
spc.AddSource($"KiotaVersion.g.cs", SourceText.From(source, Encoding.UTF8));
}
catch(Exception e)
{
throw new FileNotFoundException($"KiotaVersionGenerator expanded in an invalid project, missing 'Directory.Build.props' file in the following directory {projectDirectory}", e);
}
});
}

Expand Down

0 comments on commit 8360b57

Please sign in to comment.