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
[Bug] Invalid Resources generated for DesignTime #3007
Comments
I was able to reproduce some resolution issues when loading this project "untouched" in VS2017/2019, but deleting the included |
@pjcollins Thanks for your feedback. Have you restartet VS after you where able to build? What I observed is the Designer file recreated on a restart. |
I think I can reproduce it command-line (I deleted bin/obj directories first): # Build the netstandard project
> msbuild .\App1\App1\App1.csproj /restore
# Simulate a design-time build that would happen in the IDE
> msbuild .\App1\App1.Android\App1.Android.csproj /restore /t:Compile /p:DesignTimeBuild=True /p:BuildingInsideVisualStudio=True This was VS 2019 GA. Got a bunch of errors like:
Will see if this happens with xamarin-android/master. |
So it looks like master is working, but with lots of warnings:
I need to figure out where the problem is here, it seems we have duplicate resources in some of the support library NuGets? It looks like the problem with the C# compiler error was fixed in: 752a25f Duplicates are now warnings, why are there so many? |
@jonathanpeppers This issue is also reported on other places, see: https://stackoverflow.com/questions/55137449/xamarin-forms-generates-wrong-ressources |
This looks related to this change https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. Xamarin.Forms is using It should be producing There might be a way to work around this but it will come at a design time build performance cost. You can set the Place the following in the first
|
@dellis1972 Seems to solve the issue but what did you mean with this?
Do you mean the very aweful Xamarin.Forms Previewer? Or the Android native "designer" which is also average at best? |
The Design Time Build is what Visual Studio does in the background to generate code completion and intellisense. Normally this build should run very quickly, this is one of the reasons the ManagedResourceParser exists. Aapt however can be very slow, especially on projects with allot of resources. So disabling the ManagedResourceParser might mean the IDE becomes a bit sluggish when a Design Time Build is running, this is normally when you save a I'm working on a fix for the ManagedResourceParser now. |
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit reworks the parser to use the `CodeDomProvider.CreateValidIdentifier` method to create a valid c# identifier from the name passed in. However.. it turns out that `CodeDomProvider.CreateValidIdentifier` thinks that a `.` is a valid identifier character. This is despite `CodeDomProvider.IsValidIdentifier` returning `false` for that value... So lets ALSO do a string replace '.' for '_' as well. I also updated the unit test to test for this senario. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13.
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit reworks the parser to use the `CodeDomProvider.CreateValidIdentifier` method to create a valid c# identifier from the name passed in. However.. it turns out that `CodeDomProvider.CreateValidIdentifier` thinks that a `.` is a valid identifier character. This is despite `CodeDomProvider.IsValidIdentifier` returning `false` for that value... So lets ALSO do a string replace '.' for '_' as well. I also updated the unit test to test for this senario. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13.
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit reworks the parser to use the `CodeDomProvider.CreateValidIdentifier` method to create a valid c# identifier from the name passed in. However.. it turns out that `CodeDomProvider.CreateValidIdentifier` thinks that a `.` is a valid identifier character. This is despite `CodeDomProvider.IsValidIdentifier` returning `false` for that value... So lets ALSO do a string replace '.' for '_' as well. I also updated the unit test to test for this senario. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13.
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit reworks the parser to use the `CodeDomProvider.CreateValidIdentifier` method to create a valid c# identifier from the name passed in. However.. it turns out that `CodeDomProvider.CreateValidIdentifier` thinks that a `.` is a valid identifier character. This is despite `CodeDomProvider.IsValidIdentifier` returning `false` for that value... So lets ALSO do a string replace '.' for '_' as well. I also updated the unit test to test for this senario. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13.
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords Rework the ManagedResourceParser to produce the same results as R.txt
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
…ime (#3054) Fixes: #3007 Xamarin.Forms introduced some new `android:id` values in the [`Xamarin.Forms.Platform.Android` assembly][1]. These values include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid Java identifiers, replacing `.` with `_`. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the [C# language specification][1]. It also does keyword detection and prepends an `@` if required, just in case a user calls an item `base` or `class` or any other C# keyword. [1]: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13 [2]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
…ime (#3054) Fixes: #3007 Xamarin.Forms introduced some new `android:id` values in the [`Xamarin.Forms.Platform.Android` assembly][1]. These values include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid Java identifiers, replacing `.` with `_`. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the [C# language specification][1]. It also does keyword detection and prepends an `@` if required, just in case a user calls an item `base` or `class` or any other C# keyword. [1]: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13 [2]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Fixes xamarin#3007 Xamarin.Forms introduced some new `android:id` values in the `Xamarin.Forms.Platform.Android` assembly [1]. These include a period `.` in the identifier, such as android:id="@+id/bottomtab.tabbar" android:id="@+id/toolbar.one" When processing these with `aapt` or `aapt2` these identifiers are "fixed up" to be valid java identifiers. The same is NOT true for the `ManagedResourceParser`. As a result the very first design time build will fail with the following error. obj\Debug\81\designtime\Resource.designer.cs(5048,21,5048,30): error CS0145: A const field requires a value to be provided obj\Debug\81\designtime\Resource.designer.cs(5048,30,5048,31): error CS1003: Syntax error, ',' obj\Debug\81\designtime\Resource.designer.cs(5048,31,5048,38): error CS1002: ; expected This is because it is generating the following code in the `Resource.designer.cs` public const int toolbar.one = 2131230899; which is NOT a valid C# identifier. This commit adds a new `ResourceIdentifier` class which is responsible for making sure the identifier we generate is a valid C# identifier. This logic is based on the C# language specifications [1]. It also does keyword detection and prepends an `@` if required. Just in case a user calls an item `base` or `class` or any other C# keyword. This commit also reworks the id generation of the `ManagedResourceParser` to replicate exactly the ids which `aapt2` produce. As a result if the managed parser generates the code from the `R.txt` file or directly from the resources, the resulting designer.cs file will be IDENTICAL. This should help us reduce some of the calls to `aapt` in the future. [1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Resources/Layout/BottomTabLayout.axml#L13. [2] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#keywords
Just a heads up I'm still seeing this issue on the latest version of VS2019 4.7.03190 Deleting the Resource Designer fixes temporarily, then rebuilding brings it right back. |
@aherrick you will still see it in the stable release since we just merged this into master, and cherry-picked it to d16-2 (which is the next preview). |
@dellis1972 thanks for the update... will keep an eye out. |
FYI this still isn't fixed. VS 2019 16.1.0 |
@aherrick the fix was cherry-picked to the 16.2 branch , it should be in Preview 2. I don't think we can back port this to 16.1 . Note the work around for 16.1 is to add
to your csproj |
Thanks! The work around solved this for me. |
Can this fix be released for S 2017 as well? |
as said above by @jgold6 , it's very important support vs2017! |
@jgold6 @candidodmv does the work around not work for VS2017? |
The work around does work for VS 2017. As such I have already been informed by @bholmes that the fix for this will not be backported to VS 2017. |
I have 3 computers with the same setup and this only happens on one machine. Anybody knows why? I have to fix it with the workaround but wonder whats different to the other installations. They are totally same, even packages, updates. |
I am facing this issue still exists in latest VS 2019 version. and works with work around changes in project file. Is this issue addressed already as it is in closed state now? Tx |
@dev-thinks The fix was shipped, you might have hit a different corner case. Can you open a new issue and attach a repo project and/or diagnostic build logs so we can investigate. |
Description
With Version 3.5.x of Xamarin Forms I have a lot of errors all regarding the Resource.Designer in the obj-Debug-[Version]-designtime folder.
I experimented around with the target and minimum Android SDK Version but had it with both 9.0 and 8.1.
(since I was no able to get the errors in an output, I add a Screenshot here)
It seems that this is caused by entries like:
Also these do not exist in the Resource.Designer used to build the app.
I tried deleting all the bin and obj folders, but the file is always regenerated with the same entries.
Steps to Reproduce
Open a solution in either VS 2019 or 2017 with Xamarin Forms >= 3.5 in the project.
Expected Behavior
No Errors.
Actual Behavior
Error messages appear.
Basic Information
Screenshots
Reproduction Link
App1.zip
The text was updated successfully, but these errors were encountered: