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

AnyCPU - Simplify support via ModuleInitializer #4063

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amaitland
Copy link
Member

@amaitland amaitland commented Apr 13, 2022

Summary:
Now that we use the SDK Style csproj files and target VS2019 we can use a custom attribute
(same as in .Net Core 3.1) to get the compiler to output a ModuleInitializer.
ModuleInitializer can be used to resolve AnyCpu dlls at runtime. Should greatly simplify AnyCpu
support.

Changes:

  • Checks if the Assembly.GetEntryAssembly() is MSIL
  • Change CefSharp.Core.csproj to use LangVersion 9 so we can get the compiler to output
    the ModuleInitializer
  • Remove CefSharpPlatformCheck and other CefSharpAnyCpuSupport checks
  • CefSharp.Common.targets still has CefSharpAnyCpuSupport references for backwards compatibility with those with it set and Prefer32bit
    The default behaviour for this case is to simply copy the 32bit libs
  • Calling CefRuntime.SubscribeAnyCpuAssemblyResolver multiple times now will simply Unsubscribe the previous resolver

How Has This Been Tested?
Further testing required.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Updated documentation

Checklist:

  • Tested the code(if applicable)
  • Commented my code
  • Changed the documentation(if applicable)
  • New files have a license disclaimer
  • The formatting is consistent with the project (project supports .editorconfig)

Reference:

@amaitland
Copy link
Member Author

This will need more testing before merging.

@AppVeyorBot
Copy link

- Checks if the Assembly.GetEntryAssembly() is MSIL
- Change CefSharp.Core.csproj to use LangVersion 9 so we can get the compiler to output
  the ModuleInitializer
- Remove CefSharpPlatformCheck and other CefSharpAnyCpuSupport checks
- CefSharp.Common.targets still has CefSharpAnyCpuSupport references for backwards compatibility with those with it set and Prefer32bit
  The default behaviour for this case is to simply copy the 32bit libs
- Calling CefRuntime.SubscribeAnyCpuAssemblyResolver multiple times now will simply Unsubscribe the previous resolver

This change should remove the need for users to perform any action when supporting AnyCpu.
@AppVeyorBot
Copy link

@amaitland amaitland changed the title AnyCPU - Simply support via ModuleInitializer AnyCPU - Simplify support via ModuleInitializer Apr 13, 2022
@amaitland amaitland modified the milestones: 101.0.x, 102.0.x May 3, 2022
@amaitland amaitland removed this from the 102.0.x milestone May 30, 2022
@amaitland
Copy link
Member Author

On the MSBuild related code, rather than aggressively removing the code, we could just set the value to True effectively disabling the checks, just incase they needed to be rolled back quickly. Then actively removed at a later point in time.

Some additional extensibility points for the user and an even that'll make it easier to debug when the module initializer has run, possibly the ability to cancel it's execution allowing the user to perform their own action directly.

  • Allow event to trigger when module initializer has run (with option to cancel the execution)
  • Allow path configuration
  • Default CefSharpAnyCpuSupport to true for short term.

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.

2 participants