-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit [GeneratedCode] for C# code generation #4907
Comments
I think this is a valid suggestion. It's great that the attribute is part of .NET, Any objections @baywet? Essentially, what we'd probably need to do is very similar to the PR at https://github.com/microsoft/kiota/pull/3034/files as well as add usings for
|
No objections on my side. For some reason I had not caught the subtility of using a doc comment versus using an attribute for the static analysis options. I think adding this attribute will be a great improvement for tools like sonarCloud or others which work on compiled static analysis. |
Sure - I was just waiting for an agreement it would be a wanted change before starting 😄 |
Emit `[GeneratedCode]` attribute for C# types. Resolves microsoft#4907.
Emit `[GeneratedCode]` attribute for C# types. Resolves microsoft#4907.
…tribute Emit [GeneratedCode] attribute for C# types
Signed-off-by: Vincent Biret <[email protected]>
ci: fixes preview generated code unit test failure introduced by #4907
Is your feature request related to a problem? Please describe the problem.
When generating C# client code with Kiota, the classes produced are not annotated with the
[GeneratedCode]
attribute.While
// <auto-generated/>
is added to the source files, which is useful for tools like style analyzers, this is not visible to static analysis tools that work with compiled binaries.For example, it is common to exclude generated code from tools such as code coverage tools, as often the coverage of such code is not considered interesting when determining test suite coverage. Many tools such as coverlet support excluding code marked with specific attributes, such as
[ExcludeFromCodeCoverage]
or[GeneratedCode]
, as these are easy to blanket-apply, rather than requiring types be excluded by specific names/namespaces.See here for a similar feature request for source-generated code in the .NET runtime: dotnet/runtime#89007
As well as the specific motivating factor of easier code coverage tooling exclusions, such annotations would also be useful for other static analysis that may wish to specifically find code that has been generated by Kiota as opposed to user-written.
Client library/SDK language
Csharp
Describe the solution you'd like
All C# types generated by Kiota are decorated with
[GeneratedCode("{tool}", "{version}")]
.For example:
+ [System.CodeDom.Compiler.GeneratedCode("kiota", "1.15.0")] public class ApiClient : BaseRequestBuilder { }
Additional context
No response
The text was updated successfully, but these errors were encountered: