Skip to content

Allow @rendermode and @typeparam to coexist in basic scenarios#12591

Merged
davidwengier merged 8 commits intomainfrom
dev/dawengie/RenderModeWithTypeParam
Dec 16, 2025
Merged

Allow @rendermode and @typeparam to coexist in basic scenarios#12591
davidwengier merged 8 commits intomainfrom
dev/dawengie/RenderModeWithTypeParam

Conversation

@davidwengier
Copy link
Member

Fixes #9683

This doesn't fix the issue in all scenarios, due to limitations of C# (not allowing open generics in attribute names, for example), but the specific cases where this doesn't work, the workaround of defining your own attribute and using [attribute: ...] also doesn't work, so I think this is a net positive and unblocks the common case for users.

@davidwengier davidwengier requested a review from a team as a code owner December 12, 2025 05:23
["7.0"] = Version_7_0,
["8.0"] = Version_8_0,
["9.0"] = Version_9_0,
["10.0"] = Version_10_0,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature needs to be tied to .NET 11 in order to not break CI builds, we just have to decide what Razor lang version that is. .NET 10 shipped with RazorLangVersion 9, sadly, and it's not clear to me if its too late to change that so everything lines up nicely:
https://github.com/dotnet/sdk/blob/main/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets#L57

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we could just introduce a V10 in the .2xx SDK band without any real issues. We might not actually gate anything behind it heh, but at least it would line up. I really like the idea of having a single razor language version per .NET, but that does potentially stop us introducing breaking changes in higher SDK bands 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, our language versions have a minor part too. So I wonder if we should decide on a policy of major == netversion, and we can introduce minor revisions for things like codgen changes if we need it (Ideally, we solve the code gen thing in a better way, but until then).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna make this v11, since we can't light up this til .net 11 anyway, and we can worry about what to do with v10 later. I don't think there is any reason to not line up major versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think "latest" maybe should be v9, but that breaks one of the existing tests. Will bring this up for discussion at the next opportunity

Copy link
Contributor

@MattParkerDev MattParkerDev Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature needs to be tied to .NET 11 in order to not break CI builds, we just have to decide what Razor lang version that is. .NET 10 shipped with RazorLangVersion 9, sadly, and it's not clear to me if its too late to change that so everything lines up nicely:

https://github.com/dotnet/sdk/blob/main/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets#L57

<RazorLangVersion>preview</RazorLangVersion> 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll work if someone has a .NET 11 preview SDK installed (though I intend to make it unnecessary in that case), or if someone wants the IDE to allow it, but their builds to not allow it (and hot reload to not work)

Copy link
Member

@chsienki chsienki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo a decision on the language versioning.

["7.0"] = Version_7_0,
["8.0"] = Version_8_0,
["9.0"] = Version_9_0,
["10.0"] = Version_10_0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we could just introduce a V10 in the .2xx SDK band without any real issues. We might not actually gate anything behind it heh, but at least it would line up. I really like the idea of having a single razor language version per .NET, but that does potentially stop us introducing breaking changes in higher SDK bands 🤔

["7.0"] = Version_7_0,
["8.0"] = Version_8_0,
["9.0"] = Version_9_0,
["10.0"] = Version_10_0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, our language versions have a minor part too. So I wonder if we should decide on a policy of major == netversion, and we can introduce minor revisions for things like codgen changes if we need it (Ideally, we solve the code gen thing in a better way, but until then).

@davidwengier davidwengier merged commit 62f8816 into main Dec 16, 2025
10 checks passed
@davidwengier davidwengier deleted the dev/dawengie/RenderModeWithTypeParam branch December 16, 2025 10:40
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 16, 2025
@davidwengier davidwengier modified the milestones: Next, 18.3 Jan 6, 2026
@davidwengier davidwengier added the feature request Large improvement request label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Large improvement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Known Issue] Specifying a @rendermode fails when a component uses @typeparam

3 participants