Nullability supported since C# 7.0. Replace Contract.Requires(variable != null); with ArgumentNullException.ThrowIfNull
system.diagnostics.codeanalysis supported in NET core. Compatible with framework but feature essentially not available. Use Postconditions: MaybeNull and NotNull
Summary:
What are code contracts? https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts
Solutions:
Contract.Requires(variable != null);
with ArgumentNullException.ThrowIfNullFurther reading:
dotnet runtime 23869 stackexchange 47108 dotnet roslyn-analyzers 3134 nullable-analysis