Skip to content
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

Add "generated-code" XmlDoc and [GeneratedCode] attribute to C# models. #1784

Closed
RowlandBanks opened this issue Feb 7, 2024 · 2 comments
Closed
Labels
area/typescript Specify what technical area given issue relates to. Its goal is to ease filtering good first issues. C# generator Anything related to the C# generator enhancement New feature or request good first issue Good for newcomers stale

Comments

@RowlandBanks
Copy link
Contributor

It's very common in the C# generator world to add the GeneratedCodeAttribute to generated code.

For example:

[GeneratedCode("some-code-generator", "1.2.3")]
public class SomeGeneratedModel
{
}

I would also suggest adding a documentation header to the generated code:

//----------------------
// <auto-generated>
//     Generated by the Modelina C# compiler. Do not edit - changes may be overwritten.
//     source: some-service.yaml
// </auto-generated>
//----------------------
public class SomeGeneratedModel
{
}

Reason/Context

Please try answering few of those questions

  • Why we need this improvement?
    These two methods of marking generated code are frequently used as part of a heuristic test to determine if code is generated. This may be done to, for example, exclude it from code coverage or static analysis checks,

  • How will this change help?
    This change will clearly mark generated code as generated, in line with standard dotnet practices and customs.

  • What is the motivation?
    Excluding generated code from static analysis tooling is the driving motivation.

Description

Please try answering few of those questions

  • What changes have to be introduced?

  • Will this be a breaking change?
    No - the xmldoc comments are just comments, and thus compiled out.

The GeneratedCode attribute is extremely unlikely to cause downstream issues - it would require a developer to be enabling a behaviour in the absence of a [GeneratedCode] attribute and to want that behaviour to apply to this generated code.

  • How could it be implemented/designed?

This issue was initially discussed in Slack.

@jonaslagoni suggested

I would add this as a new preset, or maybe even add this functionality as part of the same preset for this: #1330 (comment)
Call it description preset i.e. similar to https://github.com/asyncapi/modelina/blob/master/src%2Fgenerators%2Ftypescript%2Fpresets%2FDescriptionPreset.ts

Note that this issue is similar to #1330.

@RowlandBanks RowlandBanks added the enhancement New feature or request label Feb 7, 2024
@RowlandBanks
Copy link
Contributor Author

/gfi ts

@asyncapi-bot asyncapi-bot added area/typescript Specify what technical area given issue relates to. Its goal is to ease filtering good first issues. good first issue Good for newcomers labels Feb 7, 2024
@jonaslagoni jonaslagoni added the C# generator Anything related to the C# generator label Feb 7, 2024
Copy link
Contributor

github-actions bot commented Jun 7, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Jun 7, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/typescript Specify what technical area given issue relates to. Its goal is to ease filtering good first issues. C# generator Anything related to the C# generator enhancement New feature or request good first issue Good for newcomers stale
Projects
None yet
Development

No branches or pull requests

3 participants