Skip to content

NET-2394 Fix S2325 FP: aspnet middleware should have non-static InvokeAsync method #9757

Description

@sm-g

Description

see https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/write?view=aspnetcore-9.0

Reproducer

public class VersionMiddleware
    {
        public VersionMiddleware(RequestDelegate next)
        {
            // ctor with 'next' required
        }

        public async Task InvokeAsync(HttpContext context, IWebHostEnvironment environment)
        {
            await context.Response.WriteAsync("1.2.3");
        }
    }

Product and Version

SonarAnalyzer.CSharp 10.15.0.120848

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    False PositiveRule IS triggered when it shouldn't be.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions