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

Resources should not be emitted into ref assemblies #31244

Merged
merged 5 commits into from
Jan 15, 2019

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Nov 18, 2018

Currently, resources are emitted into ref assemblies produced with /refout. The impact is that modifying a resource file causes dependent projects to re-compile un-necessarily.

Fixes #31197

Update (12/5/2018):
From discussion with Jared and Neal, we will not include resources in ref assemblies produced by /refonly either. We would like to hear from customer that need that. If there are some and we decide we need to include resources in that scenario after all, we'll have to design some solution (/refout:<option> or something).

Update (12/6/2018):
There is still some discussion about the /refonly case (#2184 (comment))

Update (1/10/2019):
From discussion with Eric StJohn and other BCL folks, we think it is safe to remove the resources. I'll still document as a breaking change though.

@jcouv jcouv added this to the 16.0.P2 milestone Nov 18, 2018
@jcouv jcouv self-assigned this Nov 18, 2018
@jcouv jcouv requested a review from a team as a code owner November 18, 2018 22:38
@jcouv jcouv added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Nov 19, 2018
@@ -2862,7 +2862,7 @@ private static Stream ConditionalGetOrCreateStream(EmitStreamProvider metadataPE
Debug.Assert(!includePrivateMembers);

if (!Cci.PeWriter.WritePeToStream(
new EmitContext(moduleBeingBuilt, null, metadataDiagnostics, metadataOnly: true, includePrivateMembers: false),
new EmitContext(moduleBeingBuilt, null, metadataDiagnostics, metadataOnly: true, includePrivateMembers: false, includeManifestResources: false),
Copy link
Member

@jaredpar jaredpar Nov 19, 2018

Choose a reason for hiding this comment

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

Why do we have this new parameter vs. keying off of metadataOnly? #Resolved

Copy link
Member Author

@jcouv jcouv Nov 19, 2018

Choose a reason for hiding this comment

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

In the refonly scenario, the primary assembly will be emitted with metadataOnly=true, but it should contain the metadata resource.
This is the spec'ed behavior (#2184) which Neal confirmed. It is a bit different from what you and I discussed last week.
Neal's reasoning is that if you specified resources on the command-line, you mean them to go somewhere. #Resolved

{
// Manifest resources are not included in ref assemblies
// Ref assemblies don't support added modules
return ImmutableArray<Cci.ManagedResource>.Empty;
Copy link
Member

@jaredpar jaredpar Nov 19, 2018

Choose a reason for hiding this comment

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

This comment does not line up with the behavior. The behavior is that resources are included when the ref assembly is a secondary compilation. When it's the primary compilation then they are included.

I don't agree with this behavior but the change appears to be currently implemneted this way. #Resolved

@@ -2840,7 +2840,7 @@ private static Stream ConditionalGetOrCreateStream(EmitStreamProvider metadataPE
bool includePrivateMembersOnPrimaryOutput = metadataOnly ? includePrivateMembers : true;
bool deterministicPrimaryOutput = (metadataOnly && !includePrivateMembers) || isDeterministic;
if (!Cci.PeWriter.WritePeToStream(
new EmitContext(moduleBeingBuilt, null, metadataDiagnostics, metadataOnly, includePrivateMembersOnPrimaryOutput),
new EmitContext(moduleBeingBuilt, null, metadataDiagnostics, metadataOnly, includePrivateMembersOnPrimaryOutput, includeManifestResources: true),
Copy link
Member

@jaredpar jaredpar Nov 19, 2018

Choose a reason for hiding this comment

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

Feel like this is the wrong approach. It means reference assemblies will have different content depending on how they are compiled. It also means that /refout is not equivalent to /out + /refonly. That feels wrong. #Resolved

Copy link
Member Author

@jcouv jcouv Nov 19, 2018

Choose a reason for hiding this comment

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

Tagging @gafter for discussion of desired behavior. #Resolved

{
builder.Add(resource);
// resources are not emitted into ref assemblies when a full assembly is also produced
Copy link
Member

@jaredpar jaredpar Nov 19, 2018

Choose a reason for hiding this comment

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

The comment and if check seem out of sync (private members vs. resources) #Resolved

@jaredpar
Copy link
Member

jaredpar commented Nov 19, 2018

Done with review pass (iteration 1) #Resolved

@jcouv
Copy link
Member Author

jcouv commented Nov 27, 2018

FYI, I'm holding off this PR to resolve the desired behavior with Jared and Neal. #Resolved

@jcouv jcouv requested a review from a team as a code owner January 10, 2019 19:30
@jcouv jcouv force-pushed the refout-resource branch 3 times, most recently from 7fdf2e0 to 8c47772 Compare January 10, 2019 23:00
@jcouv jcouv changed the title Resources should not be emitted into secondary output assemblies Resources should not be emitted into ref assemblies Jan 10, 2019
@jcouv jcouv changed the base branch from master to dev16.0-preview2 January 10, 2019 23:03
@jcouv jcouv modified the milestones: 16.0.P2, 16.0.P3 Jan 11, 2019
@jcouv jcouv changed the base branch from dev16.0-preview2 to master January 11, 2019 00:04
@jcouv jcouv removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jan 11, 2019
@jcouv
Copy link
Member Author

jcouv commented Jan 11, 2019

@jaredpar This is ready for review again. Removed resources from all ref assemblies. #Resolved

@jasonmalinowski
Copy link
Member

jasonmalinowski commented Jan 11, 2019

@jcouv Does this include any resources that specify version metadata if I pull up File Properties in Windows? I admit I don't know the exact file formats involved there; I could have sworn one of those counts as a resource of some kind. #Resolved

@jcouv
Copy link
Member Author

jcouv commented Jan 11, 2019

@jasonmalinowski No, this only affect resources passed from -resource: command-line option.

I've double-checked that CommonCommandLineArguments.ManifestResources flows straight into CommonPEModuleBuilder.ManifestResources (which this PR interacts with). #Resolved

@@ -17,6 +17,7 @@ internal abstract class PEAssemblyBuilderBase : PEModuleBuilder, Cci.IAssemblyRe
private readonly SourceAssemblySymbol _sourceAssembly;
private readonly ImmutableArray<NamedTypeSymbol> _additionalTypes;
private ImmutableArray<Cci.IFileReference> _lazyFiles;
private ImmutableArray<Cci.IFileReference> _lazyFilesWithoutManifestResources; // we don't include manifest resources in ref assemblies
Copy link
Member

Choose a reason for hiding this comment

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

Consider putting the comment above the field. That will cause it to show up in Intellisense IIRC.

Copy link
Member

Choose a reason for hiding this comment

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

The only comments we show are going to be doc comments with a <summary> tag.

Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

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

:shipit:

@jcouv
Copy link
Member Author

jcouv commented Jan 14, 2019

@gafter @dotnet/roslyn-compiler for a second review. Thanks

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

:shipit:

@jcouv jcouv merged commit 50bb3fa into dotnet:master Jan 15, 2019
@jcouv jcouv deleted the refout-resource branch January 15, 2019 05:59
xoofx pushed a commit to stark-lang/stark-roslyn that referenced this pull request Apr 16, 2019
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.

4 participants