For https://github.com/terrafx/terrafx.interop.windows/pull/341, setting <field name="s_disableResolveLibraryHook" value="false" /> works as expected. However, <field name="s_disableResolveLibraryHook" value="false" initialize="true" /> does not and results in the error given below.
It is expected that this functionality work. In particularly it should at the very least work when all usages are trimmed, but I can't think of any reason why it shouldn't just work more generally either.
EXEC : error : One or more errors occurred. (Code generation failed for method '[TerraFX.Interop.Windows]TerraFX.Interop.Windows.HMODULE.
op_Implicit(HMODULE)') [D:\Users\tagoo\source\repos\terrafx.interop.windows\samples\DirectX\TerraFX.Samples.DirectX.csproj]
System.AggregateException: One or more errors occurred. (Code generation failed for method '[TerraFX.Interop.Windows]TerraFX.Interop.Wi
ndows.HMODULE.op_Implicit(HMODULE)')
---> ILCompiler.CodeGenerationFailedException: Code generation failed for method '[TerraFX.Interop.Windows]TerraFX.Interop.Windows.HMO
DULE.op_Implicit(HMODULE)'
---> System.NotSupportedException: Specified method is not supported.
at ILCompiler.ProcessLinkerXmlBase.ProcessXml(Boolean) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessLinkerXmlBase
.cs:line 104
at ILCompiler.BodySubstitutionsParser.GetSubstitutions(TypeSystemContext, UnmanagedMemoryStream, ManifestResource, ModuleDesc, Strin
g, IReadOnlyDictionary`2) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs:line 168
at ILCompiler.FeatureSwitchManager.AssemblyFeatureInfo..ctor(EcmaModule, IReadOnlyDictionary`2) in /_/src/coreclr/tools/aot/ILCompil
er.Compiler/Compiler/FeatureSwitchManager.cs:line 743
at ILCompiler.FeatureSwitchManager.FeatureSwitchHashtable.CreateValueFromKey(EcmaModule) in /_/src/coreclr/tools/aot/ILCompiler.Comp
iler/Compiler/FeatureSwitchManager.cs:line 704
at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey) in /_/src/coreclr/tools/Common/TypeSystem/
Common/Utilities/LockFreeReaderHashtable.cs:line 559
at ILCompiler.FeatureSwitchManager.GetSubstitution(MethodDesc) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitc
hManager.cs:line 35
at ILCompiler.FeatureSwitchManager.GetMethodIL(MethodDesc) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchMan
ager.cs:line 69
at ILCompiler.Compilation.CombinedILProvider.GetMethodIL(MethodDesc) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compil
ation.cs:line 588
at ILCompiler.Compilation.ILCache.CreateValueFromKey(MethodDesc) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilatio
n.cs:line 565
at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey) in /_/src/coreclr/tools/Common/TypeSystem/
Common/Utilities/LockFreeReaderHashtable.cs:line 559
at ILCompiler.Compilation.GetMethodIL(MethodDesc) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs:line 88
at Internal.IL.ILImporter..ctor(ILScanner, MethodDesc, MethodIL ) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scan
ner.cs:line 70
at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs
:line 122
--- End of inner exception stack trace ---
at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs
:line 134
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker&, Int32, Boolean& )
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker&, Int32, Boolean& )
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1, ParallelOptions, Boolean)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection, CancellationToken, Exception)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1, ParallelOptions, Action`1, Action`2, Action`3, Func`
4, Func`5, Func`1, Action`1)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1, ParallelOptions, Action`1)
at ILCompiler.ILScanner.CompileMultiThreaded(List`1) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 97
at ILCompiler.ILScanner.ComputeDependencyNodeDependencies(List`1) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner
.cs:line 86
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/coreclr/tools/aot/ILCompiler.Dependenc
yAnalysisFramework/DependencyAnalyzer.cs:line 315
at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 140
at ILCompiler.Program.<Run>g__RunScanner|73_4(<>c__DisplayClass73_0&) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 884
at ILCompiler.Program.Run(String[]) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 866
at ILCompiler.Program.Main(String[]) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 1150
NativeAOT will not support this. IL Linker should instead drop this undocumented feature. The way this is implemented is ridiculous: https://github.com/dotnet/linker/issues/2323
For https://github.com/terrafx/terrafx.interop.windows/pull/341, setting
<field name="s_disableResolveLibraryHook" value="false" />
works as expected. However,<field name="s_disableResolveLibraryHook" value="false" initialize="true" />
does not and results in the error given below.It is expected that this functionality work. In particularly it should at the very least work when all usages are trimmed, but I can't think of any reason why it shouldn't just work more generally either.