Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to C# 10, Code Analyzers #96

Closed
JeremyCaney opened this issue Nov 27, 2021 · 1 comment
Closed

Upgrade to C# 10, Code Analyzers #96

JeremyCaney opened this issue Nov 27, 2021 · 1 comment
Assignees
Labels
Priority: 1 Severity 1: Minor Status 5: Complete Task is considered complete, and ready for deployment. Type: Improvement Improves the functionality or interface of an existing feature.
Milestone

Comments

@JeremyCaney
Copy link
Member

Upgrade to C# 10. This is simple enough per se. But this will expose new issues with the updated Roslyn Code Analyzers. As a result, this should be paired with a review of new guidance as well as any past suppressions (which may no longer be needed).

This may also enable some new opportunities for pattern matching and, potentially, switch statements.

@JeremyCaney JeremyCaney added Severity 1: Minor Priority: 1 Type: Improvement Improves the functionality or interface of an existing feature. Status 2: Scheduled Planned for an upcoming release. labels Nov 27, 2021
@JeremyCaney JeremyCaney added this to the OnTopic 5.2.0 milestone Nov 27, 2021
@JeremyCaney JeremyCaney self-assigned this Nov 27, 2021
JeremyCaney added a commit that referenced this issue Dec 9, 2021
Upgraded the project to use both C# 10 as well as the associated .NET 6 code analyzers.

Modified code to take advantage of natural types for generics; this was especially useful for XUNit's `Assert.Equal<>()` overloads, which no longer need the type parameter to be set in order to identify the correct overload.

Updated type checking statements to prefer `is` and `is not` where practice. This replaced a handful of cases where we were previously using `Equals(typeof())` or even `IsAssignableFrom()`.

Implemented new C# 10 constant string interpolation for `[Obsolete()]` attributes, which allows (most) class and member references to use `nameof()` instead of being hardcoded as strings.

Fixed a handful of new issues identified by the new code analyzers while I was at it.

This resolves Issue #96.
@JeremyCaney
Copy link
Member Author

As part of this, I took advantage of the following new(er) C# capabilities:

  • Modified code to use natural types for generics; this was especially useful for XUNit's Assert.Equal<>() overloads, which no longer need the type parameter to be set explicitly; these can be inferred (6aca48c).
  • Updated type checking statements to prefer is and is not where practical. This replaced a handful of cases where we were previously using Equals(typeof()) or even IsAssignableFrom() (e6bd2b7, 5852d10).
  • Implemented new C# 10 constant string interpolation for [Obsolete()] attributes, which allows (most) class and member references to use nameof() instead of being hardcoded as strings (427959b).
  • Fixed a handful of new issues identified by the new code analyzers while I was at it (89900d4, 32f85b9, 995bba9, &c.).

See 5eaa417 for details.

@JeremyCaney JeremyCaney added Status 5: Complete Task is considered complete, and ready for deployment. and removed Status 2: Scheduled Planned for an upcoming release. labels Dec 9, 2021
JeremyCaney added a commit that referenced this issue Jun 26, 2022
OnTopic 5.2.0 introduces support for response caching (#89), a new `ErrorController` for HTTP error codes (#91), and improvements to `ITopicMappingService` performance via optional `AttributeDictionary` constructors (#99), updates to the internal reflection libraries (#90), and caching of compatible properties (#102). In addition, it also includes a number of internal code improvements, such as adoption of new C# 10 capabilities (#96), including global using directives (#93).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 1 Severity 1: Minor Status 5: Complete Task is considered complete, and ready for deployment. Type: Improvement Improves the functionality or interface of an existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant