Monthly Archives: May 2019

c# new feature request : AutoInitListsOnFirstUse

Another sugar coating – a compiler should easily generate code for this (?) without any side effects. why force people to do new boiler plate code ?

List<string> myListOfStrings;


This throws NullReferenceException until we do new List<string>();

The probability of it happening is more when this is part of another data class, which we initialized but forgot to look into all hose other initializations we need to do.

In case somebody want to avoid this behavior we should have an attribute to support old behavior.


Creating dotnet solution, project and test project with cli

This is a good source. 

mkidr MyConsoleProjectWithUnitTest
cd MyConsoleProjectWithUnitTest/
dotnet new sln
mkdir HelloWorldConsole
cd HelloWorldConsole/
dotnet new console 
(or dotnet new classlib for creating Library instead of console project)
dotnet run
cd ..
mkdir HelloWorldConsole.Tests
cd HelloWorldConsole.Tests/
dotnet new mstest 
dotnet add reference ../HelloWorldConsole/HelloWorldConsole.csproj 
cd ..
dotnet sln add HelloWorldConsole/HelloWorldConsole.csproj 
dotnet sln add HelloWorldConsole.Tests/HelloWorldConsole.Tests.csproj
code . 
# Make modifications to your tests, program. 
Cd HelloWorldConsole.Tests
dotnet test