Skip to content

Conversation

@BartoszKlonowski
Copy link
Contributor

@BartoszKlonowski BartoszKlonowski commented Jan 28, 2025

This pull request fixes #42312

It removes the unsafe scope applied to the whole class code, but applies the unsafe modifier for each separate statement that requires it, so that every time the unsafe is needed, it is clearly visible included in the code snippet presented on the page.

Note: For the part with InvokeViaFunctionPointer, where I put product outside of the unsafe scope, is because the Console.WriteLine that requires that product to be in the same scope of course. But, that Console.WriteLine is not included on the page, so I'm not sure if this will not be confusing for the reader to have that product being put out of unsafe because... no reason from the reader perspective.
(Other option, that I considered was to remove the Console.WriteLine call)
Let me know, please, what is your opinion, when reviewing 🙏

@BartoszKlonowski BartoszKlonowski requested review from a team and BillWagner as code owners January 28, 2025 15:39
@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 28, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-csharp/svc lang-reference/subsvc community-contribution Indicates PR is created by someone from the .NET community. labels Jan 28, 2025
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM @BartoszKlonowski

I do like keeping the declaration of product outside the unsafe block. It's in keeping with the goal of keeping unsafe blocks smaller.

@BillWagner BillWagner enabled auto-merge (squash) January 29, 2025 13:29
@BillWagner BillWagner merged commit e5cfd53 into dotnet:main Jan 29, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-csharp/svc lang-reference/subsvc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function pointers examples lack unsafe context

2 participants