Browse Source

Fix CA1507:UseNameofInPlaceOfString, adjust formatting of some older source files copied from NRefactory.

pull/1790/head
Siegfried Pammer 6 years ago
parent
commit
e211b01595
  1. 4
      ICSharpCode.Decompiler/CSharp/Annotations.cs
  2. 16
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs
  3. 36
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  4. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs
  5. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
  6. 7
      ICSharpCode.Decompiler/CSharp/Resolver/AwaitResolveResult.cs
  7. 46
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
  8. 20
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  9. 20
      ICSharpCode.Decompiler/CSharp/Resolver/MemberLookup.cs
  10. 2
      ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
  11. 14
      ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
  12. 24
      ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
  13. 274
      ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
  14. 6
      ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs
  15. 2
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
  16. 2
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs
  17. 62
      ICSharpCode.Decompiler/CSharp/Syntax/IAnnotatable.cs
  18. 4
      ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs
  19. 2
      ICSharpCode.Decompiler/CSharp/Syntax/IdentifierExpressionBackreference.cs
  20. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Backreference.cs
  21. 4
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Choice.cs
  22. 4
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/INode.cs
  23. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/NamedNode.cs
  24. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/OptionalNode.cs
  25. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Repeat.cs
  26. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Role.cs
  27. 2
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
  28. 16
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  29. 2
      ICSharpCode.Decompiler/CSharp/TypeSystem/AliasNamespaceReference.cs
  30. 4
      ICSharpCode.Decompiler/CSharp/TypeSystem/MemberTypeOrNamespaceReference.cs
  31. 4
      ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  32. 2
      ICSharpCode.Decompiler/CSharp/TypeSystem/SimpleTypeOrNamespaceReference.cs
  33. 4
      ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs
  34. 2
      ICSharpCode.Decompiler/DebugInfo/DebugInfoGenerator.cs
  35. 2
      ICSharpCode.Decompiler/DecompilerException.cs
  36. 10
      ICSharpCode.Decompiler/Documentation/IdStringProvider.cs
  37. 4
      ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs
  38. 6
      ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
  39. 2
      ICSharpCode.Decompiler/IL/Instructions/CallIndirect.cs
  40. 2
      ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs
  41. 4
      ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
  42. 2
      ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs
  43. 4
      ICSharpCode.Decompiler/Semantics/ArrayAccessResolveResult.cs
  44. 2
      ICSharpCode.Decompiler/Semantics/ArrayCreateResolveResult.cs
  45. 6
      ICSharpCode.Decompiler/Semantics/Conversion.cs
  46. 4
      ICSharpCode.Decompiler/Semantics/ConversionResolveResult.cs
  47. 8
      ICSharpCode.Decompiler/Semantics/ForEachResolveResult.cs
  48. 2
      ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs
  49. 8
      ICSharpCode.Decompiler/Semantics/NamedArgumentResolveResult.cs
  50. 4
      ICSharpCode.Decompiler/Semantics/OperatorResolveResult.cs
  51. 2
      ICSharpCode.Decompiler/Semantics/ResolveResult.cs
  52. 2
      ICSharpCode.Decompiler/Semantics/SizeOfResolveResult.cs
  53. 4
      ICSharpCode.Decompiler/Semantics/TypeIsResolveResult.cs
  54. 2
      ICSharpCode.Decompiler/Semantics/TypeOfResolveResult.cs
  55. 2
      ICSharpCode.Decompiler/Semantics/UnknownMemberResolveResult.cs
  56. 8
      ICSharpCode.Decompiler/TypeSystem/ArrayType.cs
  57. 2
      ICSharpCode.Decompiler/TypeSystem/ByReferenceType.cs
  58. 4
      ICSharpCode.Decompiler/TypeSystem/FullTypeName.cs
  59. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractTypeParameter.cs
  60. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAttribute.cs
  61. 8
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs
  62. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs
  63. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
  64. 8
      ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
  65. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs
  66. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs
  67. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
  68. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs
  69. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/TypeWithElementType.cs
  70. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/UnknownType.cs
  71. 6
      ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs
  72. 10
      ICSharpCode.Decompiler/TypeSystem/NullableType.cs
  73. 2
      ICSharpCode.Decompiler/TypeSystem/ParameterListComparer.cs
  74. 8
      ICSharpCode.Decompiler/TypeSystem/ParameterizedType.cs
  75. 2
      ICSharpCode.Decompiler/TypeSystem/PointerType.cs
  76. 2
      ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
  77. 4
      ICSharpCode.Decompiler/TypeSystem/SimpleTypeResolveContext.cs
  78. 2
      ICSharpCode.Decompiler/TypeSystem/SpecialType.cs
  79. 4
      ICSharpCode.Decompiler/TypeSystem/TaskType.cs
  80. 4
      ICSharpCode.Decompiler/TypeSystem/TopLevelTypeName.cs
  81. 22
      ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  82. 2
      ICSharpCode.Decompiler/Util/CallbackOnDispose.cs
  83. 4
      ICSharpCode.Decompiler/Util/EmptyList.cs
  84. 8
      ICSharpCode.Decompiler/Util/GraphVizGraph.cs
  85. 6
      ICSharpCode.Decompiler/Util/KeyComparer.cs
  86. 8
      ICSharpCode.Decompiler/Util/ProjectedList.cs
  87. 30
      ICSharpCode.Decompiler/Util/ResXResourceWriter.cs

4
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// <summary>
/// Currently unused; we'll probably use the LdToken ILInstruction as annotation instead when LdToken support gets reimplemented.
/// </summary>
public class LdTokenAnnotation {}
public class LdTokenAnnotation { }
public static class AnnotationExtensions
{
@ -223,7 +223,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -223,7 +223,7 @@ namespace ICSharpCode.Decompiler.CSharp
public ILVariableResolveResult(ILVariable v, IType type) : base(type)
{
this.Variable = v ?? throw new ArgumentNullException("v");
this.Variable = v ?? throw new ArgumentNullException(nameof(v));
}
}

16
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public string ConvertSymbol(ISymbol symbol)
{
if (symbol == null)
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
StringWriter writer = new StringWriter();
ConvertSymbol(symbol, new TextWriterTokenWriter(writer), FormattingOptionsFactory.CreateEmpty());
@ -48,11 +48,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -48,11 +48,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public void ConvertSymbol(ISymbol symbol, TokenWriter writer, CSharpFormattingOptions formattingPolicy)
{
if (symbol == null)
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
if (writer == null)
throw new ArgumentNullException("writer");
throw new ArgumentNullException(nameof(writer));
if (formattingPolicy == null)
throw new ArgumentNullException("formattingPolicy");
throw new ArgumentNullException(nameof(formattingPolicy));
TypeSystemAstBuilder astBuilder = CreateAstBuilder();
AstNode node = astBuilder.ConvertSymbol(symbol);
@ -93,8 +93,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -93,8 +93,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
if ((ConversionFlags & ConversionFlags.PlaceReturnTypeAfterParameterList) != ConversionFlags.PlaceReturnTypeAfterParameterList
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType)
{
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType) {
var rt = node.GetChildByRole(Roles.Type);
if (!rt.IsNull) {
rt.AcceptVisitor(new CSharpOutputVisitor(writer, formattingPolicy));
@ -131,8 +130,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -131,8 +130,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
if ((ConversionFlags & ConversionFlags.PlaceReturnTypeAfterParameterList) == ConversionFlags.PlaceReturnTypeAfterParameterList
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType)
{
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType) {
var rt = node.GetChildByRole(Roles.Type);
if (!rt.IsNull) {
writer.Space();
@ -318,7 +316,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -318,7 +316,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public string ConvertType(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
TypeSystemAstBuilder astBuilder = CreateAstBuilder();
astBuilder.AlwaysUseShortTypeNames = (ConversionFlags & ConversionFlags.UseFullyQualifiedEntityNames) != ConversionFlags.UseFullyQualifiedEntityNames;

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

@ -36,27 +36,27 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -36,27 +36,27 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
readonly protected TokenWriter writer;
readonly protected CSharpFormattingOptions policy;
readonly protected Stack<AstNode> containerStack = new Stack<AstNode> ();
readonly protected Stack<AstNode> containerStack = new Stack<AstNode>();
public CSharpOutputVisitor (TextWriter textWriter, CSharpFormattingOptions formattingPolicy)
public CSharpOutputVisitor(TextWriter textWriter, CSharpFormattingOptions formattingPolicy)
{
if (textWriter == null) {
throw new ArgumentNullException ("textWriter");
throw new ArgumentNullException(nameof(textWriter));
}
if (formattingPolicy == null) {
throw new ArgumentNullException ("formattingPolicy");
throw new ArgumentNullException(nameof(formattingPolicy));
}
this.writer = TokenWriter.Create(textWriter, formattingPolicy.IndentationString);
this.policy = formattingPolicy;
}
public CSharpOutputVisitor (TokenWriter writer, CSharpFormattingOptions formattingPolicy)
public CSharpOutputVisitor(TokenWriter writer, CSharpFormattingOptions formattingPolicy)
{
if (writer == null) {
throw new ArgumentNullException ("writer");
throw new ArgumentNullException(nameof(writer));
}
if (formattingPolicy == null) {
throw new ArgumentNullException ("formattingPolicy");
throw new ArgumentNullException(nameof(formattingPolicy));
}
this.writer = new InsertSpecialsDecorator(new InsertRequiredSpacesDecorator(writer));
this.policy = formattingPolicy;
@ -148,7 +148,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -148,7 +148,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
RPar();
}
#if DOTNET35
#if DOTNET35
void WriteCommaSeparatedList(IEnumerable<VariableInitializer> list)
{
WriteCommaSeparatedList(list.SafeCast<VariableInitializer, AstNode>());
@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteCommaSeparatedListInParenthesis(list.SafeCast<ParameterDeclaration, AstNode>(), spaceWithin);
}
#endif
#endif
protected virtual void WriteCommaSeparatedListInBrackets(IEnumerable<ParameterDeclaration> list, bool spaceWithin)
{
@ -337,7 +337,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -337,7 +337,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
writer.WriteToken(Roles.LBrace, "{");
break;
default:
throw new ArgumentOutOfRangeException ();
throw new ArgumentOutOfRangeException();
}
writer.Indent();
NewLine();
@ -720,7 +720,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -720,7 +720,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
spacePolicy = true;
break;
default:
throw new NotSupportedException ("Invalid value for BinaryOperatorType");
throw new NotSupportedException("Invalid value for BinaryOperatorType");
}
Space(spacePolicy);
WriteToken(BinaryOperatorExpression.GetOperatorRole(binaryOperatorExpression.Operator));
@ -803,7 +803,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -803,7 +803,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteKeyword(DirectionExpression.InKeywordRole);
break;
default:
throw new NotSupportedException ("Invalid value for FieldDirection");
throw new NotSupportedException("Invalid value for FieldDirection");
}
Space();
directionExpression.Expression.AcceptVisitor(this);
@ -1350,7 +1350,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -1350,7 +1350,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
StartNode(namespaceDeclaration);
WriteKeyword(Roles.NamespaceKeyword);
namespaceDeclaration.NamespaceName.AcceptVisitor (this);
namespaceDeclaration.NamespaceName.AcceptVisitor(this);
OpenBrace(policy.NamespaceBraceStyle);
foreach (var member in namespaceDeclaration.Members) {
member.AcceptVisitor(this);
@ -2409,9 +2409,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2409,9 +2409,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public virtual void VisitNewLine(NewLineNode newLineNode)
{
// formatter.StartNode(newLineNode);
// formatter.NewLine();
// formatter.EndNode(newLineNode);
// formatter.StartNode(newLineNode);
// formatter.NewLine();
// formatter.EndNode(newLineNode);
}
public virtual void VisitWhitespace(WhitespaceNode whitespaceNode)
@ -2445,7 +2445,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2445,7 +2445,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteKeyword(TypeParameterDeclaration.InVarianceKeywordRole);
break;
default:
throw new NotSupportedException ("Invalid value for VarianceModifier");
throw new NotSupportedException("Invalid value for VarianceModifier");
}
WriteIdentifier(typeParameterDeclaration.NameToken);
EndNode(typeParameterDeclaration);
@ -2472,7 +2472,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2472,7 +2472,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// StartNode(parentNode)-EndNode(parentNode)-pair is a child of parentNode.
WriteKeyword(CSharpModifierToken.GetModifierName(mod.Modifier), cSharpTokenNode.Role);
} else {
throw new NotSupportedException ("Should never visit individual tokens");
throw new NotSupportedException("Should never visit individual tokens");
}
}

2
ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs

@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
protected DecoratingTokenWriter(TokenWriter decoratedWriter)
{
if (decoratedWriter == null)
throw new ArgumentNullException("decoratedWriter");
throw new ArgumentNullException(nameof(decoratedWriter));
this.decoratedWriter = decoratedWriter;
}

2
ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public TextWriterTokenWriter(TextWriter textWriter)
{
if (textWriter == null)
throw new ArgumentNullException("textWriter");
throw new ArgumentNullException(nameof(textWriter));
this.textWriter = textWriter;
this.IndentationString = "\t";
this.line = 1;

7
ICSharpCode.Decompiler/CSharp/Resolver/AwaitResolveResult.cs

@ -58,9 +58,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -58,9 +58,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
: base(resultType)
{
if (awaiterType == null)
throw new ArgumentNullException("awaiterType");
throw new ArgumentNullException(nameof(awaiterType));
if (getAwaiterInvocation == null)
throw new ArgumentNullException("getAwaiterInvocation");
throw new ArgumentNullException(nameof(getAwaiterInvocation));
this.GetAwaiterInvocation = getAwaiterInvocation;
this.AwaiterType = awaiterType;
this.IsCompletedProperty = isCompletedProperty;
@ -72,7 +72,8 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -72,7 +72,8 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
get { return this.GetAwaiterInvocation.IsError || (AwaiterType.Kind != TypeKind.Dynamic && (this.IsCompletedProperty == null || this.OnCompletedMethod == null || this.GetResultMethod == null)); }
}
public override IEnumerable<ResolveResult> GetChildResults() {
public override IEnumerable<ResolveResult> GetChildResults()
{
return new[] { GetAwaiterInvocation };
}
}

46
ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public CSharpConversions(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
this.compilation = compilation;
}
@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public static CSharpConversions Get(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
CacheManager cache = compilation.CacheManager;
CSharpConversions operators = (CSharpConversions)cache.GetShared(typeof(CSharpConversions));
if (operators == null) {
@ -151,16 +151,16 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -151,16 +151,16 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public Conversion ImplicitConversion(ResolveResult resolveResult, IType toType)
{
if (resolveResult == null)
throw new ArgumentNullException("resolveResult");
throw new ArgumentNullException(nameof(resolveResult));
return ImplicitConversion(resolveResult, toType, allowUserDefined: true, allowTuple: true);
}
public Conversion ImplicitConversion(IType fromType, IType toType)
{
if (fromType == null)
throw new ArgumentNullException("fromType");
throw new ArgumentNullException(nameof(fromType));
if (toType == null)
throw new ArgumentNullException("toType");
throw new ArgumentNullException(nameof(toType));
TypePair pair = new TypePair(fromType, toType);
Conversion c;
@ -176,9 +176,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -176,9 +176,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public Conversion StandardImplicitConversion(IType fromType, IType toType)
{
if (fromType == null)
throw new ArgumentNullException("fromType");
throw new ArgumentNullException(nameof(fromType));
if (toType == null)
throw new ArgumentNullException("toType");
throw new ArgumentNullException(nameof(toType));
return StandardImplicitConversion(fromType, toType, allowTupleConversion: true);
}
@ -220,9 +220,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -220,9 +220,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public bool IsConstraintConvertible(IType fromType, IType toType)
{
if (fromType == null)
throw new ArgumentNullException("fromType");
throw new ArgumentNullException(nameof(fromType));
if (toType == null)
throw new ArgumentNullException("toType");
throw new ArgumentNullException(nameof(toType));
if (IdentityConversion(fromType, toType))
return true;
@ -247,9 +247,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -247,9 +247,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public Conversion ExplicitConversion(ResolveResult resolveResult, IType toType)
{
if (resolveResult == null)
throw new ArgumentNullException("resolveResult");
throw new ArgumentNullException(nameof(resolveResult));
if (toType == null)
throw new ArgumentNullException("toType");
throw new ArgumentNullException(nameof(toType));
if (resolveResult.Type.Kind == TypeKind.Dynamic)
return Conversion.ExplicitDynamicConversion;
@ -270,9 +270,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -270,9 +270,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public Conversion ExplicitConversion(IType fromType, IType toType)
{
if (fromType == null)
throw new ArgumentNullException("fromType");
throw new ArgumentNullException(nameof(fromType));
if (toType == null)
throw new ArgumentNullException("toType");
throw new ArgumentNullException(nameof(toType));
Conversion c = ImplicitConversion(fromType, toType, allowUserDefined: false, allowTuple: false);
if (c != Conversion.None)
@ -861,13 +861,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -861,13 +861,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return other;
}
return selected;
}
else if (NullableType.IsNullable(toType))
} else if (NullableType.IsNullable(toType))
return UserDefinedImplicitConversion(fromResult, fromType, NullableType.GetUnderlyingType(toType));
else
return Conversion.None;
}
else {
} else {
return Conversion.None;
}
}
@ -913,15 +911,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -913,15 +911,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return other;
}
return selected;
}
else if (NullableType.IsNullable(toType))
} else if (NullableType.IsNullable(toType))
return UserDefinedExplicitConversion(fromResult, fromType, NullableType.GetUnderlyingType(toType));
else if (NullableType.IsNullable(fromType))
return UserDefinedExplicitConversion(null, NullableType.GetUnderlyingType(fromType), toType); // A? -> A -> B
else
return Conversion.None;
}
else {
} else {
return Conversion.None;
}
}
@ -1106,9 +1102,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1106,9 +1102,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public bool IsDelegateCompatible(IMethod method, IType delegateType)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));
if (delegateType == null)
throw new ArgumentNullException("delegateType");
throw new ArgumentNullException(nameof(delegateType));
IMethod invoke = delegateType.GetDelegateInvokeMethod();
if (invoke == null)
return false;
@ -1126,9 +1122,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1126,9 +1122,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
bool IsDelegateCompatible(IMethod m, IMethod invoke, bool isExtensionMethodInvocation)
{
if (m == null)
throw new ArgumentNullException("m");
throw new ArgumentNullException(nameof(m));
if (invoke == null)
throw new ArgumentNullException("invoke");
throw new ArgumentNullException(nameof(invoke));
int firstParameterInM = isExtensionMethodInvocation ? 1 : 0;
if (m.Parameters.Count - firstParameterInM != invoke.Parameters.Count)
return false;

20
ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs

@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public CSharpResolver(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
this.compilation = compilation;
this.conversions = CSharpConversions.Get(compilation);
this.context = new CSharpTypeResolveContext(compilation.MainModule);
@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public CSharpResolver(CSharpTypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
this.compilation = context.Compilation;
this.conversions = CSharpConversions.Get(compilation);
this.context = context;
@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public CSharpResolver AddVariable(IVariable variable)
{
if (variable == null)
throw new ArgumentNullException("variable");
throw new ArgumentNullException(nameof(variable));
return WithLocalVariableStack(localVariableStack.Push(variable));
}
@ -313,7 +313,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -313,7 +313,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public CSharpResolver PushObjectInitializer(ResolveResult initializedObject)
{
if (initializedObject == null)
throw new ArgumentNullException("initializedObject");
throw new ArgumentNullException(nameof(initializedObject));
return WithObjectInitializerStack(new ObjectInitializerContext(initializedObject, objectInitializerStack));
}
@ -1313,9 +1313,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1313,9 +1313,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
// C# 4.0 spec: §3.8 Namespace and type names; §7.6.2 Simple Names
if (identifier == null)
throw new ArgumentNullException("identifier");
throw new ArgumentNullException(nameof(identifier));
if (typeArguments == null)
throw new ArgumentNullException("typeArguments");
throw new ArgumentNullException(nameof(typeArguments));
int k = typeArguments.Count;
@ -1866,9 +1866,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1866,9 +1866,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public static bool IsEligibleExtensionMethod(IType targetType, IMethod method, bool useTypeInference, out IType[] outInferredTypes)
{
if (targetType == null)
throw new ArgumentNullException("targetType");
throw new ArgumentNullException(nameof(targetType));
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));
var compilation = method.Compilation;
return IsEligibleExtensionMethod(compilation, CSharpConversions.Get(compilation), targetType, method, useTypeInference, out outInferredTypes);
}
@ -2348,7 +2348,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2348,7 +2348,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public ResolveResult ResolveCondition(ResolveResult input)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
IType boolean = compilation.FindType(KnownTypeCode.Boolean);
Conversion c = conversions.ImplicitConversion(input, boolean);
if (!c.IsValid) {
@ -2368,7 +2368,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2368,7 +2368,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public ResolveResult ResolveConditionFalse(ResolveResult input)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
IType boolean = compilation.FindType(KnownTypeCode.Boolean);
Conversion c = conversions.ImplicitConversion(input, boolean);
if (!c.IsValid) {

20
ICSharpCode.Decompiler/CSharp/Resolver/MemberLookup.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public static bool IsInvocable(IMember member)
{
if (member == null)
throw new ArgumentNullException("member");
throw new ArgumentNullException(nameof(member));
// C# 4.0 spec, §7.4 member lookup
if (member is IEvent || member is IMethod)
return true;
@ -99,7 +99,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -99,7 +99,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public bool IsAccessible(IEntity entity, bool allowProtectedAccess)
{
if (entity == null)
throw new ArgumentNullException("entity");
throw new ArgumentNullException(nameof(entity));
// C# 4.0 spec, §3.5.2 Accessiblity domains
switch (entity.Accessibility) {
case Accessibility.None:
@ -159,7 +159,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -159,7 +159,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IEnumerable<IEntity> GetAccessibleMembers(ResolveResult targetResolveResult)
{
if (targetResolveResult == null)
throw new ArgumentNullException("targetResolveResult");
throw new ArgumentNullException(nameof(targetResolveResult));
bool targetIsTypeParameter = targetResolveResult.Type.Kind == TypeKind.TypeParameter;
bool allowProtectedAccess = IsProtectedAccessAllowed(targetResolveResult);
@ -276,11 +276,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -276,11 +276,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public ResolveResult LookupType(IType declaringType, string name, IReadOnlyList<IType> typeArguments, bool parameterizeResultType = true)
{
if (declaringType == null)
throw new ArgumentNullException("declaringType");
throw new ArgumentNullException(nameof(declaringType));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (typeArguments == null)
throw new ArgumentNullException("typeArguments");
throw new ArgumentNullException(nameof(typeArguments));
int typeArgumentCount = typeArguments.Count;
Predicate<ITypeDefinition> filter = delegate (ITypeDefinition d) {
@ -335,11 +335,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -335,11 +335,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public ResolveResult Lookup(ResolveResult targetResolveResult, string name, IReadOnlyList<IType> typeArguments, bool isInvocation)
{
if (targetResolveResult == null)
throw new ArgumentNullException("targetResolveResult");
throw new ArgumentNullException(nameof(targetResolveResult));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (typeArguments == null)
throw new ArgumentNullException("typeArguments");
throw new ArgumentNullException(nameof(typeArguments));
bool targetIsTypeParameter = targetResolveResult.Type.Kind == TypeKind.TypeParameter;
@ -413,7 +413,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -413,7 +413,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IReadOnlyList<MethodListWithDeclaringType> LookupIndexers(ResolveResult targetResolveResult)
{
if (targetResolveResult == null)
throw new ArgumentNullException("targetResolveResult");
throw new ArgumentNullException(nameof(targetResolveResult));
IType targetType = targetResolveResult.Type;
bool allowProtectedAccess = IsProtectedAccessAllowed(targetResolveResult);

2
ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs

@ -86,7 +86,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -86,7 +86,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
: base(SpecialType.NoType)
{
if (methods == null)
throw new ArgumentNullException("methods");
throw new ArgumentNullException(nameof(methods));
this.targetResult = targetResult;
this.methodName = methodName;
this.methodLists = methods;

14
ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs

@ -135,9 +135,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -135,9 +135,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public OverloadResolution(ICompilation compilation, ResolveResult[] arguments, string[] argumentNames = null, IType[] typeArguments = null, CSharpConversions conversions = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
if (arguments == null)
throw new ArgumentNullException("arguments");
throw new ArgumentNullException(nameof(arguments));
if (argumentNames == null)
argumentNames = new string[arguments.Length];
else if (argumentNames.Length != arguments.Length)
@ -218,7 +218,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -218,7 +218,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public OverloadResolutionErrors AddCandidate(IParameterizedMember member, OverloadResolutionErrors additionalErrors)
{
if (member == null)
throw new ArgumentNullException("member");
throw new ArgumentNullException(nameof(member));
Candidate c = new Candidate(member, false);
c.AddError(additionalErrors);
@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public void AddMethodLists(IReadOnlyList<MethodListWithDeclaringType> methodLists)
{
if (methodLists == null)
throw new ArgumentNullException("methodLists");
throw new ArgumentNullException(nameof(methodLists));
// Base types come first, so go through the list backwards (derived types first)
bool[] isHiddenByDerivedType;
if (methodLists.Count > 1)
@ -500,9 +500,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -500,9 +500,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public static bool ValidateConstraints(ITypeParameter typeParameter, IType typeArgument, TypeVisitor substitution = null)
{
if (typeParameter == null)
throw new ArgumentNullException("typeParameter");
throw new ArgumentNullException(nameof(typeParameter));
if (typeArgument == null)
throw new ArgumentNullException("typeArgument");
throw new ArgumentNullException(nameof(typeArgument));
return ValidateConstraints(typeParameter, typeArgument, substitution, CSharpConversions.Get(typeParameter.Owner.Compilation));
}
@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
bool c1IsBetter = false;
bool c2IsBetter = false;
foreach (var pair in t1.Zip(t2, (a,b) => new { Item1 = a, Item2 = b })) {
foreach (var pair in t1.Zip(t2, (a, b) => new { Item1 = a, Item2 = b })) {
switch (MoreSpecificFormalParameter(pair.Item1, pair.Item2)) {
case 1:
c1IsBetter = true;

24
ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public TypeInference(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
this.compilation = compilation;
this.conversions = CSharpConversions.Get(compilation);
}
@ -115,11 +115,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -115,11 +115,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IType[] InferTypeArguments(IReadOnlyList<ITypeParameter> typeParameters, IReadOnlyList<ResolveResult> arguments, IReadOnlyList<IType> parameterTypes, out bool success, IReadOnlyList<IType> classTypeArguments = null)
{
if (typeParameters == null)
throw new ArgumentNullException("typeParameters");
throw new ArgumentNullException(nameof(typeParameters));
if (arguments == null)
throw new ArgumentNullException("arguments");
throw new ArgumentNullException(nameof(arguments));
if (parameterTypes == null)
throw new ArgumentNullException("parameterTypes");
throw new ArgumentNullException(nameof(parameterTypes));
try {
this.typeParameters = new TP[typeParameters.Count];
for (int i = 0; i < this.typeParameters.Length; i++) {
@ -173,13 +173,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -173,13 +173,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IType[] InferTypeArgumentsFromBounds(IReadOnlyList<ITypeParameter> typeParameters, IType targetType, IEnumerable<IType> lowerBounds, IEnumerable<IType> upperBounds, out bool success)
{
if (typeParameters == null)
throw new ArgumentNullException("typeParameters");
throw new ArgumentNullException(nameof(typeParameters));
if (targetType == null)
throw new ArgumentNullException("targetType");
throw new ArgumentNullException(nameof(targetType));
if (lowerBounds == null)
throw new ArgumentNullException("lowerBounds");
throw new ArgumentNullException(nameof(lowerBounds));
if (upperBounds == null)
throw new ArgumentNullException("upperBounds");
throw new ArgumentNullException(nameof(upperBounds));
this.typeParameters = new TP[typeParameters.Count];
for (int i = 0; i < this.typeParameters.Length; i++) {
if (i != typeParameters[i].Index)
@ -223,7 +223,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -223,7 +223,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public TP(ITypeParameter typeParameter)
{
if (typeParameter == null)
throw new ArgumentNullException("typeParameter");
throw new ArgumentNullException(nameof(typeParameter));
this.TypeParameter = typeParameter;
}
@ -834,7 +834,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -834,7 +834,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IType GetBestCommonType(IList<ResolveResult> expressions, out bool success)
{
if (expressions == null)
throw new ArgumentNullException("expressions");
throw new ArgumentNullException(nameof(expressions));
if (expressions.Count == 1) {
success = IsValidType(expressions[0].Type);
return expressions[0].Type;
@ -861,9 +861,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -861,9 +861,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public IType FindTypeInBounds(IReadOnlyList<IType> lowerBounds, IReadOnlyList<IType> upperBounds)
{
if (lowerBounds == null)
throw new ArgumentNullException("lowerBounds");
throw new ArgumentNullException(nameof(lowerBounds));
if (upperBounds == null)
throw new ArgumentNullException("upperBounds");
throw new ArgumentNullException(nameof(upperBounds));
var result = FindTypesInBounds(lowerBounds, upperBounds);

274
ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs

@ -38,10 +38,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -38,10 +38,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public abstract class AstNode : AbstractAnnotatable, IFreezable, INode, ICloneable
{
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
internal static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root");
internal static readonly Role<AstNode> RootRole = new Role<AstNode>("Root");
#region Null
public static readonly AstNode Null = new NullAstNode ();
public static readonly AstNode Null = new NullAstNode();
sealed class NullAstNode : AstNode
{
@ -57,22 +57,22 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -57,22 +57,22 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public override void AcceptVisitor (IAstVisitor visitor)
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
@ -80,16 +80,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -80,16 +80,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
#endregion
#region PatternPlaceholder
public static implicit operator AstNode (PatternMatching.Pattern pattern)
public static implicit operator AstNode(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder (pattern) : null;
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AstNode, INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder (PatternMatching.Pattern child)
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
@ -98,29 +98,29 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -98,29 +98,29 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return NodeType.Pattern; }
}
public override void AcceptVisitor (IAstVisitor visitor)
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder (this, child);
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder (this, child);
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder (this, child, data);
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch (other, match);
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection (role, pos, match, backtrackingInfo);
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
@ -205,7 +205,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -205,7 +205,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
set {
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (!value.IsValid(this))
throw new ArgumentException("This node is not valid in the new role.");
ThrowIfFrozen();
@ -248,7 +248,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -248,7 +248,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get {
AstNode next;
for (AstNode cur = firstChild; cur != null; cur = next) {
Debug.Assert (cur.parent == this);
Debug.Assert(cur.parent == this);
// Remember next before yielding cur.
// This allows removing/replacing nodes while iterating through the list.
next = cur.nextSibling;
@ -293,12 +293,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -293,12 +293,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetDescendantsImpl(true); }
}
public IEnumerable<AstNode> DescendantNodes (Func<AstNode, bool> descendIntoChildren = null)
public IEnumerable<AstNode> DescendantNodes(Func<AstNode, bool> descendIntoChildren = null)
{
return GetDescendantsImpl(false, descendIntoChildren);
}
public IEnumerable<AstNode> DescendantNodesAndSelf (Func<AstNode, bool> descendIntoChildren = null)
public IEnumerable<AstNode> DescendantNodesAndSelf(Func<AstNode, bool> descendIntoChildren = null)
{
return GetDescendantsImpl(true, descendIntoChildren);
}
@ -335,7 +335,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -335,7 +335,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public T GetChildByRole<T>(Role<T> role) where T : AstNode
{
if (role == null)
throw new ArgumentNullException ("role");
throw new ArgumentNullException(nameof(role));
uint roleIndex = role.Index;
for (var cur = firstChild; cur != null; cur = cur.nextSibling) {
if ((cur.flags & roleIndexMask) == roleIndex)
@ -354,54 +354,54 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -354,54 +354,54 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return Ancestors.FirstOrDefault(pred);
}
public AstNodeCollection<T> GetChildrenByRole<T> (Role<T> role) where T : AstNode
public AstNodeCollection<T> GetChildrenByRole<T>(Role<T> role) where T : AstNode
{
return new AstNodeCollection<T> (this, role);
return new AstNodeCollection<T>(this, role);
}
protected void SetChildByRole<T> (Role<T> role, T newChild) where T : AstNode
protected void SetChildByRole<T>(Role<T> role, T newChild) where T : AstNode
{
AstNode oldChild = GetChildByRole (role);
AstNode oldChild = GetChildByRole(role);
if (oldChild.IsNull)
AddChild (newChild, role);
AddChild(newChild, role);
else
oldChild.ReplaceWith (newChild);
oldChild.ReplaceWith(newChild);
}
public void AddChild<T> (T child, Role<T> role) where T : AstNode
public void AddChild<T>(T child, Role<T> role) where T : AstNode
{
if (role == null)
throw new ArgumentNullException ("role");
throw new ArgumentNullException(nameof(role));
if (child == null || child.IsNull)
return;
ThrowIfFrozen();
if (child == this)
throw new ArgumentException ("Cannot add a node to itself as a child.", "child");
throw new ArgumentException("Cannot add a node to itself as a child.", nameof(child));
if (child.parent != null)
throw new ArgumentException ("Node is already used in another tree.", "child");
throw new ArgumentException("Node is already used in another tree.", nameof(child));
if (child.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "child");
AddChildUnsafe (child, role);
throw new ArgumentException("Cannot add a frozen node.", nameof(child));
AddChildUnsafe(child, role);
}
public void AddChildWithExistingRole (AstNode child)
public void AddChildWithExistingRole(AstNode child)
{
if (child == null || child.IsNull)
return;
ThrowIfFrozen();
if (child == this)
throw new ArgumentException ("Cannot add a node to itself as a child.", "child");
throw new ArgumentException("Cannot add a node to itself as a child.", nameof(child));
if (child.parent != null)
throw new ArgumentException ("Node is already used in another tree.", "child");
throw new ArgumentException("Node is already used in another tree.", nameof(child));
if (child.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "child");
AddChildUnsafe (child, child.Role);
throw new ArgumentException("Cannot add a frozen node.", nameof(child));
AddChildUnsafe(child, child.Role);
}
/// <summary>
/// Adds a child without performing any safety checks.
/// </summary>
internal void AddChildUnsafe (AstNode child, Role role)
internal void AddChildUnsafe(AstNode child, Role role)
{
child.parent = this;
child.SetRole(role);
@ -414,12 +414,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -414,12 +414,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public void InsertChildBefore<T> (AstNode nextSibling, T child, Role<T> role) where T : AstNode
public void InsertChildBefore<T>(AstNode nextSibling, T child, Role<T> role) where T : AstNode
{
if (role == null)
throw new ArgumentNullException ("role");
throw new ArgumentNullException(nameof(role));
if (nextSibling == null || nextSibling.IsNull) {
AddChild (child, role);
AddChild(child, role);
return;
}
@ -427,17 +427,17 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -427,17 +427,17 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return;
ThrowIfFrozen();
if (child.parent != null)
throw new ArgumentException ("Node is already used in another tree.", "child");
throw new ArgumentException("Node is already used in another tree.", nameof(child));
if (child.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "child");
throw new ArgumentException("Cannot add a frozen node.", nameof(child));
if (nextSibling.parent != this)
throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling");
throw new ArgumentException("NextSibling is not a child of this node.", nameof(nextSibling));
// No need to test for "Cannot add children to null nodes",
// as there isn't any valid nextSibling in null nodes.
InsertChildBeforeUnsafe (nextSibling, child, role);
InsertChildBeforeUnsafe(nextSibling, child, role);
}
internal void InsertChildBeforeUnsafe (AstNode nextSibling, AstNode child, Role role)
internal void InsertChildBeforeUnsafe(AstNode nextSibling, AstNode child, Role role)
{
child.parent = this;
child.SetRole(role);
@ -445,39 +445,39 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -445,39 +445,39 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
child.prevSibling = nextSibling.prevSibling;
if (nextSibling.prevSibling != null) {
Debug.Assert (nextSibling.prevSibling.nextSibling == nextSibling);
Debug.Assert(nextSibling.prevSibling.nextSibling == nextSibling);
nextSibling.prevSibling.nextSibling = child;
} else {
Debug.Assert (firstChild == nextSibling);
Debug.Assert(firstChild == nextSibling);
firstChild = child;
}
nextSibling.prevSibling = child;
}
public void InsertChildAfter<T> (AstNode prevSibling, T child, Role<T> role) where T : AstNode
public void InsertChildAfter<T>(AstNode prevSibling, T child, Role<T> role) where T : AstNode
{
InsertChildBefore ((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role);
InsertChildBefore((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role);
}
/// <summary>
/// Removes this node from its parent.
/// </summary>
public void Remove ()
public void Remove()
{
if (parent != null) {
ThrowIfFrozen();
if (prevSibling != null) {
Debug.Assert (prevSibling.nextSibling == this);
Debug.Assert(prevSibling.nextSibling == this);
prevSibling.nextSibling = nextSibling;
} else {
Debug.Assert (parent.firstChild == this);
Debug.Assert(parent.firstChild == this);
parent.firstChild = nextSibling;
}
if (nextSibling != null) {
Debug.Assert (nextSibling.prevSibling == this);
Debug.Assert(nextSibling.prevSibling == this);
nextSibling.prevSibling = prevSibling;
} else {
Debug.Assert (parent.lastChild == this);
Debug.Assert(parent.lastChild == this);
parent.lastChild = prevSibling;
}
parent = null;
@ -489,35 +489,35 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -489,35 +489,35 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Replaces this node with the new node.
/// </summary>
public void ReplaceWith (AstNode newNode)
public void ReplaceWith(AstNode newNode)
{
if (newNode == null || newNode.IsNull) {
Remove ();
Remove();
return;
}
if (newNode == this)
return; // nothing to do...
if (parent == null) {
throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
}
ThrowIfFrozen();
// Because this method doesn't statically check the new node's type with the role,
// we perform a runtime test:
if (!this.Role.IsValid (newNode)) {
throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, this.Role.ToString ()), "newNode");
if (!this.Role.IsValid(newNode)) {
throw new ArgumentException(string.Format("The new node '{0}' is not valid in the role {1}", newNode.GetType().Name, this.Role.ToString()), nameof(newNode));
}
if (newNode.parent != null) {
// newNode is used within this tree?
if (newNode.Ancestors.Contains (this)) {
if (newNode.Ancestors.Contains(this)) {
// e.g. "parenthesizedExpr.ReplaceWith(parenthesizedExpr.Expression);"
// enable automatic removal
newNode.Remove ();
newNode.Remove();
} else {
throw new ArgumentException ("Node is already used in another tree.", "newNode");
throw new ArgumentException("Node is already used in another tree.", nameof(newNode));
}
}
if (newNode.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "newNode");
throw new ArgumentException("Cannot add a frozen node.", nameof(newNode));
newNode.parent = parent;
newNode.SetRole(this.Role);
@ -525,17 +525,17 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -525,17 +525,17 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
newNode.nextSibling = nextSibling;
if (prevSibling != null) {
Debug.Assert (prevSibling.nextSibling == this);
Debug.Assert(prevSibling.nextSibling == this);
prevSibling.nextSibling = newNode;
} else {
Debug.Assert (parent.firstChild == this);
Debug.Assert(parent.firstChild == this);
parent.firstChild = newNode;
}
if (nextSibling != null) {
Debug.Assert (nextSibling.prevSibling == this);
Debug.Assert(nextSibling.prevSibling == this);
nextSibling.prevSibling = newNode;
} else {
Debug.Assert (parent.lastChild == this);
Debug.Assert(parent.lastChild == this);
parent.lastChild = newNode;
}
parent = null;
@ -543,31 +543,31 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -543,31 +543,31 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
nextSibling = null;
}
public AstNode ReplaceWith (Func<AstNode, AstNode> replaceFunction)
public AstNode ReplaceWith(Func<AstNode, AstNode> replaceFunction)
{
if (replaceFunction == null)
throw new ArgumentNullException ("replaceFunction");
throw new ArgumentNullException(nameof(replaceFunction));
if (parent == null) {
throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
}
AstNode oldParent = parent;
AstNode oldSuccessor = nextSibling;
Role oldRole = this.Role;
Remove ();
AstNode replacement = replaceFunction (this);
Remove();
AstNode replacement = replaceFunction(this);
if (oldSuccessor != null && oldSuccessor.parent != oldParent)
throw new InvalidOperationException ("replace function changed nextSibling of node being replaced?");
throw new InvalidOperationException("replace function changed nextSibling of node being replaced?");
if (!(replacement == null || replacement.IsNull)) {
if (replacement.parent != null)
throw new InvalidOperationException ("replace function must return the root of a tree");
if (!oldRole.IsValid (replacement)) {
throw new InvalidOperationException (string.Format ("The new node '{0}' is not valid in the role {1}", replacement.GetType ().Name, oldRole.ToString ()));
throw new InvalidOperationException("replace function must return the root of a tree");
if (!oldRole.IsValid(replacement)) {
throw new InvalidOperationException(string.Format("The new node '{0}' is not valid in the role {1}", replacement.GetType().Name, oldRole.ToString()));
}
if (oldSuccessor != null)
oldParent.InsertChildBeforeUnsafe (oldSuccessor, replacement, oldRole);
oldParent.InsertChildBeforeUnsafe(oldSuccessor, replacement, oldRole);
else
oldParent.AddChildUnsafe (replacement, oldRole);
oldParent.AddChildUnsafe(replacement, oldRole);
}
return replacement;
}
@ -576,9 +576,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -576,9 +576,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Clones the whole subtree starting at this AST node.
/// </summary>
/// <remarks>Annotations are copied over to the new nodes; and any annotations implementing ICloneable will be cloned.</remarks>
public AstNode Clone ()
public AstNode Clone()
{
AstNode copy = (AstNode)MemberwiseClone ();
AstNode copy = (AstNode)MemberwiseClone();
// First, reset the shallow pointer copies
copy.parent = null;
copy.firstChild = null;
@ -589,7 +589,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -589,7 +589,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// Then perform a deep copy:
for (AstNode cur = firstChild; cur != null; cur = cur.nextSibling) {
copy.AddChildUnsafe (cur.Clone (), cur.Role);
copy.AddChildUnsafe(cur.Clone(), cur.Role);
}
// Finally, clone the annotation, if necessary
@ -603,31 +603,31 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -603,31 +603,31 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return Clone();
}
public abstract void AcceptVisitor (IAstVisitor visitor);
public abstract void AcceptVisitor(IAstVisitor visitor);
public abstract T AcceptVisitor<T> (IAstVisitor<T> visitor);
public abstract T AcceptVisitor<T>(IAstVisitor<T> visitor);
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data);
public abstract S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data);
#region Pattern Matching
protected static bool MatchString (string pattern, string text)
protected static bool MatchString(string pattern, string text)
{
return PatternMatching.Pattern.MatchString(pattern, text);
}
protected internal abstract bool DoMatch (AstNode other, PatternMatching.Match match);
protected internal abstract bool DoMatch(AstNode other, PatternMatching.Match match);
bool PatternMatching.INode.DoMatch (PatternMatching.INode other, PatternMatching.Match match)
bool PatternMatching.INode.DoMatch(PatternMatching.INode other, PatternMatching.Match match)
{
AstNode o = other as AstNode;
// try matching if other is null, or if other is an AstNode
return (other == null || o != null) && DoMatch (o, match);
return (other == null || o != null) && DoMatch(o, match);
}
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
AstNode o = pos as AstNode;
return (pos == null || o != null) && DoMatch (o, match);
return (pos == null || o != null) && DoMatch(o, match);
}
PatternMatching.INode PatternMatching.INode.NextSibling {
@ -640,12 +640,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -640,12 +640,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
#endregion
public AstNode GetNextNode ()
public AstNode GetNextNode()
{
if (NextSibling != null)
return NextSibling;
if (Parent != null)
return Parent.GetNextNode ();
return Parent.GetNextNode();
return null;
}
@ -654,20 +654,20 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -654,20 +654,20 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
/// <returns>The next node.</returns>
/// <param name="pred">The predicate.</param>
public AstNode GetNextNode (Func<AstNode, bool> pred)
public AstNode GetNextNode(Func<AstNode, bool> pred)
{
var next = GetNextNode();
while (next != null && !pred (next))
while (next != null && !pred(next))
next = next.GetNextNode();
return next;
}
public AstNode GetPrevNode ()
public AstNode GetPrevNode()
{
if (PrevSibling != null)
return PrevSibling;
if (Parent != null)
return Parent.GetPrevNode ();
return Parent.GetPrevNode();
return null;
}
@ -676,21 +676,21 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -676,21 +676,21 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
/// <returns>The next node.</returns>
/// <param name="pred">The predicate.</param>
public AstNode GetPrevNode (Func<AstNode, bool> pred)
public AstNode GetPrevNode(Func<AstNode, bool> pred)
{
var prev = GetPrevNode();
while (prev != null && !pred (prev))
while (prev != null && !pred(prev))
prev = prev.GetPrevNode();
return prev;
}
// filters all non c# nodes (comments, white spaces or pre processor directives)
public AstNode GetCSharpNodeBefore (AstNode node)
public AstNode GetCSharpNodeBefore(AstNode node)
{
var n = node.PrevSibling;
while (n != null) {
if (n.Role != Roles.Comment)
return n;
n = n.GetPrevNode ();
n = n.GetPrevNode();
}
return null;
}
@ -700,10 +700,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -700,10 +700,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
/// <returns>The next node.</returns>
/// <param name="pred">The predicate.</param>
public AstNode GetNextSibling (Func<AstNode, bool> pred)
public AstNode GetNextSibling(Func<AstNode, bool> pred)
{
var next = NextSibling;
while (next != null && !pred (next))
while (next != null && !pred(next))
next = next.NextSibling;
return next;
}
@ -713,10 +713,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -713,10 +713,10 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
/// <returns>The next node.</returns>
/// <param name="pred">The predicate.</param>
public AstNode GetPrevSibling (Func<AstNode, bool> pred)
public AstNode GetPrevSibling(Func<AstNode, bool> pred)
{
var prev = PrevSibling;
while (prev != null && !pred (prev))
while (prev != null && !pred(prev))
prev = prev.PrevSibling;
return prev;
}
@ -727,9 +727,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -727,9 +727,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End exclusive)
/// </summary>
public AstNode GetNodeAt (int line, int column, Predicate<AstNode> pred = null)
public AstNode GetNodeAt(int line, int column, Predicate<AstNode> pred = null)
{
return GetNodeAt (new TextLocation (line, column), pred);
return GetNodeAt(new TextLocation(line, column), pred);
}
/// <summary>
@ -737,7 +737,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -737,7 +737,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End exclusive)
/// </summary>
public AstNode GetNodeAt (TextLocation location, Predicate<AstNode> pred = null)
public AstNode GetNodeAt(TextLocation location, Predicate<AstNode> pred = null)
{
AstNode result = null;
AstNode node = this;
@ -746,7 +746,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -746,7 +746,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
while (child != null && child.StartLocation > location)
child = child.prevSibling;
if (child != null && location < child.EndLocation) {
if (pred == null || pred (child))
if (pred == null || pred(child))
result = child;
node = child;
} else {
@ -762,9 +762,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -762,9 +762,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End exclusive)
/// </summary>
public T GetNodeAt<T> (int line, int column) where T : AstNode
public T GetNodeAt<T>(int line, int column) where T : AstNode
{
return GetNodeAt<T> (new TextLocation (line, column));
return GetNodeAt<T>(new TextLocation(line, column));
}
/// <summary>
@ -772,7 +772,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -772,7 +772,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End exclusive)
/// </summary>
public T GetNodeAt<T> (TextLocation location) where T : AstNode
public T GetNodeAt<T>(TextLocation location) where T : AstNode
{
T result = null;
AstNode node = this;
@ -802,7 +802,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -802,7 +802,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public AstNode GetAdjacentNodeAt(int line, int column, Predicate<AstNode> pred = null)
{
return GetAdjacentNodeAt (new TextLocation (line, column), pred);
return GetAdjacentNodeAt(new TextLocation(line, column), pred);
}
/// <summary>
@ -810,7 +810,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -810,7 +810,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End inclusive)
/// </summary>
public AstNode GetAdjacentNodeAt (TextLocation location, Predicate<AstNode> pred = null)
public AstNode GetAdjacentNodeAt(TextLocation location, Predicate<AstNode> pred = null)
{
AstNode result = null;
AstNode node = this;
@ -819,7 +819,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -819,7 +819,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
while (child != null && child.StartLocation > location)
child = child.prevSibling;
if (child != null && location <= child.EndLocation) {
if (pred == null || pred (child))
if (pred == null || pred(child))
result = child;
node = child;
} else {
@ -837,7 +837,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -837,7 +837,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public T GetAdjacentNodeAt<T>(int line, int column) where T : AstNode
{
return GetAdjacentNodeAt<T> (new TextLocation (line, column));
return GetAdjacentNodeAt<T>(new TextLocation(line, column));
}
/// <summary>
@ -845,7 +845,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -845,7 +845,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// the current method declaration.
/// (End inclusive)
/// </summary>
public T GetAdjacentNodeAt<T> (TextLocation location) where T : AstNode
public T GetAdjacentNodeAt<T>(TextLocation location) where T : AstNode
{
T result = null;
AstNode node = this;
@ -882,15 +882,15 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -882,15 +882,15 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Returns the root nodes of all subtrees that are fully contained in the specified region.
/// </summary>
public IEnumerable<AstNode> GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn)
public IEnumerable<AstNode> GetNodesBetween(int startLine, int startColumn, int endLine, int endColumn)
{
return GetNodesBetween (new TextLocation (startLine, startColumn), new TextLocation (endLine, endColumn));
return GetNodesBetween(new TextLocation(startLine, startColumn), new TextLocation(endLine, endColumn));
}
/// <summary>
/// Returns the root nodes of all subtrees that are fully contained between <paramref name="start"/> and <paramref name="end"/> (inclusive).
/// </summary>
public IEnumerable<AstNode> GetNodesBetween (TextLocation start, TextLocation end)
public IEnumerable<AstNode> GetNodesBetween(TextLocation start, TextLocation end)
{
AstNode node = this;
while (node != null) {
@ -920,13 +920,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -920,13 +920,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <param name='formattingOptions'>
/// Formatting options.
/// </param>
public virtual string ToString (CSharpFormattingOptions formattingOptions)
public virtual string ToString(CSharpFormattingOptions formattingOptions)
{
if (IsNull)
return "";
var w = new StringWriter ();
AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? FormattingOptionsFactory.CreateMono ()));
return w.ToString ();
var w = new StringWriter();
AcceptVisitor(new CSharpOutputVisitor(w, formattingOptions ?? FormattingOptionsFactory.CreateMono()));
return w.ToString();
}
public sealed override string ToString()
@ -940,9 +940,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -940,9 +940,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <returns>
/// True, if the given coordinates are between StartLocation and EndLocation (exclusive); otherwise, false.
/// </returns>
public bool Contains (int line, int column)
public bool Contains(int line, int column)
{
return Contains (new TextLocation (line, column));
return Contains(new TextLocation(line, column));
}
/// <summary>
@ -951,7 +951,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -951,7 +951,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <returns>
/// True, if location is between StartLocation and EndLocation (exclusive); otherwise, false.
/// </returns>
public bool Contains (TextLocation location)
public bool Contains(TextLocation location)
{
return this.StartLocation <= location && location < this.EndLocation;
}
@ -962,9 +962,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -962,9 +962,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <returns>
/// True, if the given coordinates are between StartLocation and EndLocation (inclusive); otherwise, false.
/// </returns>
public bool IsInside (int line, int column)
public bool IsInside(int line, int column)
{
return IsInside (new TextLocation (line, column));
return IsInside(new TextLocation(line, column));
}
/// <summary>
@ -973,16 +973,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -973,16 +973,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <returns>
/// True, if location is between StartLocation and EndLocation (inclusive); otherwise, false.
/// </returns>
public bool IsInside (TextLocation location)
public bool IsInside(TextLocation location)
{
return this.StartLocation <= location && location <= this.EndLocation;
}
public override void AddAnnotation (object annotation)
public override void AddAnnotation(object annotation)
{
if (this.IsNull)
throw new InvalidOperationException ("Cannot add annotations to the null node");
base.AddAnnotation (annotation);
throw new InvalidOperationException("Cannot add annotations to the null node");
base.AddAnnotation(annotation);
}
internal string DebugToString()

6
ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs

@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstNodeCollection(AstNode node, Role<T> role)
{
if (node == null)
throw new ArgumentNullException("node");
throw new ArgumentNullException(nameof(node));
if (role == null)
throw new ArgumentNullException("role");
throw new ArgumentNullException(nameof(role));
this.node = node;
this.role = role;
}
@ -96,7 +96,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -96,7 +96,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public void MoveTo(ICollection<T> targetCollection)
{
if (targetCollection == null)
throw new ArgumentNullException("targetCollection");
throw new ArgumentNullException(nameof(targetCollection));
foreach (T node in this) {
node.Remove();
targetCollection.Add(node);

2
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs

@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public Expression ReplaceWith(Func<Expression, Expression> replaceFunction)
{
if (replaceFunction == null)
throw new ArgumentNullException("replaceFunction");
throw new ArgumentNullException(nameof(replaceFunction));
return (Expression)base.ReplaceWith(node => replaceFunction((Expression)node));
}
}

2
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
static AstType ConstructType(string[] arr, int i)
{
if (i < 0 || i >= arr.Length)
throw new ArgumentOutOfRangeException("i");
throw new ArgumentOutOfRangeException(nameof(i));
if (i == 0)
return new SimpleType(arr[i]);
return new MemberType(ConstructType(arr, i - 1), arr[i]);

62
ICSharpCode.Decompiler/CSharp/Syntax/IAnnotatable.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <typeparam name='T'>
/// The type of the annotation.
/// </typeparam>
T Annotation<T> () where T: class;
T Annotation<T>() where T : class;
/// <summary>
/// Gets the first annotation of the specified type.
@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <param name='type'>
/// The type of the annotation.
/// </param>
object Annotation (Type type);
object Annotation(Type type);
/// <summary>
/// Adds an annotation to this instance.
@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <param name='annotation'>
/// The annotation to add.
/// </param>
void AddAnnotation (object annotation);
void AddAnnotation(object annotation);
/// <summary>
/// Removes all annotations of the specified type.
@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <typeparam name='T'>
/// The type of the annotations to remove.
/// </typeparam>
void RemoveAnnotations<T> () where T : class;
void RemoveAnnotations<T>() where T : class;
/// <summary>
/// Removes all annotations of the specified type.
@ -111,86 +111,86 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -111,86 +111,86 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// There are two uses for this custom list type:
// 1) it's private, and thus (unlike List<object>) cannot be confused with real annotations
// 2) It allows us to simplify the cloning logic by making the list behave the same as a clonable annotation.
public AnnotationList (int initialCapacity) : base(initialCapacity)
public AnnotationList(int initialCapacity) : base(initialCapacity)
{
}
public object Clone ()
public object Clone()
{
lock (this) {
AnnotationList copy = new AnnotationList (this.Count);
AnnotationList copy = new AnnotationList(this.Count);
for (int i = 0; i < this.Count; i++) {
object obj = this [i];
object obj = this[i];
ICloneable c = obj as ICloneable;
copy.Add (c != null ? c.Clone () : obj);
copy.Add(c != null ? c.Clone() : obj);
}
return copy;
}
}
}
public virtual void AddAnnotation (object annotation)
public virtual void AddAnnotation(object annotation)
{
if (annotation == null)
throw new ArgumentNullException ("annotation");
throw new ArgumentNullException(nameof(annotation));
retry: // Retry until successful
object oldAnnotation = Interlocked.CompareExchange (ref this.annotations, annotation, null);
object oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null);
if (oldAnnotation == null) {
return; // we successfully added a single annotation
}
AnnotationList list = oldAnnotation as AnnotationList;
if (list == null) {
// we need to transform the old annotation into a list
list = new AnnotationList (4);
list.Add (oldAnnotation);
list.Add (annotation);
if (Interlocked.CompareExchange (ref this.annotations, list, oldAnnotation) != oldAnnotation) {
list = new AnnotationList(4);
list.Add(oldAnnotation);
list.Add(annotation);
if (Interlocked.CompareExchange(ref this.annotations, list, oldAnnotation) != oldAnnotation) {
// the transformation failed (some other thread wrote to this.annotations first)
goto retry;
}
} else {
// once there's a list, use simple locking
lock (list) {
list.Add (annotation);
list.Add(annotation);
}
}
}
public virtual void RemoveAnnotations<T> () where T : class
public virtual void RemoveAnnotations<T>() where T : class
{
retry: // Retry until successful
object oldAnnotations = this.annotations;
AnnotationList list = oldAnnotations as AnnotationList;
if (list != null) {
lock (list)
list.RemoveAll (obj => obj is T);
list.RemoveAll(obj => obj is T);
} else if (oldAnnotations is T) {
if (Interlocked.CompareExchange (ref this.annotations, null, oldAnnotations) != oldAnnotations) {
if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) {
// Operation failed (some other thread wrote to this.annotations first)
goto retry;
}
}
}
public virtual void RemoveAnnotations (Type type)
public virtual void RemoveAnnotations(Type type)
{
if (type == null)
throw new ArgumentNullException ("type");
throw new ArgumentNullException(nameof(type));
retry: // Retry until successful
object oldAnnotations = this.annotations;
AnnotationList list = oldAnnotations as AnnotationList;
if (list != null) {
lock (list)
list.RemoveAll(type.IsInstanceOfType);
} else if (type.IsInstanceOfType (oldAnnotations)) {
if (Interlocked.CompareExchange (ref this.annotations, null, oldAnnotations) != oldAnnotations) {
} else if (type.IsInstanceOfType(oldAnnotations)) {
if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) {
// Operation failed (some other thread wrote to this.annotations first)
goto retry;
}
}
}
public T Annotation<T> () where T: class
public T Annotation<T>() where T : class
{
object annotations = this.annotations;
AnnotationList list = annotations as AnnotationList;
@ -208,21 +208,21 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -208,21 +208,21 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public object Annotation (Type type)
public object Annotation(Type type)
{
if (type == null)
throw new ArgumentNullException ("type");
throw new ArgumentNullException(nameof(type));
object annotations = this.annotations;
AnnotationList list = annotations as AnnotationList;
if (list != null) {
lock (list) {
foreach (object obj in list) {
if (type.IsInstanceOfType (obj))
if (type.IsInstanceOfType(obj))
return obj;
}
}
} else {
if (type.IsInstanceOfType (annotations))
if (type.IsInstanceOfType(annotations))
return annotations;
}
return null;
@ -237,13 +237,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -237,13 +237,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AnnotationList list = annotations as AnnotationList;
if (list != null) {
lock (list) {
return list.ToArray ();
return list.ToArray();
}
} else {
if (annotations != null)
return new object[] { annotations };
else
return Enumerable.Empty<object> ();
return Enumerable.Empty<object>();
}
}
}

4
ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs

@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return this.name; }
set {
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
ThrowIfFrozen();
this.name = value;
}
@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
protected Identifier (string name, TextLocation location)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.Name = name;
this.startLocation = location;
}

2
ICSharpCode.Decompiler/CSharp/Syntax/IdentifierExpressionBackreference.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public IdentifierExpressionBackreference(string referencedGroupName)
{
if (referencedGroupName == null)
throw new ArgumentNullException("referencedGroupName");
throw new ArgumentNullException(nameof(referencedGroupName));
this.referencedGroupName = referencedGroupName;
}

2
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Backreference.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public Backreference(string referencedGroupName)
{
if (referencedGroupName == null)
throw new ArgumentNullException("referencedGroupName");
throw new ArgumentNullException(nameof(referencedGroupName));
this.referencedGroupName = referencedGroupName;
}

4
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Choice.cs

@ -32,14 +32,14 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -32,14 +32,14 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public void Add(string name, INode alternative)
{
if (alternative == null)
throw new ArgumentNullException("alternative");
throw new ArgumentNullException(nameof(alternative));
alternatives.Add(new NamedNode(name, alternative));
}
public void Add(INode alternative)
{
if (alternative == null)
throw new ArgumentNullException("alternative");
throw new ArgumentNullException(nameof(alternative));
alternatives.Add(alternative);
}

4
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/INode.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public static Match Match(this INode pattern, INode other)
{
if (pattern == null)
throw new ArgumentNullException("pattern");
throw new ArgumentNullException(nameof(pattern));
Match match = PatternMatching.Match.CreateNew();
if (pattern.DoMatch(other, match))
return match;
@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public static bool IsMatch(this INode pattern, INode other)
{
if (pattern == null)
throw new ArgumentNullException("pattern");
throw new ArgumentNullException(nameof(pattern));
return pattern.DoMatch(other, PatternMatching.Match.CreateNew());
}

2
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/NamedNode.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public NamedNode(string groupName, INode childNode)
{
if (childNode == null)
throw new ArgumentNullException("childNode");
throw new ArgumentNullException(nameof(childNode));
this.groupName = groupName;
this.childNode = childNode;
}

2
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/OptionalNode.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public OptionalNode(INode childNode)
{
if (childNode == null)
throw new ArgumentNullException("childNode");
throw new ArgumentNullException(nameof(childNode));
this.childNode = childNode;
}

2
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Repeat.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
public Repeat(INode childNode)
{
if (childNode == null)
throw new ArgumentNullException("childNode");
throw new ArgumentNullException(nameof(childNode));
this.childNode = childNode;
this.MinCount = 0;
this.MaxCount = int.MaxValue;

6
ICSharpCode.Decompiler/CSharp/Syntax/Role.cs

@ -89,16 +89,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -89,16 +89,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public Role(string name)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.name = name;
}
public Role(string name, T nullObject)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (nullObject == null)
throw new ArgumentNullException ("nullObject");
throw new ArgumentNullException (nameof(nullObject));
this.nullObject = nullObject;
this.name = name;
}

2
ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public Statement ReplaceWith(Func<Statement, Statement> replaceFunction)
{
if (replaceFunction == null)
throw new ArgumentNullException("replaceFunction");
throw new ArgumentNullException(nameof(replaceFunction));
return (Statement)base.ReplaceWith(node => replaceFunction((Statement)node));
}

16
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public TypeSystemAstBuilder(CSharpResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
throw new ArgumentNullException(nameof(resolver));
this.resolver = resolver;
InitProperties();
}
@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstType ConvertType(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
AstType astType = ConvertTypeHelper(type);
AddTypeAnnotation(astType, type);
return astType;
@ -579,7 +579,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -579,7 +579,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstType ConvertAttributeType(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
AstType astType = ConvertTypeHelper(type);
string shortName = null;
@ -663,7 +663,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -663,7 +663,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public Expression ConvertConstantValue(ResolveResult rr)
{
if (rr == null)
throw new ArgumentNullException("rr");
throw new ArgumentNullException(nameof(rr));
bool isBoxing = false;
if (rr is ConversionResolveResult crr) {
// unpack ConversionResolveResult if necessary
@ -734,7 +734,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -734,7 +734,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public Expression ConvertConstantValue(IType expectedType, IType type, object constantValue)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (constantValue == null) {
if (type.IsReferenceType == true || type.IsKnownType(KnownTypeCode.NullableOfT)) {
var expr = new NullReferenceExpression();
@ -1248,7 +1248,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1248,7 +1248,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public ParameterDeclaration ConvertParameter(IParameter parameter)
{
if (parameter == null)
throw new ArgumentNullException("parameter");
throw new ArgumentNullException(nameof(parameter));
ParameterDeclaration decl = new ParameterDeclaration();
if (parameter.IsRef) {
decl.ParameterModifier = ParameterModifier.Ref;
@ -1286,7 +1286,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1286,7 +1286,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstNode ConvertSymbol(ISymbol symbol)
{
if (symbol == null)
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
switch (symbol.SymbolKind) {
case SymbolKind.Namespace:
return ConvertNamespaceDeclaration((INamespace)symbol);
@ -1307,7 +1307,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1307,7 +1307,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public EntityDeclaration ConvertEntity(IEntity entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
throw new ArgumentNullException(nameof(entity));
switch (entity.SymbolKind) {
case SymbolKind.TypeDefinition:
return ConvertTypeDefinition((ITypeDefinition)entity);

2
ICSharpCode.Decompiler/CSharp/TypeSystem/AliasNamespaceReference.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public AliasNamespaceReference(string identifier)
{
if (identifier == null)
throw new ArgumentNullException("identifier");
throw new ArgumentNullException(nameof(identifier));
this.identifier = identifier;
}

4
ICSharpCode.Decompiler/CSharp/TypeSystem/MemberTypeOrNamespaceReference.cs

@ -40,9 +40,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -40,9 +40,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public MemberTypeOrNamespaceReference(TypeOrNamespaceReference target, string identifier, IList<ITypeReference> typeArguments, NameLookupMode lookupMode = NameLookupMode.Type)
{
if (target == null)
throw new ArgumentNullException("target");
throw new ArgumentNullException(nameof(target));
if (identifier == null)
throw new ArgumentNullException("identifier");
throw new ArgumentNullException(nameof(identifier));
this.target = target;
this.identifier = identifier;
this.typeArguments = typeArguments ?? EmptyList<ITypeReference>.Instance;

4
ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs

@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public ResolvedUsingScope(CSharpTypeResolveContext context, UsingScope usingScope)
{
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
if (usingScope == null)
throw new ArgumentNullException("usingScope");
throw new ArgumentNullException(nameof(usingScope));
this.parentContext = context;
this.usingScope = usingScope;
if (usingScope.Parent != null) {

2
ICSharpCode.Decompiler/CSharp/TypeSystem/SimpleTypeOrNamespaceReference.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public SimpleTypeOrNamespaceReference(string identifier, IList<ITypeReference> typeArguments, NameLookupMode lookupMode = NameLookupMode.Type)
{
if (identifier == null)
throw new ArgumentNullException("identifier");
throw new ArgumentNullException(nameof(identifier));
this.identifier = identifier;
this.typeArguments = typeArguments ?? EmptyList<ITypeReference>.Instance;
this.lookupMode = lookupMode;

4
ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs

@ -67,9 +67,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -67,9 +67,9 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public UsingScope(UsingScope parent, string shortName)
{
if (parent == null)
throw new ArgumentNullException("parent");
throw new ArgumentNullException(nameof(parent));
if (shortName == null)
throw new ArgumentNullException("shortName");
throw new ArgumentNullException(nameof(shortName));
this.parent = parent;
this.shortName = shortName;
}

2
ICSharpCode.Decompiler/DebugInfo/DebugInfoGenerator.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.Decompiler.DebugInfo @@ -60,7 +60,7 @@ namespace ICSharpCode.Decompiler.DebugInfo
public DebugInfoGenerator(IDecompilerTypeSystem typeSystem)
{
this.typeSystem = typeSystem ?? throw new ArgumentNullException("typeSystem");
this.typeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem));
this.currentImportScope = globalImportScope;
}

2
ICSharpCode.Decompiler/DecompilerException.cs

@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler @@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler
string ToString(Exception exception)
{
if (exception == null)
throw new ArgumentNullException("exception");
throw new ArgumentNullException(nameof(exception));
string exceptionType = GetTypeName(exception);
string stacktrace = GetStackTrace(exception);
while (exception.InnerException != null) {

10
ICSharpCode.Decompiler/Documentation/IdStringProvider.cs

@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.Documentation
public static string GetTypeName(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
StringBuilder b = new StringBuilder();
AppendTypeName(b, type, false);
return b.ToString();
@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.Documentation
public static IMemberReference ParseMemberIdString(string memberIdString)
{
if (memberIdString == null)
throw new ArgumentNullException("memberIdString");
throw new ArgumentNullException(nameof(memberIdString));
if (memberIdString.Length < 2 || memberIdString[1] != ':')
throw new ReflectionNameParseException(0, "Missing type tag");
char typeChar = memberIdString[0];
@ -242,7 +242,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -242,7 +242,7 @@ namespace ICSharpCode.Decompiler.Documentation
public static ITypeReference ParseTypeName(string typeName)
{
if (typeName == null)
throw new ArgumentNullException("typeName");
throw new ArgumentNullException(nameof(typeName));
int pos = 0;
if (typeName.StartsWith("T:", StringComparison.Ordinal))
pos = 2;
@ -378,9 +378,9 @@ namespace ICSharpCode.Decompiler.Documentation @@ -378,9 +378,9 @@ namespace ICSharpCode.Decompiler.Documentation
public static IEntity FindEntity(string idString, ITypeResolveContext context)
{
if (idString == null)
throw new ArgumentNullException("idString");
throw new ArgumentNullException(nameof(idString));
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
if (idString.StartsWith("T:", StringComparison.Ordinal)) {
return ParseTypeName(idString.Substring(2)).Resolve(context).GetDefinition();
} else {

4
ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Documentation
public XmlDocumentationElement(XElement element, IEntity declaringEntity, Func<string, IEntity> crefResolver)
{
if (element == null)
throw new ArgumentNullException("element");
throw new ArgumentNullException(nameof(element));
this.element = element;
this.declaringEntity = declaringEntity;
this.crefResolver = crefResolver;
@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.Documentation
public XmlDocumentationElement(string text, IEntity declaringEntity)
{
if (text == null)
throw new ArgumentNullException("text");
throw new ArgumentNullException(nameof(text));
this.declaringEntity = declaringEntity;
this.textContent = text;
}

6
ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.Documentation
public XmlDocumentationCache(int size = 50)
{
if (size <= 0)
throw new ArgumentOutOfRangeException("size", size, "Value must be positive");
throw new ArgumentOutOfRangeException(nameof(size), size, "Value must be positive");
this.entries = new KeyValuePair<string, string>[size];
}
@ -129,7 +129,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -129,7 +129,7 @@ namespace ICSharpCode.Decompiler.Documentation
public XmlDocumentationProvider(string fileName)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
throw new ArgumentNullException(nameof(fileName));
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) {
using (XmlTextReader xmlReader = new XmlTextReader(fs)) {
@ -328,7 +328,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -328,7 +328,7 @@ namespace ICSharpCode.Decompiler.Documentation
public string GetDocumentation(string key)
{
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));
return GetDocumentation(key, true);
}

2
ICSharpCode.Decompiler/IL/Instructions/CallIndirect.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.Decompiler.IL @@ -68,7 +68,7 @@ namespace ICSharpCode.Decompiler.IL
this.IsInstance = isInstance;
this.HasExplicitThis = hasExplicitThis;
this.CallingConvention = callingConvention;
this.ReturnType = returnType ?? throw new ArgumentNullException("returnType");
this.ReturnType = returnType ?? throw new ArgumentNullException(nameof(returnType));
this.ParameterTypes = parameterTypes.ToImmutableArray();
this.Arguments = new InstructionCollection<ILInstruction>(this, 0);
this.Arguments.AddRange(arguments);

2
ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs

@ -313,7 +313,7 @@ namespace ICSharpCode.Decompiler.IL @@ -313,7 +313,7 @@ namespace ICSharpCode.Decompiler.IL
: base(OpCode.DynamicCompoundAssign, CompoundEvalModeFromOperation(op), target, targetKind, value)
{
if (!IsExpressionTypeSupported(op))
throw new ArgumentOutOfRangeException("op");
throw new ArgumentOutOfRangeException(nameof(op));
this.BinderFlags = binderFlags;
this.Operation = op;
this.TargetArgumentInfo = targetArgumentInfo;

4
ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs

@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return NullableLiftingTransform.MatchGetValueOrDefault(inst, out ILInstruction arg)
&& arg.MatchLdLoc(testedVar);
default:
throw new ArgumentOutOfRangeException("mode");
throw new ArgumentOutOfRangeException(nameof(mode));
}
}
@ -306,7 +306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -306,7 +306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
).WithILRange(varLoad);
break;
default:
throw new ArgumentOutOfRangeException("mode");
throw new ArgumentOutOfRangeException(nameof(mode));
}
oldParentChildren[oldChildIndex] = replacement;
}

2
ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler.Metadata
public static AssemblyNameReference Parse(string fullName)
{
if (fullName == null)
throw new ArgumentNullException("fullName");
throw new ArgumentNullException(nameof(fullName));
if (fullName.Length == 0)
throw new ArgumentException("Name can not be empty");

4
ICSharpCode.Decompiler/Semantics/ArrayAccessResolveResult.cs

@ -34,9 +34,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -34,9 +34,9 @@ namespace ICSharpCode.Decompiler.Semantics
public ArrayAccessResolveResult(IType elementType, ResolveResult array, IList<ResolveResult> indexes) : base(elementType)
{
if (array == null)
throw new ArgumentNullException("array");
throw new ArgumentNullException(nameof(array));
if (indexes == null)
throw new ArgumentNullException("indexes");
throw new ArgumentNullException(nameof(indexes));
this.Array = array;
this.Indexes = indexes;
}

2
ICSharpCode.Decompiler/Semantics/ArrayCreateResolveResult.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(arrayType)
{
if (sizeArguments == null)
throw new ArgumentNullException("sizeArguments");
throw new ArgumentNullException(nameof(sizeArguments));
this.SizeArguments = sizeArguments;
this.InitializerElements = initializerElements;
}

6
ICSharpCode.Decompiler/Semantics/Conversion.cs

@ -89,21 +89,21 @@ namespace ICSharpCode.Decompiler.Semantics @@ -89,21 +89,21 @@ namespace ICSharpCode.Decompiler.Semantics
public static Conversion UserDefinedConversion(IMethod operatorMethod, bool isImplicit, Conversion conversionBeforeUserDefinedOperator, Conversion conversionAfterUserDefinedOperator, bool isLifted = false, bool isAmbiguous = false)
{
if (operatorMethod == null)
throw new ArgumentNullException("operatorMethod");
throw new ArgumentNullException(nameof(operatorMethod));
return new UserDefinedConv(isImplicit, operatorMethod, conversionBeforeUserDefinedOperator, conversionAfterUserDefinedOperator, isLifted, isAmbiguous);
}
public static Conversion MethodGroupConversion(IMethod chosenMethod, bool isVirtualMethodLookup, bool delegateCapturesFirstArgument)
{
if (chosenMethod == null)
throw new ArgumentNullException("chosenMethod");
throw new ArgumentNullException(nameof(chosenMethod));
return new MethodGroupConv(chosenMethod, isVirtualMethodLookup, delegateCapturesFirstArgument, isValid: true);
}
public static Conversion InvalidMethodGroupConversion(IMethod chosenMethod, bool isVirtualMethodLookup, bool delegateCapturesFirstArgument)
{
if (chosenMethod == null)
throw new ArgumentNullException("chosenMethod");
throw new ArgumentNullException(nameof(chosenMethod));
return new MethodGroupConv(chosenMethod, isVirtualMethodLookup, delegateCapturesFirstArgument, isValid: false);
}

4
ICSharpCode.Decompiler/Semantics/ConversionResolveResult.cs

@ -42,9 +42,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -42,9 +42,9 @@ namespace ICSharpCode.Decompiler.Semantics
: base(targetType)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
if (conversion == null)
throw new ArgumentNullException("conversion");
throw new ArgumentNullException(nameof(conversion));
this.Input = input;
this.Conversion = conversion;
}

8
ICSharpCode.Decompiler/Semantics/ForEachResolveResult.cs

@ -64,13 +64,13 @@ namespace ICSharpCode.Decompiler.Semantics @@ -64,13 +64,13 @@ namespace ICSharpCode.Decompiler.Semantics
: base(voidType)
{
if (getEnumeratorCall == null)
throw new ArgumentNullException("getEnumeratorCall");
throw new ArgumentNullException(nameof(getEnumeratorCall));
if (collectionType == null)
throw new ArgumentNullException("collectionType");
throw new ArgumentNullException(nameof(collectionType));
if (enumeratorType == null)
throw new ArgumentNullException("enumeratorType");
throw new ArgumentNullException(nameof(enumeratorType));
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
this.GetEnumeratorCall = getEnumeratorCall;
this.CollectionType = collectionType;
this.EnumeratorType = enumeratorType;

2
ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.Semantics
static IType UnpackTypeIfByRefParameter(IVariable variable)
{
if (variable == null)
throw new ArgumentNullException("variable");
throw new ArgumentNullException(nameof(variable));
IType type = variable.Type;
if (type.Kind == TypeKind.ByReference) {
IParameter p = variable as IParameter;

8
ICSharpCode.Decompiler/Semantics/NamedArgumentResolveResult.cs

@ -53,9 +53,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -53,9 +53,9 @@ namespace ICSharpCode.Decompiler.Semantics
: base(argument.Type)
{
if (parameter == null)
throw new ArgumentNullException("parameter");
throw new ArgumentNullException(nameof(parameter));
if (argument == null)
throw new ArgumentNullException("argument");
throw new ArgumentNullException(nameof(argument));
this.Member = member;
this.Parameter = parameter;
this.ParameterName = parameter.Name;
@ -66,9 +66,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -66,9 +66,9 @@ namespace ICSharpCode.Decompiler.Semantics
: base(argument.Type)
{
if (parameterName == null)
throw new ArgumentNullException("parameterName");
throw new ArgumentNullException(nameof(parameterName));
if (argument == null)
throw new ArgumentNullException("argument");
throw new ArgumentNullException(nameof(argument));
this.ParameterName = parameterName;
this.Argument = argument;
}

4
ICSharpCode.Decompiler/Semantics/OperatorResolveResult.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(resultType)
{
if (operands == null)
throw new ArgumentNullException("operands");
throw new ArgumentNullException(nameof(operands));
this.operatorType = operatorType;
this.operands = operands;
}
@ -46,7 +46,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -46,7 +46,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(resultType)
{
if (operands == null)
throw new ArgumentNullException("operands");
throw new ArgumentNullException(nameof(operands));
this.operatorType = operatorType;
this.userDefinedOperatorMethod = userDefinedOperatorMethod;
this.isLiftedOperator = isLiftedOperator;

2
ICSharpCode.Decompiler/Semantics/ResolveResult.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Semantics
public ResolveResult(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
this.type = type;
}

2
ICSharpCode.Decompiler/Semantics/SizeOfResolveResult.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(int32)
{
if (referencedType == null)
throw new ArgumentNullException("referencedType");
throw new ArgumentNullException(nameof(referencedType));
this.referencedType = referencedType;
this.constantValue = constantValue;
}

4
ICSharpCode.Decompiler/Semantics/TypeIsResolveResult.cs

@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler.Semantics
: base(booleanType)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
if (targetType == null)
throw new ArgumentNullException("targetType");
throw new ArgumentNullException(nameof(targetType));
this.Input = input;
this.TargetType = targetType;
}

2
ICSharpCode.Decompiler/Semantics/TypeOfResolveResult.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(systemType)
{
if (referencedType == null)
throw new ArgumentNullException("referencedType");
throw new ArgumentNullException(nameof(referencedType));
this.referencedType = referencedType;
}

2
ICSharpCode.Decompiler/Semantics/UnknownMemberResolveResult.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.Semantics
: base(SpecialType.UnknownType)
{
if (targetType == null)
throw new ArgumentNullException("targetType");
throw new ArgumentNullException(nameof(targetType));
this.targetType = targetType;
this.memberName = memberName;
this.typeArguments = new ReadOnlyCollection<IType>(typeArguments.ToArray());

8
ICSharpCode.Decompiler/TypeSystem/ArrayType.cs

@ -35,9 +35,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -35,9 +35,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public ArrayType(ICompilation compilation, IType elementType, int dimensions = 1, Nullability nullability = Nullability.Oblivious) : base(elementType)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
if (dimensions <= 0)
throw new ArgumentOutOfRangeException("dimensions", dimensions, "dimensions must be positive");
throw new ArgumentOutOfRangeException(nameof(dimensions), dimensions, "dimensions must be positive");
this.compilation = compilation;
this.dimensions = dimensions;
this.nullability = nullability;
@ -181,9 +181,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -181,9 +181,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public ArrayTypeReference(ITypeReference elementType, int dimensions = 1)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
if (dimensions <= 0)
throw new ArgumentOutOfRangeException("dimensions", dimensions, "dimensions must be positive");
throw new ArgumentOutOfRangeException(nameof(dimensions), dimensions, "dimensions must be positive");
this.elementType = elementType;
this.dimensions = dimensions;
}

2
ICSharpCode.Decompiler/TypeSystem/ByReferenceType.cs

@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public ByReferenceTypeReference(ITypeReference elementType)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
this.elementType = elementType;
}

4
ICSharpCode.Decompiler/TypeSystem/FullTypeName.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public NestedTypeName(string name, int additionalTypeParameterCount)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.Name = name;
this.AdditionalTypeParameterCount = additionalTypeParameterCount;
}
@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public FullTypeName NestedType(string name, int additionalTypeParameterCount)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
var newNestedType = new NestedTypeName(name, additionalTypeParameterCount);
if (nestedTypes == null)
return new FullTypeName(topLevelType, new[] { newNestedType });

4
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractTypeParameter.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -36,7 +36,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
protected AbstractTypeParameter(IEntity owner, int index, string name, VarianceModifier variance)
{
if (owner == null)
throw new ArgumentNullException("owner");
throw new ArgumentNullException(nameof(owner));
this.owner = owner;
this.compilation = owner.Compilation;
this.ownerType = owner.SymbolKind;
@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
protected AbstractTypeParameter(ICompilation compilation, SymbolKind ownerType, int index, string name, VarianceModifier variance)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
this.compilation = compilation;
this.ownerType = ownerType;
this.index = index;

4
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAttribute.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
ImmutableArray<CustomAttributeNamedArgument<IType>> namedArguments)
{
if (attributeType == null)
throw new ArgumentNullException("attributeType");
throw new ArgumentNullException(nameof(attributeType));
this.attributeType = attributeType;
this.FixedArguments = fixedArguments;
this.NamedArguments = namedArguments;
@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
ImmutableArray<CustomAttributeNamedArgument<IType>> namedArguments)
{
if (constructor == null)
throw new ArgumentNullException("constructor");
throw new ArgumentNullException(nameof(constructor));
this.constructor = constructor;
this.attributeType = constructor.DeclaringType ?? SpecialType.UnknownType;
this.FixedArguments = fixedArguments;

8
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs

@ -39,9 +39,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -39,9 +39,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public DefaultParameter(IType type, string name)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.type = type;
this.name = name;
this.attributes = EmptyList<IAttribute>.Instance;
@ -51,9 +51,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -51,9 +51,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
ReferenceKind referenceKind = ReferenceKind.None, bool isParams = false, bool isOptional = false, object defaultValue = null)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.type = type;
this.name = name;
this.owner = owner;

4
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs

@ -33,9 +33,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -33,9 +33,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public DefaultVariable(IType type, string name)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.type = type;
this.name = name;
}

2
ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -98,7 +98,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public IType Resolve(ITypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
IType type = null;
if (module == null) {

8
ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs

@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public MergedNamespace(ICompilation compilation, INamespace[] namespaces, string externAlias = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
if (namespaces == null)
throw new ArgumentNullException("namespaces");
throw new ArgumentNullException(nameof(namespaces));
this.compilation = compilation;
this.namespaces = namespaces;
this.externAlias = externAlias;
@ -60,9 +60,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -60,9 +60,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public MergedNamespace(INamespace parentNamespace, INamespace[] namespaces)
{
if (parentNamespace == null)
throw new ArgumentNullException("parentNamespace");
throw new ArgumentNullException(nameof(parentNamespace));
if (namespaces == null)
throw new ArgumentNullException("namespaces");
throw new ArgumentNullException(nameof(namespaces));
this.parentNamespace = parentNamespace;
this.namespaces = namespaces;
this.compilation = parentNamespace.Compilation;

4
ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs

@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public NestedTypeReference(ITypeReference declaringTypeRef, string name, int additionalTypeParameterCount, bool? isReferenceType = null)
{
if (declaringTypeRef == null)
throw new ArgumentNullException("declaringTypeRef");
throw new ArgumentNullException(nameof(declaringTypeRef));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.declaringTypeRef = declaringTypeRef;
this.name = name;
this.additionalTypeParameterCount = additionalTypeParameterCount;

4
ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs

@ -52,9 +52,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -52,9 +52,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
protected void Init(IModuleReference mainAssembly, IEnumerable<IModuleReference> assemblyReferences)
{
if (mainAssembly == null)
throw new ArgumentNullException("mainAssembly");
throw new ArgumentNullException(nameof(mainAssembly));
if (assemblyReferences == null)
throw new ArgumentNullException("assemblyReferences");
throw new ArgumentNullException(nameof(assemblyReferences));
var context = new SimpleTypeResolveContext(this);
this.mainModule = mainAssembly.Resolve(context);
List<IModule> assemblies = new List<IModule>();

2
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
protected SpecializedMember(IMember memberDefinition)
{
if (memberDefinition == null)
throw new ArgumentNullException("memberDefinition");
throw new ArgumentNullException(nameof(memberDefinition));
if (memberDefinition is SpecializedMember)
throw new ArgumentException("Member definition cannot be specialized. Please use IMember.Specialize() instead of directly constructing SpecializedMember instances.");

2
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
: base(methodDefinition)
{
if (substitution == null)
throw new ArgumentNullException("substitution");
throw new ArgumentNullException(nameof(substitution));
this.methodDefinition = methodDefinition;
this.isParameterized = substitution.MethodTypeArguments != null;
if (methodDefinition.TypeParameters.Count > 0) {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/TypeWithElementType.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -27,7 +27,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
protected TypeWithElementType(IType elementType)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
this.elementType = elementType;
}

4
ICSharpCode.Decompiler/TypeSystem/Implementation/UnknownType.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public UnknownType(string namespaceName, string name, int typeParameterCount = 0, bool? isReferenceType = null)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.namespaceKnown = namespaceName != null;
this.fullTypeName = new TopLevelTypeName(namespaceName ?? string.Empty, name, typeParameterCount);
this.isReferenceType = isReferenceType;
@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
IType ITypeReference.Resolve(ITypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
return this;
}

6
ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IEnumerable<IMember> GetBaseMembers(IMember member, bool includeImplementedInterfaces)
{
if (member == null)
throw new ArgumentNullException("member");
throw new ArgumentNullException(nameof(member));
if (includeImplementedInterfaces) {
if (member.IsExplicitInterfaceImplementation && member.ExplicitlyImplementedInterfaceMembers.Count() == 1) {
@ -100,9 +100,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -100,9 +100,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IMember GetDerivedMember(IMember baseMember, ITypeDefinition derivedType)
{
if (baseMember == null)
throw new ArgumentNullException("baseMember");
throw new ArgumentNullException(nameof(baseMember));
if (derivedType == null)
throw new ArgumentNullException("derivedType");
throw new ArgumentNullException(nameof(derivedType));
if (baseMember.Compilation != derivedType.Compilation)
throw new ArgumentException("baseMember and derivedType must be from the same compilation");

10
ICSharpCode.Decompiler/TypeSystem/NullableType.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static bool IsNullable(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
ParameterizedType pt = type.SkipModifiers() as ParameterizedType;
return pt != null && pt.TypeParameterCount == 1 && pt.GenericType.IsKnownType(KnownTypeCode.NullableOfT);
}
@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IType GetUnderlyingType(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
ParameterizedType pt = type.SkipModifiers() as ParameterizedType;
if (pt != null && pt.TypeParameterCount == 1 && pt.GenericType.IsKnownType(KnownTypeCode.NullableOfT))
return pt.GetTypeArgument(0);
@ -62,9 +62,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -62,9 +62,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IType Create(ICompilation compilation, IType elementType)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
IType nullableType = compilation.FindType(KnownTypeCode.NullableOfT);
ITypeDefinition nullableTypeDef = nullableType.GetDefinition();
@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static ParameterizedTypeReference Create(ITypeReference elementType)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
return new ParameterizedTypeReference(KnownTypeReference.Get(KnownTypeCode.NullableOfT), new [] { elementType });
}
}

2
ICSharpCode.Decompiler/TypeSystem/ParameterListComparer.cs

@ -111,7 +111,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -111,7 +111,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public SignatureComparer(StringComparer nameComparer)
{
if (nameComparer == null)
throw new ArgumentNullException("nameComparer");
throw new ArgumentNullException(nameof(nameComparer));
this.nameComparer = nameComparer;
}

8
ICSharpCode.Decompiler/TypeSystem/ParameterizedType.cs

@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -44,9 +44,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public ParameterizedType(IType genericType, IEnumerable<IType> typeArguments)
{
if (genericType == null)
throw new ArgumentNullException("genericType");
throw new ArgumentNullException(nameof(genericType));
if (typeArguments == null)
throw new ArgumentNullException("typeArguments");
throw new ArgumentNullException(nameof(typeArguments));
this.genericType = genericType;
this.typeArguments = typeArguments.ToArray(); // copy input array to ensure it isn't modified
if (this.typeArguments.Length == 0)
@ -358,9 +358,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -358,9 +358,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public ParameterizedTypeReference(ITypeReference genericType, IEnumerable<ITypeReference> typeArguments)
{
if (genericType == null)
throw new ArgumentNullException("genericType");
throw new ArgumentNullException(nameof(genericType));
if (typeArguments == null)
throw new ArgumentNullException("typeArguments");
throw new ArgumentNullException(nameof(typeArguments));
this.genericType = genericType;
this.typeArguments = typeArguments.ToArray();
for (int i = 0; i < this.typeArguments.Length; i++) {

2
ICSharpCode.Decompiler/TypeSystem/PointerType.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -75,7 +75,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public PointerTypeReference(ITypeReference elementType)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
this.elementType = elementType;
}

2
ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs

@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static ITypeReference ParseReflectionName(string reflectionTypeName)
{
if (reflectionTypeName == null)
throw new ArgumentNullException("reflectionTypeName");
throw new ArgumentNullException(nameof(reflectionTypeName));
int pos = 0;
ITypeReference r = ParseReflectionName(reflectionTypeName, ref pos);
if (pos < reflectionTypeName.Length)

4
ICSharpCode.Decompiler/TypeSystem/SimpleTypeResolveContext.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public SimpleTypeResolveContext(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
this.compilation = compilation;
}
@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public SimpleTypeResolveContext(IEntity entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
throw new ArgumentNullException(nameof(entity));
this.compilation = entity.Compilation;
this.currentModule = entity.ParentModule;
this.currentTypeDefinition = (entity as ITypeDefinition) ?? entity.DeclaringTypeDefinition;

2
ICSharpCode.Decompiler/TypeSystem/SpecialType.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
IType ITypeReference.Resolve(ITypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
throw new ArgumentNullException(nameof(context));
return this;
}

4
ICSharpCode.Decompiler/TypeSystem/TaskType.cs

@ -121,9 +121,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -121,9 +121,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IType Create(ICompilation compilation, IType elementType)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
if (elementType == null)
throw new ArgumentNullException("elementType");
throw new ArgumentNullException(nameof(elementType));
if (elementType.Kind == TypeKind.Void)
return compilation.FindType(KnownTypeCode.Task);

4
ICSharpCode.Decompiler/TypeSystem/TopLevelTypeName.cs

@ -36,9 +36,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -36,9 +36,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public TopLevelTypeName(string namespaceName, string name, int typeParameterCount = 0)
{
if (namespaceName == null)
throw new ArgumentNullException("namespaceName");
throw new ArgumentNullException(nameof(namespaceName));
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
this.namespaceName = namespaceName;
this.name = name;
this.typeParameterCount = typeParameterCount;

22
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

@ -44,7 +44,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -44,7 +44,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IEnumerable<IType> GetAllBaseTypes(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
BaseTypeCollector collector = new BaseTypeCollector();
collector.CollectBaseTypes(type);
return collector;
@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IEnumerable<IType> GetNonInterfaceBaseTypes(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
BaseTypeCollector collector = new BaseTypeCollector();
collector.SkipImplementedInterfaces = true;
collector.CollectBaseTypes(type);
@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IEnumerable<ITypeDefinition> GetAllBaseTypeDefinitions(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
return type.GetAllBaseTypes().Select(t => t.GetDefinition()).Where(d => d != null).Distinct();
}
@ -91,7 +91,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -91,7 +91,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static bool IsDerivedFrom(this ITypeDefinition type, ITypeDefinition baseType)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (baseType == null)
return false;
if (type.Compilation != baseType.Compilation) {
@ -106,7 +106,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -106,7 +106,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static bool IsDerivedFrom(this ITypeDefinition type, KnownTypeCode baseType)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (baseType == KnownTypeCode.None)
return false;
return IsDerivedFrom(type, type.Compilation.FindType(baseType).GetDefinition());
@ -178,7 +178,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -178,7 +178,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static bool IsOpen(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
TypeClassificationVisitor v = new TypeClassificationVisitor();
type.AcceptVisitor(v);
return v.isOpen;
@ -193,7 +193,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -193,7 +193,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
static IEntity GetTypeParameterOwner(IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
TypeClassificationVisitor v = new TypeClassificationVisitor();
type.AcceptVisitor(v);
return v.typeParameterOwner;
@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static bool IsUnbound(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
return type is ITypeDefinition && type.TypeParameterCount > 0;
}
@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IMethod GetDelegateInvokeMethod(this IType type)
{
if (type == null)
throw new ArgumentNullException("type");
throw new ArgumentNullException(nameof(type));
if (type.Kind == TypeKind.Delegate)
return type.GetMethods(m => m.Name == "Invoke", GetMemberOptions.IgnoreInheritedMembers).FirstOrDefault();
else
@ -310,7 +310,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -310,7 +310,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IReadOnlyList<IType> Resolve(this IList<ITypeReference> typeReferences, ITypeResolveContext context)
{
if (typeReferences == null)
throw new ArgumentNullException("typeReferences");
throw new ArgumentNullException(nameof(typeReferences));
if (typeReferences.Count == 0)
return EmptyList<IType>.Instance;
else
@ -336,7 +336,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -336,7 +336,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public static IType FindType(this ICompilation compilation, FullTypeName fullTypeName)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
throw new ArgumentNullException(nameof(compilation));
foreach (IModule asm in compilation.Modules) {
ITypeDefinition def = asm.GetTypeDefinition(fullTypeName);
if (def != null)

2
ICSharpCode.Decompiler/Util/CallbackOnDispose.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.Util @@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.Util
public CallbackOnDispose(Action action)
{
if (action == null)
throw new ArgumentNullException("action");
throw new ArgumentNullException(nameof(action));
this.action = action;
}

4
ICSharpCode.Decompiler/Util/EmptyList.cs

@ -30,8 +30,8 @@ namespace ICSharpCode.Decompiler.Util @@ -30,8 +30,8 @@ namespace ICSharpCode.Decompiler.Util
private EmptyList() {}
public T this[int index] {
get { throw new ArgumentOutOfRangeException("index"); }
set { throw new ArgumentOutOfRangeException("index"); }
get { throw new ArgumentOutOfRangeException(nameof(index)); }
set { throw new ArgumentOutOfRangeException(nameof(index)); }
}
public int Count {

8
ICSharpCode.Decompiler/Util/GraphVizGraph.cs

@ -114,7 +114,7 @@ namespace ICSharpCode.Decompiler.Util @@ -114,7 +114,7 @@ namespace ICSharpCode.Decompiler.Util
public void Save(TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
throw new ArgumentNullException(nameof(writer));
writer.WriteLine("digraph G {");
writer.WriteLine("node [fontsize = 16];");
WriteGraphAttribute(writer, "rankdir", rankdir);
@ -147,9 +147,9 @@ namespace ICSharpCode.Decompiler.Util @@ -147,9 +147,9 @@ namespace ICSharpCode.Decompiler.Util
public GraphVizEdge(string source, string target)
{
if (source == null)
throw new ArgumentNullException("source");
throw new ArgumentNullException(nameof(source));
if (target == null)
throw new ArgumentNullException("target");
throw new ArgumentNullException(nameof(target));
this.Source = source;
this.Target = target;
}
@ -195,7 +195,7 @@ namespace ICSharpCode.Decompiler.Util @@ -195,7 +195,7 @@ namespace ICSharpCode.Decompiler.Util
public GraphVizNode(string id)
{
if (id == null)
throw new ArgumentNullException("id");
throw new ArgumentNullException(nameof(id));
this.ID = id;
}

6
ICSharpCode.Decompiler/Util/KeyComparer.cs

@ -58,11 +58,11 @@ namespace ICSharpCode.Decompiler.Util @@ -58,11 +58,11 @@ namespace ICSharpCode.Decompiler.Util
public KeyComparer(Func<TElement, TKey> keySelector, IComparer<TKey> keyComparer, IEqualityComparer<TKey> keyEqualityComparer)
{
if (keySelector == null)
throw new ArgumentNullException("keySelector");
throw new ArgumentNullException(nameof(keySelector));
if (keyComparer == null)
throw new ArgumentNullException("keyComparer");
throw new ArgumentNullException(nameof(keyComparer));
if (keyEqualityComparer == null)
throw new ArgumentNullException("keyEqualityComparer");
throw new ArgumentNullException(nameof(keyEqualityComparer));
this.keySelector = keySelector;
this.keyComparer = keyComparer;
this.keyEqualityComparer = keyEqualityComparer;

8
ICSharpCode.Decompiler/Util/ProjectedList.cs

@ -30,9 +30,9 @@ namespace ICSharpCode.Decompiler.Util @@ -30,9 +30,9 @@ namespace ICSharpCode.Decompiler.Util
public ProjectedList(IList<TInput> input, Func<TInput, TOutput> projection)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
if (projection == null)
throw new ArgumentNullException("projection");
throw new ArgumentNullException(nameof(projection));
this.input = input;
this.projection = projection;
this.items = new TOutput[input.Count];
@ -75,9 +75,9 @@ namespace ICSharpCode.Decompiler.Util @@ -75,9 +75,9 @@ namespace ICSharpCode.Decompiler.Util
public ProjectedList(TContext context, IList<TInput> input, Func<TContext, TInput, TOutput> projection)
{
if (input == null)
throw new ArgumentNullException("input");
throw new ArgumentNullException(nameof(input));
if (projection == null)
throw new ArgumentNullException("projection");
throw new ArgumentNullException(nameof(projection));
this.input = input;
this.context = context;
this.projection = projection;

30
ICSharpCode.Decompiler/Util/ResXResourceWriter.cs

@ -69,10 +69,10 @@ namespace ICSharpCode.Decompiler.Util @@ -69,10 +69,10 @@ namespace ICSharpCode.Decompiler.Util
public ResXResourceWriter(Stream stream)
{
if (stream == null)
throw new ArgumentNullException("stream");
throw new ArgumentNullException(nameof(stream));
if (!stream.CanWrite)
throw new ArgumentException("stream is not writable.", "stream");
throw new ArgumentException("stream is not writable.", nameof(stream));
this.stream = stream;
}
@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.Util @@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.Util
public ResXResourceWriter(TextWriter textWriter)
{
if (textWriter == null)
throw new ArgumentNullException("textWriter");
throw new ArgumentNullException(nameof(textWriter));
this.textwriter = textWriter;
}
@ -88,7 +88,7 @@ namespace ICSharpCode.Decompiler.Util @@ -88,7 +88,7 @@ namespace ICSharpCode.Decompiler.Util
public ResXResourceWriter(string fileName)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
throw new ArgumentNullException(nameof(fileName));
this.filename = fileName;
}
@ -217,10 +217,10 @@ namespace ICSharpCode.Decompiler.Util @@ -217,10 +217,10 @@ namespace ICSharpCode.Decompiler.Util
public void AddResource(string name, byte[] value)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (written)
throw new InvalidOperationException("The resource is already generated.");
@ -244,7 +244,7 @@ namespace ICSharpCode.Decompiler.Util @@ -244,7 +244,7 @@ namespace ICSharpCode.Decompiler.Util
}
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (written)
throw new InvalidOperationException("The resource is already generated.");
@ -307,10 +307,10 @@ namespace ICSharpCode.Decompiler.Util @@ -307,10 +307,10 @@ namespace ICSharpCode.Decompiler.Util
private void AddResource(string name, string value, string comment)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (written)
throw new InvalidOperationException("The resource is already generated.");
@ -324,10 +324,10 @@ namespace ICSharpCode.Decompiler.Util @@ -324,10 +324,10 @@ namespace ICSharpCode.Decompiler.Util
public void AddMetadata(string name, string value)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (written)
throw new InvalidOperationException("The resource is already generated.");
@ -347,10 +347,10 @@ namespace ICSharpCode.Decompiler.Util @@ -347,10 +347,10 @@ namespace ICSharpCode.Decompiler.Util
public void AddMetadata(string name, byte[] value)
{
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (written)
throw new InvalidOperationException("The resource is already generated.");
@ -383,10 +383,10 @@ namespace ICSharpCode.Decompiler.Util @@ -383,10 +383,10 @@ namespace ICSharpCode.Decompiler.Util
}
if (name == null)
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
if (!value.GetType().IsSerializable)
throw new InvalidOperationException(String.Format("The element '{0}' of type '{1}' is not serializable.", name, value.GetType().Name));

Loading…
Cancel
Save