Development Notes by Gleb Sevruk
среда, 20 апреля 2016 г.
четверг, 12 марта 2015 г.
NCrunch is great
It will immediately tell you, when the code is done, and you can go in bed without any fear.
You wrote several test cases, and have uncertainty with red mess:
One more line of code:
Moment when everything becomes green is unforgettable experience.
Even if further testing found issue, which is unlikely with NCrunch, just add one red test and fix it in several seconds.
Forget about build, run, debug. Everything is in log window available in a few milliseconds.
You wrote several test cases, and have uncertainty with red mess:
Moment when everything becomes green is unforgettable experience.
Even if further testing found issue, which is unlikely with NCrunch, just add one red test and fix it in several seconds.
Forget about build, run, debug. Everything is in log window available in a few milliseconds.
воскресенье, 9 февраля 2014 г.
Using NDepend for planing rewrite effort
Once I got bored with old code-base and started wondering, how much effort it will take to rewrite entire software.
First, you will need to write down entire feature scope. Linear lists (like issues in Jira) or even bullets doesn't work as good as mindmaps. There are a lot of tools available. Best free are XMind and http://mind42.com/ (for free online collaboration). We build a feature map (also called as story map, or impact map) in mind mapping tool (example from the web):

As I am dealing with already existing software, I want to know exactly how much effort was put into each component. This way I'll know what components\feature are the most risky, so we can plan more time in.
As the code got rotten enough, lets first answer the question "How long it will to do rewrite?"
You can download NDepend for .Net project, it is a really good tool for visualizing software metrics. (http://www.ndepend.com/).
After it analyzes given solution (*.sln), dashboard along with web report appears:
120K lines of code... Seems a lot. So I disable some of irrelevant assemblies (Utilities and test projects):
96K looks better.
Here is the Metrics overview (element name become visible on mouse over, selected element is displayed on class browser at the left):
One of the most useful feature is LINQ to Code:
With such LINQ it is possible to query TOP-10 Assemblies with biggest LOC or cyclomatic complexity, and more!
Form what I understood out of this metrics:
First, you will need to write down entire feature scope. Linear lists (like issues in Jira) or even bullets doesn't work as good as mindmaps. There are a lot of tools available. Best free are XMind and http://mind42.com/ (for free online collaboration). We build a feature map (also called as story map, or impact map) in mind mapping tool (example from the web):
As I am dealing with already existing software, I want to know exactly how much effort was put into each component. This way I'll know what components\feature are the most risky, so we can plan more time in.
As the code got rotten enough, lets first answer the question "How long it will to do rewrite?"
You can download NDepend for .Net project, it is a really good tool for visualizing software metrics. (http://www.ndepend.com/).
After it analyzes given solution (*.sln), dashboard along with web report appears:
120K lines of code... Seems a lot. So I disable some of irrelevant assemblies (Utilities and test projects):
Fragment from web report:
Here is the Metrics overview (element name become visible on mouse over, selected element is displayed on class browser at the left):
One of the most useful feature is LINQ to Code:
Form what I understood out of this metrics:
- A lot of code is related to WinForms InitializeComponent() method
- A lot of code is only for handling UI controls
- Core components are not so big to rewrite.
Need to run onto story-map now...
пятница, 23 августа 2013 г.
Completely Disable Static Code Contract Checking on your PC
Having started using Code Contracts on our project, build
time increased dramatically.
Even with “Check in Background” turned on – the build is
still slow and causing major problems:
- *.pdb and *.dll files sometimes become locked
- Error 1 The command "C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@Application1ccrewrite.rsp"" exited with code -1 (even from unit tests)
- Process “ccheck.exe” just hang and consume 100% CPU even after build has cancelled
The solution was to do “Clean Solution”, remove all output folders
(sometimes with Unlocker, and that is sic), and do clean rebuild.
It is just unacceptable if I am debugging only one Unit Test
from one specific project to clean and rebuild everything.
There are several ways to disable checking.
Normal way
Project Properties. If you have full control over *.csproj
file you can just uncheck it.
If your team wants to check code contract, you cannot simply disable it in global project properties.
Another drawback is that you need to do it for every
project.
Msbuild way
If you only use build scripts for compilation then it is
simple to pass variable to msbuild:
msbuild .exe "AllBuild.proj" /m:8 /t:build /p:CodeContractsRunCodeAnalysis=false,RunCodeAnalysis=Never,CodeContractsReferenceAssembly=DoNotBuild
Visual Studio and
Msbuild
If you do not want to pass parameters to msbuild or you are
building from Visual Studio, there is a way to suppress static code contracts
check and code analysis.
Using this approach, you will disable it machine-wide.
Notice: each *.csproj file contains <Import
Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />.
It is possible to modify Microsoft.CSharp.targets in a way
it will emulate passing parameters to msbuild
On my PC and.Net 4 full path to *.target and msbuild is "C:\Windows\Microsoft.NET\Framework\v4.0.30319\"
Open “C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets”
Add new PropertyGroup inside Project like:
<Project>
...
<PropertyGroup>
<CodeContractsRunCodeAnalysis>false</CodeContractsRunCodeAnalysis>
<RunCodeAnalysis>Never</RunCodeAnalysis>
<CodeContractsReferenceAssembly>DoNotBuild</CodeContractsReferenceAssembly>
</PropertyGroup>
...
<!-- About 5k lines bellow... -->
</Project>
All your builds now on your pc (from either MSBuild or
Visual Studio) will skip code and static code contracts analysis, so you do not
need to pass arguments, from Command Line, and all builds will skip analysis.
Note: all assemblies will still be rewritten so you cannot use "Edit And Continue" feature. I hope to find solution to it soon.
четверг, 15 августа 2013 г.
How to fix Ncrunch in Visual Studio 2013 Preview for code analyse
If you have a following error in NChrunch 2013:
..\..\..\..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (298)#0: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
..\..\..\..\..\..\..\..\..\..\..\..\..\..\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (298)#1: The "CodeAnalysis" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
You can easily fix it!
Backup "Microsoft.CodeAnalysis.Targets" in c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis : i named it "Microsoft.CodeAnalysis.Targets_2013"
Copy file from 2012 to 2013 folder
c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets
=> to
c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets
Open for editing: (best to open in VS)
c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets
Replace all occurences of
AssemblyFile=".\FxCopTask.dll"
to the old vesion of VS =>
AssemblyFile="c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\FxCopTask.dll"
So it will look like
<UsingTask TaskName="Microsoft.Build.Tasks.NativeCodeAnalysis" AssemblyFile="c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\FxCopTask.dll"/>
That's all.
Resynchronize NChrunch.
Подписаться на:
Сообщения (Atom)








