dotnet / dotnet/sdk

[Analyzers][C#14.0]Raise a notification when an extension method call is redirected to a Span/ReadOnlySpan method

Open
#51,904 1 comment 0 reactions 0 assignees View on GitHub
Area-Microsoft.CodeAnalysis.NetAnalyzers untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.
The new [First-Class Span Types](https://github.com/dotnet/csharplang/issues/7905) feature backfired for me in a couple of scenarios:
* It can [cause](https://github.com/dotnet/csharplang/discussions/9841) a `NullReferenceException` due to a [bug](https://github.com/dotnet/runtime/issues/119901) in the `System.Memory` package
* It also can [cause](https://github.com/dotnet/csharplang/discussions/9841#discussioncomment-15074389) a `VerificationException` ("Operation could destabilize the runtime") in .NET Framework 4.x from a partially trusted domain.

### Describe the solution you'd like
A new analyzer rule could raise a warning ("Possibly unintentional method call" or something like that) when a project targets pre-.NET 10.0 versions, and some extension method call silently switches to another method when the new C# 14.0 features are enabled.

### Additional context
See the links in the bullet points above for more details.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.