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. 2
      ICSharpCode.Decompiler/CSharp/Annotations.cs
  2. 16
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs
  3. 8
      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. 12
      ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
  12. 24
      ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
  13. 34
      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. 6
      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

2
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -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;

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

@ -41,10 +41,10 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -41,10 +41,10 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
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;
@ -53,10 +53,10 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -53,10 +53,10 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
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;

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;

12
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));
}

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);

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

@ -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();
@ -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)
@ -371,16 +371,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -371,16 +371,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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");
throw new ArgumentException("Cannot add a frozen node.", nameof(child));
AddChildUnsafe(child, role);
}
@ -390,11 +390,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -390,11 +390,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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");
throw new ArgumentException("Cannot add a frozen node.", nameof(child));
AddChildUnsafe(child, child.Role);
}
@ -417,7 +417,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -417,7 +417,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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);
return;
@ -427,11 +427,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -427,11 +427,11 @@ 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);
@ -504,7 +504,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -504,7 +504,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// 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");
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?
@ -513,11 +513,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -513,11 +513,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// enable automatic removal
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);
@ -546,7 +546,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -546,7 +546,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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");
}

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]);

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

@ -132,7 +132,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -132,7 +132,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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);
if (oldAnnotation == null) {
@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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;
@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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) {

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