Skip to content

Commit

Permalink
Fix for #3714
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman committed Apr 24, 2024
1 parent 274d199 commit 6e03e5f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs
Expand Up @@ -227,16 +227,19 @@ private static int GetControlIdByName(Assembly assembly, string? name)
assembly,
currentAssembly =>
{
var resources = currentAssembly.GetModules().SelectMany(x => x.GetTypes()).First(x => x.Name == "Resource");
var idType = resources.GetNestedType("Id");
if (idType is null)
{
throw new InvalidOperationException("Id is not a valid nested type in the resources.");
}
return idType.GetFields()
#if NET8_0_OR_GREATER
var resources = Assembly.Load(currentAssembly
.GetReferencedAssemblies()
.First(an => an.FullName.StartsWith("_Microsoft.Android.Resource.Designer")).ToString())
.GetModules()
.SelectMany(x => x.GetTypes())
.First(x => x.Name == "ResourceConstant");
#else
var resources = currentAssembly.GetModules().SelectMany(x => x.GetTypes()).First(x => x.Name == "Resource");
#endif
var idType = resources.GetNestedType("Id") ?? throw new InvalidOperationException("Id is not a valid nested type in the resources.");
return idType.GetFields()
.Where(x => x.FieldType == typeof(int))
.ToDictionary(k => k.Name, v => ((int?)v.GetRawConstantValue()) ?? 0, StringComparer.InvariantCultureIgnoreCase);
});
Expand Down

0 comments on commit 6e03e5f

Please sign in to comment.