meziantou / Meziantou.Analyzer

A Roslyn analyzer to enforce some good practices in C#.
MIT License
952 stars 49 forks source link

MA0115 FP for CaptureUnmatchedValues #766

Open Bouke opened 2 weeks ago

Bouke commented 2 weeks ago

Version of the Meziantou.Analyzer NuGet package

2.0.176

Rule Identifier

MA0115

Target Framework

net8.0

C# Language version

C# 12

Description

When a component has a Parameter specifying CaptureUnmatchedValues, MA0115 should no longer apply for that component.

Reproduction Steps

Minimal code:

<Foo Bar="1" />
@* Foo.razor *@
@code {
    [Parameter(CaptureUnmatchedValues = true)]
    public IReadOnlyDictionary<string, object>? AdditionalAttributes { get; set; }
}

Produces:

Components_Pages_Home_razor.g.cs(100,13): Warning MA0115 : The parameter 'Bar' does not exist on component 'BlazorComponentLifecycle2.Components.Foo'. Available parameters: AdditionalAttributes. (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0115.md)

Other information

Arbitrary attributes

meziantou commented 2 weeks ago

By default the rule reports unmatched pascal case parameters. You can disable it by using the .editorconfig:

MA0115.ReportPascalCaseUnmatchedParameter = false