pengweiqhca / Xunit.DependencyInjection

Use Microsoft.Extensions.DependencyInjection to resolve xUnit test cases.
MIT License
370 stars 49 forks source link

Member 'ConfigureServices' does not access instance data and can be marked as static (CA1822) #110

Closed glen-84 closed 10 months ago

glen-84 commented 10 months ago

Solutions

Library:

  1. Add a diagnostic suppressor for the Startup class. (example)
  2. Add an interface that the Startup class can implement.

Developer:

  1. Disable inline – looks very messy.
    #pragma warning disable CA1822 // Mark members as static
        public void ConfigureServices(IServiceCollection services)
    #pragma warning restore CA1822 // Mark members as static
        {
  2. Disable in .editorconfig – applies to the whole file.
    [Startup.cs]
    dotnet_diagnostic.CA1822.severity = none
pengweiqhca commented 10 months ago

Allow static

glen-84 commented 10 months ago

Oh! I didn't realize that. Thank you. 🙂