Browse Source

Revert "Add support for C# 11 parameter null checks"

This reverts commit 9e462b53ad.
pull/3244/head
Daniel Grunwald 10 months ago
parent
commit
8e7e4ba856
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/YieldReturn.cs
  2. 8
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  3. 4
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  4. 1
      ICSharpCode.Decompiler/CSharp/Syntax/Roles.cs
  5. 21
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs
  6. 15
      ICSharpCode.Decompiler/IL/ILVariable.cs

9
ICSharpCode.Decompiler.Tests/TestCases/Pretty/YieldReturn.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@ -427,13 +427,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -427,13 +427,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("normal exit");
}
#if CS110 && false
public IEnumerable<object> YieldBangBang(object x!!)
{
yield return x;
}
#endif
internal IEnumerable<int> ForLoopWithYieldReturn(int end, int evil)
{
// This loop needs to pick the implicit "yield break;" as exit point

8
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -1825,14 +1825,6 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1825,14 +1825,6 @@ namespace ICSharpCode.Decompiler.CSharp
RemoveAttribute(entityDecl, KnownAttribute.AsyncStateMachine);
RemoveAttribute(entityDecl, KnownAttribute.DebuggerStepThrough);
}
foreach (var parameter in entityDecl.GetChildrenByRole(Roles.Parameter))
{
var variable = parameter.Annotation<ILVariableResolveResult>()?.Variable;
if (variable != null && variable.HasNullCheck)
{
parameter.HasNullCheck = true;
}
}
}
internal static bool RemoveAttribute(EntityDeclaration entityDecl, KnownAttribute attributeType)

4
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -2647,10 +2647,6 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2647,10 +2647,6 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
WriteIdentifier(parameterDeclaration.NameToken);
}
if (parameterDeclaration.HasNullCheck)
{
WriteToken(Roles.DoubleExclamation);
}
if (!parameterDeclaration.DefaultExpression.IsNull)
{
Space(policy.SpaceAroundAssignment);

1
ICSharpCode.Decompiler/CSharp/Syntax/Roles.cs

@ -68,7 +68,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -68,7 +68,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public static readonly TokenRole Colon = new TokenRole(":");
public static readonly TokenRole DoubleColon = new TokenRole("::");
public static readonly TokenRole Arrow = new TokenRole("=>");
public static readonly TokenRole DoubleExclamation = new TokenRole("!!");
public static readonly Role<Comment> Comment = new Role<Comment>("Comment", null);
public static readonly Role<PreProcessorDirective> PreProcessorDirective = new Role<PreProcessorDirective>("PreProcessorDirective", null);

21
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs

@ -164,26 +164,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -164,26 +164,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
bool hasNullCheck;
public CSharpTokenNode DoubleExclamationToken {
get {
if (hasNullCheck)
{
return GetChildByRole(Roles.DoubleExclamation);
}
return CSharpTokenNode.Null;
}
}
public bool HasNullCheck {
get { return hasNullCheck; }
set {
ThrowIfFrozen();
hasNullCheck = value;
}
}
public CSharpTokenNode AssignToken {
get { return GetChildByRole(Roles.Assign); }
}
@ -213,7 +193,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -213,7 +193,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
var o = other as ParameterDeclaration;
return o != null && this.Attributes.DoMatch(o.Attributes, match) && this.ParameterModifier == o.ParameterModifier
&& this.Type.DoMatch(o.Type, match) && MatchString(this.Name, o.Name)
&& this.HasNullCheck == o.HasNullCheck
&& this.DefaultExpression.DoMatch(o.DefaultExpression, match);
}

15
ICSharpCode.Decompiler/IL/ILVariable.cs

@ -438,21 +438,6 @@ namespace ICSharpCode.Decompiler.IL @@ -438,21 +438,6 @@ namespace ICSharpCode.Decompiler.IL
/// </summary>
internal bool RemoveIfRedundant;
private bool hasNullCheck;
/// <summary>
/// Gets/sets whether a parameter has an auto-generated null check, i.e., the !! modifier.
/// Returns false for all variables except parameters.
/// </summary>
public bool HasNullCheck {
get => hasNullCheck;
set {
if (Kind != VariableKind.Parameter && value)
throw new InvalidOperationException("Cannot set HasNullCheck on local variables!");
hasNullCheck = value;
}
}
public ILVariable(VariableKind kind, IType type, int? index = null)
{
if (type == null)

Loading…
Cancel
Save