Skip to main content
58 votes
Accepted

Why would a development team insist that using a single solution for multiple projects in Visual Studio "increases interdependence complexity"?

You don't need to tell them how to structure their projects. Instead, make it a hard requirement that you can build the system from source by running one single script, without getting any errors. If ...
Doc Brown's user avatar
  • 210k
37 votes
Accepted

Strategies for merging 1 year of development in Visual Studio

There would have been a simple way which had kept your new development separate from the main branch without bringing you into this unfortunate situation: any change from the trunk should have been ...
Doc Brown's user avatar
  • 210k
31 votes
Accepted

Directory structure for a .NET Solution

On MSDN, there are some very old official guidelines. These are out of date though. As the page says, "This content is outdated and is no longer being maintained. It is provided as a courtesy for ...
David Arno's user avatar
  • 39.4k
28 votes
Accepted

Is Microsoft discouraging the use of 'var' in C#? (VS2017)

TL;DR: no, Microsoft are not discouraging the use of 'var' in C#. The image is simply lacking context to explain why it's complaining. If you install VS2017 RC and open up the Options panel and go to ...
David Arno's user avatar
  • 39.4k
26 votes

Forbid calls to arbitrary functions/classes in external code

You can do time-consuming things like writing a wrapper around the external API that leaves out your undesired operations, but nothing beats training and code reviews, because whatever standards or ...
Karl Bielefeldt's user avatar
19 votes
Accepted

Why use a local variable over a global variable?

This is a great question! Much programming advice and "best practices" comes down to the question of managing complexity. Or to put it plainly: How do we write and manage a large complex program ...
JacquesB's user avatar
  • 59.9k
16 votes
Accepted

If you follow the rule of Zero, how will you debug the construction of an object?

After much debate, many lunches, posts on various forums, and head scratching, a colleague of mine came up with the following: In Visual Studio, go to Debug->New Breakpoint->Function Breakpoint and ...
Christopher Pisz's user avatar
14 votes
Accepted

Where to put the Angular app in a ASP.NET Web API solution?

You have two options. Create separate mywebsite.api and a mywebsite.app projects in your solution. Advantages Proper separation of concerns. You can deploy updates to your api and your front end ...
CountZero's user avatar
  • 256
14 votes
Accepted

Have the unit test "using" the project, or just have same namespace?

Your unit tests are in a separate project and serve a separate function from your main code, so putting them into a separate namespace makes the most sense to me. If you're considering putting them ...
svick's user avatar
  • 10.1k
14 votes

Strategies for merging 1 year of development in Visual Studio

At that stage of merge I would say that automated merging may only over complicate the process. I have had similar issues with branches that have diverged for over a year and the most effective method ...
Erdrik Ironrose's user avatar
13 votes

Extension methods vs. Static Class Methods

I think extension methods are more "discoverable". If I have a certain type, Intelli-sense will automatically give me the extension methods. When a static class and method, I have to know the name ...
Jon Raynor's user avatar
  • 11.6k
12 votes
Accepted

Forbid calls to arbitrary functions/classes in external code

Are there any reliable and reasonably straightforward ways to achieve these constraints on external code, except from certain specific places in our own code? As the question is specifically about C#,...
David Arno's user avatar
  • 39.4k
11 votes

Extension methods vs. Static Class Methods

The biggest advantage for me is readability. Consider for a moment a typical LINQ statement that uses method chaining: var total = myList.Where(x => x.num > 5) .Select(x =>...
Becuzz's user avatar
  • 4,835
9 votes

Extension methods vs. Static Class Methods

There is no industry standard here about whether to use extension methods or static classes. Honestly, "extension methods" are in static classes. This is a case where the language designers of C# ...
Greg Burghardt's user avatar
8 votes

Strategies for merging 1 year of development in Visual Studio

A few years back we had a client with the same requirements of keeping branches separate. So we did. We never merged their branch back. They had there own unique version. We charged them extra ...
Jon Raynor's user avatar
  • 11.6k
7 votes
Accepted

How to "state of the art" integrate multiple sub-modules with duplicate dependencies?

Your incompatible Logger implementations cannot be linked because they have the same name. This leads to a simple solution that will solve all your problems: Incompatible versions should have ...
amon's user avatar
  • 135k
6 votes

Is Microsoft discouraging the use of 'var' in C#? (VS2017)

I think you are reading too much into it. So, there is a feature that allows you to replace usages of implicit typing with explicit type annotations, and you conclude from that, that implicit typing ...
Jörg W Mittag's user avatar
6 votes
Accepted

Organizing Visual Studio solution for microservices?

We ultimately found that decisions made about the devops pipeline and the microservices platform will likely dictate how the Visual Studio projects and solutions are organized. Initially, we decided ...
Daniel's user avatar
  • 249
6 votes
Accepted

IOC Classes are polluting my project

IoC is a very good thing. But factories that have a strictly 1 to 1 relationship with what they make aren't doing you much good. A factory should make something FOR something. They shouldn't be a ...
candied_orange's user avatar
6 votes

Extension methods vs. Static Class Methods

The big gain for extension methods is that they allow you to add extra functionality to .Net Framework or 3rd party classes that you don't have the source code for or can't otherwise modify. For ...
Peregrine's user avatar
  • 1,236
6 votes

Is it possible to throw compiler error when attempting to use an unimplemented method?

Someone had posted earlier about the Obsolete attribute, which can be configured to throw an compile error when attempting to use a method that is decorated as such. I don't know why that answer got ...
christok's user avatar
  • 187
6 votes
Accepted

What is the benefit of using "filters" instead of "folders" in Visual Studio C++ projects?

The primary benefit of filters in my experience is to separate headers (.h) files from source (.cpp) files. Then it's easier to traverse your c++ classes by using headers (you can use the refactoring ...
Whyan's user avatar
  • 126
6 votes

Best practice for knowing the link between binaries (*.exe and *.dll) and their source code?

The general idea is always the same: whenever you create a release of your product, make sure you assign a new unique version number to the end product, and use that version number for tagging the ...
Doc Brown's user avatar
  • 210k
5 votes
Accepted

Proper way to deploy ASP.net to production web server

From my painful experience, the more of deployment process is being done manually, the bigger trouble you'll get into. And both your current steps require heavy manual effort. Here are my ...
Harry Ninh's user avatar
5 votes

Have the unit test "using" the project, or just have same namespace?

I've used unit tests project with the same namespace as the real project (by manually removing the Tests suffix on the test project namespace) for a few years with zero issues. I think it leads to ...
julealgon's user avatar
  • 287
5 votes

Abuse of XML comments to keep comments up-to-date (in C#)

Outside the world of Visual Studio, where developers expect everything to happen automagically, greping source code is a usual practice, and it actually works very well. The problem with Visual ...
Arseni Mourzenko's user avatar
5 votes

When should I care about code metrics in Visual Studio?

Code metrics are simply sensors that indicate when something is out of an expected range. Taken in isolation, they really aren't that interesting as you point out, you can already guess at what it's ...
Berin Loritsch's user avatar
5 votes
Accepted

When developing for C++ in Visual Studio, is there a quick way of being able to test your code as an exe and DLL?

Is there a good method of developing a C++ program and quickly being able to switch between compiling it as a DLL and exe? A better strategy will be: Keep the DLL as is. Create an EXE by linking ...
R Sahu's user avatar
  • 1,986
5 votes
Accepted

Newbie: OOP working with different class-datatypes and loop through them

Your named objects either need Inherits abstractClass or Implements interfaceclass.name Make whichever one you pick and give it a Name method with no implementation. Then main needs either Private ...
candied_orange's user avatar
4 votes

How to organize MVVM files in solution

I have separated my solution in 8 projects: Converters Helpers Models.Business Models.DataContext Models.Entities Startup ViewModels Views I had to create the Startup project only to house the App....
Rodolfo Gaspar's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible