How to enable Nullable Reference Types feature of C# 8.0 for the whole project

前端 未结 6 1819
庸人自扰
庸人自扰 2020-12-05 03:44

According to the C# 8 announcement video the \"nullable reference types\" feature can be enabled for the whole project.

But how to enable it for the project? I did n

6条回答
  •  不知归路
    2020-12-05 04:32

    In addition to @DrewNoakes accepted answer, note that the nullable property can be set for all projects at once by adding a file called Directory.Build.props in the folder that contains your .sln file.

    Just define your Directory.Build.props file like this:

    
    
      
        enable
      
    
    
    

    You will need to restart Visual Studio for this to take effect.

    More about Directory.Build.props.

提交回复
热议问题