Skip to content

Comments

Unsafe evolution: warn for using the attribute under legacy rules and some cleanup#82456

Open
jjonescz wants to merge 12 commits intodotnet:features/UnsafeEvolutionfrom
jjonescz:Unsafe-16-CleanupPrototypeComments
Open

Unsafe evolution: warn for using the attribute under legacy rules and some cleanup#82456
jjonescz wants to merge 12 commits intodotnet:features/UnsafeEvolutionfrom
jjonescz:Unsafe-16-CleanupPrototypeComments

Conversation

@jjonescz
Copy link
Member

@jjonescz jjonescz commented Feb 19, 2026

Test plan: #81207
Related speclet update: dotnet/csharplang#9999

Commits should be mostly self-contained.

@jjonescz jjonescz changed the title Unsafe evolution: warn for using attribute under legacy rules and some cleanup Unsafe evolution: warn for using the attribute under legacy rules and some cleanup Feb 19, 2026
@jjonescz jjonescz marked this pull request as ready for review February 19, 2026 12:46
@jjonescz jjonescz requested a review from a team as a code owner February 19, 2026 12:46
@jjonescz jjonescz requested review from 333fred and jcouv February 19, 2026 12:46
@jcouv jcouv self-assigned this Feb 19, 2026
@333fred 333fred self-assigned this Feb 19, 2026

| Warning ID | Description |
|------------|-------------|
| CS9508 | [RequiresUnsafeAttribute is only valid under the updated memory safety rules](https://github.com/dotnet/csharplang/issues/9704) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS9508

Let's leave a PROTOTYPE since this will need to be adjusted when ErrorCodes are compacted

return MessageID.IDS_FeatureUnsafeEvolution.GetFeatureAvailabilityDiagnosticInfo(this.Compilation);
}

// PROTOTYPE: Update the error message to hint that one can enable updated memory safety rules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the resolution?

diagnostics.Add(ErrorCode.ERR_PartialMemberReadOnlyDifference, implementation.GetFirstLocation());
}

// PROTOTYPE: Update and test this for unsafe evolution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the resolution?

break;
case ErrorCode.WRN_RequiresUnsafeAttributeLegacyRules:
// These are the warnings introduced with the warning "wave" shipped with dotnet 11 and C# 15.
Assert.Equal(11, ErrorFacts.GetWarningLevel(errorCode));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not related to this PR, but it may be good to have a comment at the bottom of this test indicating that the warning wave doc should be updated

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with review pass (commit 12). Only minor comments/questions

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants