microsoft / SimpleStubs

*SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver.
Other
66 stars 29 forks source link

Unable to exclude vcxproj file #54

Closed 33kelder closed 5 years ago

33kelder commented 5 years ago

In my solution there is a '.vcxproj' file. When compiling the unit test project with Etg.SimpleStubs, I get the error message: 1> Simplestubs encountered errors when opening the workspace; Stubs will be generated only for projects that successfully opened. Errors: [Failure] Cannot open project '.vcxproj' because the file extension '.vcxproj' is not associated with a language. Adding the name of the project to the 'SimpleStubs.json' file in the 'IgnoredProjects' node, does not solve the error.

nehmebilal commented 5 years ago

@oakrefactory is your .vcxproj project referenced by the test project?

nehmebilal commented 5 years ago

Also is this actually causing your build to fail?

33kelder commented 5 years ago

The build doesn't fail, it just gives an error message in the output section. I get the error message if I reference the project directly, but also if I don't reference it.

nehmebilal commented 5 years ago

https://github.com/Microsoft/SimpleStubs/blob/master/src/SimpleStubs.CodeGen/CodeGen/SimpleStubsGenerator.cs#L38

This issue is happening when the project is being opened with Roslyn. Probably Roslyn having trouble dealing with the reference to the .vcxproj project. Given that the problem is happening when the test project is being opened with workspace.OpenProjectAsync(testProjectPath), I would expect to only see the issue if the .vcxproj project is referenced by the test project.

Maybe try moving the stubs to a different project as describe in the Tips and Tricks section and let me know if that fixes the issue.

Good thing that it's not failing your build.

I also encourage you to try to debug it and maybe fix it yourself. SimpleStubs code is not much more complicated that any other C# code and the code base is quite small actually. The Dev Docs should get you started quickly.

33kelder commented 5 years ago

I debugged the project. The diagnostic message is created when MSBuildWorkspace.OpenProjectAsync is called. It is not a message generated by SimpleStubs code. Supressing this message might have some unwanted side-effects. Since it is not failing the build, my suggesting is to leave it as it is.