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

Add runtime strategy 'IgnoresAccessChecksTo' #28

Merged
merged 2 commits into from
Aug 11, 2022
Merged

Conversation

krafs
Copy link
Owner

@krafs krafs commented Aug 11, 2022

This adds the concept of runtime strategies to Publicizer - ways to make sure the runtime doesn't throw a MemberAccessException when accessing a member in an assembly that was publicized at compile time.

There are two strategies:

Unsafe
This is what we have had all along. Publicizer has been setting <AllowUnsafeBlocks>true</AllowUnsafeBlocks>, which causes some runtimes (mainly Mono) to suppress access checks at runtime.

IgnoresAccessChecksTo
This emits an IgnoresAccessChecksToAttribute to the user's assembly, which causes some runtimes (most non-Mono) to suppress access checks.

The runtime strategy can be chosen in the project file by specifying it in the PublicizerRuntimeStrategies property.
By default, both of these strategies are used:

<PropertyGroup>
    <PublicizerRuntimeStrategies>Unsafe;IgnoresAccessChecksTo</PublicizerRuntimeStrategies>
</PropertyGroup>

Users should generally not have to do anything for their assemblies to work in the runtime by default. Picking a specific runtime strategy should only be for people who needs more control of how their assemblies are compiled, e.g. omitting the IgnoresAccessChecksToAttribute.

@krafs krafs added the enhancement New feature or request label Aug 11, 2022
@krafs krafs self-assigned this Aug 11, 2022
@krafs krafs changed the title Add runtime strategy 'IgnoresAccessChecksToAttribute' Add runtime strategy 'IgnoresAccessChecksTo' Aug 11, 2022
@krafs krafs merged commit ec4f639 into main Aug 11, 2022
@krafs krafs deleted the ignores-access-checks-to branch August 11, 2022 11:02
@krafs
Copy link
Owner Author

krafs commented Aug 28, 2022

Closes #12.
Closes #13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant