@obscurity: Ustawiłem <WarningsAsErrors>Nullable</WarningsAsErrors>
oraz <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
oraz odpalilem taki kod:
using System;
using System.Text.Json;
namespace ClassLibrary1;
class Program
{
record Value(string value);
public static void Main()
{
Value value = JsonSerializer.Deserialize<Value>("{}")!;
accept(value.value);
}
public static void accept(string value)
{
if (value == null)
{
Console.Write("fucked up design");
}
else
{
Console.Write("Good design");
}
}
}
Nie ważne czy użyję samego WarningsAsErrors
, czy samego TreatWarningsAsErrors
, czy obu - zawsze jest ta sama odpowiedź, czyli null
wchodzi do (string value)
.
Comments?