-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
48ab876
to
fd19dfe
Compare
@@ -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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Done with review pass (iteration 1) #Resolved |
99e86ec
to
460e565
Compare
FYI, I'm holding off this PR to resolve the desired behavior with Jared and Neal. #Resolved |
460e565
to
6c6d158
Compare
7fdf2e0
to
8c47772
Compare
8c47772
to
9d607df
Compare
9d607df
to
56c9840
Compare
@jaredpar This is ready for review again. Removed resources from all ref assemblies. #Resolved |
@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 |
@jasonmalinowski No, this only affect resources passed from I've double-checked that |
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gafter @dotnet/roslyn-compiler for a second review. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.