forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.net8 Android not building because Resources from resx not found.
Fixes https://github.com/dotnet/maui/issues/19117 With the release of the new Resource Designer assembly we purposely removed the existing legacy `Resource.designer.cs` file from the `@(Compile)` ItemGroup. This is so that we did not get any clashes with the new system. Unfortunately the name `Resource.designer.cs` is also used by developers as the name for the generated class when using `.resx` files. As a result we got the above bug report because the class was disappearing. ``` error CS0234: The type or namespace name 'Resources' does not exist in the namespace 'StringResourcesBug' (are you missing an assembly reference?) ``` It turns out that the `_RemoveLegacyDesigner` was being a bit too aggressive with its removal of files. Because it was matching on filename only it was removing files which had nothing to do with Android Resources. This would cause the above error. The fix in this case is to check for additional metadata. In the case of `.resx` file designers they typically have a `DependentUpon` metadata to signal that they are generated from the `.resx`. So we should check this metadata to make sure it is NOT set before removing a file. A new unit test was added to test this fix and it worked. But it did show up one other issue. In certain cases we would end up with two `Resource` classes in the same namespace. This would then cause the following build error. ``` error CS0260: Missing partial modifier on declaration of type 'Resource'; another partial declaration of this type exists ``` This is because the two classes had different modifiers. We could also get an error if the access modifiers are different (public vs internal). So lets add a new MSBuild property `AndroidResourceDesignerClassModifier`. This property defaults to `public`, but can be overridden by the user to control the access modifier of the generated class.
- Loading branch information
1 parent
06bb1dc
commit b8ccd51
Showing
7 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters