Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

SimpleStubs fails in VS 2019 v16.7.5 #63

Open
labarilem-nitro opened this issue Oct 12, 2020 · 3 comments
Open

SimpleStubs fails in VS 2019 v16.7.5 #63

labarilem-nitro opened this issue Oct 12, 2020 · 3 comments

Comments

@labarilem-nitro
Copy link

Hi,

I'm trying to use SimpleStubs in a UI test project for UWP but I get the following error:

3>  SimpleStubs: Generating stubs for project: <...>
3>  SimpleStubs: Failed to generate stubs: System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Stack trace:

3>     at System.MemoryExtensions.AsSpan(String text)
3>     at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
3>     at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__18.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadProjectInfoAsync>d__22.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__24.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()
3>     --- End of inner exception stack trace ---
3>     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
3>     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
3>     at System.Threading.Tasks.Task`1.get_Result()
3>     at Etg.SimpleStubs.CodeGen.Program.Main(String[] args)
3>  ---> (Inner Exception #0) System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
3>  File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
3>     at System.MemoryExtensions.AsSpan(String text)
3>     at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
3>     at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__18.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadProjectInfoAsync>d__22.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__24.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()

Detailed log:

3>  === Pre-bind state information ===
3>  LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
3>   (Fully-specified)
3>  LOG: Appbase = file:///C:/Users/nitroagility/.nuget/packages/simplestubs/2.4.8.2/tools/
3>  LOG: Initial PrivatePath = NULL
3>  Calling assembly : System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
3>  ===
3>  LOG: This bind starts in LoadFrom load context.
3>  WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
3>  LOG: Using application configuration file: C:\Users\nitroagility\.nuget\packages\simplestubs\2.4.8.2\tools\Etg.SimpleStubs.CodeGen.exe.Config
3>  LOG: Using host configuration file: 
3>  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
3>  LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
3>  LOG: The same bind was seen before, and was failed with hr = 0x80070002.
3>  <---

Is there a way to fix the issue?

@labarilem-nitro labarilem-nitro changed the title SimpleStubs fails in Visual Studio v16.7.5 SimpleStubs fails in VS 2019 v16.7.5 Oct 12, 2020
@nehmebilal
Copy link
Collaborator

Hello @labarilem-nitro, thank you for reporting this. I currently don't have a lot of time to keep updating SimpleStubs but I encourage users to contribute by submitting PRs. SimpleStubs code is like any other C# code and any C# dev should be able to read it and debug it. Please take a look at the Developer Documentation to get started. I suspect this issue may be a simple matter of updating Roslyn packages to latest. If you can give that a try and run the tests as described in the docs, I'd be happy to merge that in a publish a new NuGet.

@timpalpant
Copy link
Contributor

I have started PR #65 to update the dependencies in hopes that it will fix this issue. If you have any other suggestions for how to test it or proceed, I'd appreciate your help!

@nehme-bilal-ah
Copy link
Contributor

Hello @timpalpant, thanks for the PR! To test this further you can update the SimpleStubs.nuspec and generate a NuGet using NuGetPack.bat. Then you can install the NuGet locally and test it in your IDE to see if it fixes the problem.

Note that NuGets often get cached by the framework when installed so I would recommend changing the version every time you generate a new NuGet. I usually add a letter suffix for testing (e.g. 2.4.8.3-a, 2.4.8.3-b) and then remove it once I have a working version.

I hope that helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants