-
Notifications
You must be signed in to change notification settings - Fork 533
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
Replace existing Resource.designer.cs
System by using Reference assemblies.
#6310
Comments
One other issue is how do we support people using Nuget packages built with the new system on older Xamarin.Android versions... do we even bother? |
I think it's a great idea. The only question that pops in my mind is about the size of the final assembly, but it probably doesn't matter much since it would be the same size as it is now. For runtime performance it would be beneficial if all the classes in the assembly were both static and sealed, the JIT can generate a bit more efficient code for accessing them then. |
The RemoveResourceDesignerStep should still be able to function (with some tweaks). So we can still optimise the release builds to remove this new assembly completely. |
This idea does seem like it would be better, because:
The issues are around: "how do we create these extra assemblies?"
|
We could call |
I can prototype a Cecil generator and test that against a Cs call, see which is quicker. |
Could the design time assembly be in memory only? Generated using System.Reflection.Emit for instance? |
It might also be worth checking if type forwarding would work better for this idea than reference assemblies. |
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a case where a .NET MAUI app that included SkiaSharp and Telerik controls was setting ~90,000 fields at startup in the `Resource.designer.cs` file via the `UpdateIdValues()` method. This also would happen in any Xamarin.Android class library: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields So SkiaSharp is not unique to the problem here... Reviewing the SkiaSharp fields, I found: source\SkiaSharp.Views.Maui\SkiaSharp.Views.Maui.Controls\obj\Debug\net6.0-android\Resource.designer.cs 5335 fields source\SkiaSharp.Views.Maui\SkiaSharp.Views.Maui.Core\obj\Debug\net6.0-android\Resource.designer.cs 5313 fields source\SkiaSharp.Views.Maui\SkiaSharp.Views.Maui.Controls.Compatibility\obj\Debug\net6.0-android\Resource.designer.cs 5335 fields We can simply set `$(AndroidGenerateResourceDesigner)` to `false` in these projects, as they do not use any of the fields. This will prevent .NET 6 apps using these libraries from setting 16,005 fields at startup. I also did a spot check on `SkiaSharp.Views.Android`, but it's OK -- it only has 3 fields: public class Resource { public class Attribute { public static int ignorePixelScaling; //... } public class Styleable { public static int[] SKCanvasView; public static int SKCanvasView_ignorePixelScaling; //... } //... } We are working on a long-term solution for this issue in Xamarin.Android, but we can do a simple workaround in SkiaSharp for now.
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a systemic problem with Xamarin.Android class libraries: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields. That's a lot! This problem compounds itself as you include more class libraries that depend on each other. The main app will end up repeatedly setting these fields at startup for each library that contains fields in `Resource.designer.cs`... Reviewing the .NET MAUI fields, I found: src\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5310 src\Controls\src\Core\obj\Debug\net6.0-android\Resource.designer.cs 5167 fields src\Controls\src\Xaml\obj\Release\net6.0-android\Resource.designer.cs 5167 fields src\Compatibility\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5333 fields src\Essentials\src\obj\Debug\net6.0-android\Resource.designer.cs 204 fields In fact, I found 21,497 fields were set at startup for a `dotnet new maui` app in `Resource.designer.cs`! In many projects you can simply set `$(AndroidGenerateResourceDesigner)` to `false`, but the issue is .NET MAUI actually uses some of the C# `Resource.designer.cs` values at runtime. So to solve the problem here, I came up with a new pattern: https://github.com/jonathanpeppers/CustomResourceDesigner We can copy the contents of `Resource.designer.cs` and manually delete all the fields we don't need. This allows `$(AndroidGenerateResourceDesigner)` to be turned off. We are working on a long-term solution for this issue in Xamarin.Android, but we can do this workaround in .NET MAUI now. ~~ Results ~~ Building a `dotnet new maui` then `dotnet build -c Release` and running on a Pixel 5. Before: * 21,497 fields set at startup in UpdateIdValues() * Activity Displayed: 1s454ms * .apk size: 17300275 bytes After: * 65 fields set at startup in UpdateIdValues() * Activity Displayed: 1s079ms * .apk size: 16677683 bytes > apkdiff -f before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 233 assemblies/Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll - 5,264 assemblies/Microsoft.Maui.Essentials.dll - 103,010 assemblies/Microsoft.Maui.dll - 103,260 assemblies/Microsoft.Maui.Controls.Compatibility.dll - 103,811 assemblies/Microsoft.Maui.Controls.Xaml.dll - 106,127 assemblies/Microsoft.Maui.Controls.dll - 201,031 assemblies/foo.dll Summary: + 0 Other entries 0.00% (of 2,139,558) - 622,736 Assemblies -6.93% (of 8,987,664) + 0 Dalvik executables 0.00% (of 6,440,988) + 0 Shared libraries 0.00% (of 9,860,264) - 1,340,928 Uncompressed assemblies -6.55% (of 20,465,016) - 622,592 Package size difference -3.60% (of 17,300,275)
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a systemic problem with Xamarin.Android class libraries: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields. That's a lot! This problem compounds itself as you include more class libraries that depend on each other. The main app will end up repeatedly setting these fields at startup for each library that contains fields in `Resource.designer.cs`... Reviewing the .NET MAUI fields, I found: src\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5310 src\Controls\src\Core\obj\Debug\net6.0-android\Resource.designer.cs 5167 fields src\Controls\src\Xaml\obj\Release\net6.0-android\Resource.designer.cs 5167 fields src\Compatibility\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5333 fields src\Essentials\src\obj\Debug\net6.0-android\Resource.designer.cs 204 fields In fact, I found 21,497 fields were set at startup for a `dotnet new maui` app in `Resource.designer.cs`! In many projects you can simply set `$(AndroidGenerateResourceDesigner)` to `false`, but the issue is .NET MAUI actually uses some of the C# `Resource.designer.cs` values at runtime. So to solve the problem here, I came up with a new pattern: https://github.com/jonathanpeppers/CustomResourceDesigner We can copy the contents of `Resource.designer.cs` and manually delete all the fields we don't need. This allows `$(AndroidGenerateResourceDesigner)` to be turned off. We are working on a long-term solution for this issue in Xamarin.Android, but we can do this workaround in .NET MAUI now. ~~ Results ~~ Building a `dotnet new maui` then `dotnet build -c Release` and running on a Pixel 5. Before: * 21,497 fields set at startup in UpdateIdValues() * Activity Displayed: 1s454ms * .apk size: 17300275 bytes After: * 65 fields set at startup in UpdateIdValues() * Activity Displayed: 1s079ms * .apk size: 16677683 bytes > apkdiff -f before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 233 assemblies/Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll - 5,264 assemblies/Microsoft.Maui.Essentials.dll - 103,010 assemblies/Microsoft.Maui.dll - 103,260 assemblies/Microsoft.Maui.Controls.Compatibility.dll - 103,811 assemblies/Microsoft.Maui.Controls.Xaml.dll - 106,127 assemblies/Microsoft.Maui.Controls.dll - 201,031 assemblies/foo.dll Summary: + 0 Other entries 0.00% (of 2,139,558) - 622,736 Assemblies -6.93% (of 8,987,664) + 0 Dalvik executables 0.00% (of 6,440,988) + 0 Shared libraries 0.00% (of 9,860,264) - 1,340,928 Uncompressed assemblies -6.55% (of 20,465,016) - 622,592 Package size difference -3.60% (of 17,300,275)
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a systemic problem with Xamarin.Android class libraries: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields. That's a lot! This problem compounds itself as you include more class libraries that depend on each other. The main app will end up repeatedly setting these fields at startup for each library that contains fields in `Resource.designer.cs`... Reviewing the .NET MAUI fields, I found: src\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5310 src\Controls\src\Core\obj\Debug\net6.0-android\Resource.designer.cs 5167 fields src\Controls\src\Xaml\obj\Release\net6.0-android\Resource.designer.cs 5167 fields src\Compatibility\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5333 fields src\Essentials\src\obj\Debug\net6.0-android\Resource.designer.cs 204 fields In fact, I found 21,497 fields were set at startup for a `dotnet new maui` app in `Resource.designer.cs`! In many projects you can simply set `$(AndroidGenerateResourceDesigner)` to `false`, but the issue is .NET MAUI actually uses some of the C# `Resource.designer.cs` values at runtime. So to solve the problem here, I came up with a new pattern: https://github.com/jonathanpeppers/CustomResourceDesigner We can copy the contents of `Resource.designer.cs` and manually delete all the fields we don't need. This allows `$(AndroidGenerateResourceDesigner)` to be turned off. We are working on a long-term solution for this issue in Xamarin.Android, but we can do this workaround in .NET MAUI now. ~~ Results ~~ Building a `dotnet new maui` then `dotnet build -c Release` and running on a Pixel 5. Before: * 21,497 fields set at startup in UpdateIdValues() * Activity Displayed: 1s454ms * .apk size: 17300275 bytes After: * 65 fields set at startup in UpdateIdValues() * Activity Displayed: 1s079ms * .apk size: 16677683 bytes > apkdiff -f before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 233 assemblies/Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll - 5,264 assemblies/Microsoft.Maui.Essentials.dll - 103,010 assemblies/Microsoft.Maui.dll - 103,260 assemblies/Microsoft.Maui.Controls.Compatibility.dll - 103,811 assemblies/Microsoft.Maui.Controls.Xaml.dll - 106,127 assemblies/Microsoft.Maui.Controls.dll - 201,031 assemblies/foo.dll Summary: + 0 Other entries 0.00% (of 2,139,558) - 622,736 Assemblies -6.93% (of 8,987,664) + 0 Dalvik executables 0.00% (of 6,440,988) + 0 Shared libraries 0.00% (of 9,860,264) - 1,340,928 Uncompressed assemblies -6.55% (of 20,465,016) - 622,592 Package size difference -3.60% (of 17,300,275)
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a systemic problem with Xamarin.Android class libraries: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields. That's a lot! This problem compounds itself as you include more class libraries that depend on each other. The main app will end up repeatedly setting these fields at startup for each library that contains fields in `Resource.designer.cs`... Reviewing the .NET MAUI fields, I found: src\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5310 src\Controls\src\Core\obj\Debug\net6.0-android\Resource.designer.cs 5167 fields src\Controls\src\Xaml\obj\Release\net6.0-android\Resource.designer.cs 5167 fields src\Compatibility\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5333 fields src\Essentials\src\obj\Debug\net6.0-android\Resource.designer.cs 204 fields In fact, I found 21,497 fields were set at startup for a `dotnet new maui` app in `Resource.designer.cs`! In many projects you can simply set `$(AndroidGenerateResourceDesigner)` to `false`, but the issue is .NET MAUI actually uses some of the C# `Resource.designer.cs` values at runtime. So to solve the problem here, I came up with a new pattern: https://github.com/jonathanpeppers/CustomResourceDesigner We can copy the contents of `Resource.designer.cs` and manually delete all the fields we don't need. This allows `$(AndroidGenerateResourceDesigner)` to be turned off. We are working on a long-term solution for this issue in Xamarin.Android, but we can do this workaround in .NET MAUI now. ~~ Results ~~ Building a `dotnet new maui` then `dotnet build -c Release` and running on a Pixel 5. Before: * 21,497 fields set at startup in UpdateIdValues() * Activity Displayed: 1s454ms * .apk size: 17300275 bytes After: * 65 fields set at startup in UpdateIdValues() * Activity Displayed: 1s079ms * .apk size: 16677683 bytes > apkdiff -f before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 233 assemblies/Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll - 5,264 assemblies/Microsoft.Maui.Essentials.dll - 103,010 assemblies/Microsoft.Maui.dll - 103,260 assemblies/Microsoft.Maui.Controls.Compatibility.dll - 103,811 assemblies/Microsoft.Maui.Controls.Xaml.dll - 106,127 assemblies/Microsoft.Maui.Controls.dll - 201,031 assemblies/foo.dll Summary: + 0 Other entries 0.00% (of 2,139,558) - 622,736 Assemblies -6.93% (of 8,987,664) + 0 Dalvik executables 0.00% (of 6,440,988) + 0 Shared libraries 0.00% (of 9,860,264) - 1,340,928 Uncompressed assemblies -6.55% (of 20,465,016) - 622,592 Package size difference -3.60% (of 17,300,275)
Had a chat w/ @grendello recently, and I had a modification for this idea: instead of namespace Xamarin.Android.Resource.Designer
{
public class Resources
{
public partial class Id
{
public static int actions => 2131165207;
}
}
} The reason for this is JIT-time overheads: with static fields, every field is set in the static constructor. If you have 30k fields, the static constructor sets 30k fields, and needs to JIT a method that sets (and references!) 30k fields, and -- when unlucky -- the interpreter blows up because the method is too big. ;-) With static methods, as above, every method is small -- no static constructor with 30k fields -- and the JIT can potentially inline them. Methods also provide possible flexibility in the future, should we think of different implementation approaches. |
And static methods will be JIT-ed only when called |
Context: https://github.com/jonathanpeppers/CustomResourceDesigner Context: dotnet/android#6310 We found a systemic problem with Xamarin.Android class libraries: * Include AndroidX & Google Material * Include at least one `@(AndroidResource)` and use the ID from C# * `Resource.designer.cs` has 2,700+ fields. That's a lot! This problem compounds itself as you include more class libraries that depend on each other. The main app will end up repeatedly setting these fields at startup for each library that contains fields in `Resource.designer.cs`... Reviewing the .NET MAUI fields, I found: src\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5310 src\Controls\src\Core\obj\Debug\net6.0-android\Resource.designer.cs 5167 fields src\Controls\src\Xaml\obj\Release\net6.0-android\Resource.designer.cs 5167 fields src\Compatibility\Core\src\obj\Debug\net6.0-android\Resource.designer.cs 5333 fields src\Essentials\src\obj\Debug\net6.0-android\Resource.designer.cs 204 fields In fact, I found 21,497 fields were set at startup for a `dotnet new maui` app in `Resource.designer.cs`! In many projects you can simply set `$(AndroidGenerateResourceDesigner)` to `false`, but the issue is .NET MAUI actually uses some of the C# `Resource.designer.cs` values at runtime. So to solve the problem here, I came up with a new pattern: https://github.com/jonathanpeppers/CustomResourceDesigner We can copy the contents of `Resource.designer.cs` and manually delete all the fields we don't need. This allows `$(AndroidGenerateResourceDesigner)` to be turned off. We are working on a long-term solution for this issue in Xamarin.Android, but we can do this workaround in .NET MAUI now. ~~ Results ~~ Building a `dotnet new maui` then `dotnet build -c Release` and running on a Pixel 5. Before: * 21,497 fields set at startup in UpdateIdValues() * Activity Displayed: 1s454ms * .apk size: 17300275 bytes After: * 65 fields set at startup in UpdateIdValues() * Activity Displayed: 1s079ms * .apk size: 16677683 bytes > apkdiff -f before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 233 assemblies/Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll - 5,264 assemblies/Microsoft.Maui.Essentials.dll - 103,010 assemblies/Microsoft.Maui.dll - 103,260 assemblies/Microsoft.Maui.Controls.Compatibility.dll - 103,811 assemblies/Microsoft.Maui.Controls.Xaml.dll - 106,127 assemblies/Microsoft.Maui.Controls.dll - 201,031 assemblies/foo.dll Summary: + 0 Other entries 0.00% (of 2,139,558) - 622,736 Assemblies -6.93% (of 8,987,664) + 0 Dalvik executables 0.00% (of 6,440,988) + 0 Shared libraries 0.00% (of 9,860,264) - 1,340,928 Uncompressed assemblies -6.55% (of 20,465,016) - 622,592 Package size difference -3.60% (of 17,300,275)
Would it be possible to make these static properties just return the original properties? namespace Xamarin.Android.Resource.Designer
{
public class Resources
{
public partial class Id
{
public static int actions => Xamarin.Google.Android.Material.Resources.Id.actions;
}
}
} This will also work whether |
@AmrAlSayed0 I'm afraid that won't work in this context. Since the value for |
As an F# user I wonder what this change means for my projects? As a note: The F# type provider that provides access to the IDs at compile time hasn't been working for several years now. Would this allow F# projects to consume the IDs in a way that they are available at compile time, preventing the need for a C# helper project just for this (or use Resources.getIdentifier at runtime)? |
@bddckr I'm not entirely sure ,it should make things better for F# users in theory. We won't know until we try. |
So I hacked together a basic version of this, and in principal it seems to work at runtime at least. Problems I have found so far are mostly related to release mode. We get a linker error
This is despite the |
What is the |
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Context dotnet#6310 Ignore Java.Interop-Tests IntermediateDir Try StrongNaming. Based on code in https://github.com/brutaldev/StrongNameSigner/blob/master/src/Brutal.Dev.StrongNameSigner/SigningHelper.cs Use ICSharpCode.Decompiler to read Resource Designer Assembly Fix breakage Fix error with Aapt2 R.txt Use latest Xamarin.Forms for dotnet tests Disable StrongNaming for now Removed unused code and logging Remove StrongNaming support Revert "Remove StrongNaming support" This reverts commit 7f90638f1788adfa37c4ec4ab3fed9fc48569cb5. Use a cstom snk for the designer strong name Update apkdesc Change to Microsoft.Android.Resource.Designer new test Move CryptoConvert to src-ThirdParty Add StrongNameSigner code and TPN Fix missing file Fix another build error Fix a test Update and Fix the UnitTest update docs Switch to _Microsoft.Android.Resource.Designer.dll update apkdesc update apkdesc
Android Resource Assemblies
This idea is a replacement for the current
Resource.designer.cs
systemthat exists in Xamarin.Android.
Problems with the current system.
The current implementation relies on us generating code which is then
updated via reflection on application startup. Reflection is generally
slow so it is best avoided, especially on mobile platforms.
We have another issue, the code which updates the Resouce ids must be
done for each assembly that has a
Resource.desinger.cs
. This means thatas you add more assemblies, your startup time will increase.
Lets use Reference Assemblies
So the new idea is going to make use of
Reference
assemblies. Theseare assemblies which are designed be replaced at runtime.
So for class libraries what we do is instead of compiling the designer
code into the class library , we instead generate a refernce assembly
which has the Resource.designer code in it. This
Resource
class willbe in a KNOWN namespace. So the namespace is common across ALL assmblies.
Rather than the individually namespaced classes we have today.
For the main app we generate a normal assembly which contains ALL the resources
for the app in the Resource.designer code. This will not be a reference
assembly, it will be a standard (maybe even netstadard) assembly. This is
the only one which will be packaged in the applicaiton.
Because the class libraries are using reference assemblies, they should intheory
pick up this normal assembly at runtime.
How it will work
We will use our existing code to generate the
Resource.designer.cs
file, this willthen be compiled into the new assembly. For class libraries we include the
[assembly:ReferenceAssembly]
attribute. The new genearted code will NOT includethe current
UpdateIdValues
method as it will not be required.For apps, we do the same as above except we exclude the new attribute producing an
actual assembly. This assembly will also NOT require the
UpdateIdValues
method asall the ID's in it will be the FINAL id's. Because the class exists in a specific namespace
(say
Xamarin.Android.Resource.Designer
) all the class libraries should be able toresolve it.
We can then remove all the reflection code which calls
UpdateIdValues
.Example
Create a netstandard2.0 class library with the following code.
This will generate a Reference assembly.
Next create a class library which has the following code
Then reference the first Reference assembly project.
Next create a netstandard2.0 library with a class with the actual desginer values.
Next create the app program which references the class library and the FINAL designer assembly.
This will output the following when run
As you can see the refernce assembly gets replaced by the final one. And the class library
reads the actual values.
We would need to write our own MSBuild task to generate this new assemby rather than making
a user create them, but this does prove the concept will work.
How do we migrate?
One of the issues we will have is how to deal with legacy code which exists in nuget files.
We could introduce a linker step for both relase and debug which will migrate to the new
system. This could be done by altering the existing class to derive from the new
Resource
designer class, and clear out ALL of the fields. This in theory should still expose the
fields to the existing namespace.
The text was updated successfully, but these errors were encountered: