Browse Source

Focus on CS8600 (not even close to done thee is a ton of these)

pull/3287/head
apmoskevitz 9 months ago
parent
commit
dc2af218e4
  1. 1
      .editorconfig
  2. 8
      ICSharpCode.Decompiler/CSharp/Annotations.cs
  3. 10
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  4. 2
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  5. 11
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  6. 8
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  7. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/GenericGrammarAmbiguityVisitor.cs
  8. 6
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertSpecialsDecorator.cs
  9. 2
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs
  10. 2
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs
  11. 4
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetServices.cs
  12. 4
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
  13. 2
      ICSharpCode.Decompiler/CSharp/RequiredNamespaceCollector.cs
  14. 10
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
  15. 42
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  16. 8
      ICSharpCode.Decompiler/CSharp/Resolver/MemberLookup.cs
  17. 2
      ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
  18. 2
      ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
  19. 2
      ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs
  20. 15
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
  21. 2
      ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
  22. 12
      ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs
  23. 272
      ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
  24. 22
      ICSharpCode.Decompiler/CSharp/Syntax/IAnnotatable.cs
  25. 568
      ICSharpCode.Decompiler/CSharp/Syntax/IAstVisitor.cs
  26. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/INode.cs
  27. 10
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Pattern.cs
  28. 2
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Repeat.cs
  29. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
  30. 2
      ICSharpCode.Decompiler/CSharp/Syntax/SyntaxExtensions.cs
  31. 2
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs
  32. 2
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs
  33. 2
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs
  34. 16
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  35. 6
      ICSharpCode.Decompiler/CSharp/Transforms/AddCheckedBlocks.cs
  36. 4
      ICSharpCode.Decompiler/CSharp/Transforms/AddXmlDocumentationTransform.cs
  37. 4
      ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs
  38. 6
      ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
  39. 4
      ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs
  40. 24
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs
  41. 8
      ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
  42. 4
      ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
  43. 2
      ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs
  44. 2
      ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  45. 10
      ICSharpCode.Decompiler/DecompilerException.cs
  46. 8
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
  47. 2
      ICSharpCode.Decompiler/Documentation/GetPotentiallyNestedClassTypeReference.cs
  48. 2
      ICSharpCode.Decompiler/Documentation/IdStringProvider.cs
  49. 2
      ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
  50. 4
      ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
  51. 12
      ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs
  52. 4
      ICSharpCode.Decompiler/IL/ControlFlow/AwaitInFinallyTransform.cs
  53. 8
      ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs
  54. 8
      ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs
  55. 2
      ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs
  56. 16
      ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs
  57. 2
      ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs
  58. 3
      ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs
  59. 4
      ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs
  60. 67
      ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs
  61. 6
      ICSharpCode.Decompiler/Semantics/ConstantResolveResult.cs
  62. 2
      ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
  63. 4
      ICSharpCode.Decompiler/TypeSystem/TaskType.cs
  64. 2
      ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
  65. 4
      ILSpy/Languages/ILAstLanguage.cs
  66. 14
      ILSpy/MainWindow.xaml.cs
  67. 2
      ILSpy/TextView/DocumentationUIBuilder.cs
  68. 4
      ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs
  69. 2
      ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs
  70. 4
      ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs
  71. 4
      ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs
  72. 4
      ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs
  73. 11
      ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs
  74. 4
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  75. 6
      ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs
  76. 8
      ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs
  77. 4
      ILSpy/Views/DebugSteps.xaml.cs

1
.editorconfig

@ -154,6 +154,7 @@ dotnet_diagnostic.IDE2003.severity = silent @@ -154,6 +154,7 @@ dotnet_diagnostic.IDE2003.severity = silent
#cleared null error types
dotnet_diagnostic.CS8612.severity = error
dotnet_diagnostic.CS8714.severity = error
dotnet_diagnostic.CS8762.severity = error
dotnet_diagnostic.CS8765.severity = error
dotnet_diagnostic.CS8766.severity = error
dotnet_diagnostic.CS8767.severity = error

8
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -134,7 +134,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -134,7 +134,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// Retrieves the <see cref="ISymbol"/> associated with this AstNode, or null if no symbol
/// is associated with the node.
/// </summary>
public static ISymbol GetSymbol(this AstNode node)
public static ISymbol? GetSymbol(this AstNode node)
{
var rr = node.Annotation<ResolveResult>();
if (rr is MethodGroupResolveResult)
@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="IdentifierExpression"/>,
/// or <c>null</c> if no variable is associated with this identifier.
/// </summary>
public static ILVariable GetILVariable(this IdentifierExpression expr)
public static ILVariable? GetILVariable(this IdentifierExpression expr)
{
if (expr.Annotation<ResolveResult>() is ILVariableResolveResult rr)
return rr.Variable;
@ -187,7 +187,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -187,7 +187,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="VariableInitializer"/>,
/// or <c>null</c> if no variable is associated with this initializer.
/// </summary>
public static ILVariable GetILVariable(this VariableInitializer vi)
public static ILVariable? GetILVariable(this VariableInitializer vi)
{
if (vi.Annotation<ResolveResult>() is ILVariableResolveResult rr)
return rr.Variable;
@ -199,7 +199,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -199,7 +199,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="ForeachStatement"/>,
/// or <c>null</c> if no variable is associated with this foreach statement.
/// </summary>
public static ILVariable GetILVariable(this ForeachStatement loop)
public static ILVariable? GetILVariable(this ForeachStatement loop)
{
if (loop.Annotation<ResolveResult>() is ILVariableResolveResult rr)
return rr.Variable;

10
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -1213,7 +1213,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1213,7 +1213,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// <param name="member">The node of the member which new modifier state should be determined.</param>
void SetNewModifier(EntityDeclaration member)
{
var entity = (IEntity)member.GetSymbol();
var entity = member.GetSymbol() as IEntity;
var lookup = new MemberLookup(entity.DeclaringTypeDefinition, entity.ParentModule);
var baseTypes = entity.DeclaringType.GetNonInterfaceBaseTypes().Where(t => entity.DeclaringType != t).ToList();
@ -1325,7 +1325,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1325,7 +1325,7 @@ namespace ICSharpCode.Decompiler.CSharp
foreach (var p in recordDecompiler.PrimaryConstructor.Parameters)
{
ParameterDeclaration pd = typeSystemAstBuilder.ConvertParameter(p);
(IProperty prop, IField field) = recordDecompiler.GetPropertyInfoByPrimaryConstructorParameter(p);
(IProperty? prop, IField field) = recordDecompiler.GetPropertyInfoByPrimaryConstructorParameter(p);
if (prop != null)
{
@ -1567,7 +1567,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1567,7 +1567,7 @@ namespace ICSharpCode.Decompiler.CSharp
{
if (MemberIsHidden(module, field.MetadataToken, settings))
continue;
object constantValue = field.GetConstantValue();
object? constantValue = field.GetConstantValue();
if (constantValue == null)
continue;
long currentValue = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, constantValue, false);
@ -1958,7 +1958,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1958,7 +1958,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (decompilationContext.CurrentTypeDefinition.Kind == TypeKind.Enum && field.IsConst)
{
var enumDec = new EnumMemberDeclaration { Name = field.Name };
object constantValue = field.GetConstantValue();
object? constantValue = field.GetConstantValue();
if (constantValue != null)
{
enumDec.Initializer = typeSystemAstBuilder.ConvertConstantValue(decompilationContext.CurrentTypeDefinition.EnumUnderlyingType, constantValue);
@ -2022,7 +2022,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2022,7 +2022,7 @@ namespace ICSharpCode.Decompiler.CSharp
{
type = null;
elementCount = 0;
IAttribute attr = field.GetAttribute(KnownAttribute.FixedBuffer);
IAttribute? attr = field.GetAttribute(KnownAttribute.FixedBuffer);
if (attr != null && attr.FixedArguments.Length == 2)
{
if (attr.FixedArguments[0].Value is IType trr && attr.FixedArguments[1].Value is int length)

2
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -1574,7 +1574,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1574,7 +1574,7 @@ namespace ICSharpCode.Decompiler.CSharp
arguments.Remove(value);
}
IMember foundMember;
IMember? foundMember;
while (!IsUnambiguousAccess(expectedTargetDetails, targetResolveResult, method, arguments, argumentNames, out foundMember))
{
if (!argumentsCasted)

11
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -2535,7 +2535,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2535,7 +2535,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (resultType.Kind == TypeKind.Void)
return compilation.FindType(KnownTypeCode.Task);
ITypeDefinition def = compilation.FindType(KnownTypeCode.TaskOfT).GetDefinition();
ITypeDefinition? def = compilation.FindType(KnownTypeCode.TaskOfT).GetDefinition();
if (def != null)
return new ParameterizedType(def, new[] { resultType });
else
@ -2988,7 +2988,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2988,7 +2988,7 @@ namespace ICSharpCode.Decompiler.CSharp
memberName = "LongLength";
code = KnownTypeCode.Int64;
}
IProperty member = arrayType.GetProperties(p => p.Name == memberName).FirstOrDefault();
IProperty? member = arrayType.GetProperties(p => p.Name == memberName).FirstOrDefault();
ResolveResult rr = member == null
? new ResolveResult(compilation.FindType(code))
: new MemberResolveResult(arrayExpr.ResolveResult, member);
@ -3917,7 +3917,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -3917,7 +3917,8 @@ namespace ICSharpCode.Decompiler.CSharp
{
TranslatedExpression value;
IType type;
if (inst.Value is StringToInt strToInt)
var strToInt = inst.Value as StringToInt;
if (strToInt != null)
{
value = Translate(strToInt.Argument)
.ConvertTo(
@ -4534,7 +4535,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -4534,7 +4535,7 @@ namespace ICSharpCode.Decompiler.CSharp
{
if (subPattern.HasDesignator)
{
if (!conversionMapping.TryGetValue(subPattern.Variable, out ILVariable value))
if (!conversionMapping.TryGetValue(subPattern.Variable, out ILVariable? value))
{
value = subPattern.Variable;
}
@ -4639,7 +4640,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -4639,7 +4640,7 @@ namespace ICSharpCode.Decompiler.CSharp
Debug.Fail("Invalid sub pattern");
continue;
}
IMember member;
IMember? member;
if (testedOperand is CallInstruction call)
{
member = call.Method.AccessorOwner;

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

@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// </summary>
/// <param name="nextNode">The next node after the comma.</param>
/// <param name="noSpaceAfterComma">When set prevents printing a space after comma.</param>
protected virtual void Comma(AstNode nextNode, bool noSpaceAfterComma = false)
protected virtual void Comma(AstNode? nextNode, bool noSpaceAfterComma = false)
{
Space(policy.SpaceBeforeBracketComma);
// TODO: Comma policy has changed.
@ -105,7 +105,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -105,7 +105,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// <summary>
/// Writes an optional comma, e.g. at the end of an enum declaration or in an array initializer
/// </summary>
protected virtual void OptionalComma(AstNode pos)
protected virtual void OptionalComma(AstNode? pos)
{
// Look if there's a comma after the current node, and insert it if it exists.
while (pos != null && pos.NodeType == NodeType.Whitespace)
@ -121,7 +121,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -121,7 +121,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// <summary>
/// Writes an optional semicolon, e.g. at the end of a type or namespace declaration.
/// </summary>
protected virtual void OptionalSemicolon(AstNode pos)
protected virtual void OptionalSemicolon(AstNode? pos)
{
// Look if there's a semicolon after the current node, and insert it if it exists.
while (pos != null && pos.NodeType == NodeType.Whitespace)
@ -1947,7 +1947,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -1947,7 +1947,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteIdentifier(labelStatement.GetChildByRole(Roles.Identifier));
WriteToken(Roles.Colon);
bool foundLabelledStatement = false;
for (AstNode tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling)
for (AstNode? tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling)
{
if (tmp.Role == labelStatement.Role)
{

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

@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
var v = new GenericGrammarAmbiguityVisitor();
v.genericNestingLevel = 1;
for (AstNode node = binaryOperatorExpression.Right; node != null; node = node.GetNextNode())
for (AstNode? node = binaryOperatorExpression.Right; node != null; node = node.GetNextNode())
{
if (node.AcceptVisitor(v))
return v.ambiguityFound;

6
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertSpecialsDecorator.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// </summary>
void WriteSpecials(AstNode start, AstNode end)
{
for (AstNode pos = start; pos != end; pos = pos.NextSibling)
for (AstNode? pos = start; pos != end; pos = pos.NextSibling)
{
if (pos.Role == Roles.Comment)
{
@ -125,7 +125,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -125,7 +125,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
return;
}
// Look for the role between the current position and the nextNode.
for (AstNode pos = positionStack.Peek(); pos != null && pos != nextNode; pos = pos.NextSibling)
for (AstNode? pos = positionStack.Peek(); pos != null && pos != nextNode; pos = pos.NextSibling)
{
if (pos.Role == role)
{
@ -149,7 +149,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -149,7 +149,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
return;
}
for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling)
for (AstNode? pos = positionStack.Peek(); pos != null; pos = pos.NextSibling)
{
if (pos == node)
{

2
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs

@ -272,7 +272,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -272,7 +272,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
foreach (var reference in module.AssemblyReferences.Where(r => !ImplicitReferences.Contains(r.Name)))
{
if (isNetCoreApp && project.AssemblyReferenceClassifier.IsSharedAssembly(reference, out string runtimePack) && targetPacks.Contains(runtimePack))
if (isNetCoreApp && project.AssemblyReferenceClassifier.IsSharedAssembly(reference, out string? runtimePack) && targetPacks.Contains(runtimePack))
{
continue;
}

2
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
/// <summary>
/// Gets the target framework identifier. Can be null if not defined.
/// </summary>
public string Identifier { get; }
public string? Identifier { get; }
/// <summary>
/// Gets the target framework moniker. Can be null if not supported.

4
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetServices.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
{
string[] frameworkParts = targetFramework.Split(',');
targetFrameworkIdentifier = frameworkParts.FirstOrDefault(a => !a.StartsWith(VersionToken, StringComparison.OrdinalIgnoreCase) && !a.StartsWith(ProfileToken, StringComparison.OrdinalIgnoreCase));
string frameworkVersion = frameworkParts.FirstOrDefault(a => a.StartsWith(VersionToken, StringComparison.OrdinalIgnoreCase));
string? frameworkVersion = frameworkParts.FirstOrDefault(a => a.StartsWith(VersionToken, StringComparison.OrdinalIgnoreCase));
if (frameworkVersion != null)
{
@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
versionNumber *= 10;
}
string frameworkProfile = frameworkParts.FirstOrDefault(a => a.StartsWith(ProfileToken, StringComparison.OrdinalIgnoreCase));
string? frameworkProfile = frameworkParts.FirstOrDefault(a => a.StartsWith(ProfileToken, StringComparison.OrdinalIgnoreCase));
if (frameworkProfile != null)
targetFrameworkProfile = frameworkProfile.Substring(ProfileToken.Length);
}

4
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs

@ -325,7 +325,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -325,7 +325,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
{
foreach (var r in module.Resources.Where(r => r.ResourceType == ResourceType.Embedded))
{
Stream stream = r.TryOpenStream();
Stream? stream = r.TryOpenStream();
stream.Position = 0;
if (r.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
@ -341,7 +341,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -341,7 +341,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
{
string fileName = SanitizeFileName(name)
.Replace('/', Path.DirectorySeparatorChar);
string dirName = Path.GetDirectoryName(fileName);
string? dirName = Path.GetDirectoryName(fileName);
if (!string.IsNullOrEmpty(dirName) && directories.Add(dirName))
{
Directory.CreateDirectory(Path.Combine(TargetDirectory, dirName));

2
ICSharpCode.Decompiler/CSharp/RequiredNamespaceCollector.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -37,7 +37,7 @@ namespace ICSharpCode.Decompiler.CSharp
var collector = new RequiredNamespaceCollector(namespaces);
foreach (var type in module.TypeDefinitions)
{
collector.CollectNamespaces(type, module, (CodeMappingInfo)null);
collector.CollectNamespaces(type, module, (CodeMappingInfo?)null);
}
collector.HandleAttributes(module.GetAssemblyAttributes());
collector.HandleAttributes(module.GetModuleAttributes());

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

@ -56,7 +56,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -56,7 +56,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
if (compilation == null)
throw new ArgumentNullException(nameof(compilation));
CacheManager cache = compilation.CacheManager;
CSharpConversions operators = (CSharpConversions)cache.GetShared(typeof(CSharpConversions));
CSharpConversions? operators = (CSharpConversions)cache.GetShared(typeof(CSharpConversions));
if (operators == null)
{
operators = (CSharpConversions)cache.GetOrAddShared(typeof(CSharpConversions), new CSharpConversions(compilation));
@ -182,7 +182,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -182,7 +182,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
throw new ArgumentNullException(nameof(toType));
TypePair pair = new TypePair(fromType, toType);
if (implicitConversionCache.TryGetValue(pair, out Conversion c))
if (implicitConversionCache.TryGetValue(pair, out Conversion? c))
return c;
c = ImplicitConversion(fromType, toType, allowUserDefined: true, allowTuple: true);
@ -600,7 +600,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -600,7 +600,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
bool IdentityOrVarianceConversion(IType s, IType t, int subtypeCheckNestingDepth)
{
ITypeDefinition def = s.GetDefinition();
ITypeDefinition? def = s.GetDefinition();
if (def != null)
{
if (!def.Equals(t.GetDefinition()))
@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
else if (fromType.Kind == TypeKind.Delegate && toType.Kind == TypeKind.Delegate)
{
ITypeDefinition def = fromType.GetDefinition();
ITypeDefinition? def = fromType.GetDefinition();
if (def == null || !def.Equals(toType.GetDefinition()))
return false;
ParameterizedType? ps = fromType as ParameterizedType;
@ -811,7 +811,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -811,7 +811,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
else if (fromTypeCode == TypeCode.Int32)
{
object cv = rr.ConstantValue;
object? cv = rr.ConstantValue;
if (cv == null)
return false;
int val = (int)cv;

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

@ -506,7 +506,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -506,7 +506,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
else if (expression.IsCompileTimeConstant && m.CanEvaluateAtCompileTime)
{
object val;
object? val;
try
{
val = m.Invoke(this, expression.ConstantValue);
@ -923,7 +923,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -923,7 +923,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
else if (lhs.IsCompileTimeConstant && rhs.IsCompileTimeConstant && m.CanEvaluateAtCompileTime)
{
object val;
object? val;
try
{
val = m.Invoke(this, lhs.ConstantValue, rhs.ConstantValue);
@ -982,7 +982,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -982,7 +982,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#region Enum helper methods
IType GetEnumUnderlyingType(IType enumType)
{
ITypeDefinition def = enumType.GetDefinition();
ITypeDefinition? def = enumType.GetDefinition();
return def != null ? def.EnumUnderlyingType : SpecialType.UnknownType;
}
@ -1609,12 +1609,12 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1609,12 +1609,12 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return trr != null && trr.Type.Equals(rr.Type);
}
ResolveResult LookInCurrentType(string identifier, IReadOnlyList<IType> typeArguments, NameLookupMode lookupMode, bool parameterizeResultType)
ResolveResult? LookInCurrentType(string identifier, IReadOnlyList<IType> typeArguments, NameLookupMode lookupMode, bool parameterizeResultType)
{
int k = typeArguments.Count;
MemberLookup lookup = CreateMemberLookup(lookupMode);
// look in current type definitions
for (ITypeDefinition t = this.CurrentTypeDefinition; t != null; t = t.DeclaringTypeDefinition)
for (ITypeDefinition? t = this.CurrentTypeDefinition; t != null; t = t.DeclaringTypeDefinition)
{
if (k == 0)
{
@ -1651,7 +1651,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1651,7 +1651,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return null;
}
ResolveResult LookInCurrentUsingScope(string identifier, IReadOnlyList<IType> typeArguments, bool isInUsingDeclaration, bool parameterizeResultType)
ResolveResult? LookInCurrentUsingScope(string identifier, IReadOnlyList<IType> typeArguments, bool isInUsingDeclaration, bool parameterizeResultType)
{
// look in current namespace definitions
ResolvedUsingScope currentUsingScope = this.CurrentUsingScope;
@ -1684,7 +1684,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1684,7 +1684,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
IType? firstResult = null;
foreach (var importedNamespace in u.Usings)
{
ITypeDefinition def = importedNamespace.GetTypeDefinition(identifier, typeArguments.Count);
ITypeDefinition? def = importedNamespace.GetTypeDefinition(identifier, typeArguments.Count);
if (def != null)
{
IType resultType;
@ -1712,7 +1712,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1712,7 +1712,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return null;
}
ResolveResult LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType)
ResolveResult? LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType)
{
if (n == null)
return null;
@ -1720,7 +1720,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1720,7 +1720,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
int k = typeArguments.Count;
if (k == 0)
{
INamespace childNamespace = n.GetChildNamespace(identifier);
INamespace? childNamespace = n.GetChildNamespace(identifier);
if (childNamespace != null)
{
if (usingScope != null && usingScope.HasAlias(identifier))
@ -1729,7 +1729,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1729,7 +1729,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
}
// then look for a type
ITypeDefinition def = n.GetTypeDefinition(identifier, k);
ITypeDefinition? def = n.GetTypeDefinition(identifier, k);
if (def != null && TopLevelTypeDefinitionIsAccessible(def))
{
IType result = def;
@ -1781,7 +1781,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1781,7 +1781,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
ResolveResult ResolveExternAlias(string alias)
{
INamespace ns = compilation.GetNamespaceForExternAlias(alias);
INamespace? ns = compilation.GetNamespaceForExternAlias(alias);
if (ns != null)
return new NamespaceResolveResult(ns);
else
@ -1854,11 +1854,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1854,11 +1854,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
if (typeArguments.Count == 0)
{
INamespace childNamespace = nrr.Namespace.GetChildNamespace(identifier);
INamespace? childNamespace = nrr.Namespace.GetChildNamespace(identifier);
if (childNamespace != null)
return new NamespaceResolveResult(childNamespace);
}
ITypeDefinition def = nrr.Namespace.GetTypeDefinition(identifier, typeArguments.Count);
ITypeDefinition? def = nrr.Namespace.GetTypeDefinition(identifier, typeArguments.Count);
if (def != null)
{
if (parameterizeResultType && typeArguments.Count > 0)
@ -1985,13 +1985,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1985,13 +1985,13 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
elementType = expression.Type.GetElementTypeFromIEnumerable(compilation, false, out bool? isGeneric);
if (isGeneric == true)
{
ITypeDefinition enumerableOfT = compilation.FindType(KnownTypeCode.IEnumerableOfT).GetDefinition();
ITypeDefinition? enumerableOfT = compilation.FindType(KnownTypeCode.IEnumerableOfT).GetDefinition();
if (enumerableOfT != null)
collectionType = new ParameterizedType(enumerableOfT, new[] { elementType });
else
collectionType = SpecialType.UnknownType;
ITypeDefinition enumeratorOfT = compilation.FindType(KnownTypeCode.IEnumeratorOfT).GetDefinition();
ITypeDefinition? enumeratorOfT = compilation.FindType(KnownTypeCode.IEnumeratorOfT).GetDefinition();
if (enumeratorOfT != null)
enumeratorType = new ParameterizedType(enumeratorOfT, new[] { elementType });
else
@ -2060,7 +2060,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2060,7 +2060,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// new List { all extensions from SomeExtensions }
/// }
/// </remarks>
public List<List<IMethod>> GetExtensionMethods(IType targetType, string? name = null, IReadOnlyList<IType>? typeArguments = null, bool substituteInferredTypes = false)
public List<List<IMethod>> GetExtensionMethods(IType? targetType, string? name = null, IReadOnlyList<IType>? typeArguments = null, bool substituteInferredTypes = false)
{
var lookup = CreateMemberLookup();
List<List<IMethod>> extensionMethodGroups = new List<List<IMethod>>();
@ -2073,7 +2073,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2073,7 +2073,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
continue;
if (!lookup.IsAccessible(method, false))
continue;
IType[] inferredTypes;
IType[]? inferredTypes;
if (typeArguments != null && typeArguments.Count > 0)
{
if (method.TypeParameters.Count != typeArguments.Count)
@ -2118,7 +2118,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2118,7 +2118,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// If an array is returned, any slot with an uninferred type argument will be set to the method's
/// corresponding type parameter.
/// </param>
public static bool IsEligibleExtensionMethod(IType targetType, IMethod method, bool useTypeInference, out IType[] outInferredTypes)
public static bool IsEligibleExtensionMethod(IType targetType, IMethod method, bool useTypeInference, out IType[]? outInferredTypes)
{
if (targetType == null)
throw new ArgumentNullException(nameof(targetType));
@ -2128,7 +2128,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2128,7 +2128,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return IsEligibleExtensionMethod(compilation, CSharpConversions.Get(compilation), targetType, method, useTypeInference, out outInferredTypes);
}
static bool IsEligibleExtensionMethod(ICompilation compilation, CSharpConversions conversions, IType targetType, IMethod method, bool useTypeInference, out IType[]? outInferredTypes)
static bool IsEligibleExtensionMethod(ICompilation compilation, CSharpConversions conversions, IType? targetType, IMethod method, bool useTypeInference, out IType[]? outInferredTypes)
{
outInferredTypes = null;
if (targetType == null)
@ -2814,9 +2814,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2814,9 +2814,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return new ConstantResolveResult(type, GetDefaultValue(type));
}
public static object GetDefaultValue(IType type)
public static object? GetDefaultValue(IType type)
{
ITypeDefinition typeDef = type.GetDefinition();
ITypeDefinition? typeDef = type.GetDefinition();
if (typeDef == null)
return null;
if (typeDef.Kind == TypeKind.Enum)

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

@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
if (targetType.Kind == TypeKind.TypeParameter)
targetType = ((ITypeParameter)targetType).EffectiveBaseClass;
ITypeDefinition typeDef = targetType.GetDefinition();
ITypeDefinition? typeDef = targetType.GetDefinition();
if (typeDef == null)
return false;
for (ITypeDefinition c = currentTypeDefinition; c != null; c = c.DeclaringTypeDefinition)
@ -195,7 +195,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -195,7 +195,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
foreach (var entityGroup in entities.GroupBy(e => e.Name))
{
List<LookupGroup> lookupGroups = new List<LookupGroup>();
List<LookupGroup>? lookupGroups = new List<LookupGroup>();
if (!lookupGroupDict.TryGetValue(entityGroup.Key, out lookupGroups))
lookupGroupDict.Add(entityGroup.Key, lookupGroups = new List<LookupGroup>());
@ -243,7 +243,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -243,7 +243,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
foreach (IType type in lookupGroup.NestedTypes)
{
ITypeDefinition typeDef = type.GetDefinition();
ITypeDefinition? typeDef = type.GetDefinition();
if (typeDef != null)
yield return typeDef;
}
@ -691,7 +691,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -691,7 +691,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
// return true if type is an interface or System.Object
if (type.Kind == TypeKind.Interface)
return true;
ITypeDefinition d = type.GetDefinition();
ITypeDefinition? d = type.GetDefinition();
return d != null && d.KnownTypeCode == KnownTypeCode.Object;
}
#endregion

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

@ -582,7 +582,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -582,7 +582,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
if (typeParameter.HasDefaultConstructorConstraint)
{
ITypeDefinition def = typeArgument.GetDefinition();
ITypeDefinition? def = typeArgument.GetDefinition();
if (def != null && def.IsAbstract)
return false;
var ctors = typeArgument.GetConstructors(

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

@ -1109,7 +1109,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1109,7 +1109,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
// Now filter out candidates that violate the upper bounds:
foreach (IType ub in upperBounds)
{
ITypeDefinition ubDef = ub.GetDefinition();
ITypeDefinition? ubDef = ub.GetDefinition();
if (ubDef != null)
{
candidateTypeDefinitions.RemoveAll(c => !c.IsDerivedFrom(ubDef));

2
ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs

@ -547,7 +547,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -547,7 +547,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
List<int> sequencePointCandidates = function.SequencePointCandidates;
List<int>? sequencePointCandidates = function.SequencePointCandidates;
int currSPCandidateIndex = 0;
for (int i = 0; i < newList.Count - 1; i++)

15
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -213,7 +213,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -213,7 +213,8 @@ namespace ICSharpCode.Decompiler.CSharp
TranslatedExpression value;
IType type;
if (inst.Value is StringToInt strToInt)
var strToInt = inst.Value as StringToInt;
if (strToInt != null)
{
value = exprBuilder.Translate(strToInt.Argument)
.ConvertTo(
@ -328,7 +329,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -328,7 +329,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
Debug.Assert(block.FinalInstruction.OpCode == OpCode.Nop);
}
if (endContainerLabels.TryGetValue(switchContainer, out string label))
if (endContainerLabels.TryGetValue(switchContainer, out string? label))
{
lastSectionStatements.Add(new LabelStatement { Label = label });
lastSectionStatements.Add(new BreakStatement());
@ -411,7 +412,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -411,7 +412,7 @@ namespace ICSharpCode.Decompiler.CSharp
else
return new ReturnStatement().WithILInstruction(inst);
}
if (!endContainerLabels.TryGetValue(inst.TargetContainer, out string label))
if (!endContainerLabels.TryGetValue(inst.TargetContainer, out string? label))
{
label = "end_" + inst.TargetLabel;
if (!duplicateLabels.TryGetValue(label, out int count))
@ -1261,8 +1262,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1261,8 +1262,8 @@ namespace ICSharpCode.Decompiler.CSharp
Statement ConvertLoop(BlockContainer container)
{
ILInstruction condition;
Block loopBody;
ILInstruction? condition;
Block? loopBody;
BlockStatement blockStatement;
continueCount = 0;
breakTarget = container;
@ -1480,7 +1481,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1480,7 +1481,7 @@ namespace ICSharpCode.Decompiler.CSharp
blockStatement.Add(Convert(block.FinalInstruction));
}
}
if (endContainerLabels.TryGetValue(container, out string label))
if (endContainerLabels.TryGetValue(container, out string? label))
{
if (isLoop && !(blockStatement.LastOrDefault() is ContinueStatement))
{
@ -1500,7 +1501,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1500,7 +1501,7 @@ namespace ICSharpCode.Decompiler.CSharp
string EnsureUniqueLabel(Block block)
{
if (labels.TryGetValue(block, out string label))
if (labels.TryGetValue(block, out string? label))
return label;
if (!duplicateLabels.TryGetValue(block.Label, out int count))
{

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

@ -202,7 +202,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -202,7 +202,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return parent; }
}
public Role Role {
public Role? Role {
get {
return Role.GetByIndex(flags & roleIndexMask);
}

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

@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get {
int count = 0;
uint roleIndex = role.Index;
for (AstNode cur = node.FirstChild; cur != null; cur = cur.NextSibling)
for (AstNode? cur = node.FirstChild; cur != null; cur = cur.NextSibling)
{
if (cur.RoleIndex == roleIndex)
count++;
@ -177,8 +177,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -177,8 +177,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public IEnumerator<T> GetEnumerator()
{
uint roleIndex = role.Index;
AstNode next;
for (AstNode cur = node.FirstChild; cur != null; cur = next)
AstNode? next;
for (AstNode? cur = node.FirstChild; cur != null; cur = next)
{
Debug.Assert(cur.Parent == node);
// Remember next before yielding cur.
@ -214,7 +214,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -214,7 +214,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return Pattern.DoMatchCollection(role, node.FirstChild, other.node.FirstChild, match);
}
public void InsertAfter(T existingItem, T newItem)
public void InsertAfter(T? existingItem, T newItem)
{
node.InsertChildAfter(existingItem, newItem, role);
}
@ -230,8 +230,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -230,8 +230,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public void AcceptVisitor(IAstVisitor visitor)
{
uint roleIndex = role.Index;
AstNode next;
for (AstNode cur = node.FirstChild; cur != null; cur = next)
AstNode? next;
for (AstNode? cur = node.FirstChild; cur != null; cur = next)
{
Debug.Assert(cur.Parent == node);
// Remember next before yielding cur.

272
ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
protected virtual void VisitChildren(AstNode node)
{
AstNode next;
AstNode? next;
for (var child = node.FirstChild; child != null; child = next)
{
// Store next to allow the loop to continue
@ -715,7 +715,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -715,7 +715,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
protected virtual T VisitChildren(AstNode node)
{
AstNode next;
AstNode? next;
for (var child = node.FirstChild; child != null; child = next)
{
// Store next to allow the loop to continue
@ -1396,9 +1396,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1396,9 +1396,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public abstract class DepthFirstAstVisitor<T, S> : IAstVisitor<T, S>
{
protected virtual S VisitChildren(AstNode node, T data)
protected virtual S? VisitChildren(AstNode node, T data)
{
AstNode next;
AstNode? next;
for (var child = node.FirstChild; child != null; child = next)
{
// Store next to allow the loop to continue
@ -1409,7 +1409,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1409,7 +1409,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return default(S);
}
public virtual S VisitNullNode(AstNode nullNode, T data)
public virtual S? VisitNullNode(AstNode nullNode, T data)
{
// Should we call VisitChildren here?
// We usually want to ignore null nodes.
@ -1418,657 +1418,657 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1418,657 +1418,657 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return default(S);
}
public virtual S VisitSyntaxTree(SyntaxTree unit, T data)
public virtual S? VisitSyntaxTree(SyntaxTree unit, T data)
{
return VisitChildren(unit, data);
}
public virtual S VisitComment(Comment comment, T data)
public virtual S? VisitComment(Comment comment, T data)
{
return VisitChildren(comment, data);
}
public virtual S VisitDocumentationReference(DocumentationReference documentationReference, T data)
public virtual S? VisitDocumentationReference(DocumentationReference documentationReference, T data)
{
return VisitChildren(documentationReference, data);
}
public virtual S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data)
public virtual S? VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data)
{
return VisitChildren(preProcessorDirective, data);
}
public virtual S VisitIdentifier(Identifier identifier, T data)
public virtual S? VisitIdentifier(Identifier identifier, T data)
{
return VisitChildren(identifier, data);
}
public virtual S VisitCSharpTokenNode(CSharpTokenNode token, T data)
public virtual S? VisitCSharpTokenNode(CSharpTokenNode token, T data)
{
return VisitChildren(token, data);
}
public virtual S VisitPrimitiveType(PrimitiveType primitiveType, T data)
public virtual S? VisitPrimitiveType(PrimitiveType primitiveType, T data)
{
return VisitChildren(primitiveType, data);
}
public virtual S VisitComposedType(ComposedType composedType, T data)
public virtual S? VisitComposedType(ComposedType composedType, T data)
{
return VisitChildren(composedType, data);
}
public virtual S VisitSimpleType(SimpleType simpleType, T data)
public virtual S? VisitSimpleType(SimpleType simpleType, T data)
{
return VisitChildren(simpleType, data);
}
public virtual S VisitMemberType(MemberType memberType, T data)
public virtual S? VisitMemberType(MemberType memberType, T data)
{
return VisitChildren(memberType, data);
}
public virtual S VisitTupleType(TupleAstType tupleType, T data)
public virtual S? VisitTupleType(TupleAstType tupleType, T data)
{
return VisitChildren(tupleType, data);
}
public virtual S VisitTupleTypeElement(TupleTypeElement tupleTypeElement, T data)
public virtual S? VisitTupleTypeElement(TupleTypeElement tupleTypeElement, T data)
{
return VisitChildren(tupleTypeElement, data);
}
public virtual S VisitFunctionPointerType(FunctionPointerAstType functionPointerType, T data)
public virtual S? VisitFunctionPointerType(FunctionPointerAstType functionPointerType, T data)
{
return VisitChildren(functionPointerType, data);
}
public virtual S VisitInvocationType(InvocationAstType invocationType, T data)
public virtual S? VisitInvocationType(InvocationAstType invocationType, T data)
{
return VisitChildren(invocationType, data);
}
public virtual S VisitAttribute(Attribute attribute, T data)
public virtual S? VisitAttribute(Attribute attribute, T data)
{
return VisitChildren(attribute, data);
}
public virtual S VisitAttributeSection(AttributeSection attributeSection, T data)
public virtual S? VisitAttributeSection(AttributeSection attributeSection, T data)
{
return VisitChildren(attributeSection, data);
}
public virtual S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data)
public virtual S? VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data)
{
return VisitChildren(delegateDeclaration, data);
}
public virtual S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data)
public virtual S? VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data)
{
return VisitChildren(namespaceDeclaration, data);
}
public virtual S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data)
public virtual S? VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data)
{
return VisitChildren(typeDeclaration, data);
}
public virtual S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data)
public virtual S? VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data)
{
return VisitChildren(typeParameterDeclaration, data);
}
public virtual S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data)
public virtual S? VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data)
{
return VisitChildren(enumMemberDeclaration, data);
}
public virtual S VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data)
public virtual S? VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data)
{
return VisitChildren(usingDeclaration, data);
}
public virtual S VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration, T data)
public virtual S? VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration, T data)
{
return VisitChildren(usingDeclaration, data);
}
public virtual S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data)
public virtual S? VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data)
{
return VisitChildren(externAliasDeclaration, data);
}
public virtual S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data)
public virtual S? VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data)
{
return VisitChildren(constructorDeclaration, data);
}
public virtual S VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data)
public virtual S? VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data)
{
return VisitChildren(constructorInitializer, data);
}
public virtual S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data)
public virtual S? VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data)
{
return VisitChildren(destructorDeclaration, data);
}
public virtual S VisitEventDeclaration(EventDeclaration eventDeclaration, T data)
public virtual S? VisitEventDeclaration(EventDeclaration eventDeclaration, T data)
{
return VisitChildren(eventDeclaration, data);
}
public virtual S VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration, T data)
public virtual S? VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration, T data)
{
return VisitChildren(eventDeclaration, data);
}
public virtual S VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data)
public virtual S? VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data)
{
return VisitChildren(fieldDeclaration, data);
}
public virtual S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data)
public virtual S? VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data)
{
return VisitChildren(fixedFieldDeclaration, data);
}
public virtual S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data)
public virtual S? VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data)
{
return VisitChildren(fixedVariableInitializer, data);
}
public virtual S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data)
public virtual S? VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data)
{
return VisitChildren(indexerDeclaration, data);
}
public virtual S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data)
public virtual S? VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data)
{
return VisitChildren(methodDeclaration, data);
}
public virtual S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data)
public virtual S? VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data)
{
return VisitChildren(operatorDeclaration, data);
}
public virtual S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data)
public virtual S? VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data)
{
return VisitChildren(propertyDeclaration, data);
}
public virtual S VisitAccessor(Accessor accessor, T data)
public virtual S? VisitAccessor(Accessor accessor, T data)
{
return VisitChildren(accessor, data);
}
public virtual S VisitVariableInitializer(VariableInitializer variableInitializer, T data)
public virtual S? VisitVariableInitializer(VariableInitializer variableInitializer, T data)
{
return VisitChildren(variableInitializer, data);
}
public virtual S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data)
public virtual S? VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data)
{
return VisitChildren(parameterDeclaration, data);
}
public virtual S VisitConstraint(Constraint constraint, T data)
public virtual S? VisitConstraint(Constraint constraint, T data)
{
return VisitChildren(constraint, data);
}
public virtual S VisitBlockStatement(BlockStatement blockStatement, T data)
public virtual S? VisitBlockStatement(BlockStatement blockStatement, T data)
{
return VisitChildren(blockStatement, data);
}
public virtual S VisitExpressionStatement(ExpressionStatement expressionStatement, T data)
public virtual S? VisitExpressionStatement(ExpressionStatement expressionStatement, T data)
{
return VisitChildren(expressionStatement, data);
}
public virtual S VisitBreakStatement(BreakStatement breakStatement, T data)
public virtual S? VisitBreakStatement(BreakStatement breakStatement, T data)
{
return VisitChildren(breakStatement, data);
}
public virtual S VisitCheckedStatement(CheckedStatement checkedStatement, T data)
public virtual S? VisitCheckedStatement(CheckedStatement checkedStatement, T data)
{
return VisitChildren(checkedStatement, data);
}
public virtual S VisitContinueStatement(ContinueStatement continueStatement, T data)
public virtual S? VisitContinueStatement(ContinueStatement continueStatement, T data)
{
return VisitChildren(continueStatement, data);
}
public virtual S VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data)
public virtual S? VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data)
{
return VisitChildren(doWhileStatement, data);
}
public virtual S VisitEmptyStatement(EmptyStatement emptyStatement, T data)
public virtual S? VisitEmptyStatement(EmptyStatement emptyStatement, T data)
{
return VisitChildren(emptyStatement, data);
}
public virtual S VisitFixedStatement(FixedStatement fixedStatement, T data)
public virtual S? VisitFixedStatement(FixedStatement fixedStatement, T data)
{
return VisitChildren(fixedStatement, data);
}
public virtual S VisitForeachStatement(ForeachStatement foreachStatement, T data)
public virtual S? VisitForeachStatement(ForeachStatement foreachStatement, T data)
{
return VisitChildren(foreachStatement, data);
}
public virtual S VisitForStatement(ForStatement forStatement, T data)
public virtual S? VisitForStatement(ForStatement forStatement, T data)
{
return VisitChildren(forStatement, data);
}
public virtual S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data)
public virtual S? VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data)
{
return VisitChildren(gotoCaseStatement, data);
}
public virtual S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data)
public virtual S? VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data)
{
return VisitChildren(gotoDefaultStatement, data);
}
public virtual S VisitGotoStatement(GotoStatement gotoStatement, T data)
public virtual S? VisitGotoStatement(GotoStatement gotoStatement, T data)
{
return VisitChildren(gotoStatement, data);
}
public virtual S VisitIfElseStatement(IfElseStatement ifElseStatement, T data)
public virtual S? VisitIfElseStatement(IfElseStatement ifElseStatement, T data)
{
return VisitChildren(ifElseStatement, data);
}
public virtual S VisitLabelStatement(LabelStatement labelStatement, T data)
public virtual S? VisitLabelStatement(LabelStatement labelStatement, T data)
{
return VisitChildren(labelStatement, data);
}
public virtual S VisitLockStatement(LockStatement lockStatement, T data)
public virtual S? VisitLockStatement(LockStatement lockStatement, T data)
{
return VisitChildren(lockStatement, data);
}
public virtual S VisitReturnStatement(ReturnStatement returnStatement, T data)
public virtual S? VisitReturnStatement(ReturnStatement returnStatement, T data)
{
return VisitChildren(returnStatement, data);
}
public virtual S VisitSwitchStatement(SwitchStatement switchStatement, T data)
public virtual S? VisitSwitchStatement(SwitchStatement switchStatement, T data)
{
return VisitChildren(switchStatement, data);
}
public virtual S VisitSwitchSection(SwitchSection switchSection, T data)
public virtual S? VisitSwitchSection(SwitchSection switchSection, T data)
{
return VisitChildren(switchSection, data);
}
public virtual S VisitCaseLabel(CaseLabel caseLabel, T data)
public virtual S? VisitCaseLabel(CaseLabel caseLabel, T data)
{
return VisitChildren(caseLabel, data);
}
public virtual S VisitSwitchExpression(SwitchExpression switchExpression, T data)
public virtual S? VisitSwitchExpression(SwitchExpression switchExpression, T data)
{
return VisitChildren(switchExpression, data);
}
public virtual S VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection, T data)
public virtual S? VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection, T data)
{
return VisitChildren(switchExpressionSection, data);
}
public virtual S VisitThrowStatement(ThrowStatement throwStatement, T data)
public virtual S? VisitThrowStatement(ThrowStatement throwStatement, T data)
{
return VisitChildren(throwStatement, data);
}
public virtual S VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data)
public virtual S? VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data)
{
return VisitChildren(tryCatchStatement, data);
}
public virtual S VisitCatchClause(CatchClause catchClause, T data)
public virtual S? VisitCatchClause(CatchClause catchClause, T data)
{
return VisitChildren(catchClause, data);
}
public virtual S VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data)
public virtual S? VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data)
{
return VisitChildren(uncheckedStatement, data);
}
public virtual S VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data)
public virtual S? VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data)
{
return VisitChildren(unsafeStatement, data);
}
public virtual S VisitUsingStatement(UsingStatement usingStatement, T data)
public virtual S? VisitUsingStatement(UsingStatement usingStatement, T data)
{
return VisitChildren(usingStatement, data);
}
public virtual S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data)
public virtual S? VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data)
{
return VisitChildren(variableDeclarationStatement, data);
}
public virtual S VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement, T data)
public virtual S? VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement, T data)
{
return VisitChildren(localFunctionDeclarationStatement, data);
}
public virtual S VisitWhileStatement(WhileStatement whileStatement, T data)
public virtual S? VisitWhileStatement(WhileStatement whileStatement, T data)
{
return VisitChildren(whileStatement, data);
}
public virtual S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data)
public virtual S? VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data)
{
return VisitChildren(yieldBreakStatement, data);
}
public virtual S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data)
public virtual S? VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data)
{
return VisitChildren(yieldReturnStatement, data);
}
public virtual S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data)
public virtual S? VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data)
{
return VisitChildren(anonymousMethodExpression, data);
}
public virtual S VisitLambdaExpression(LambdaExpression lambdaExpression, T data)
public virtual S? VisitLambdaExpression(LambdaExpression lambdaExpression, T data)
{
return VisitChildren(lambdaExpression, data);
}
public virtual S VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data)
public virtual S? VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data)
{
return VisitChildren(assignmentExpression, data);
}
public virtual S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data)
public virtual S? VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data)
{
return VisitChildren(baseReferenceExpression, data);
}
public virtual S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data)
public virtual S? VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data)
{
return VisitChildren(binaryOperatorExpression, data);
}
public virtual S VisitCastExpression(CastExpression castExpression, T data)
public virtual S? VisitCastExpression(CastExpression castExpression, T data)
{
return VisitChildren(castExpression, data);
}
public virtual S VisitCheckedExpression(CheckedExpression checkedExpression, T data)
public virtual S? VisitCheckedExpression(CheckedExpression checkedExpression, T data)
{
return VisitChildren(checkedExpression, data);
}
public virtual S VisitConditionalExpression(ConditionalExpression conditionalExpression, T data)
public virtual S? VisitConditionalExpression(ConditionalExpression conditionalExpression, T data)
{
return VisitChildren(conditionalExpression, data);
}
public virtual S VisitIdentifierExpression(IdentifierExpression identifierExpression, T data)
public virtual S? VisitIdentifierExpression(IdentifierExpression identifierExpression, T data)
{
return VisitChildren(identifierExpression, data);
}
public virtual S VisitIndexerExpression(IndexerExpression indexerExpression, T data)
public virtual S? VisitIndexerExpression(IndexerExpression indexerExpression, T data)
{
return VisitChildren(indexerExpression, data);
}
public virtual S VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression, T data)
public virtual S? VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression, T data)
{
return VisitChildren(interpolatedStringExpression, data);
}
public virtual S VisitInterpolation(Interpolation interpolation, T data)
public virtual S? VisitInterpolation(Interpolation interpolation, T data)
{
return VisitChildren(interpolation, data);
}
public virtual S VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText, T data)
public virtual S? VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText, T data)
{
return VisitChildren(interpolatedStringText, data);
}
public virtual S VisitInvocationExpression(InvocationExpression invocationExpression, T data)
public virtual S? VisitInvocationExpression(InvocationExpression invocationExpression, T data)
{
return VisitChildren(invocationExpression, data);
}
public virtual S VisitDirectionExpression(DirectionExpression directionExpression, T data)
public virtual S? VisitDirectionExpression(DirectionExpression directionExpression, T data)
{
return VisitChildren(directionExpression, data);
}
public virtual S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data)
public virtual S? VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data)
{
return VisitChildren(memberReferenceExpression, data);
}
public virtual S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data)
public virtual S? VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data)
{
return VisitChildren(nullReferenceExpression, data);
}
public virtual S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data)
public virtual S? VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data)
{
return VisitChildren(objectCreateExpression, data);
}
public virtual S VisitDeclarationExpression(DeclarationExpression declarationExpression, T data)
public virtual S? VisitDeclarationExpression(DeclarationExpression declarationExpression, T data)
{
return VisitChildren(declarationExpression, data);
}
public virtual S VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression, T data)
public virtual S? VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression, T data)
{
return VisitChildren(recursivePatternExpression, data);
}
public virtual S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data)
public virtual S? VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data)
{
return VisitChildren(outVarDeclarationExpression, data);
}
public virtual S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data)
public virtual S? VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data)
{
return VisitChildren(anonymousTypeCreateExpression, data);
}
public virtual S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data)
public virtual S? VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data)
{
return VisitChildren(arrayCreateExpression, data);
}
public virtual S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data)
public virtual S? VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data)
{
return VisitChildren(parenthesizedExpression, data);
}
public virtual S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data)
public virtual S? VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data)
{
return VisitChildren(pointerReferenceExpression, data);
}
public virtual S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data)
public virtual S? VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data)
{
return VisitChildren(primitiveExpression, data);
}
public virtual S VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data)
public virtual S? VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data)
{
return VisitChildren(sizeOfExpression, data);
}
public virtual S VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data)
public virtual S? VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data)
{
return VisitChildren(stackAllocExpression, data);
}
public virtual S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data)
public virtual S? VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data)
{
return VisitChildren(thisReferenceExpression, data);
}
public virtual S VisitThrowExpression(ThrowExpression throwExpression, T data)
public virtual S? VisitThrowExpression(ThrowExpression throwExpression, T data)
{
return VisitChildren(throwExpression, data);
}
public virtual S VisitTupleExpression(TupleExpression tupleExpression, T data)
public virtual S? VisitTupleExpression(TupleExpression tupleExpression, T data)
{
return VisitChildren(tupleExpression, data);
}
public virtual S VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data)
public virtual S? VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data)
{
return VisitChildren(typeOfExpression, data);
}
public virtual S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data)
public virtual S? VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data)
{
return VisitChildren(typeReferenceExpression, data);
}
public virtual S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data)
public virtual S? VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data)
{
return VisitChildren(unaryOperatorExpression, data);
}
public virtual S VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data)
public virtual S? VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data)
{
return VisitChildren(uncheckedExpression, data);
}
public virtual S VisitQueryExpression(QueryExpression queryExpression, T data)
public virtual S? VisitQueryExpression(QueryExpression queryExpression, T data)
{
return VisitChildren(queryExpression, data);
}
public virtual S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data)
public virtual S? VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data)
{
return VisitChildren(queryContinuationClause, data);
}
public virtual S VisitQueryFromClause(QueryFromClause queryFromClause, T data)
public virtual S? VisitQueryFromClause(QueryFromClause queryFromClause, T data)
{
return VisitChildren(queryFromClause, data);
}
public virtual S VisitQueryLetClause(QueryLetClause queryLetClause, T data)
public virtual S? VisitQueryLetClause(QueryLetClause queryLetClause, T data)
{
return VisitChildren(queryLetClause, data);
}
public virtual S VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data)
public virtual S? VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data)
{
return VisitChildren(queryWhereClause, data);
}
public virtual S VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data)
public virtual S? VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data)
{
return VisitChildren(queryJoinClause, data);
}
public virtual S VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data)
public virtual S? VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data)
{
return VisitChildren(queryOrderClause, data);
}
public virtual S VisitQueryOrdering(QueryOrdering queryOrdering, T data)
public virtual S? VisitQueryOrdering(QueryOrdering queryOrdering, T data)
{
return VisitChildren(queryOrdering, data);
}
public virtual S VisitQuerySelectClause(QuerySelectClause querySelectClause, T data)
public virtual S? VisitQuerySelectClause(QuerySelectClause querySelectClause, T data)
{
return VisitChildren(querySelectClause, data);
}
public virtual S VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data)
public virtual S? VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data)
{
return VisitChildren(queryGroupClause, data);
}
public virtual S VisitAsExpression(AsExpression asExpression, T data)
public virtual S? VisitAsExpression(AsExpression asExpression, T data)
{
return VisitChildren(asExpression, data);
}
public virtual S VisitIsExpression(IsExpression isExpression, T data)
public virtual S? VisitIsExpression(IsExpression isExpression, T data)
{
return VisitChildren(isExpression, data);
}
public virtual S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data)
public virtual S? VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data)
{
return VisitChildren(defaultValueExpression, data);
}
public virtual S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data)
public virtual S? VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data)
{
return VisitChildren(undocumentedExpression, data);
}
public virtual S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data)
public virtual S? VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data)
{
return VisitChildren(arrayInitializerExpression, data);
}
public virtual S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data)
public virtual S? VisitArraySpecifier(ArraySpecifier arraySpecifier, T data)
{
return VisitChildren(arraySpecifier, data);
}
public virtual S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data)
public virtual S? VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data)
{
return VisitChildren(namedArgumentExpression, data);
}
public virtual S VisitNamedExpression(NamedExpression namedExpression, T data)
public virtual S? VisitNamedExpression(NamedExpression namedExpression, T data)
{
return VisitChildren(namedExpression, data);
}
public virtual S VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation, T data)
public virtual S? VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation, T data)
{
return VisitChildren(singleVariableDesignation, data);
}
public virtual S VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation, T data)
public virtual S? VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation, T data)
{
return VisitChildren(parenthesizedVariableDesignation, data);
}
public virtual S VisitErrorNode(AstNode errorNode, T data)
public virtual S? VisitErrorNode(AstNode errorNode, T data)
{
return VisitChildren(errorNode, data);
}
public virtual S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data)
public virtual S? VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data)
{
return VisitChildren(placeholder, data);
}
public virtual S VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression, T data)
public virtual S? VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression, T data)
{
return VisitChildren(withInitializerExpression, data);
}

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

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <typeparam name='T'>
/// The type of the annotation.
/// </typeparam>
T Annotation<T>() where T : class;
T? Annotation<T>() where T : class;
/// <summary>
/// Gets the first annotation of the specified type.
@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <param name='type'>
/// The type of the annotation.
/// </param>
object Annotation(Type type);
object? Annotation(Type type);
/// <summary>
/// Adds an annotation to this instance.
@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// or to an AnnotationList.
// Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list)
object annotations;
object? annotations;
/// <summary>
/// Clones all annotations.
@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
if (annotation == null)
throw new ArgumentNullException(nameof(annotation));
retry: // Retry until successful
object oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null);
object? oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null);
if (oldAnnotation == null)
{
return; // we successfully added a single annotation
@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public virtual void RemoveAnnotations<T>() where T : class
{
retry: // Retry until successful
object oldAnnotations = this.annotations;
object? oldAnnotations = this.annotations;
AnnotationList? list = oldAnnotations as AnnotationList;
if (list != null)
{
@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
if (type == null)
throw new ArgumentNullException(nameof(type));
retry: // Retry until successful
object oldAnnotations = this.annotations;
object? oldAnnotations = this.annotations;
AnnotationList? list = oldAnnotations as AnnotationList;
if (list != null)
{
@ -206,9 +206,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -206,9 +206,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public T Annotation<T>() where T : class
public T? Annotation<T>() where T : class
{
object annotations = this.annotations;
object? annotations = this.annotations;
AnnotationList? list = annotations as AnnotationList;
if (list != null)
{
@ -229,11 +229,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -229,11 +229,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public object Annotation(Type type)
public object? Annotation(Type type)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
object annotations = this.annotations;
object? annotations = this.annotations;
AnnotationList? list = annotations as AnnotationList;
if (list != null)
{
@ -259,7 +259,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -259,7 +259,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public IEnumerable<object> Annotations {
get {
object annotations = this.annotations;
object? annotations = this.annotations;
AnnotationList? list = annotations as AnnotationList;
if (list != null)
{

568
ICSharpCode.Decompiler/CSharp/Syntax/IAstVisitor.cs

@ -173,148 +173,148 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -173,148 +173,148 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public interface IAstVisitor<out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
S VisitAsExpression(AsExpression asExpression);
S VisitAssignmentExpression(AssignmentExpression assignmentExpression);
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
S VisitCastExpression(CastExpression castExpression);
S VisitCheckedExpression(CheckedExpression checkedExpression);
S VisitConditionalExpression(ConditionalExpression conditionalExpression);
S VisitDeclarationExpression(DeclarationExpression declarationExpression);
S VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression);
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
S VisitDirectionExpression(DirectionExpression directionExpression);
S VisitIdentifierExpression(IdentifierExpression identifierExpression);
S VisitIndexerExpression(IndexerExpression indexerExpression);
S VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression);
S VisitInvocationExpression(InvocationExpression invocationExpression);
S VisitIsExpression(IsExpression isExpression);
S VisitLambdaExpression(LambdaExpression lambdaExpression);
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
S VisitNamedExpression(NamedExpression namedExpression);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
S VisitThrowExpression(ThrowExpression throwExpression);
S VisitTupleExpression(TupleExpression tupleExpression);
S VisitTypeOfExpression(TypeOfExpression typeOfExpression);
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
S VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression);
S VisitQueryExpression(QueryExpression queryExpression);
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
S VisitQueryFromClause(QueryFromClause queryFromClause);
S VisitQueryLetClause(QueryLetClause queryLetClause);
S VisitQueryWhereClause(QueryWhereClause queryWhereClause);
S VisitQueryJoinClause(QueryJoinClause queryJoinClause);
S VisitQueryOrderClause(QueryOrderClause queryOrderClause);
S VisitQueryOrdering(QueryOrdering queryOrdering);
S VisitQuerySelectClause(QuerySelectClause querySelectClause);
S VisitQueryGroupClause(QueryGroupClause queryGroupClause);
S VisitAttribute(Attribute attribute);
S VisitAttributeSection(AttributeSection attributeSection);
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
S VisitTypeDeclaration(TypeDeclaration typeDeclaration);
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
S VisitUsingDeclaration(UsingDeclaration usingDeclaration);
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
S VisitBlockStatement(BlockStatement blockStatement);
S VisitBreakStatement(BreakStatement breakStatement);
S VisitCheckedStatement(CheckedStatement checkedStatement);
S VisitContinueStatement(ContinueStatement continueStatement);
S VisitDoWhileStatement(DoWhileStatement doWhileStatement);
S VisitEmptyStatement(EmptyStatement emptyStatement);
S VisitExpressionStatement(ExpressionStatement expressionStatement);
S VisitFixedStatement(FixedStatement fixedStatement);
S VisitForeachStatement(ForeachStatement foreachStatement);
S VisitForStatement(ForStatement forStatement);
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
S VisitGotoStatement(GotoStatement gotoStatement);
S VisitIfElseStatement(IfElseStatement ifElseStatement);
S VisitLabelStatement(LabelStatement labelStatement);
S VisitLockStatement(LockStatement lockStatement);
S VisitReturnStatement(ReturnStatement returnStatement);
S VisitSwitchStatement(SwitchStatement switchStatement);
S VisitSwitchSection(SwitchSection switchSection);
S VisitCaseLabel(CaseLabel caseLabel);
S VisitSwitchExpression(SwitchExpression switchExpression);
S VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection);
S VisitThrowStatement(ThrowStatement throwStatement);
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
S VisitCatchClause(CatchClause catchClause);
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
S VisitUnsafeStatement(UnsafeStatement unsafeStatement);
S VisitUsingStatement(UsingStatement usingStatement);
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
S VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement);
S VisitWhileStatement(WhileStatement whileStatement);
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
S VisitAccessor(Accessor accessor);
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
S VisitEventDeclaration(EventDeclaration eventDeclaration);
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
S VisitMethodDeclaration(MethodDeclaration methodDeclaration);
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
S VisitVariableInitializer(VariableInitializer variableInitializer);
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
S VisitSyntaxTree(SyntaxTree syntaxTree);
S VisitSimpleType(SimpleType simpleType);
S VisitMemberType(MemberType memberType);
S VisitTupleType(TupleAstType tupleType);
S VisitTupleTypeElement(TupleTypeElement tupleTypeElement);
S VisitFunctionPointerType(FunctionPointerAstType functionPointerType);
S VisitInvocationType(InvocationAstType invocationType);
S VisitComposedType(ComposedType composedType);
S VisitArraySpecifier(ArraySpecifier arraySpecifier);
S VisitPrimitiveType(PrimitiveType primitiveType);
S VisitComment(Comment comment);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
S VisitDocumentationReference(DocumentationReference documentationReference);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
S VisitConstraint(Constraint constraint);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
S VisitIdentifier(Identifier identifier);
S VisitInterpolation(Interpolation interpolation);
S VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText);
S VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation);
S VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation);
S VisitNullNode(AstNode nullNode);
S VisitErrorNode(AstNode errorNode);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
S? VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
S? VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
S? VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
S? VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
S? VisitAsExpression(AsExpression asExpression);
S? VisitAssignmentExpression(AssignmentExpression assignmentExpression);
S? VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
S? VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
S? VisitCastExpression(CastExpression castExpression);
S? VisitCheckedExpression(CheckedExpression checkedExpression);
S? VisitConditionalExpression(ConditionalExpression conditionalExpression);
S? VisitDeclarationExpression(DeclarationExpression declarationExpression);
S? VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression);
S? VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
S? VisitDirectionExpression(DirectionExpression directionExpression);
S? VisitIdentifierExpression(IdentifierExpression identifierExpression);
S? VisitIndexerExpression(IndexerExpression indexerExpression);
S? VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression);
S? VisitInvocationExpression(InvocationExpression invocationExpression);
S? VisitIsExpression(IsExpression isExpression);
S? VisitLambdaExpression(LambdaExpression lambdaExpression);
S? VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
S? VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
S? VisitNamedExpression(NamedExpression namedExpression);
S? VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
S? VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
S? VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
S? VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
S? VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
S? VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
S? VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
S? VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
S? VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
S? VisitThrowExpression(ThrowExpression throwExpression);
S? VisitTupleExpression(TupleExpression tupleExpression);
S? VisitTypeOfExpression(TypeOfExpression typeOfExpression);
S? VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
S? VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
S? VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
S? VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
S? VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression);
S? VisitQueryExpression(QueryExpression queryExpression);
S? VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
S? VisitQueryFromClause(QueryFromClause queryFromClause);
S? VisitQueryLetClause(QueryLetClause queryLetClause);
S? VisitQueryWhereClause(QueryWhereClause queryWhereClause);
S? VisitQueryJoinClause(QueryJoinClause queryJoinClause);
S? VisitQueryOrderClause(QueryOrderClause queryOrderClause);
S? VisitQueryOrdering(QueryOrdering queryOrdering);
S? VisitQuerySelectClause(QuerySelectClause querySelectClause);
S? VisitQueryGroupClause(QueryGroupClause queryGroupClause);
S? VisitAttribute(Attribute attribute);
S? VisitAttributeSection(AttributeSection attributeSection);
S? VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
S? VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
S? VisitTypeDeclaration(TypeDeclaration typeDeclaration);
S? VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
S? VisitUsingDeclaration(UsingDeclaration usingDeclaration);
S? VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
S? VisitBlockStatement(BlockStatement blockStatement);
S? VisitBreakStatement(BreakStatement breakStatement);
S? VisitCheckedStatement(CheckedStatement checkedStatement);
S? VisitContinueStatement(ContinueStatement continueStatement);
S? VisitDoWhileStatement(DoWhileStatement doWhileStatement);
S? VisitEmptyStatement(EmptyStatement emptyStatement);
S? VisitExpressionStatement(ExpressionStatement expressionStatement);
S? VisitFixedStatement(FixedStatement fixedStatement);
S? VisitForeachStatement(ForeachStatement foreachStatement);
S? VisitForStatement(ForStatement forStatement);
S? VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
S? VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
S? VisitGotoStatement(GotoStatement gotoStatement);
S? VisitIfElseStatement(IfElseStatement ifElseStatement);
S? VisitLabelStatement(LabelStatement labelStatement);
S? VisitLockStatement(LockStatement lockStatement);
S? VisitReturnStatement(ReturnStatement returnStatement);
S? VisitSwitchStatement(SwitchStatement switchStatement);
S? VisitSwitchSection(SwitchSection switchSection);
S? VisitCaseLabel(CaseLabel caseLabel);
S? VisitSwitchExpression(SwitchExpression switchExpression);
S? VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection);
S? VisitThrowStatement(ThrowStatement throwStatement);
S? VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
S? VisitCatchClause(CatchClause catchClause);
S? VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
S? VisitUnsafeStatement(UnsafeStatement unsafeStatement);
S? VisitUsingStatement(UsingStatement usingStatement);
S? VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
S? VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement);
S? VisitWhileStatement(WhileStatement whileStatement);
S? VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
S? VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
S? VisitAccessor(Accessor accessor);
S? VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
S? VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
S? VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
S? VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
S? VisitEventDeclaration(EventDeclaration eventDeclaration);
S? VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
S? VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
S? VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
S? VisitMethodDeclaration(MethodDeclaration methodDeclaration);
S? VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
S? VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
S? VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
S? VisitVariableInitializer(VariableInitializer variableInitializer);
S? VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
S? VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
S? VisitSyntaxTree(SyntaxTree syntaxTree);
S? VisitSimpleType(SimpleType simpleType);
S? VisitMemberType(MemberType memberType);
S? VisitTupleType(TupleAstType tupleType);
S? VisitTupleTypeElement(TupleTypeElement tupleTypeElement);
S? VisitFunctionPointerType(FunctionPointerAstType functionPointerType);
S? VisitInvocationType(InvocationAstType invocationType);
S? VisitComposedType(ComposedType composedType);
S? VisitArraySpecifier(ArraySpecifier arraySpecifier);
S? VisitPrimitiveType(PrimitiveType primitiveType);
S? VisitComment(Comment comment);
S? VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
S? VisitDocumentationReference(DocumentationReference documentationReference);
S? VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
S? VisitConstraint(Constraint constraint);
S? VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
S? VisitIdentifier(Identifier identifier);
S? VisitInterpolation(Interpolation interpolation);
S? VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText);
S? VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation);
S? VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation);
S? VisitNullNode(AstNode nullNode);
S? VisitErrorNode(AstNode errorNode);
S? VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
/// <summary>
@ -322,147 +322,147 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -322,147 +322,147 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public interface IAstVisitor<in T, out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data);
S VisitAsExpression(AsExpression asExpression, T data);
S VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data);
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data);
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data);
S VisitCastExpression(CastExpression castExpression, T data);
S VisitCheckedExpression(CheckedExpression checkedExpression, T data);
S VisitConditionalExpression(ConditionalExpression conditionalExpression, T data);
S VisitDeclarationExpression(DeclarationExpression declarationExpression, T data);
S VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression, T data);
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data);
S VisitDirectionExpression(DirectionExpression directionExpression, T data);
S VisitIdentifierExpression(IdentifierExpression identifierExpression, T data);
S VisitIndexerExpression(IndexerExpression indexerExpression, T data);
S VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression, T data);
S VisitInvocationExpression(InvocationExpression invocationExpression, T data);
S VisitIsExpression(IsExpression isExpression, T data);
S VisitLambdaExpression(LambdaExpression lambdaExpression, T data);
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data);
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
S VisitNamedExpression(NamedExpression namedExpression, T data);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data);
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data);
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data);
S VisitThrowExpression(ThrowExpression throwExpression, T data);
S VisitTupleExpression(TupleExpression tupleExpression, T data);
S VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data);
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data);
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data);
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data);
S VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression, T data);
S VisitQueryExpression(QueryExpression queryExpression, T data);
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data);
S VisitQueryFromClause(QueryFromClause queryFromClause, T data);
S VisitQueryLetClause(QueryLetClause queryLetClause, T data);
S VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data);
S VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data);
S VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data);
S VisitQueryOrdering(QueryOrdering queryOrdering, T data);
S VisitQuerySelectClause(QuerySelectClause querySelectClause, T data);
S VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data);
S VisitAttribute(Attribute attribute, T data);
S VisitAttributeSection(AttributeSection attributeSection, T data);
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data);
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data);
S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data);
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, T data);
S VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data);
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data);
S VisitBlockStatement(BlockStatement blockStatement, T data);
S VisitBreakStatement(BreakStatement breakStatement, T data);
S VisitCheckedStatement(CheckedStatement checkedStatement, T data);
S VisitContinueStatement(ContinueStatement continueStatement, T data);
S VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data);
S VisitEmptyStatement(EmptyStatement emptyStatement, T data);
S VisitExpressionStatement(ExpressionStatement expressionStatement, T data);
S VisitFixedStatement(FixedStatement fixedStatement, T data);
S VisitForeachStatement(ForeachStatement foreachStatement, T data);
S VisitForStatement(ForStatement forStatement, T data);
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data);
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data);
S VisitGotoStatement(GotoStatement gotoStatement, T data);
S VisitIfElseStatement(IfElseStatement ifElseStatement, T data);
S VisitLabelStatement(LabelStatement labelStatement, T data);
S VisitLockStatement(LockStatement lockStatement, T data);
S VisitReturnStatement(ReturnStatement returnStatement, T data);
S VisitSwitchStatement(SwitchStatement switchStatement, T data);
S VisitSwitchSection(SwitchSection switchSection, T data);
S VisitCaseLabel(CaseLabel caseLabel, T data);
S VisitSwitchExpression(SwitchExpression switchExpression, T data);
S VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection, T data);
S VisitThrowStatement(ThrowStatement throwStatement, T data);
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data);
S VisitCatchClause(CatchClause catchClause, T data);
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data);
S VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data);
S VisitUsingStatement(UsingStatement usingStatement, T data);
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data);
S VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement, T data);
S VisitWhileStatement(WhileStatement whileStatement, T data);
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data);
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data);
S VisitAccessor(Accessor accessor, T data);
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data);
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data);
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data);
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data);
S VisitEventDeclaration(EventDeclaration eventDeclaration, T data);
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, T data);
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data);
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data);
S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data);
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data);
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data);
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data);
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data);
S VisitSyntaxTree(SyntaxTree syntaxTree, T data);
S VisitSimpleType(SimpleType simpleType, T data);
S VisitMemberType(MemberType memberType, T data);
S VisitTupleType(TupleAstType tupleType, T data);
S VisitTupleTypeElement(TupleTypeElement tupleTypeElement, T data);
S VisitFunctionPointerType(FunctionPointerAstType functionPointerType, T data);
S VisitInvocationType(InvocationAstType invocationType, T data);
S VisitComposedType(ComposedType composedType, T data);
S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data);
S VisitPrimitiveType(PrimitiveType primitiveType, T data);
S VisitComment(Comment comment, T data);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data);
S VisitDocumentationReference(DocumentationReference documentationReference, T data);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data);
S VisitConstraint(Constraint constraint, T data);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, T data);
S VisitIdentifier(Identifier identifier, T data);
S VisitInterpolation(Interpolation interpolation, T data);
S VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText, T data);
S VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation, T data);
S VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation, T data);
S VisitNullNode(AstNode nullNode, T data);
S VisitErrorNode(AstNode errorNode, T data);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
S? VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data);
S? VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S? VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data);
S? VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data);
S? VisitAsExpression(AsExpression asExpression, T data);
S? VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data);
S? VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data);
S? VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data);
S? VisitCastExpression(CastExpression castExpression, T data);
S? VisitCheckedExpression(CheckedExpression checkedExpression, T data);
S? VisitConditionalExpression(ConditionalExpression conditionalExpression, T data);
S? VisitDeclarationExpression(DeclarationExpression declarationExpression, T data);
S? VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression, T data);
S? VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data);
S? VisitDirectionExpression(DirectionExpression directionExpression, T data);
S? VisitIdentifierExpression(IdentifierExpression identifierExpression, T data);
S? VisitIndexerExpression(IndexerExpression indexerExpression, T data);
S? VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression, T data);
S? VisitInvocationExpression(InvocationExpression invocationExpression, T data);
S? VisitIsExpression(IsExpression isExpression, T data);
S? VisitLambdaExpression(LambdaExpression lambdaExpression, T data);
S? VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data);
S? VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
S? VisitNamedExpression(NamedExpression namedExpression, T data);
S? VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
S? VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
S? VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data);
S? VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S? VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
S? VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);
S? VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data);
S? VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data);
S? VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data);
S? VisitThrowExpression(ThrowExpression throwExpression, T data);
S? VisitTupleExpression(TupleExpression tupleExpression, T data);
S? VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data);
S? VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data);
S? VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data);
S? VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data);
S? VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data);
S? VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression, T data);
S? VisitQueryExpression(QueryExpression queryExpression, T data);
S? VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data);
S? VisitQueryFromClause(QueryFromClause queryFromClause, T data);
S? VisitQueryLetClause(QueryLetClause queryLetClause, T data);
S? VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data);
S? VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data);
S? VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data);
S? VisitQueryOrdering(QueryOrdering queryOrdering, T data);
S? VisitQuerySelectClause(QuerySelectClause querySelectClause, T data);
S? VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data);
S? VisitAttribute(Attribute attribute, T data);
S? VisitAttributeSection(AttributeSection attributeSection, T data);
S? VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data);
S? VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data);
S? VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data);
S? VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, T data);
S? VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data);
S? VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data);
S? VisitBlockStatement(BlockStatement blockStatement, T data);
S? VisitBreakStatement(BreakStatement breakStatement, T data);
S? VisitCheckedStatement(CheckedStatement checkedStatement, T data);
S? VisitContinueStatement(ContinueStatement continueStatement, T data);
S? VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data);
S? VisitEmptyStatement(EmptyStatement emptyStatement, T data);
S? VisitExpressionStatement(ExpressionStatement expressionStatement, T data);
S? VisitFixedStatement(FixedStatement fixedStatement, T data);
S? VisitForeachStatement(ForeachStatement foreachStatement, T data);
S? VisitForStatement(ForStatement forStatement, T data);
S? VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data);
S? VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data);
S? VisitGotoStatement(GotoStatement gotoStatement, T data);
S? VisitIfElseStatement(IfElseStatement ifElseStatement, T data);
S? VisitLabelStatement(LabelStatement labelStatement, T data);
S? VisitLockStatement(LockStatement lockStatement, T data);
S? VisitReturnStatement(ReturnStatement returnStatement, T data);
S? VisitSwitchStatement(SwitchStatement switchStatement, T data);
S? VisitSwitchSection(SwitchSection switchSection, T data);
S? VisitCaseLabel(CaseLabel caseLabel, T data);
S? VisitSwitchExpression(SwitchExpression switchExpression, T data);
S? VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection, T data);
S? VisitThrowStatement(ThrowStatement throwStatement, T data);
S? VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data);
S? VisitCatchClause(CatchClause catchClause, T data);
S? VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data);
S? VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data);
S? VisitUsingStatement(UsingStatement usingStatement, T data);
S? VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data);
S? VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement, T data);
S? VisitWhileStatement(WhileStatement whileStatement, T data);
S? VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data);
S? VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data);
S? VisitAccessor(Accessor accessor, T data);
S? VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data);
S? VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data);
S? VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data);
S? VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data);
S? VisitEventDeclaration(EventDeclaration eventDeclaration, T data);
S? VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, T data);
S? VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data);
S? VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data);
S? VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data);
S? VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data);
S? VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data);
S? VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data);
S? VisitVariableInitializer(VariableInitializer variableInitializer, T data);
S? VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data);
S? VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data);
S? VisitSyntaxTree(SyntaxTree syntaxTree, T data);
S? VisitSimpleType(SimpleType simpleType, T data);
S? VisitMemberType(MemberType memberType, T data);
S? VisitTupleType(TupleAstType tupleType, T data);
S? VisitTupleTypeElement(TupleTypeElement tupleTypeElement, T data);
S? VisitFunctionPointerType(FunctionPointerAstType functionPointerType, T data);
S? VisitInvocationType(InvocationAstType invocationType, T data);
S? VisitComposedType(ComposedType composedType, T data);
S? VisitArraySpecifier(ArraySpecifier arraySpecifier, T data);
S? VisitPrimitiveType(PrimitiveType primitiveType, T data);
S? VisitComment(Comment comment, T data);
S? VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data);
S? VisitDocumentationReference(DocumentationReference documentationReference, T data);
S? VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data);
S? VisitConstraint(Constraint constraint, T data);
S? VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, T data);
S? VisitIdentifier(Identifier identifier, T data);
S? VisitInterpolation(Interpolation interpolation, T data);
S? VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText, T data);
S? VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation, T data);
S? VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation, T data);
S? VisitNullNode(AstNode nullNode, T data);
S? VisitErrorNode(AstNode errorNode, T data);
S? VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
}
}

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

@ -25,7 +25,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -25,7 +25,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
/// </summary>
public interface INode
{
Role Role { get; }
Role? Role { get; }
INode? FirstChild { get; }
INode? NextSibling { get; }
bool IsNull { get; }

10
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Pattern.cs

@ -52,15 +52,15 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -52,15 +52,15 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
get { return false; }
}
Role INode.Role {
Role? INode.Role {
get { return null; }
}
INode INode.NextSibling {
INode? INode.NextSibling {
get { return null; }
}
INode INode.FirstChild {
INode? INode.FirstChild {
get { return null; }
}
@ -80,8 +80,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -80,8 +80,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
stack.Push(new PossibleMatch(firstOtherChild, match.CheckPoint()));
while (stack.Count > 0)
{
INode cur1 = patternStack.Pop();
INode cur2 = stack.Peek().NextOther;
INode? cur1 = patternStack.Pop();
INode? cur2 = stack.Peek().NextOther;
match.RestoreCheckPoint(stack.Pop().Checkpoint);
bool success = true;
while (cur1 != null && success)

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

@ -44,7 +44,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching @@ -44,7 +44,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
this.MaxCount = int.MaxValue;
}
public override bool DoMatchCollection(Role role, INode pos, Match match, BacktrackingInfo backtrackingInfo)
public override bool DoMatchCollection(Role role, INode? pos, Match match, BacktrackingInfo backtrackingInfo)
{
var backtrackingStack = backtrackingInfo.backtrackingStack;
Debug.Assert(pos == null || pos.Role == role);

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

@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
#endregion
#region PatternPlaceholder
public static implicit operator Statement(PatternMatching.Pattern pattern)
public static implicit operator Statement?(PatternMatching.Pattern? pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
@ -86,12 +86,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -86,12 +86,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
public override T? AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
public override S? AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}

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

@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public static Statement GetNextStatement(this Statement statement)
{
AstNode next = statement.NextSibling;
AstNode? next = statement.NextSibling;
while (next != null && !(next is Statement))
next = next.NextSibling;
return (Statement)next;

2
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -76,7 +76,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary>
public CSharpTokenNode Keyword {
get {
for (AstNode child = this.FirstChild; child != null; child = child.NextSibling)
for (AstNode? child = this.FirstChild; child != null; child = child.NextSibling)
{
if (child.Role == PropertyDeclaration.GetKeywordRole || child.Role == PropertyDeclaration.SetKeywordRole
|| child.Role == PropertyDeclaration.InitKeywordRole

2
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs

@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
internal static void SetModifiers(AstNode node, Modifiers newValue)
{
Modifiers oldValue = GetModifiers(node);
AstNode insertionPos = node.GetChildrenByRole(AttributeRole).LastOrDefault();
AstNode? insertionPos = node.GetChildrenByRole(AttributeRole).LastOrDefault();
foreach (Modifiers m in CSharpModifierToken.AllModifiers)
{
if ((m & newValue) != 0)

2
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -70,7 +70,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public bool IsExtensionMethod {
get {
ParameterDeclaration pd = (ParameterDeclaration)GetChildByRole(Roles.Parameter);
ParameterDeclaration? pd = GetChildByRole(Roles.Parameter) as ParameterDeclaration;
return pd != null && pd.HasThisModifier;
}
}

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

@ -462,13 +462,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -462,13 +462,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AstType ConvertTypeHelper(IType genericType, IReadOnlyList<IType> typeArguments)
{
ITypeDefinition typeDef = genericType.GetDefinition();
ITypeDefinition? typeDef = genericType.GetDefinition();
Debug.Assert(typeDef != null || genericType.Kind == TypeKind.Unknown);
Debug.Assert(typeArguments.Count >= genericType.TypeParameterCount);
if (UseKeywordsForBuiltinTypes && typeDef != null)
{
string keyword = KnownTypeReference.GetCSharpNameByTypeCode(typeDef.KnownTypeCode);
string? keyword = KnownTypeReference.GetCSharpNameByTypeCode(typeDef.KnownTypeCode);
if (keyword != null)
{
return new PrimitiveType(keyword);
@ -1053,7 +1053,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1053,7 +1053,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
if (underlyingType.IsKnownType(KnownTypeCode.Double) || underlyingType.IsKnownType(KnownTypeCode.Single))
return ConvertFloatingPointLiteral(underlyingType, constantValue);
IType literalType = underlyingType;
IType? literalType = underlyingType;
bool integerTypeMismatch = underlyingType.IsCSharpSmallIntegerType() || underlyingType.IsCSharpNativeIntegerType();
if (integerTypeMismatch)
{
@ -1213,7 +1213,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1213,7 +1213,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Expression ConvertEnumValue(IType type, long val)
{
ITypeDefinition enumDefinition = type.GetDefinition();
ITypeDefinition? enumDefinition = type.GetDefinition();
TypeCode enumBaseTypeCode = ReflectionHelper.GetTypeCode(enumDefinition.EnumUnderlyingType);
var fields = enumDefinition.Fields
.Select(PrepareConstant)
@ -1295,7 +1295,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1295,7 +1295,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
if (!field.IsConst)
return (-1, null);
object constantValue = field.GetConstantValue();
object? constantValue = field.GetConstantValue();
if (constantValue == null)
return (-1, null);
return ((long)CSharpPrimitiveCast.Cast(TypeCode.Int64, constantValue, checkForOverflow: false), field);
@ -1890,7 +1890,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1890,7 +1890,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
DelegateDeclaration ConvertDelegate(IMethod invokeMethod, Modifiers modifiers)
{
ITypeDefinition d = invokeMethod.DeclaringTypeDefinition;
ITypeDefinition? d = invokeMethod.DeclaringTypeDefinition;
DelegateDeclaration decl = new DelegateDeclaration();
decl.Modifiers = modifiers & ~Modifiers.Sealed;
@ -2019,7 +2019,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -2019,7 +2019,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
decl.Modifiers = ModifierFromAccessibility(accessor.Accessibility);
if (this.ShowModifiers && accessor.HasReadonlyModifier())
decl.Modifiers |= Modifiers.Readonly;
TokenRole keywordRole = kind switch {
TokenRole? keywordRole = kind switch {
MethodSemanticsAttributes.Getter => PropertyDeclaration.GetKeywordRole,
MethodSemanticsAttributes.Setter => PropertyDeclaration.SetKeywordRole,
MethodSemanticsAttributes.Adder => CustomEventDeclaration.AddKeywordRole,
@ -2460,7 +2460,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -2460,7 +2460,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
static bool IsObjectOrValueType(IType type)
{
ITypeDefinition d = type.GetDefinition();
ITypeDefinition? d = type.GetDefinition();
return d != null && (d.KnownTypeCode == KnownTypeCode.Object || d.KnownTypeCode == KnownTypeCode.ValueType);
}
#endregion

6
ICSharpCode.Decompiler/CSharp/Transforms/AddCheckedBlocks.cs

@ -244,7 +244,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -244,7 +244,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
BlockStatement? block = node as BlockStatement;
if (block == null)
{
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling)
for (AstNode? child = node.FirstChild; child != null; child = child.NextSibling)
{
Run(child, context);
}
@ -275,7 +275,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -275,7 +275,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
InsertedNode? nodesUncheckedContextCheckedBlockOpen = null;
Statement? checkedBlockStart = null;
Statement statement = block.Statements.FirstOrDefault();
Statement? statement = block.Statements.FirstOrDefault();
while (true)
{
// Blocks can be closed 'for free'. We use '<=' so that blocks are closed as late as possible (goal 4b)
@ -340,7 +340,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -340,7 +340,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (node is BlockStatement)
return GetResultFromBlock((BlockStatement)node);
Result result = new Result();
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling)
for (AstNode? child = node.FirstChild; child != null; child = child.NextSibling)
{
Result childResult = GetResult(child);
result.CostInCheckedContext += childResult.CostInCheckedContext;

4
ICSharpCode.Decompiler/CSharp/Transforms/AddXmlDocumentationTransform.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
static void InsertXmlDocumentation(AstNode node, StringReader r)
{
// Find the first non-empty line:
string firstLine;
string? firstLine;
do
{
firstLine = r.ReadLine();
@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return;
} while (string.IsNullOrWhiteSpace(firstLine));
string indentation = firstLine.Substring(0, firstLine.Length - firstLine.TrimStart().Length);
string line = firstLine;
string? line = firstLine;
int skippedWhitespaceLines = 0;
// Copy all lines from input to output, except for empty lines at the end.
while (line != null)

4
ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs

@ -47,8 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -47,8 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
void CombineQueries(AstNode node, Dictionary<string, object> fromOrLetIdentifiers)
{
AstNode next;
for (AstNode child = node.FirstChild; child != null; child = next)
AstNode? next;
for (AstNode? child = node.FirstChild; child != null; child = next)
{
// store reference to next child before transformation
next = child.NextSibling;

6
ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs

@ -297,7 +297,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -297,7 +297,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
try
{
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling)
for (AstNode? child = node.FirstChild; child != null; child = child.NextSibling)
{
FindInsertionPoints(child, nodeLevel + 1);
}
@ -321,7 +321,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -321,7 +321,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
InsertionPoint newPoint;
int startIndex = scopeTracking.Count - 1;
BlockContainer captureScope = variable.CaptureScope;
BlockContainer? captureScope = variable.CaptureScope;
while (captureScope != null && !IsRelevantScope(captureScope))
{
captureScope = BlockContainer.FindClosestContainer(captureScope.Parent);
@ -356,7 +356,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -356,7 +356,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
}
}
if (variableDict.TryGetValue(variable, out VariableToDeclare v))
if (variableDict.TryGetValue(variable, out VariableToDeclare? v))
{
v.InsertionPoint = FindCommonParent(v.InsertionPoint, newPoint);
}

4
ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs

@ -67,8 +67,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -67,8 +67,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
if (node is IdentifierExpression || node is MemberReferenceExpression)
{
ISymbol symbol = node.GetSymbol();
if (symbol != null && renamedSymbols.TryGetValue(symbol, out string newName))
ISymbol? symbol = node.GetSymbol();
if (symbol != null && renamedSymbols.TryGetValue(symbol, out string? newName))
{
node.GetChildByRole(Roles.Identifier).Name = newName;
}

24
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs

@ -88,8 +88,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -88,8 +88,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
node.ReplaceWith(query);
}
AstNode next;
for (AstNode child = (query ?? node).FirstChild; child != null; child = next)
AstNode? next;
for (AstNode? child = (query ?? node).FirstChild; child != null; child = next)
{
// store reference to next child before transformation
next = child.NextSibling;
@ -103,7 +103,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -103,7 +103,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return context.Settings.Discards;
}
QueryExpression DecompileQuery(InvocationExpression invocation)
QueryExpression? DecompileQuery(InvocationExpression? invocation)
{
if (invocation == null)
return null;
@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (!IsComplexQuery(mre))
return null;
Expression expr = invocation.Arguments.Single();
if (MatchSimpleLambda(expr, out ParameterDeclaration parameter, out Expression body))
if (MatchSimpleLambda(expr, out ParameterDeclaration? parameter, out Expression? body))
{
QueryExpression query = new QueryExpression();
query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach()));
@ -134,8 +134,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -134,8 +134,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
Expression keyLambda = invocation.Arguments.ElementAt(0);
Expression projectionLambda = invocation.Arguments.ElementAt(1);
if (MatchSimpleLambda(keyLambda, out ParameterDeclaration parameter1, out Expression keySelector)
&& MatchSimpleLambda(projectionLambda, out ParameterDeclaration parameter2, out Expression elementSelector)
if (MatchSimpleLambda(keyLambda, out ParameterDeclaration? parameter1, out Expression? keySelector)
&& MatchSimpleLambda(projectionLambda, out ParameterDeclaration? parameter2, out Expression? elementSelector)
&& parameter1.Name == parameter2.Name)
{
QueryExpression query = new QueryExpression();
@ -152,7 +152,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -152,7 +152,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
else if (invocation.Arguments.Count == 1)
{
Expression lambda = invocation.Arguments.Single();
if (MatchSimpleLambda(lambda, out ParameterDeclaration parameter, out Expression keySelector))
if (MatchSimpleLambda(lambda, out ParameterDeclaration? parameter, out Expression? keySelector))
{
QueryExpression query = new QueryExpression();
query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach()));
@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (invocation.Arguments.Count != 2)
return null;
var fromExpressionLambda = invocation.Arguments.ElementAt(0);
if (!MatchSimpleLambda(fromExpressionLambda, out ParameterDeclaration parameter, out Expression collectionSelector))
if (!MatchSimpleLambda(fromExpressionLambda, out ParameterDeclaration? parameter, out Expression? collectionSelector))
return null;
if (IsNullConditional(collectionSelector))
return null;
@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (!IsComplexQuery(mre))
return null;
Expression expr = invocation.Arguments.Single();
if (MatchSimpleLambda(expr, out ParameterDeclaration parameter, out Expression body))
if (MatchSimpleLambda(expr, out ParameterDeclaration? parameter, out Expression? body))
{
QueryExpression query = new QueryExpression();
query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach()));
@ -213,7 +213,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -213,7 +213,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (!IsComplexQuery(mre))
return null;
var lambda = invocation.Arguments.Single();
if (MatchSimpleLambda(lambda, out ParameterDeclaration parameter, out Expression orderExpression))
if (MatchSimpleLambda(lambda, out ParameterDeclaration? parameter, out Expression? orderExpression))
{
if (ValidateThenByChain(invocation, parameter.Name))
{
@ -257,10 +257,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -257,10 +257,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (IsNullConditional(source2))
return null;
Expression outerLambda = invocation.Arguments.ElementAt(1);
if (!MatchSimpleLambda(outerLambda, out ParameterDeclaration element1, out Expression key1))
if (!MatchSimpleLambda(outerLambda, out ParameterDeclaration? element1, out Expression? key1))
return null;
Expression innerLambda = invocation.Arguments.ElementAt(2);
if (!MatchSimpleLambda(innerLambda, out ParameterDeclaration element2, out Expression key2))
if (!MatchSimpleLambda(innerLambda, out ParameterDeclaration? element2, out Expression? key2))
return null;
LambdaExpression? lambda = invocation.Arguments.ElementAt(3) as LambdaExpression;
if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression)

8
ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
// Go through the children, and keep visiting a node as long as it changes.
// Because some transforms delete/replace nodes before and after the node being transformed, we rely
// on the transform's return value to know where we need to keep iterating.
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling)
for (AstNode? child = node.FirstChild; child != null; child = child.NextSibling)
{
AstNode oldChild;
do
@ -88,7 +88,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -88,7 +88,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public override AstNode VisitForStatement(ForStatement forStatement)
{
AstNode result = TransformForeachOnArray(forStatement);
AstNode? result = TransformForeachOnArray(forStatement);
if (result != null)
return result;
return base.VisitForStatement(forStatement);
@ -174,7 +174,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -174,7 +174,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
};
public ForStatement TransformFor(ExpressionStatement node)
public ForStatement? TransformFor(ExpressionStatement node)
{
if (!context.Settings.ForStatement)
return null;
@ -339,7 +339,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -339,7 +339,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return false;
}
Statement TransformForeachOnArray(ForStatement forStatement)
Statement? TransformForeachOnArray(ForStatement forStatement)
{
if (!context.Settings.ForEachStatement)
return null;

4
ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs

@ -206,7 +206,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -206,7 +206,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
Match m = fieldInitializerPattern.Match(instanceCtorsNotChainingWithThis[0].Body.FirstOrDefault());
if (!m.Success)
break;
IMember fieldOrPropertyOrEvent = (m.Get<AstNode>("fieldAccess").Single().GetSymbol() as IMember)?.MemberDefinition;
IMember? fieldOrPropertyOrEvent = (m.Get<AstNode>("fieldAccess").Single().GetSymbol() as IMember)?.MemberDefinition;
if (!(fieldOrPropertyOrEvent is IField) && !(fieldOrPropertyOrEvent is IProperty) && !(fieldOrPropertyOrEvent is IEvent))
break;
var fieldOrPropertyOrEventDecl = members.FirstOrDefault(f => f.GetSymbol() == fieldOrPropertyOrEvent) as EntityDeclaration;
@ -346,7 +346,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -346,7 +346,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
AssignmentExpression? assignment = es.Expression as AssignmentExpression;
if (assignment == null || assignment.Operator != AssignmentOperatorType.Assign)
break;
IMember fieldOrProperty = (assignment.Left.GetSymbol() as IMember)?.MemberDefinition;
IMember? fieldOrProperty = (assignment.Left.GetSymbol() as IMember)?.MemberDefinition;
if (!(fieldOrProperty is IField || fieldOrProperty is IProperty) || !fieldOrProperty.IsStatic)
break;
// Only move fields that are constants, if the declaring type is not marked beforefieldinit.

2
ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.CSharp
{
if (descendant == Expression)
return this;
for (AstNode parent = descendant.Parent; parent != null; parent = parent.Parent)
for (AstNode? parent = descendant.Parent; parent != null; parent = parent.Parent)
{
foreach (var inst in parent.Annotations.OfType<ILInstruction>())
descendant.AddAnnotation(inst);

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

@ -70,7 +70,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -70,7 +70,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public INamespace Namespace {
get {
INamespace result = LazyInit.VolatileRead(ref this.@namespace);
INamespace? result = LazyInit.VolatileRead(ref this.@namespace);
if (result != null)
{
return result;

10
ICSharpCode.Decompiler/DecompilerException.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.Decompiler @@ -98,7 +98,7 @@ namespace ICSharpCode.Decompiler
static string GetTypeName(Exception exception)
{
string type = exception.GetType().FullName;
string? type = exception.GetType().FullName;
if (exception is ExternalException || exception is IOException)
return type + " (" + Marshal.GetHRForException(exception).ToString("x8") + ")";
else
@ -114,8 +114,8 @@ namespace ICSharpCode.Decompiler @@ -114,8 +114,8 @@ namespace ICSharpCode.Decompiler
StringBuilder b = new StringBuilder();
for (int i = 0; i < stackTrace.FrameCount; i++)
{
StackFrame frame = stackTrace.GetFrame(i);
MethodBase method = frame.GetMethod();
StackFrame? frame = stackTrace.GetFrame(i);
MethodBase? method = frame.GetMethod();
if (method == null)
continue;
@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler @@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler
b.AppendLine();
b.Append(" at ");
Type declaringType = method.DeclaringType;
Type? declaringType = method.DeclaringType;
if (declaringType != null)
{
b.Append(declaringType.FullName.Replace('+', '.'));
@ -173,7 +173,7 @@ namespace ICSharpCode.Decompiler @@ -173,7 +173,7 @@ namespace ICSharpCode.Decompiler
string? filename = null;
try
{
string fullpath = frame.GetFileName();
string? fullpath = frame.GetFileName();
if (fullpath != null)
filename = Path.GetFileName(fullpath);
}

8
ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -1040,10 +1040,10 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -1040,10 +1040,10 @@ namespace ICSharpCode.Decompiler.Disassembler
output.Write("lpstruct");
break;
case 0x2c: // CustomMarshaler
string guidValue = blob.ReadSerializedString();
string unmanagedType = blob.ReadSerializedString();
string managedType = blob.ReadSerializedString();
string cookie = blob.ReadSerializedString();
string? guidValue = blob.ReadSerializedString();
string? unmanagedType = blob.ReadSerializedString();
string? managedType = blob.ReadSerializedString();
string? cookie = blob.ReadSerializedString();
var guid = !string.IsNullOrEmpty(guidValue) ? new Guid(guidValue) : Guid.Empty;

2
ICSharpCode.Decompiler/Documentation/GetPotentiallyNestedClassTypeReference.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -57,7 +57,7 @@ namespace ICSharpCode.Decompiler.Documentation
{
if (asm == null)
continue;
ITypeDefinition typeDef = asm.GetTypeDefinition(new TopLevelTypeName(ns, name, topLevelTPC));
ITypeDefinition? typeDef = asm.GetTypeDefinition(new TopLevelTypeName(ns, name, topLevelTPC));
for (int j = i + 1; j < parts.Length && typeDef != null; j++)
{
int tpc = (j == parts.Length - 1 ? typeParameterCount : 0);

2
ICSharpCode.Decompiler/Documentation/IdStringProvider.cs

@ -155,7 +155,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -155,7 +155,7 @@ namespace ICSharpCode.Decompiler.Documentation
b.Append('@');
break;
default:
IType declType = type.DeclaringType;
IType? declType = type.DeclaringType;
if (declType != null)
{
AppendTypeName(b, declType, explicitInterfaceImpl);

2
ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.Documentation
throw new ArgumentNullException(nameof(module));
lock (cache)
{
if (!cache.TryGetValue(module, out XmlDocumentationProvider xmlDoc))
if (!cache.TryGetValue(module, out XmlDocumentationProvider? xmlDoc))
{
string xmlDocFile = LookupLocalizedXmlDoc(module.FileName);
if (xmlDocFile == null)

4
ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs

@ -1084,8 +1084,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -1084,8 +1084,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
bool IsBuilderFieldOnThis(ILInstruction inst)
{
IField field;
ILInstruction target;
IField? field;
ILInstruction? target;
if (builderType.IsReferenceType == true)
{
// ldfld(StateMachine::<>t__builder, ldloc(this))

12
ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs

@ -102,7 +102,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -102,7 +102,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
break;
case SwitchSection jumpTableEntry:
Debug.Assert(switchInstructionOpt == null || jumpTableEntry.Parent == switchInstructionOpt);
switchInstructionOpt = (SwitchInstruction)jumpTableEntry.Parent;
switchInstructionOpt = jumpTableEntry.Parent as SwitchInstruction;
break;
}
@ -142,7 +142,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -142,7 +142,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
if (result.NextBlockOrExitContainer is Block nextBlock && nextBlock.IncomingEdgeCount == 0)
{
List<Block> dependentBlocks = new List<Block>();
Block current = nextBlock;
Block? current = nextBlock;
do
{
@ -201,8 +201,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -201,8 +201,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{
ILVariable? v = null;
if (MatchExceptionCaptureBlock(context, block,
ref v, out StLoc typedExceptionVariableStore,
out Block captureBlock, out Block throwBlock))
ref v, out StLoc? typedExceptionVariableStore,
out Block? captureBlock, out Block? throwBlock))
{
context.Step($"ExceptionDispatchInfo.Capture({v.Name}).Throw() => throw;", typedExceptionVariableStore);
block.Instructions.RemoveRange(typedExceptionVariableStore.ChildIndex + 1, 2);
@ -355,7 +355,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -355,7 +355,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
}
bool ParseIfJumpTable(int id, Block jumpTableEntryBlock, ILVariable identifierVariable, out Block? realEntryPoint, out ILInstruction? nextBlockOrExitContainer, out ILInstruction? jumpTableEntry)
bool ParseIfJumpTable(int id, Block jumpTableEntryBlock, ILVariable identifierVariable, [NotNullWhen(true)] out Block? realEntryPoint, out ILInstruction? nextBlockOrExitContainer, [NotNullWhen(true)] out ILInstruction? jumpTableEntry)
{
realEntryPoint = null;
nextBlockOrExitContainer = null;
@ -420,7 +420,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -420,7 +420,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// =>
// throw(ldloc result.Handler.Variable)
internal static bool MatchExceptionCaptureBlock(ILTransformContext context, Block block,
ref ILVariable objectVariable, out StLoc? typedExceptionVariableStore, out Block? captureBlock, out Block? throwBlock)
ref ILVariable? objectVariable, out StLoc? typedExceptionVariableStore, out Block? captureBlock, out Block? throwBlock)
{
bool DerivesFromException(IType t) => t.GetAllBaseTypes().Any(ty => ty.IsKnownType(KnownTypeCode.Exception));

4
ICSharpCode.Decompiler/IL/ControlFlow/AwaitInFinallyTransform.cs

@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// stloc V_6(ldloc V_3) - store exception in 'global' object variable
// br IL_0075 - jump out of catch block to the head of the finallyBlock
var catchBlockEntry = catchBlockContainer.EntryPoint;
ILVariable objectVariable;
ILVariable? objectVariable;
switch (catchBlockEntry.Instructions.Count)
{
case 2:
@ -127,7 +127,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -127,7 +127,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
StateRangeAnalysis sra = new StateRangeAnalysis(StateRangeAnalysisMode.AwaitInFinally, null, stateVariable);
sra.AssignStateRanges(noThrowBlock, Util.LongSet.Universe);
var mapping = sra.GetBlockStateSetMapping((BlockContainer)noThrowBlock.Parent);
var mapping = sra.GetBlockStateSetMapping(noThrowBlock.Parent as BlockContainer);
var mappingForLeave = sra.GetBlockStateSetMappingForLeave();
context.StepStartGroup("Inline finally block with await", tryCatch.Handlers[0]);

8
ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs

@ -45,9 +45,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -45,9 +45,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
Other
}
private BlockTransformContext context;
private ControlFlowNode cfgNode;
private BlockContainer currentContainer;
private BlockTransformContext? context;
private ControlFlowNode? cfgNode;
private BlockContainer? currentContainer;
/// <summary>
/// Builds structured control flow for the block associated with the control flow node.
@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
public void Run(Block block, BlockTransformContext context)
{
this.context = context;
currentContainer = (BlockContainer)block.Parent;
currentContainer = block.Parent as BlockContainer;
// We only embed blocks into this block if they aren't referenced anywhere else,
// so those blocks are dominated by this block.

8
ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs

@ -120,11 +120,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -120,11 +120,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// (where 'v' has no other uses)
// Simplify these to a simple `ret(<inst>)` so that they match the release build version.
//
if (block.Instructions.Count == 2 && block.Instructions[1].MatchReturn(out ILInstruction value))
if (block.Instructions.Count == 2 && block.Instructions[1].MatchReturn(out ILInstruction? value))
{
var ret = (Leave)block.Instructions[1];
if (value.MatchLdLoc(out ILVariable v)
&& v.IsSingleDefinition && v.LoadCount == 1 && block.Instructions[0].MatchStLoc(v, out ILInstruction inst))
if (value.MatchLdLoc(out ILVariable? v)
&& v.IsSingleDefinition && v.LoadCount == 1 && block.Instructions[0].MatchStLoc(v, out ILInstruction? inst))
{
context.Step("Inline variable in return block", block);
inst.AddILRange(ret.Value);
@ -228,7 +228,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -228,7 +228,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
if (!value.MatchLdLoc(out var returnVar))
return false;
var container = branch.TargetContainer;
for (ILInstruction inst = branch; inst != container; inst = inst.Parent)
for (ILInstruction? inst = branch; inst != container; inst = inst.Parent)
{
if (inst.Parent is TryFinally tryFinally && inst.SlotInfo == TryFinally.TryBlockSlot)
{

2
ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs

@ -106,7 +106,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -106,7 +106,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
for (int j = 0; j < block.Instructions.Count - 1; j++)
{
var inst = block.Instructions[j];
if (inst.MatchStLoc(out ILVariable v, out var value) && v.Kind == VariableKind.PinnedLocal)
if (inst.MatchStLoc(out ILVariable? v, out var value) && v.Kind == VariableKind.PinnedLocal)
{
if (block.Instructions[j + 1].OpCode != OpCode.Branch)
{

16
ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs

@ -88,9 +88,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -88,9 +88,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (trueInst == null || trueInst.Instructions.Count != 1 || !inst.FalseInst.MatchNop())
return false;
var storeInst = trueInst.Instructions[0];
if (!inst.Condition.MatchCompEquals(out ILInstruction left, out ILInstruction right) || !left.MatchLdsFld(out IField field) || !right.MatchLdNull())
if (!inst.Condition.MatchCompEquals(out ILInstruction? left, out ILInstruction? right) || !left.MatchLdsFld(out IField? field) || !right.MatchLdNull())
return false;
if (!storeInst.MatchStsFld(out IField field2, out ILInstruction value) || !field.Equals(field2) || !field.IsCompilerGeneratedOrIsInCompilerGeneratedClass())
if (!storeInst.MatchStsFld(out IField? field2, out ILInstruction? value) || !field.Equals(field2) || !field.IsCompilerGeneratedOrIsInCompilerGeneratedClass())
return false;
if (!DelegateConstruction.MatchDelegateConstruction(value.UnwrapConv(ConversionKind.Invalid) as NewObj, out _, out _, out _, true))
return false;
@ -117,10 +117,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -117,10 +117,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? trueInst = inst.TrueInst as Block;
if (trueInst == null || (trueInst.Instructions.Count != 1) || !inst.FalseInst.MatchNop())
return false;
if (!inst.Condition.MatchCompEquals(out ILInstruction left, out ILInstruction right) || !left.MatchLdLoc(out ILVariable v) || !right.MatchLdNull())
if (!inst.Condition.MatchCompEquals(out ILInstruction? left, out ILInstruction? right) || !left.MatchLdLoc(out ILVariable? v) || !right.MatchLdNull())
return false;
var storeInst = trueInst.Instructions.Last();
if (!storeInst.MatchStLoc(v, out ILInstruction value))
if (!storeInst.MatchStLoc(v, out ILInstruction? value))
return false;
if (!DelegateConstruction.MatchDelegateConstruction(value as NewObj, out _, out _, out _, true))
return false;
@ -157,7 +157,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -157,7 +157,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? trueInst = inst.TrueInst as Block;
if (trueInst == null || (trueInst.Instructions.Count != 1) || !inst.FalseInst.MatchNop())
return false;
if (!inst.Condition.MatchCompEquals(out ILInstruction left, out ILInstruction right) || !left.MatchLdLoc(out ILVariable s) || !right.MatchLdNull())
if (!inst.Condition.MatchCompEquals(out ILInstruction? left, out ILInstruction? right) || !left.MatchLdLoc(out ILVariable? s) || !right.MatchLdNull())
return false;
var storeInst = trueInst.Instructions.Last() as StLoc;
var storeBeforeIf = inst.Parent.Children.ElementAtOrDefault(inst.ChildIndex - 1) as StLoc;
@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? trueInst = inst.TrueInst as Block;
if (trueInst == null || (trueInst.Instructions.Count != 1) || !inst.FalseInst.MatchNop())
return false;
if (!inst.Condition.MatchCompEquals(out ILInstruction left, out ILInstruction right) || !left.MatchLdLoc(out ILVariable s) || !right.MatchLdNull())
if (!inst.Condition.MatchCompEquals(out ILInstruction? left, out ILInstruction? right) || !left.MatchLdLoc(out ILVariable? s) || !right.MatchLdNull())
return false;
var storeInst = trueInst.Instructions.Last() as StLoc;
var storeBeforeIf = inst.Parent.Children.ElementAtOrDefault(inst.ChildIndex - 1) as StLoc;
@ -240,7 +240,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -240,7 +240,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
return false;
}
if (!inst.Condition.MatchCompEquals(out ILInstruction left, out ILInstruction right) || !right.MatchLdNull())
if (!inst.Condition.MatchCompEquals(out ILInstruction? left, out ILInstruction? right) || !right.MatchLdNull())
return false;
if (!ldobj.Match(left).Success)
return false;
@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
return false;
}
if (!inst.Condition.MatchCompNotEqualsNull(out ILInstruction left))
if (!inst.Condition.MatchCompNotEqualsNull(out ILInstruction? left))
return false;
if (!ldobj.Match(left).Success)
return false;

2
ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -65,7 +65,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
for (int i = 0; i < block.Instructions.Count; i++)
{
if (block.Instructions[i].MatchStLoc(out ILVariable v, out ILInstruction copiedExpr))
if (block.Instructions[i].MatchStLoc(out ILVariable? v, out ILInstruction? copiedExpr))
{
if (v.IsSingleDefinition && v.LoadCount == 0 && v.Kind == VariableKind.StackSlot)
{

3
ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs

@ -104,7 +104,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -104,7 +104,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// This transform is required because ILInlining only works with stloc/ldloc
internal static bool StObjToStLoc(StObj inst, ILTransformContext context)
{
if (inst.Target.MatchLdLoca(out ILVariable v)
if (inst.Target.MatchLdLoca(out ILVariable? v)
&& TypeUtils.IsCompatibleTypeForMemoryAccess(v.Type, inst.Type)
&& inst.UnalignedPrefix == 0
&& !inst.IsVolatile)
@ -222,6 +222,5 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -222,6 +222,5 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
return false;
}
}
}

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

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
if (!context.Settings.Ranges)
return false;
if (!ldelema.Array.MatchLdLoc(out ILVariable array))
if (!ldelema.Array.MatchLdLoc(out ILVariable? array))
return false;
if (ldelema.Indices.Count != 1)
return false; // the index/range feature doesn't support multi-dimensional arrays
@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
// stloc startOffsetVar(call GetOffset(startIndexLoad, ldloc length))
if (!(block.Instructions[pos].MatchStLoc(out ILVariable startOffsetVar, out ILInstruction startOffsetVarInit)
if (!(block.Instructions[pos].MatchStLoc(out ILVariable? startOffsetVar, out ILInstruction? startOffsetVarInit)
&& startOffsetVar.IsSingleDefinition && startOffsetVar.StackType == StackType.I4))
{
// Not our primary indexing/slicing pattern.

67
ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs

@ -106,9 +106,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -106,9 +106,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
context.Step("Remove hashtable initializer", actual);
if (jumpToNext != null)
{
actual.Instructions.SecondToLastOrDefault().ReplaceWith(jumpToNext);
actual.Instructions.SecondToLastOrDefault()?.ReplaceWith(jumpToNext);
}
actual.Instructions.LastOrDefault().ReplaceWith(new Branch(next));
actual.Instructions.LastOrDefault()?.ReplaceWith(new Branch(next));
omittedBlocks.Add(containingBlock, previous);
changedContainers.Add(body);
}
@ -196,7 +196,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -196,7 +196,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ExtensionMethods.Swap(ref firstBlockOrDefaultJump, ref nextCaseJump);
}
// match call to operator ==(string, string)
if (!MatchStringEqualityComparison(condition, out var switchValueVar, out string firstBlockValue, out bool isVBCompareString))
if (!MatchStringEqualityComparison(condition, out var switchValueVar, out string? firstBlockValue, out bool isVBCompareString))
return false;
if (isVBCompareString)
{
@ -217,13 +217,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -217,13 +217,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
}
var values = new List<(string, ILInstruction)>();
var uniqueValues = new HashSet<string>();
var values = new List<(string?, ILInstruction)>();
var uniqueValues = new HashSet<string?>();
int numberOfUniqueMatchesWithCurrentVariable = 0;
HashSet<Block> caseBlocks = new HashSet<Block>();
caseBlocks.Add((Block)instructions[i].Parent);
bool AddSwitchSection(string value, ILInstruction inst)
bool AddSwitchSection(string? value, ILInstruction inst)
{
if (!uniqueValues.Add(value))
return false;
@ -306,14 +306,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -306,14 +306,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
// if instruction must be followed by a branch to the next case
if (!nextCaseJump.MatchBranch(out Block currentCaseBlock))
if (!nextCaseJump.MatchBranch(out Block? currentCaseBlock))
return false;
// extract all cases and add them to the values list.
ILInstruction nextCaseBlock;
do
{
nextCaseBlock = MatchCaseBlock(currentCaseBlock, switchValueVar, out string value, out bool emptyStringEqualsNull, out ILInstruction block);
if (nextCaseBlock == null)
(nextCaseBlock, var block) = MatchCaseBlock(currentCaseBlock, switchValueVar, out string? value, out bool emptyStringEqualsNull);
if (nextCaseBlock == null || block == null)
break;
if (emptyStringEqualsNull && string.IsNullOrEmpty(value))
{
@ -474,7 +474,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -474,7 +474,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true;
}
bool IsIsInternedCall(Call call, [NotNullWhen(true)] out ILInstruction? argument)
bool IsIsInternedCall(Call? call, [NotNullWhen(true)] out ILInstruction? argument)
{
if (call != null
&& call.Method.DeclaringType.IsKnownType(KnownTypeCode.String)
@ -504,19 +504,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -504,19 +504,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// The <paramref name="switchVariable"/> is updated if the value gets copied to a different variable.
/// See comments below for more info.
/// </summary>
ILInstruction? MatchCaseBlock(Block currentBlock, ILVariable switchVariable, out string? value, out bool emptyStringEqualsNull, out ILInstruction? caseBlockOrLeave)
(ILInstruction? NextBlock, ILInstruction? CaseBlockOrLeave) MatchCaseBlock(Block currentBlock, ILVariable switchVariable, out string? value, out bool emptyStringEqualsNull)
{
value = null;
caseBlockOrLeave = null;
ILInstruction? caseBlockOrLeave = null;
emptyStringEqualsNull = false;
if (currentBlock.IncomingEdgeCount != 1 || currentBlock.Instructions.Count != 2)
return null;
return (null, null);
if (!currentBlock.MatchIfAtEndOfBlock(out var condition, out var caseBlockBranch, out var nextBlockBranch))
return null;
return (null, null);
if (!MatchStringEqualityComparison(condition, switchVariable, out value, out bool isVBCompareString))
{
return null;
return (null, null);
}
if (isVBCompareString)
{
@ -533,21 +534,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -533,21 +534,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
else
{
return null;
return (null, null);
}
if (nextBlockBranch.MatchBranch(out Block? nextBlock))
{
// success
return nextBlock;
return (nextBlock, caseBlockOrLeave);
}
else if (nextBlockBranch.MatchLeave(out BlockContainer? blockContainer))
{
// success
return blockContainer;
return (blockContainer, caseBlockOrLeave);
}
else
{
return null;
return (null, caseBlockOrLeave);
}
}
@ -1030,20 +1031,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1030,20 +1031,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
}
var stringValues = new List<(string Value, ILInstruction TargetBlockOrLeave)>();
var stringValues = new List<(string? Value, ILInstruction TargetBlockOrLeave)>();
SwitchSection defaultSection = switchInst.GetDefaultSection();
if (!(defaultSection.Body.MatchBranch(out Block exitOrDefaultBlock) || defaultSection.Body.MatchLeave(out _)))
if (!(defaultSection.Body.MatchBranch(out Block? exitOrDefaultBlock) || defaultSection.Body.MatchLeave(out _)))
return false;
foreach (var section in switchInst.Sections)
{
if (section == defaultSection)
continue;
// extract target block
if (!section.Body.MatchBranch(out Block target))
if (!section.Body.MatchBranch(out Block? target))
return false;
string stringValue;
string? stringValue;
bool emptyStringEqualsNull;
if (MatchRoslynEmptyStringCaseBlockHead(target, switchValueLoad.Variable, out ILInstruction targetOrLeave, out Block currentExitBlock))
if (MatchRoslynEmptyStringCaseBlockHead(target, switchValueLoad.Variable, out ILInstruction? targetOrLeave, out Block? currentExitBlock))
{
stringValue = "";
emptyStringEqualsNull = false;
@ -1168,7 +1169,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1168,7 +1169,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// implements https://github.com/dotnet/roslyn/pull/66081
// if (comp(ldloc switchValueVar == ldnull)) br nullCase
// br nextBlock
Block switchOnLengthBlock;
Block? switchOnLengthBlock;
int switchOnLengthBlockStartOffset;
Block? nullCase = null;
if (instructions[i].MatchIfInstruction(out var condition, out var exitBlockJump)
@ -1206,7 +1207,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1206,7 +1207,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? defaultCase = null;
if (!MatchSwitchOnLengthBlock(ref switchValueVar, switchOnLengthBlock, switchOnLengthBlockStartOffset, out var blocksByLength))
return false;
List<(string, ILInstruction)> stringValues = new();
List<(string?, ILInstruction)> stringValues = new();
foreach (var b in blocksByLength)
{
if (b.Length.Count() != 1)
@ -1231,7 +1232,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1231,7 +1232,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
}
else if (MatchRoslynCaseBlockHead(b.TargetBlock, switchValueVar, out var bodyOrLeave, out var exit, out string stringValue, out _))
else if (MatchRoslynCaseBlockHead(b.TargetBlock, switchValueVar, out var bodyOrLeave, out var exit, out string? stringValue, out _))
{
if (exit != defaultCase)
return false;
@ -1269,7 +1270,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1269,7 +1270,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
context.Step(nameof(MatchRoslynSwitchOnStringUsingLengthAndChar), instructions[i]);
var defaultLabel = new LongSet(new LongInterval(0, stringValues.Count)).Invert();
var values = new string[stringValues.Count];
var values = new string?[stringValues.Count];
var sections = new SwitchSection[stringValues.Count];
foreach (var (idx, (value, bodyInstruction)) in stringValues.WithIndex())
{
@ -1400,7 +1401,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1400,7 +1401,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return results?.Count > 0;
}
bool MatchSwitchOnLengthBlock(ref ILVariable switchValueVar, Block switchOnLengthBlock, int startOffset, [NotNullWhen(true)] out List<(LongSet Length, Block TargetBlock)>? blocks)
bool MatchSwitchOnLengthBlock(ref ILVariable? switchValueVar, Block switchOnLengthBlock, int startOffset, out List<(LongSet Length, Block TargetBlock)>? blocks)
{
blocks = null;
SwitchInstruction? @switch;
@ -1476,6 +1477,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1476,6 +1477,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
default:
return false;
}
if (@switch == null)
return true;
blocks = new(@switch.Sections.Count);
@ -1507,7 +1509,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1507,7 +1509,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// br newDefaultBlock
/// }
/// </summary>
private bool IsNullCheckInDefaultBlock(ref Block exitOrDefaultBlock, ILVariable switchVar, [NotNullWhen(true)] out Block? nullValueCaseBlock)
private bool IsNullCheckInDefaultBlock(ref Block? exitOrDefaultBlock, ILVariable switchVar, [NotNullWhen(true)] out Block? nullValueCaseBlock)
{
nullValueCaseBlock = null;
if (exitOrDefaultBlock == null)
@ -1533,7 +1535,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1533,7 +1535,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// if (call op_Equality(ldloc switchValueVar, stringValue)) br body
/// br exit
/// </summary>
bool MatchRoslynCaseBlockHead(Block target, ILVariable switchValueVar, [NotNullWhen(true)] out ILInstruction? bodyOrLeave, [NotNullWhen(true)] out Block? defaultOrExitBlock, [NotNullWhen(true)] out string? stringValue, out bool emptyStringEqualsNull)
bool MatchRoslynCaseBlockHead(Block target, ILVariable switchValueVar, [NotNullWhen(true)] out ILInstruction? bodyOrLeave, out Block? defaultOrExitBlock, out string? stringValue, out bool emptyStringEqualsNull)
{
bodyOrLeave = null;
defaultOrExitBlock = null;
@ -1593,7 +1595,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1593,7 +1595,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// br exit
/// }
/// </summary>
bool MatchRoslynEmptyStringCaseBlockHead(Block target, ILVariable switchValueVar, [NotNullWhen(true)] out ILInstruction? bodyOrLeave, [NotNullWhen(true)] out Block? defaultOrExitBlock)
bool MatchRoslynEmptyStringCaseBlockHead(Block target, ILVariable switchValueVar, [NotNullWhen(true)] out ILInstruction? bodyOrLeave, out Block? defaultOrExitBlock)
{
bodyOrLeave = null;
defaultOrExitBlock = null;
@ -1628,6 +1630,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1628,6 +1630,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (bodyBranch.MatchLeave(out _))
{
bodyOrLeave = bodyBranch;
return true;
}

6
ICSharpCode.Decompiler/Semantics/ConstantResolveResult.cs

@ -32,9 +32,9 @@ namespace ICSharpCode.Decompiler.Semantics @@ -32,9 +32,9 @@ namespace ICSharpCode.Decompiler.Semantics
/// </summary>
public class ConstantResolveResult : ResolveResult
{
object constantValue;
object? constantValue;
public ConstantResolveResult(IType type, object constantValue) : base(type)
public ConstantResolveResult(IType type, object? constantValue) : base(type)
{
this.constantValue = constantValue;
}
@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.Semantics @@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.Semantics
get { return true; }
}
public override object ConstantValue {
public override object? ConstantValue {
get { return constantValue; }
}

2
ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs

@ -227,7 +227,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -227,7 +227,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary>
/// Gets the type code for the specified type, or TypeCode.Empty if none of the other type codes match.
/// </summary>
public static TypeCode GetTypeCode(this IType type)
public static TypeCode GetTypeCode(this IType? type)
{
ITypeDefinition? def = type as ITypeDefinition;
if (def != null)

4
ICSharpCode.Decompiler/TypeSystem/TaskType.cs

@ -74,8 +74,8 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -74,8 +74,8 @@ namespace ICSharpCode.Decompiler.TypeSystem
var arg = attribute.FixedArguments[0];
if (!arg.Type.IsKnownType(KnownTypeCode.Type))
return false;
builderType = (IType)arg.Value;
return true;
builderType = arg.Value as IType;
return builderType != null;
}
return false;
}

2
ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs

@ -35,7 +35,7 @@ namespace ILSpy.BamlDecompiler @@ -35,7 +35,7 @@ namespace ILSpy.BamlDecompiler
[PartCreationPolicy(CreationPolicy.Shared)]
public sealed class BamlResourceNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".baml", StringComparison.OrdinalIgnoreCase))
return new BamlResourceEntryNode(resource.Name, resource.TryOpenStream);

4
ILSpy/Languages/ILAstLanguage.cs

@ -39,9 +39,9 @@ namespace ICSharpCode.ILSpy @@ -39,9 +39,9 @@ namespace ICSharpCode.ILSpy
/// </summary>
abstract class ILAstLanguage : Language
{
public event EventHandler StepperUpdated;
public event EventHandler? StepperUpdated;
protected virtual void OnStepperUpdated(EventArgs e = null)
protected virtual void OnStepperUpdated(EventArgs? e = null)
{
StepperUpdated?.Invoke(this, e ?? new EventArgs());
}

14
ILSpy/MainWindow.xaml.cs

@ -44,6 +44,7 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -44,6 +44,7 @@ using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy.AppEnv;
using ICSharpCode.ILSpy.Commands;
using ICSharpCode.ILSpy.Controls.TreeView;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Search;
@ -51,16 +52,15 @@ using ICSharpCode.ILSpy.TextView; @@ -51,16 +52,15 @@ using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.Themes;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.Updates;
using ICSharpCode.ILSpy.Util;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX;
using ICSharpCode.ILSpyX.Extensions;
using ICSharpCode.ILSpyX.FileLoaders;
using ICSharpCode.ILSpyX.Settings;
using ICSharpCode.ILSpy.Controls.TreeView;
using ICSharpCode.ILSpy.Util;
using ICSharpCode.ILSpyX.Extensions;
using ICSharpCode.ILSpyX.TreeView;
using Microsoft.Win32;
using ICSharpCode.ILSpyX.TreeView;
using TomsToolbox.Composition;
@ -749,10 +749,10 @@ namespace ICSharpCode.ILSpy @@ -749,10 +749,10 @@ namespace ICSharpCode.ILSpy
}
}
internal static IEntity FindEntityInRelevantAssemblies(string navigateTo, IEnumerable<LoadedAssembly> relevantAssemblies)
internal static IEntity? FindEntityInRelevantAssemblies(string navigateTo, IEnumerable<LoadedAssembly> relevantAssemblies)
{
ITypeReference typeRef = null;
IMemberReference memberRef = null;
ITypeReference? typeRef = null;
IMemberReference? memberRef = null;
if (navigateTo.StartsWith("T:", StringComparison.Ordinal))
{
typeRef = IdStringProvider.ParseTypeName(navigateTo);

2
ILSpy/TextView/DocumentationUIBuilder.cs

@ -128,7 +128,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -128,7 +128,7 @@ namespace ICSharpCode.ILSpy.TextView
AddBlock(block);
}
public void AddXmlDocumentation(string xmlDocumentation, IEntity declaringEntity, Func<string, IEntity> resolver)
public void AddXmlDocumentation(string xmlDocumentation, IEntity declaringEntity, Func<string, IEntity?> resolver)
{
if (xmlDocumentation == null)
return;

4
ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
static readonly string[] imageFileExtensions = { ".cur" };
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in imageFileExtensions)
@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
return false;
//HACK: windows imaging does not understand that .cur files have the same layout as .ico
// so load to data, and modify the ResourceType in the header to make look like an icon...
MemoryStream s = data as MemoryStream;
MemoryStream? s = data as MemoryStream;
if (s == null)
{
// data was stored in another stream type (e.g. PinnedBufferedMemoryStream)

2
ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs

@ -26,6 +26,6 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -26,6 +26,6 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
public interface IResourceNodeFactory
{
ITreeNode CreateNode(Resource resource);
ITreeNode? CreateNode(Resource resource);
}
}

4
ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class IconResourceNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".ico", StringComparison.OrdinalIgnoreCase))
{
@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
sealed class IconResourceEntryNode : ResourceEntryNode
{
public IconResourceEntryNode(string key, Func<Stream> data)
public IconResourceEntryNode(string key, Func<Stream?> data)
: base(key, data)
{
}

4
ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs

@ -31,12 +31,12 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -31,12 +31,12 @@ namespace ICSharpCode.ILSpy.TreeNodes
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class ImageListResourceEntryNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
return null;
}
public ILSpyTreeNode CreateNode(string key, object data)
public ILSpyTreeNode? CreateNode(string key, object data)
{
if (data is ImageListStreamer)
return new ImageListResourceEntryNode(key, (ImageListStreamer)data);

4
ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
static readonly string[] imageFileExtensions = { ".png", ".gif", ".bmp", ".jpg" };
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in imageFileExtensions)
@ -50,7 +50,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -50,7 +50,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
sealed class ImageResourceEntryNode : ResourceEntryNode
{
public ImageResourceEntryNode(string key, Func<Stream> openStream)
public ImageResourceEntryNode(string key, Func<Stream?> openStream)
: base(key, openStream)
{
}

11
ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs

@ -34,18 +34,18 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -34,18 +34,18 @@ namespace ICSharpCode.ILSpy.TreeNodes
public class ResourceEntryNode : ILSpyTreeNode
{
private readonly string key;
private readonly Func<Stream> openStream;
private readonly Func<Stream?> openStream;
public override object Text => Language.EscapeName(key);
public override object Icon => Images.Resource;
protected Stream OpenStream()
protected Stream? OpenStream()
{
return openStream();
}
public ResourceEntryNode(string key, Func<Stream> openStream)
public ResourceEntryNode(string key, Func<Stream?> openStream)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
@ -57,7 +57,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -57,7 +57,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public static ILSpyTreeNode Create(Resource resource)
{
ILSpyTreeNode result = null;
ILSpyTreeNode? result = null;
foreach (var factory in App.ExportProvider.GetExportedValues<IResourceNodeFactory>())
{
result = factory.CreateNode(resource) as ILSpyTreeNode;
@ -78,13 +78,14 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -78,13 +78,14 @@ namespace ICSharpCode.ILSpy.TreeNodes
language.WriteCommentLine(output, string.Format("{0} = {1}", key, data));
}
public override bool Save(ViewModels.TabPageModel tabPage)
public override bool Save(ViewModels.TabPageModel? tabPage)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = Path.GetFileName(WholeProjectDecompiler.SanitizeFileName(key));
if (dlg.ShowDialog() == true)
{
using var data = OpenStream();
using var fs = dlg.OpenFile();
data.CopyTo(fs);
}

4
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class ResourcesFileTreeNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
{
@ -50,7 +50,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -50,7 +50,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
return null;
}
public ILSpyTreeNode CreateNode(string key, object data)
public ILSpyTreeNode? CreateNode(string key, object data)
{
return null;
}

6
ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Xaml @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Xaml
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class XamlResourceNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
return new XamlResourceEntryNode(resource.Name, resource.TryOpenStream);
@ -45,9 +45,9 @@ namespace ICSharpCode.ILSpy.Xaml @@ -45,9 +45,9 @@ namespace ICSharpCode.ILSpy.Xaml
sealed class XamlResourceEntryNode : ResourceEntryNode
{
string xaml;
string? xaml;
public XamlResourceEntryNode(string key, Func<Stream> openStream) : base(key, openStream)
public XamlResourceEntryNode(string key, Func<Stream?> openStream) : base(key, openStream)
{
}

8
ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Xaml @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Xaml
{
private readonly static string[] xmlFileExtensions = { ".xml", ".xsd", ".xslt" };
public ITreeNode CreateNode(Resource resource)
public ITreeNode? CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in xmlFileExtensions)
@ -50,9 +50,9 @@ namespace ICSharpCode.ILSpy.Xaml @@ -50,9 +50,9 @@ namespace ICSharpCode.ILSpy.Xaml
sealed class XmlResourceEntryNode : ResourceEntryNode
{
string xml;
string? xml;
public XmlResourceEntryNode(string key, Func<Stream> data)
public XmlResourceEntryNode(string key, Func<Stream?> data)
: base(key, data)
{
}
@ -74,7 +74,7 @@ namespace ICSharpCode.ILSpy.Xaml @@ -74,7 +74,7 @@ namespace ICSharpCode.ILSpy.Xaml
public override bool View(TabPageModel tabPage)
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
IHighlightingDefinition highlighting = null;
IHighlightingDefinition? highlighting = null;
tabPage.ShowTextView(textView => textView.RunWithCancellation(
token => Task.Factory.StartNew(

4
ILSpy/Views/DebugSteps.xaml.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.ILSpy @@ -48,7 +48,7 @@ namespace ICSharpCode.ILSpy
#endif
}
private void WritingOptions_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
private void WritingOptions_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
DecompileAsync(lastSelectedStep);
}
@ -80,7 +80,7 @@ namespace ICSharpCode.ILSpy @@ -80,7 +80,7 @@ namespace ICSharpCode.ILSpy
#endif
}
private void ILAstStepperUpdated(object sender, EventArgs e)
private void ILAstStepperUpdated(object? sender, EventArgs? e)
{
#if DEBUG
if (language == null)

Loading…
Cancel
Save