Coder Social home page Coder Social logo

Comments (7)

lksr-demant avatar lksr-demant commented on June 12, 2024 1

I have updated to newest version and MA0115 works fine.

Thank you very much for your feedback and fast fix!!!

from meziantou.analyzer.

meziantou avatar meziantou commented on June 12, 2024
  • Which version of the SDK do you use? (dotnet --info)
  • Are the rules reported when using dotnet build?

from meziantou.analyzer.

lksr-demant avatar lksr-demant commented on June 12, 2024

Hi,
at least MA0117 and MA0118 works fine
image

Generated from code like

@code {

    [SupplyParameterFromQuery] // MA0116: Missing [Parameter] attribute - DO NOT WORK
    public string? Value2 { get; set; }

    [EditorRequired] // MA0117: Missing [Parameter] attribute - WORKS
    public string? Value { get; set; }

    [JSInvokable] // MA0118: The method must be public - WORKS
    internal static int[] ReturnArray()
    {
        return [1, 2, 3];
    }
}

Which is strange because from what I see in your repo both MA0116 and MA0117 comes from one Analyzer class ParameterAttributeForRazorComponentAnalyzer. When I use same code in project with .net 7.0 then all works fine!


λ dotnet --info
.NET SDK:
Version: 8.0.200
Commit: 438cab6a9d
Workload version: 8.0.200-manifests.e575128c

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.200\

.NET workloads installed:
[android]
Installation Source: VS 17.9.34622.214, VS 17.9.34310.174
Manifest Version: 34.0.52/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.52\WorkloadManifest.json
Install Type: Msi

[maui-windows]
Installation Source: VS 17.9.34622.214, VS 17.9.34310.174
Manifest Version: 8.0.6/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.6\WorkloadManifest.json
Install Type: Msi

[maccatalyst]
Installation Source: VS 17.9.34622.214, VS 17.9.34310.174
Manifest Version: 17.2.8004/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8004\WorkloadManifest.json
Install Type: Msi

[ios]
Installation Source: VS 17.9.34622.214, VS 17.9.34310.174
Manifest Version: 17.2.8004/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8004\WorkloadManifest.json
Install Type: Msi

Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2

.NET SDKs installed:
7.0.116 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]
8.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

from meziantou.analyzer.

meziantou avatar meziantou commented on June 12, 2024

Can you try with the latest SDK (Version: 8.0.201)? I think it contains some fixes related to analyzers.

I'll try to reproduce the bug on my side later, maybe this weekend.

from meziantou.analyzer.

meziantou avatar meziantou commented on June 12, 2024

Note that some rules such as MA0116 and MA0122 are not reported on .NET 8 as the attributes are now useless. More info: https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-6/?WT.mc_id=DT-MVP-5003978#cascade-query-string-values-to-blazor-components

On my machine the analyzer seems to work correctly on .NET 8 with the latest SDK. Could you provide a repro if you still have the issue?

from meziantou.analyzer.

lksr-demant avatar lksr-demant commented on June 12, 2024

Unfortunately after installing new SDK situation do not changes.

Repro steps:

  1. With this repository
    BlazorWithRoslynAnalyzersClean.zip

  2. Go into solution folder. From cmd execute "dotnet build"

  3. I get following errors. MA0115 and MA0116 are valid just for .net 7.0 project. Eventhough MA0116 is useless and not reporten on .net8.0 MA0115 still should work, right?

D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\Pages\Index.razor(13,20): error MA0117: Parameters with [EditorRequired] attributes should also be marked as [Parameter] (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0117.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\BlazorWithRoslynAnalyzers.Client.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\Program.cs(5,1): error MA0004: Use Task.ConfigureAwait(false) if the current SynchronizationContext is not needed (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0004.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\BlazorWithRoslynAnalyzers.Client.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\Pages\Index.razor(16,27): error MA0118: [JSInvokable] methods must be public (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0118.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzers\BlazorWithRoslynAnalyzers.Client\BlazorWithRoslynAnalyzers.Client.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\Pages\Index.razor(10,20): error MA0116: Parameters with [SupplyParameterFromQuery] attributes should also be marked as [Parameter] (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0116.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\BlazorApp7.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\Pages\Index.razor(13,20): error MA0117: Parameters with [EditorRequired] attributes should also be marked as [Parameter] (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0117.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\BlazorApp7.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_razor.g.cs(104,13): error MA0115: The parameter 'Undef' does not exist on component 'BlazorApp7.Components.CustomLabel' (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0115.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\BlazorApp7.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\Pages\Index.razor(16,27): error MA0118: [JSInvokable] methods must be public (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0118.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\BlazorApp7.csproj]
D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\Program.cs(11,1): error MA0004: Use Task.ConfigureAwait(false) if the current SynchronizationContext is not needed (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0004.md) [D:\src-tests\Blazor\BlazorWithRoslynAnalyzersClean\BlazorWithRoslynAnalyzersClean\BlazorApp7\BlazorApp7.csproj]
    0 Warning(s)
    8 Error(s)

λ dotnet --list-sdks
7.0.116 [C:\Program Files\dotnet\sdk]
8.0.200 [C:\Program Files\dotnet\sdk]
8.0.201 [C:\Program Files\dotnet\sdk]

λ dotnet --version
8.0.201

from meziantou.analyzer.

meziantou avatar meziantou commented on June 12, 2024

MA0115 should be reported. In ASP.NET 8, Blazor introduced a new method AddComponentParameter which is not yet detected. A fix should appears soon :)

from meziantou.analyzer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.