Excluding standard directories from code coverage results with C++/CLI - visual-studio-2010

I have a Visual Studio 2010 .NET 4 solution with C# projects and a C++/CLI project.
I use Visual Studio's built in unit tests and code coverage.
Other than the fact that Visual Studio 2010 coverage tool for C++/CLI projects seems to be much weaker than Visual Studio 2008 coverage tool, I get weird results.
For example, I get uncovered code in this file:
c:\program files (x86)\microsoft
visual studio 10.0\vc\include\xstring
And some other files in that directory.
I want to exclude this code from coverage results.
Is there a way to put some exclude attributes on that code?
If not, is there a different automatic way to exclude that code from coverage? If not, is there a way to use EXCLUDE option to exclude it? Can it be done automatically within Visual Studio without running the coverage tool from command prompt?
Any other solutions?

Well, the MSDN documentation you linked to says:
EXCLUDE option is supported with code coverage.
To exclude all functions in a namespace use the wildcard character:
MyNamespace::*
Have you tried /EXCLUDE:std::* ? It sounds as if that would be the way to go.

Related

Visual Studio - Under the hood (NPM/Typescript)

How does Visual Studio (2015) work with external tools like NPM and Typescript compiler (tsc.exe) etc.? I guess, at the time of building the solution or project, something must be telling MSBuild to run these extra tools. I want to understand this under the hood operation.
It all depends...
Visual studio has multiple services and features that interlink here:
Language Services - Visual Studio can be extended with so called language services, these provide intellisense, syntax analysis, highlighting etc. For Javascript and Typescript Microsoft provides a Language service that provides such information.
MsBuild - Underneath most of Visual Studio projects lives an MsBuild project. If you search your Program files directory you'll find an MsBuild folder and underneath that there are a number of target files. This includes one for Typescript which will transform your .ts files during build. These targets files either directly use the exec MsBuild task to run tools or provide a custom MsBuild task in the form of a .NET Assembly that implements specific interfaces. These tasks can either implement the required action themselves or shell out to a tool to have it perform the action.
Roslyn - For C# and VB.NET the parsing of the projects and the background compilation of the sources is handled by a new compiler called Roslyn. This actually runs in the background while you type and has a very powerful in-memory model of all your code in your project. Roslyn supports add-ins as well in the form of analyzers and refactor action that either provide the user with feedback on common errors or provide ways to automatically rewrite/change the code.
Task Runner - The Visual Studio Task Runner is a plugin for Visual Studio that first shipped as an extension and is now part of Visual Studio. It reacts to events in the IDE (build, test, etc) and can associate actions in your package.json or grunt or bower etc scripts. The plugin will make sure your script commands are executed at the right point in time during the builds.
Test Runners - The Visual Studio Test Window has support for extensions as well, so the Mocha and the Chutzpah extension in your project will be picked up and during the test execution these plugins will be asked to first list and later execute the tests. These runners act as a kind of proxy, feeding back the list of tests and their status after execution.
Custom extensions - There are many other ways in which some vendors extend Visual Studio by providing a generic extension. These extensions may contain any of the above elements or may just listen to the events generated by Visual Studio while you do your work and react on them.
You can see the references to the typescript items if you open the .csproj
with a text editor (or from visual studio : unload the project, right-click on the project and choose edit myproject.csproj )
You'll see the typescript resources :
<ItemGroup>
<TypeScriptCompile Include="src\config.ts" />
the target for the build :
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
The external tools, are configured in Tools/Options :

Prevent Visual Studio from trying to parse typescript

Working on a project using Visual Studio as my IDE. It has an API component written in C#, and a webserver component that uses TypeScript.
I am using webpack to deal with the typescript compilation and would like to remove the Visual Studio build step from the typescript files.
Normally I wouldn't care if it was building them, but I am using Typescript > 1.8.4 which has language features that Visual Studio cannot understand which is making Visual Studio throw errors and prevent compilation. I found a workaround for this in this github issue thread but I have other developers cross team who are working on this and trying to coordinate a hack to make code among them will not work.
I have also tried removing the typescript imports line from the .csproj file, but whenever I add a new ts file, it adds the line back in.
Is there a way to completely shut down the typescript compilation/parsing step in Visual Studio and prevent it from coming back?
This in in VS 2015.
You can disable typescript compilation by editing the .csproj file to contain the following:
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
That should disable all typescript compilation within VS 2015.
To disable TypeScript compilation altogether for Visual Studio, edit:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets
(Your path might be slightly different depending on your OS/VS version, in that case just search for Microsoft.TypeScript.targets)
And add:
<PropertyGroup>
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>
This works for .NET Core projects as well.
It seems that the errors are triggered by IntelliSense and one can remove IntelliSense errors by simply filtering the list.
In case that other solutions doesn't help this is the key to clean up the error list, at least temporarily.
Sam Storie's answer is a great start and it will stop typescript errors from preventing compilation, but Visual Studio will still report the parsing errors which will prevent the ability to use the built in publishing tools.
To completely remove error reporting in ts, find all import lines in the csproj that reference typescript and set the Condition property to false, make sure to restart VS afterwards:
Example:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="false" />
Remove / Uncheck Test Javascript Content Files from the Project filter.

Integration between MSTest, Specflow and Serenity

Introduction
After a long struggle i finally found out how to run my specflow scenario's through the MSTest Runner. However i could not find a convenient way of showing the test results in the orderly overview that many BDD books and courses promote.
What i've tried so far
The way i currently generate my reports is with the following CMD commands, executed in the Visual Studio Dev CMD.
generic
"navigate\to\specific\visual\studio\folder\mstest.exe" /testcontainer:"navigate\to\test\dll\relative\to\mstest" /resultsfile:\folder\in\my\project\result.html
"navigate\to\specific\specflow\folder\in\project\specflow.exe mstestexecutionreport "absolute\path\to\my\csproj\file\under\test" /testResult:relative\directory\in\project\testResults.trx /out:directory\relative\in\project\TestResults.html
my specific unreadable (obfuscated) case
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" /testcontainer:"C:\Workspace\Branch\Sub1\Sub2a\Project\bin\Debug\Project.dll" /resultsfile:\Sub2a\TestResults\TestResults.trx
"C:\Workspace\Branch\Sub1\Sub2b\SpecFlow.2.0.0\tools\specflow.exe" mstestexecutionreport "C:\Workspace\Branch\Sub1\sub2a\Project\Project.csproj" /testResult:Sub1\TestResults\TestResults.trx /out:Sub1\TestResults\TestResults.html
I probably don't have to mention how tighlty coupled this script is to my specific machine, workspace, project, visual studio version and tests.
There must be some way to make these tools work better with a more generic script or some kind of plugin for the mstest report without going through so much cmd line statements with huge parameters.
Thanks in advance.

In Visual Studio 2013 how do I limit code analysis to my code and not to referenced assemblies?

I have a solution in Visual Studio 2013 (c# code) that has a reference to a third-party assembly that I added with NuGet (ICSharpCode.SharpZipLib). When I run the "Code Analysis" on the solution I get lots of warnings coming from the third-party assembly. How do I tell VS that I only want code analysis advice from my code?
I'm pretty sure the errors are coming from the library itself and not my usage of it. There are a total of 32 issues e.g.
CA2237: Mark ISerializable types with SerializableAttribute.
I am using ILMerge to bundle into a single executable do you think that has confused the code analysis?
There is no way to tell FxCop to ignore namespaces or types in your code if it lives in the same binaries. When using ILMerge, the SharpZipLib essentially becomes part of your code, as it's merged into your assembly.
To get proper results, run FxCop on the assembly that's generated before the merge.
Other solutions will mention to put a [GeneratedCode] attribute on classes you want excluded, but IlMerge has no option to to that while merging, so that won't help you out.
In Visual Studio 2015 Code Analysis works on the source code using the new Roslyn Engine, which will solve the issue probably, as it does the analysis even before compilation and as such will not be impacted by your use of IlMerge.

Compile Less files in Visual Studio 2013 for Web

I am new to Less and I am using Visual Studio 2013 for Web for development. And i aware Visual Studio supports less files.
I have added .less to my project and added small mix-ins..
While i build my project i didn't get corresponding css files.. Because of using Express edition i can't add Web Essential extension.
How do i compile my less files? Or is there is any other options to compile less files?
I know this is now old but if you happen to still be looking for a solution then you will need to use an external application to compile your LESS files. There are a few out there but two I can recommend are...
Koala - http://koala-app.com/
SimpLESS - http://wearekiss.com/simpless
I have used both in conjunction with Visual Studio and can recommend either. They can compile on-the-fly every time you save your LESS file within VS and work pretty seamlessly.
look at : Can Visual Studio 2013 generate CSS files from .less files?

Resources