Browse Source

Remove incomplete/wrong support for null-forgiving operator.

pull/2642/head
Siegfried Pammer 3 years ago
parent
commit
db034d3048
  1. 4
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  2. 4
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs
  3. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
  4. 3
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

4
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -552,10 +552,6 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -552,10 +552,6 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
// Never use file-scoped namespaces
FileScopedNamespaces = false
};
if (!cscOptions.HasFlag(CompilerOptions.NullableEnable))
{
settings.NullableReferenceTypes = false;
}
return settings;
}
else

4
ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public int GetLength2(string[]? arr)
{
return field_nullable_string!.Length + arr!.Length;
return field_nullable_string.Length + arr.Length;
}
public int? GetLength3(string[]? arr)
@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void CallByRef(ref string a, ref string? b)
{
ByRef(ref a).ToString();
ByRef(ref b)!.ToString();
ByRef(ref b).ToString();
}
public void Constraints<UC, C, CN, NN, S, SN, D, DN, NND>() where C : class where CN : class? where NN : notnull where S : struct where D : IDisposable where DN : IDisposable? where NND : notnull, IDisposable

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs

@ -20,11 +20,6 @@ using System; @@ -20,11 +20,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
#if ROSLYN4 && !NET40
// This is needed because there are some nullability attributes on compiler-generated lambdas,
// which are removed after IntroduceUsingDeclarations ran.
using System.Runtime.CompilerServices;
#endif
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{

3
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -2581,6 +2581,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2581,6 +2581,8 @@ namespace ICSharpCode.Decompiler.CSharp
private TranslatedExpression EnsureTargetNotNullable(TranslatedExpression expr, ILInstruction inst)
{
/*
// TODO Improve nullability support so that we do not sprinkle ! operators everywhere.
// inst is the instruction that got translated into expr.
if (expr.Type.Nullability == Nullability.Nullable)
{
@ -2598,6 +2600,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2598,6 +2600,7 @@ namespace ICSharpCode.Decompiler.CSharp
.WithRR(new ResolveResult(expr.Type.ChangeNullability(Nullability.Oblivious)))
.WithoutILInstruction();
}
*/
return expr;
}

Loading…
Cancel
Save