Skip to content

Conversation

@jonpryor
Copy link
Contributor

The TypeNameMapGenerator(IEnumerable<string>, Action<string,object[]>)
constructor attempted to use DirectoryAssemblyResolver to load each
assembly provided by the IEnumerable<string> parameter, in-order,
without updating DirectoryAssemblyResolver.SearchDirectories.

The result is that things would only work if the assemblies were
sorted in "dependency order", e.g. mscorlib.dll first, and any other
assembly dependency before it's used.

Should the order be otherwise, e.g. {System.dll, mscorlib.dll}, then
things would horrifically break:

System.IO.FileNotFoundException: Could not load assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'mscorlib.dll'
  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in <216e7ad0b70c419890a52554f287cdcd>:0
  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in <216e7ad0b70c419890a52554f287cdcd>:0
  at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x0004e] in <4f9b8c8361824d0ca9025449919e12be>:0
  at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00007] in <4f9b8c8361824d0ca9025449919e12be>:0
  at Mono.Cecil.TypeReference.Resolve () [0x00014] in <4f9b8c8361824d0ca9025449919e12be>:0

Improver the TypeNameMapGenerator constructor so that
DirectoryAssemblyResolver.SearchDirectories is set to contain all
directories for all assemblies provied, before attempting to load
any assemblies. This allows assemblies to be provided in an arbitrary
order, while still allowing assemblies to be found.

…ories

The `TypeNameMapGenerator(IEnumerable<string>, Action<string,object[]>)`
constructor attempted to use `DirectoryAssemblyResolver` to load each
assembly provided by the `IEnumerable<string>` parameter, in-order,
*without* updating `DirectoryAssemblyResolver.SearchDirectories`.

The result is that things would only work if the assemblies were
sorted in "dependency order", e.g. `mscorlib.dll` first, and any other
assembly dependency before it's used.

Should the order be otherwise, e.g. `{System.dll, mscorlib.dll}`, then
things would horrifically break:

	System.IO.FileNotFoundException: Could not load assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono for Android profile?
	File name: 'mscorlib.dll'
	  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in <216e7ad0b70c419890a52554f287cdcd>:0
	  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in <216e7ad0b70c419890a52554f287cdcd>:0
	  at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x0004e] in <4f9b8c8361824d0ca9025449919e12be>:0
	  at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00007] in <4f9b8c8361824d0ca9025449919e12be>:0
	  at Mono.Cecil.TypeReference.Resolve () [0x00014] in <4f9b8c8361824d0ca9025449919e12be>:0

Improver the `TypeNameMapGenerator` constructor so that
`DirectoryAssemblyResolver.SearchDirectories` is set to contain all
directories for all assemblies provied, *before* attempting to load
any assemblies. This allows assemblies to be provided in an arbitrary
order, while still allowing assemblies to be found.
@atsushieno atsushieno merged commit 1be10fa into dotnet:master Sep 26, 2016
jonpryor pushed a commit that referenced this pull request Sep 25, 2020
Changes: dotnet/android-tools@3974fc3...f2af06f

  * dotnet/android-tools@f2af06f: [Xamarin.Android.Tools.AndroidSdk] Fix a few nullability warnings (#97)
  * dotnet/android-tools@5718cd2: Fix sort ordering for ndk-bundle, add macOS support (#91)
  * dotnet/android-tools@8e63795: [Xamarin.Android.Tools.AndroidSdk] Add API-29, API-30 to KnownVersions (#89)
  * dotnet/android-tools@a6a23bb: [Xamarin.Android.Tools.AndroidSdk] Default SDK component versions (#93)
  * dotnet/android-tools@32a1e2c: [build] fail macOS build if tests fail (#94)
  * dotnet/android-tools@79a0141: Return a default for unknown API levels (#90)
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants