Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix ILLink.Substitutions.xml Warnings during Blazor build #40051

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

Merged
merged 2 commits into from
Jul 30, 2020

Conversation

eerhardt
Copy link
Member

When linking a Blazor application, we have a couple cases where the ILLink.Substitutions.xml files are referencing types that don't exist in the assembly. I split these 2 up into separate commits.

  1. Fix ILLink warning for System.Runtime.Serialization.Formatters
    • LocalAppContextSwitches is getting trimmed from the Browser specific assembly since it is unused. However, we still have an ILLink.Substitutions.xml file referencing it, causing the warning.
    • The fix is to only include the ILLink.Substitutions.xml file for the non-Browser build.
  2. Fix ILLink warning in System.Runtime.InteropServices.JavaScript
    • When building for Browser, the Runtime.InteropServices.JavaScript assembly doesn't use the System.SR type which causes the ILLinker to trim it during the dotnet/runtme build. But since System.SR is used for the AnyOS build we are generating an ILLink.Substitutions.xml file telling the linker to remove the System.SR type. This causes a warning during the Blazor app build because the Type doesn't exist in the assembly, but the XML file references it.
    • The fix is to not create an System.SR Type, nor embed the resources file, for the Browser build. This will need to be undone once a string is used in the Browser build.

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@eerhardt eerhardt added area-System.Runtime linkable-framework Issues associated with delivering a linker friendly framework labels Jul 28, 2020
Copy link
Member

@GrabYourPitchforks GrabYourPitchforks left a comment

Choose a reason for hiding this comment

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

Formatters changes look good! Elegant solution. :)

eerhardt added 2 commits July 29, 2020 17:51
LocalAppContextSwitches is getting trimmed from the Browser specific assembly since it is unused. However, we still have an ILLink.Substitutions.xml file referencing it, causing the warning.

The fix is to only include the ILLink.Substitutions.xml file for the non-Browser build.
When building for Browser, the Runtime.InteropServices.JavaScript assembly doesn't use the System.SR type which causes the ILLinker to trim it during the dotnet/runtme build. But since System.SR is used for the AnyOS build we are generating an ILLink.Substitutions.xml file telling the linker to remove the System.SR type. This causes a warning during the Blazor app build because the Type doesn't exist in the assembly, but the XML file references it.

The fix is to not create an System.SR Type, nor embed the resources file, for the Browser build. This will need to be undone once a string is used in the Browser build.
@eerhardt eerhardt force-pushed the FixLinkerWarningsInBlazor branch from fe8efb9 to ee96e1c Compare July 29, 2020 22:55
@eerhardt eerhardt merged commit e872afc into dotnet:master Jul 30, 2020
@eerhardt eerhardt deleted the FixLinkerWarningsInBlazor branch July 30, 2020 17:35
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
* Fix ILLink warning for System.Runtime.Serialization.Formatters

LocalAppContextSwitches is getting trimmed from the Browser specific assembly since it is unused. However, we still have an ILLink.Substitutions.xml file referencing it, causing the warning.

The fix is to only include the ILLink.Substitutions.xml file for the non-Browser build.

* Fix ILLink warning in System.Runtime.InteropServices.JavaScript

When building for Browser, the Runtime.InteropServices.JavaScript assembly doesn't use the System.SR type which causes the ILLinker to trim it during the dotnet/runtme build. But since System.SR is used for the AnyOS build we are generating an ILLink.Substitutions.xml file telling the linker to remove the System.SR type. This causes a warning during the Blazor app build because the Type doesn't exist in the assembly, but the XML file references it.

The fix is to not create an System.SR Type, nor embed the resources file, for the Browser build. This will need to be undone once a string is used in the Browser build.
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants