TemporaryGeneratedFile_[guid] in /obj/debug breaking build

I solved this issue by going to the project solution (whose build) was giving this error. right click on the project and unload the project. Then right click on the project and edit the .csproj file. Look for these temp (problematic) generated files. (see example code) remove this file references from the .csproj file. Right … Read more

The mystery of stuck inactive msbuild.exe processes, locked Stylecop.dll, Nuget AccessViolationException and CI builds clashing with each other

After a lot of digging around and trying various things to no effect, I eventually ended up creating a new minimal solution which reproduced the issue with very little else going on. The issue turned out to be caused by msbuild’s multi-core parallelisation – the ‘m’ parameter. The ‘m’ parameter tells msbuild to spawn “nodes”, … Read more

Why does StyleCop recommend prefixing method or property calls with “this”?

I don’t really follow this guidance unless I’m in the scenarios you need it: there is an actual ambiguity – mainly this impacts either constructors (this.name = name;) or things like Equals (return this.id == other.id;) you want to pass a reference to the current instance you want to call an extension method on the … Read more

Disabling StyleCop rules

In your StyleCop install, there’s a Settings.StyleCop file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it. You can also put copies of the settings file into your projects to override the global settings. If you’re using Visual Studio integration and … Read more

Stylecop vs FXcop

Stylecop is a style analysis tool that works at the source code level. It exists primarily to provide a single common style that managed projects can use to remain consistent within the larger world of managed software. It makes decisions regarding style primarily to avoid holy wars (after all, style is almost always an inherently … Read more

Should ‘using’ directives be inside or outside the namespace?

There is actually a (subtle) difference between the two. Imagine you have the following code in File1.cs: // File1.cs using System; namespace Outer.Inner { class Foo { static void Bar() { double d = Math.PI; } } } Now imagine that someone adds another file (File2.cs) to the project that looks like this: // File2.cs … Read more