dotnet / dotnet/roslyn

Compile Time Errors when assigning HTML content with event handlers to a RenderFragment

Open
#85,637 1 comment 0 reactions 0 assignees View on GitHub
Area-Razor
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Image

Image

Inside a razor-file in a @code { }, I'm trying to pass in some HTML content inside a RenderFragment-property as it shows in the 2 images above. The errors [CS1662, CS0027, CS0236] only appears when I try to assign a handler to an event. However, the code compiles and everything renders correctly if the events are not touched as shown in the image below.

Image

Visual Studio 2022 - Version 17.14.20
Visual Studio 2026 Insiders - Version: Insiders [11206.111]

@AdmiralSnyder

Contributor guide

Open the contributing guide

Research direction

The report provides screenshots but no repository files, minimal reproduction, or test name. Start by reproducing the RenderFragment assignment with an event handler in the reported Visual Studio and Razor setup, then compare it with the version without events. Done means the compiler errors are isolated and a regression test or confirmed compiler diagnosis is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.