Skip to content

Unsafe evolution: add more tests#82683

Merged
jjonescz merged 2 commits into
dotnet:mainfrom
jjonescz:Unsafe-20-Tests
Mar 12, 2026
Merged

Unsafe evolution: add more tests#82683
jjonescz merged 2 commits into
dotnet:mainfrom
jjonescz:Unsafe-20-Tests

Conversation

@jjonescz

@jjonescz jjonescz commented Mar 10, 2026

Copy link
Copy Markdown
Member

Test plan: #81207

These unchecked items from the test plan should be handled (either by this PR or already previously):

  • object initializers - Member_Property_ObjectInitializer
  • with elements - Member_CollectionConstructor_With
  • function types - Member_Method_ConvertToDelegate_Inferred
  • object creation - Member_Constructor
  • indirect usages
  • PROTOTYPE comments
  • spec open issues
  • breaking changes? - documented in the speclet
  • LangVer tests should include C#Next
  • Should reflection APIs be requires-unsafe? Or should there be a runtime check (must use special flag or API to access unsafe APIs)? - that's BCL's decision
  • Should Activator.CreateInstance() be requires-unsafe? - that's BCL's decision
  • Should dynamic be marked as requires-unsafe? - added to open questions
  • expression trees - Member_Method_ExpressionTree

@jjonescz jjonescz added Area-Compilers Test-Gap Describes a specific feature or scenario that does not have test coverage Feature - Unsafe Evolution labels Mar 10, 2026
@jjonescz jjonescz marked this pull request as ready for review March 10, 2026 11:44
@jjonescz jjonescz requested a review from a team as a code owner March 10, 2026 11:44
@jjonescz jjonescz requested review from 333fred and jcouv March 10, 2026 11:44
@jcouv jcouv mentioned this pull request Mar 10, 2026
4 tasks
options: TestOptions.UnsafeReleaseExe.WithUpdatedMemorySafetyRules(),
expectedOutput: "System.Action")
.VerifyDiagnostics();
}

@jcouv jcouv Mar 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another language question: what should we do about expression trees? (added a bullet to test plan) #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think we need to do anything? Adding a test for how it works today.

}

[Fact]
public void Member_Method_ConvertToDelegate_Inferred()

@jcouv jcouv Mar 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: For this test, consider adding an invocation of the various local variables outside of unsafe context #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extended this test, let me know if that's not what you had in mind.

options: TestOptions.UnsafeReleaseExe.WithUpdatedMemorySafetyRules(),
expectedOutput: "System.Action")
.VerifyDiagnostics();
}

@jcouv jcouv Mar 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Regarding "LangVer tests should include C#Next": Member_LangVersion should probably check RegularNext too.
Extern_ and CompatMode_ tests are probably fine, since they are intentionally targeting older LangVer only. But worth confirming #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will add RegularNext to the tests where it's missing, thanks.

@jcouv jcouv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM Thanks (commit 1)

@jcouv jcouv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM Thanks (commit 2)

@jcouv jcouv self-assigned this Mar 11, 2026
@jjonescz jjonescz merged commit a73833a into dotnet:main Mar 12, 2026
24 checks passed
@jjonescz jjonescz deleted the Unsafe-20-Tests branch March 12, 2026 11:16
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Mar 12, 2026
@jjonescz jjonescz modified the milestones: Next, 18.6 Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Unsafe Evolution Test-Gap Describes a specific feature or scenario that does not have test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants