Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to enable nullable reference types in VS 2022

Discussion in 'Code Editors & IDEs' started by timothy-s-dev, Jul 19, 2022.

  1. timothy-s-dev

    timothy-s-dev

    Joined:
    Nov 7, 2012
    Posts:
    5
    I would like to turn on nullable reference types for a unity project (2022.1.9) in visual studio 2022. I've tried a directory.build.props file as well as a csc.rsp file with no luck. Putting -Nullable:enable in the compiler options worked, but only in unity, not in visual studio. Did the method for doing that change?
     
    Aristonaut likes this.
  2. Aristonaut

    Aristonaut

    Joined:
    May 4, 2019
    Posts:
    15
    Did you ever figure this one out? I can't seem to either.
     
  3. Aristonaut

    Aristonaut

    Joined:
    May 4, 2019
    Posts:
    15
    Looks like it may be related to the this issue with IntelliSense and old-style csproj files? (See discussion here: <Nullable> has no effect in old-style csproj)
    TLDR: If I understand it right. IntelliSense tooling will not be updated to give framework 4.7.1 full support for C# 8. Microsoft says framework will only guarantee support for framework up to C# 7.3. Guess we'll have to hold out for unity to support net 6 or something. VisualStudio won't be back-fixing IntelliSense for nullable or other C# 8 features.
     
    Last edited: Aug 4, 2022