dotnet / dotnet/roslyn

Injection duplicates do not emit any errors

Open
#85,619 3 comments 0 reactions 0 assignees View on GitHub
Area-Language Design Area-Razor Area-Razor-Compiler
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

In relation to the report: https://github.com/dotnet/aspnetcore/issues/63445.

To reproduce you can use the current net10 identity template or just duplicate any `@inject` property name in Razor file of your choice. The IDE will underline the duplicate but the compilation won't produce any errors. We don't have this behavior documented. Do we want to fix it by producing an error, instead of ignoring the duplicates in https://github.com/dotnet/razor/blob/c150d2096536ce3e0fb5b1007d4e39663f22bcaa/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/InjectDirective.cs#L81?

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the current net10 identity template or a Razor file containing duplicate @inject property names, then inspect InjectDirective.cs at the linked line where duplicates are ignored. Check the related ASP.NET Core report for context; done means compilation reports an error for duplicate injection properties instead of silently ignoring them.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.