-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Apply DependentUpon Convention Only to .resx Files #4764
Conversation
// If it has a file type metadata is "Resx" | ||
bool isResxFile = (!string.IsNullOrEmpty(fileType) && fileType == "Resx"); | ||
|
||
//fall back onto the extension |
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.
I'm not familiar with when Type=Resx is set, is that up to the user or to targets that precede this do it?
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.
Yes, please document the current state at least in the PR and maybe in the comment here.
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.
Users can manually set the Type
metadata to Resx
or Non-Resx
. If that metadata isn't set, it is automatically populated by the time the task runs. Currently trying to track down when it gets set.
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.
It's set through the SplitResourcesByCulture
target here
<EmbeddedResource Include="@(_MixedResourceWithNoCulture);@(_MixedResourceWithCulture)" Condition="'%(Extension)'=='.resx' or '%(Extension)'=='.restext'">
<Type Condition="'%(_MixedResourceWithNoCulture.Type)'=='' and '%(_MixedResourceWithCulture.Type)'==''">Resx</Type>
</EmbeddedResource>
<EmbeddedResource Include="@(_MixedResourceWithNoCulture);@(_MixedResourceWithCulture)" Condition="'%(Extension)'!='.resx' and '%(Extension)'!='.restext'">
<Type Condition="'%(_MixedResourceWithNoCulture.Type)'=='' and '%(_MixedResourceWithCulture.Type)'==''">Non-Resx</Type>
</EmbeddedResource>
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.
My follow up here is do we need this fallback to extension, then? It seems like we should expect Type to be set?
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.
Yeah, I think I now lean toward "assume it's set and if it's not, no convention" as well. I'll push that.
Tests for the convention are failing. I assume they are test defects at this point? |
They are failing because the tests don't set the I am seeing some third-party calls to the task: https://github.com/search?l=XML&q=CreateCSharpManifestResourceName&type=Code |
5305a8f
to
2301506
Compare
Without this change we get lots of errors related to duplicate resource ids.
Without this change we get lots of errors related to duplicate resource ids.
Without this change we get lots of errors related to duplicate resource ids.
Two relevant offline conversations yesterday:
I'm going to merge. |
Without this change we get lots of errors related to duplicate resource ids.
Without this change we get lots of errors related to duplicate resource ids.
Without this change we get lots of errors related to duplicate resource ids.
Now that the rules for manifest resource name selection have changed, refer to this dotnet docs issue for a detailed explanation on how this selection works now. |
Description
Fix #4740, build or runtime failures that arise because non-resx resources get embedded with an unexpected name.
Customer Impact
Builds fail with
CS1508
or applications fail to extract a resource at runtime. Roadblock to adopting the final 3.0 SDK and to migrating to .NET Core 3.0 for applications with embedded resources (UI applications in particular).Reported by multiple internal partners (CoreFX, EF) and customers.
Workaround
Users can explicitly opt out of the new behavior back into preview8 behavior with a property
Regression?
Yes, builds fail in cases that passed before. Introduced with #4597, a new feature to support (resx) resources without project-file impact.
Testing
Automated tests, including a new one for this specific case. e2e validation in failing scenarios using privates.
Risk
Low. Targeted fix in a conditioned codepath, so the existing workarounds will continue to work and can mitigate any problems.
Taking the suggestion made by @nguerrera to restrict dependentupon convention to .resx files.
#4740 (comment)
Added a check on the
Type
metadata and file extension to prevent dependent upon convention from being used on non-resx files.Users can manually assign the
Type
metadata when including embedded resources in their projects like so:<EmbeddedResource Include="MyResource.txt" WithCulture="false" Type="Non-Resx" />
If the metadata isn't set, it should automatically be populated by the time the task runs.
In case the
Type
metadata is missing for whatever reason when the task runs, a check on the file's extension will be made to determine whether or not it's a resx file.