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

Templates for struct, enum, record #28915

Closed
vlada-shubina opened this issue Nov 7, 2022 · 4 comments
Closed

Templates for struct, enum, record #28915

vlada-shubina opened this issue Nov 7, 2022 · 4 comments
Assignees
Labels
Area-Common templates Covers templates in the repo (classlib, console, common item templates) triaged the item was triaged and placed to the backlog
Milestone

Comments

@vlada-shubina
Copy link
Member

Right now it’s possible to use a file template to create a class or an interface, but there are no templates for (at least) the following:

  • struct
  • enum
  • record
    It would be nice to have templates for these, too, so I don’t need to create a class and change the keyword.

Related issue: dotnet/templating#1713
Original ticket: https://developercommunity.visualstudio.com/t/Templates-for-other-types-of-C-code-fil/10153010

@vlada-shubina vlada-shubina added the Area-Common templates Covers templates in the repo (classlib, console, common item templates) label Nov 7, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Nov 7, 2022
@KalleOlaviNiemitalo
Copy link
Contributor

Would the struct template override Equals(object) and GetHashCode()? Perhaps implement IEquatable<T> as well.

@YuliiaKovalova
Copy link
Member

Hi @KalleOlaviNiemitalo,

Thank you for your suggestions, but we try to keep templates as simple as possible.
The requested functionality won't be added in the foreseeable future.

@KalleOlaviNiemitalo
Copy link
Contributor

@YuliiaKovalova, I was thinking about CA1815: Override equals and operator equals on value types; the generated code should preferably be free of warnings. Was a template added for C# 10 record struct, which would cover the equality scenario?

@YuliiaKovalova
Copy link
Member

Hi @KalleOlaviNiemitalo ,

Thank you for the reference.
We discuss this topic with the team and I will return to you later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Common templates Covers templates in the repo (classlib, console, common item templates) triaged the item was triaged and placed to the backlog
Projects
None yet
Development

No branches or pull requests

3 participants