ashmind / mirrorsharp

MirrorSharp is a code editor <textarea> built on Roslyn and CodeMirror
BSD 2-Clause "Simplified" License
220 stars 39 forks source link

TypeInitializationException when using Microsoft.NETFramework.ReferenceAssemblies for net471 tests #188

Open rstm-sf opened 1 year ago

rstm-sf commented 1 year ago
System.TypeInitializationException: The type initializer for 'MirrorSharp.Tests.MirrorSharpOptionsWithXmlDocumentation' threw an exception.

System.TypeInitializationException
The type initializer for 'MirrorSharp.Tests.MirrorSharpOptionsWithXmlDocumentation' threw an exception.
   at MirrorSharp.Tests.MirrorSharpOptionsWithXmlDocumentation.get_Instance()
   at MirrorSharp.Tests.CompletionStateHandlerTests.<ExecuteAsync_SendsItemInfo_WhenCompletionIsActiveAndIIsProvided>d__4.MoveNext() in D:\git\github\mirrorsharp\Tests\CompletionStateHandlerTests.cs:line 74
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xunit.Sdk.ExecutionTimer.<AggregateAsync>d__4.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xunit.Sdk.ExceptionAggregator.<RunAsync>d__9.MoveNext() in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90

System.IO.FileNotFoundException
Could not find a part of the path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\mscorlib.dll'.
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
   at MirrorSharp.Internal.MetadataReferenceFactory.CreateMetadataReferenceWithXmlDocumentationSlow(String path) in D:\git\github\mirrorsharp\Common\Internal\MetadataReferenceFactory.cs:line 16
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableExtensions.FallbackWrapper`1.get_Count()
   at System.Collections.Immutable.ImmutableList`1.CreateRange(IEnumerable`1 items)
   at MirrorSharp.Advanced.MirrorSharpRoslynOptions`3.AddMetadataReferencesFromFiles(String[] paths) in D:\git\github\mirrorsharp\Common\Advanced\MirrorSharpRoslynOptions.cs:line 94
   at MirrorSharp.Tests.MirrorSharpOptionsWithXmlDocumentation.<>c.<.cctor>b__4_0(MirrorSharpCSharpOptions c) in D:\git\github\mirrorsharp\Tests\MirrorSharpOptionsWithXmlDocumentation.cs:line 19
   at MirrorSharp.MirrorSharpOptions.SetupCSharp(Action`1 setup) in D:\git\github\mirrorsharp\Common\MirrorSharpOptions.cs:line 54
   at MirrorSharp.Tests.MirrorSharpOptionsWithXmlDocumentation..cctor() in D:\git\github\mirrorsharp\Tests\MirrorSharpOptionsWithXmlDocumentation.cs:line 17

System.IO.DirectoryNotFoundException
Could not find a part of the path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\mscorlib.dll'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)

https://github.com/ashmind/mirrorsharp/blob/1d17e345bbfaf9c30f3735c017794908b337e7ea/Tests/CompletionStateHandlerTests.cs#L73 https://github.com/ashmind/mirrorsharp/blob/1d17e345bbfaf9c30f3735c017794908b337e7ea/Tests/RequestInfoTipHandlerTests.cs#L43 https://github.com/ashmind/mirrorsharp/blob/1d17e345bbfaf9c30f3735c017794908b337e7ea/Tests/SignatureHelpStateHandlerTests.cs#L28 https://github.com/ashmind/mirrorsharp/blob/1d17e345bbfaf9c30f3735c017794908b337e7ea/Tests/SignatureHelpStateHandlerTests.cs#L44

rstm-sf commented 1 year ago

https://github.com/ashmind/mirrorsharp/blob/f5e650b32055e9128309ee8c9cd44e9f42e6de53/Tests/MirrorSharpOptionsWithXmlDocumentation.cs#L11-L15

Needs another path, f.ex "\packages\microsoft.netframework.referenceassemblies.net471\1.0.2\build\.NETFramework\v4.7.1\mscorlib.dll"