Skip to content

Conversation

martincostello
Copy link
Collaborator

@martincostello martincostello commented Mar 21, 2025

While working on #3283 the IDE was marking lots of suggestions to modernise the codebase.

Rather than ignore it, or make such changes part of the .NET 10 adoption, instead just go through everything now and spruce it up.

This PR adopts file-scoped namespaces for all of the code files, and also simplifies the #if ... pre-processor directives.

Post-merge there will be a PR to add the squashed commit to .git-blame-ignore-revs. #3332

PR commits are grouped in chunks for easier review if anyone wants to.

Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.Annotations*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.ApiTesting*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.Cli*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.Newtonsoft*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.ReDoc*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.SwaggerUI*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.Swagger*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.SwaggerGen*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.TestSupport*`.
Switch to file-scoped namespaces for `Swashbuckle.AspNetCore.IntegrationTests*`.
Switch to file-scoped namespaces for the test websites.
Simplify the hash define constants to either `#if NET` or `#if !NET` - most of the versions are now redundant since we only support .NET 8+.
@martincostello martincostello added the .NET Pull requests that update .NET code label Mar 21, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 84.89755% with 457 lines in your changes missing coverage. Please review.

Project coverage is 84.82%. Comparing base (99ccafa) to head (1abac7d).

Files with missing lines Patch % Lines
...DependencyInjection/SwaggerGenOptionsExtensions.cs 55.95% 85 Missing ⚠️
...ggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs 44.88% 70 Missing ⚠️
...re.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs 92.25% 46 Missing ⚠️
...waggerGen/XmlComments/XmlCommentsDocumentFilter.cs 21.73% 18 Missing ⚠️
...gerGen/XmlComments/XmlCommentsRequestBodyFilter.cs 75.36% 17 Missing ⚠️
...emaGenerator/JsonSerializerDataContractResolver.cs 90.69% 16 Missing ⚠️
...e.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs 52.94% 16 Missing ⚠️
...AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs 77.77% 16 Missing ⚠️
...SwaggerGen/SchemaGenerator/MemberInfoExtensions.cs 58.06% 13 Missing ⚠️
...Core.SwaggerGen/SchemaGenerator/SchemaGenerator.cs 94.92% 13 Missing ⚠️
... and 38 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3331      +/-   ##
==========================================
- Coverage   84.84%   84.82%   -0.03%     
==========================================
  Files          77       79       +2     
  Lines        3221     3216       -5     
  Branches      556      556              
==========================================
- Hits         2733     2728       -5     
  Misses        488      488              
Flag Coverage Δ
Linux 83.51% <83.74%> (-0.03%) ⬇️
Windows 66.26% <67.21%> (-0.06%) ⬇️
macOS 83.51% <83.74%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello marked this pull request as ready for review March 21, 2025 18:07
@martincostello martincostello merged commit d62a9f3 into master Mar 21, 2025
9 checks passed
@martincostello martincostello deleted the file-scoped-namespaces branch March 21, 2025 18:08
martincostello added a commit that referenced this pull request Mar 21, 2025
Ignore changes from #3331.
martincostello added a commit that referenced this pull request Mar 21, 2025
Ignore changes from #3331.
This was referenced Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Pull requests that update .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants