Browse Source

#nullable enable for typesystem and ILInstruction base class

pull/2308/head
Daniel Grunwald 5 years ago
parent
commit
f726a0b73e
  1. 54
      ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs
  2. 19
      ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs
  3. 20
      ICSharpCode.Decompiler/IL/Transforms/Stepper.cs
  4. 8
      ICSharpCode.Decompiler/TypeSystem/IAssembly.cs
  5. 7
      ICSharpCode.Decompiler/TypeSystem/IAttribute.cs
  6. 3
      ICSharpCode.Decompiler/TypeSystem/ICodeContext.cs
  7. 4
      ICSharpCode.Decompiler/TypeSystem/ICompilation.cs
  8. 5
      ICSharpCode.Decompiler/TypeSystem/IDecompilerTypeSystem.cs
  9. 7
      ICSharpCode.Decompiler/TypeSystem/IEntity.cs
  10. 8
      ICSharpCode.Decompiler/TypeSystem/IEvent.cs
  11. 2
      ICSharpCode.Decompiler/TypeSystem/IField.cs
  12. 2
      ICSharpCode.Decompiler/TypeSystem/IFreezable.cs
  13. 30
      ICSharpCode.Decompiler/TypeSystem/IInterningProvider.cs
  14. 7
      ICSharpCode.Decompiler/TypeSystem/IMember.cs
  15. 7
      ICSharpCode.Decompiler/TypeSystem/IMethod.cs
  16. 8
      ICSharpCode.Decompiler/TypeSystem/INamespace.cs
  17. 4
      ICSharpCode.Decompiler/TypeSystem/IParameter.cs
  18. 1
      ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs
  19. 6
      ICSharpCode.Decompiler/TypeSystem/IProperty.cs
  20. 2
      ICSharpCode.Decompiler/TypeSystem/ISupportsInterning.cs
  21. 2
      ICSharpCode.Decompiler/TypeSystem/ISymbol.cs
  22. 26
      ICSharpCode.Decompiler/TypeSystem/IType.cs
  23. 4
      ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs
  24. 6
      ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs
  25. 14
      ICSharpCode.Decompiler/TypeSystem/ITypeReference.cs
  26. 3
      ICSharpCode.Decompiler/TypeSystem/IVariable.cs
  27. 7
      ICSharpCode.Decompiler/TypeSystem/KnownTypeReference.cs

54
ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -94,7 +96,7 @@ namespace ICSharpCode.Decompiler.IL
/// </remarks> /// </remarks>
public bool IsDescendantOf(ILInstruction possibleAncestor) public bool IsDescendantOf(ILInstruction possibleAncestor)
{ {
for (ILInstruction ancestor = this; ancestor != null; ancestor = ancestor.Parent) for (ILInstruction? ancestor = this; ancestor != null; ancestor = ancestor.Parent)
{ {
if (ancestor == possibleAncestor) if (ancestor == possibleAncestor)
return true; return true;
@ -102,33 +104,33 @@ namespace ICSharpCode.Decompiler.IL
return false; return false;
} }
public ILInstruction GetCommonParent(ILInstruction other) public ILInstruction? GetCommonParent(ILInstruction other)
{ {
if (other == null) if (other == null)
throw new ArgumentNullException(nameof(other)); throw new ArgumentNullException(nameof(other));
ILInstruction a = this; ILInstruction? a = this;
ILInstruction b = other; ILInstruction? b = other;
int levelA = a.CountAncestors(); int levelA = a.CountAncestors();
int levelB = b.CountAncestors(); int levelB = b.CountAncestors();
while (levelA > levelB) while (levelA > levelB)
{ {
a = a.Parent; a = a!.Parent;
levelA--; levelA--;
} }
while (levelB > levelA) while (levelB > levelA)
{ {
b = b.Parent; b = b!.Parent;
levelB--; levelB--;
} }
while (a != b) while (a != b)
{ {
a = a.Parent; a = a!.Parent;
b = b.Parent; b = b!.Parent;
} }
return a; return a;
@ -153,13 +155,13 @@ namespace ICSharpCode.Decompiler.IL
while (levelA > levelB) while (levelA > levelB)
{ {
a = a.Parent; a = a.Parent!;
levelA--; levelA--;
} }
while (levelB > levelA) while (levelB > levelA)
{ {
b = b.Parent; b = b.Parent!;
levelB--; levelB--;
} }
@ -172,8 +174,8 @@ namespace ICSharpCode.Decompiler.IL
while (a.Parent != b.Parent) while (a.Parent != b.Parent)
{ {
a = a.Parent; a = a.Parent!;
b = b.Parent; b = b.Parent!;
} }
// now a and b have the same parent or are both root nodes // now a and b have the same parent or are both root nodes
@ -183,7 +185,7 @@ namespace ICSharpCode.Decompiler.IL
private int CountAncestors() private int CountAncestors()
{ {
int level = 0; int level = 0;
for (ILInstruction ancestor = this; ancestor != null; ancestor = ancestor.Parent) for (ILInstruction? ancestor = this; ancestor != null; ancestor = ancestor.Parent)
{ {
level++; level++;
} }
@ -240,7 +242,7 @@ namespace ICSharpCode.Decompiler.IL
protected private void MakeDirty() protected private void MakeDirty()
{ {
#if DEBUG #if DEBUG
for (ILInstruction inst = this; inst != null && !inst.IsDirty; inst = inst.parent) for (ILInstruction? inst = this; inst != null && !inst.IsDirty; inst = inst.parent)
{ {
inst.IsDirty = true; inst.IsDirty = true;
} }
@ -289,7 +291,7 @@ namespace ICSharpCode.Decompiler.IL
protected void InvalidateFlags() protected void InvalidateFlags()
{ {
for (ILInstruction inst = this; inst != null && inst.flags != invalidFlags; inst = inst.parent) for (ILInstruction? inst = this; inst != null && inst.flags != invalidFlags; inst = inst.parent)
inst.flags = invalidFlags; inst.flags = invalidFlags;
} }
@ -425,7 +427,7 @@ namespace ICSharpCode.Decompiler.IL
internal ChildrenCollection(ILInstruction inst) internal ChildrenCollection(ILInstruction inst)
{ {
Debug.Assert(inst != null); Debug.Assert(inst != null);
this.inst = inst; this.inst = inst!;
} }
public int Count { public int Count {
@ -485,7 +487,7 @@ namespace ICSharpCode.Decompiler.IL
/// </summary> /// </summary>
public struct ChildrenEnumerator : IEnumerator<ILInstruction> public struct ChildrenEnumerator : IEnumerator<ILInstruction>
{ {
ILInstruction inst; ILInstruction? inst;
readonly int end; readonly int end;
int pos; int pos;
@ -494,7 +496,7 @@ namespace ICSharpCode.Decompiler.IL
Debug.Assert(inst != null); Debug.Assert(inst != null);
this.inst = inst; this.inst = inst;
this.pos = -1; this.pos = -1;
this.end = inst.GetChildCount(); this.end = inst!.GetChildCount();
#if DEBUG #if DEBUG
inst.StartEnumerator(); inst.StartEnumerator();
#endif #endif
@ -502,7 +504,7 @@ namespace ICSharpCode.Decompiler.IL
public ILInstruction Current { public ILInstruction Current {
get { get {
return inst.GetChild(pos); return inst!.GetChild(pos);
} }
} }
@ -556,7 +558,7 @@ namespace ICSharpCode.Decompiler.IL
/// </remarks> /// </remarks>
public void ReplaceWith(ILInstruction replacement) public void ReplaceWith(ILInstruction replacement)
{ {
Debug.Assert(parent.GetChild(ChildIndex) == this); Debug.Assert(parent!.GetChild(ChildIndex) == this);
if (replacement == this) if (replacement == this)
return; return;
parent.SetChild(ChildIndex, replacement); parent.SetChild(ChildIndex, replacement);
@ -621,7 +623,7 @@ namespace ICSharpCode.Decompiler.IL
/// </summary> /// </summary>
public IEnumerable<ILInstruction> Ancestors { public IEnumerable<ILInstruction> Ancestors {
get { get {
for (ILInstruction node = this; node != null; node = node.Parent) for (ILInstruction? node = this; node != null; node = node.Parent)
{ {
yield return node; yield return node;
} }
@ -683,7 +685,7 @@ namespace ICSharpCode.Decompiler.IL
child.ReleaseRef(); child.ReleaseRef();
} }
ILInstruction parent; ILInstruction? parent;
/// <summary> /// <summary>
/// Gets the parent of this ILInstruction. /// Gets the parent of this ILInstruction.
@ -709,7 +711,7 @@ namespace ICSharpCode.Decompiler.IL
/// ///
/// Note that is it is possible (though unusual) for a stale position to reference an orphaned node. /// Note that is it is possible (though unusual) for a stale position to reference an orphaned node.
/// </remarks> /// </remarks>
public ILInstruction Parent { public ILInstruction? Parent {
get { return parent; } get { return parent; }
} }
@ -732,7 +734,7 @@ namespace ICSharpCode.Decompiler.IL
/// ///
/// Precondition: this node must not be orphaned. /// Precondition: this node must not be orphaned.
/// </remarks> /// </remarks>
public SlotInfo SlotInfo { public SlotInfo? SlotInfo {
get { get {
if (parent == null) if (parent == null)
return null; return null;
@ -748,7 +750,7 @@ namespace ICSharpCode.Decompiler.IL
/// <param name="newValue">New child</param> /// <param name="newValue">New child</param>
/// <param name="index">Index of the field in the Children collection</param> /// <param name="index">Index of the field in the Children collection</param>
protected internal void SetChildInstruction<T>(ref T childPointer, T newValue, int index) protected internal void SetChildInstruction<T>(ref T childPointer, T newValue, int index)
where T : ILInstruction where T : ILInstruction?
{ {
T oldValue = childPointer; T oldValue = childPointer;
Debug.Assert(oldValue == GetChild(index)); Debug.Assert(oldValue == GetChild(index));
@ -861,7 +863,7 @@ namespace ICSharpCode.Decompiler.IL
/// If the method returns true, it adds the capture groups (if any) to the match. /// If the method returns true, it adds the capture groups (if any) to the match.
/// If the method returns false, the match object may remain in a partially-updated state and /// If the method returns false, the match object may remain in a partially-updated state and
/// needs to be restored before it can be reused.</returns> /// needs to be restored before it can be reused.</returns>
protected internal abstract bool PerformMatch(ILInstruction other, ref Match match); protected internal abstract bool PerformMatch(ILInstruction? other, ref Match match);
/// <summary> /// <summary>
/// Attempts matching this instruction against a list of other instructions (or a part of said list). /// Attempts matching this instruction against a list of other instructions (or a part of said list).

19
ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs

@ -16,16 +16,15 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.CSharp.TypeSystem;
using ICSharpCode.Decompiler.DebugInfo; using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.IL.Transforms namespace ICSharpCode.Decompiler.IL.Transforms
{ {
@ -44,16 +43,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
public ILFunction Function { get; } public ILFunction Function { get; }
public IDecompilerTypeSystem TypeSystem { get; } public IDecompilerTypeSystem TypeSystem { get; }
public IDebugInfoProvider DebugInfo { get; } public IDebugInfoProvider? DebugInfo { get; }
public DecompilerSettings Settings { get; } public DecompilerSettings Settings { get; }
public CancellationToken CancellationToken { get; set; } public CancellationToken CancellationToken { get; set; }
public Stepper Stepper { get; set; } public Stepper Stepper { get; set; }
public Metadata.PEFile PEFile => TypeSystem.MainModule.PEFile; public Metadata.PEFile PEFile => TypeSystem.MainModule.PEFile;
internal DecompileRun DecompileRun { get; set; } internal DecompileRun? DecompileRun { get; set; }
internal ResolvedUsingScope UsingScope => DecompileRun?.UsingScope.Resolve(TypeSystem); internal ResolvedUsingScope? UsingScope => DecompileRun?.UsingScope.Resolve(TypeSystem);
public ILTransformContext(ILFunction function, IDecompilerTypeSystem typeSystem, IDebugInfoProvider debugInfo, DecompilerSettings settings = null) public ILTransformContext(ILFunction function, IDecompilerTypeSystem typeSystem, IDebugInfoProvider? debugInfo, DecompilerSettings? settings = null)
{ {
this.Function = function ?? throw new ArgumentNullException(nameof(function)); this.Function = function ?? throw new ArgumentNullException(nameof(function));
this.TypeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem)); this.TypeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem));
@ -62,7 +61,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Stepper = new Stepper(); Stepper = new Stepper();
} }
public ILTransformContext(ILTransformContext context, ILFunction function = null) public ILTransformContext(ILTransformContext context, ILFunction? function = null)
{ {
this.Function = function ?? context.Function; this.Function = function ?? context.Function;
this.TypeSystem = context.TypeSystem; this.TypeSystem = context.TypeSystem;
@ -89,13 +88,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Unlike <c>context.Stepper.Step()</c>, calls to this method are only compiled in debug builds. /// Unlike <c>context.Stepper.Step()</c>, calls to this method are only compiled in debug builds.
/// </summary> /// </summary>
[Conditional("STEP")] [Conditional("STEP")]
internal void Step(string description, ILInstruction near) internal void Step(string description, ILInstruction? near)
{ {
Stepper.Step(description, near); Stepper.Step(description, near);
} }
[Conditional("STEP")] [Conditional("STEP")]
internal void StepStartGroup(string description, ILInstruction near = null) internal void StepStartGroup(string description, ILInstruction? near = null)
{ {
Stepper.StartGroup(description, near); Stepper.StartGroup(description, near);
} }

20
ICSharpCode.Decompiler/IL/Transforms/Stepper.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -58,8 +60,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public class Node public class Node
{ {
public string Description { get; set; } public string Description { get; }
public ILInstruction Position { get; set; } public ILInstruction? Position { get; set; }
/// <summary> /// <summary>
/// BeginStep is inclusive. /// BeginStep is inclusive.
/// </summary> /// </summary>
@ -70,6 +72,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public int EndStep { get; set; } public int EndStep { get; set; }
public IList<Node> Children { get; } = new List<Node>(); public IList<Node> Children { get; } = new List<Node>();
public Node(string description)
{
Description = description;
}
} }
readonly Stack<Node> groups; readonly Stack<Node> groups;
@ -88,12 +95,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// ///
/// May throw <see cref="StepLimitReachedException"/> in debug mode. /// May throw <see cref="StepLimitReachedException"/> in debug mode.
/// </summary> /// </summary>
public void Step(string description, ILInstruction near = null) public void Step(string description, ILInstruction? near = null)
{ {
StepInternal(description, near); StepInternal(description, near);
} }
private Node StepInternal(string description, ILInstruction near) private Node StepInternal(string description, ILInstruction? near)
{ {
if (step == StepLimit) if (step == StepLimit)
{ {
@ -102,8 +109,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
else else
throw new StepLimitReachedException(); throw new StepLimitReachedException();
} }
var stepNode = new Node { var stepNode = new Node($"{step}: {description}") {
Description = $"{step}: {description}",
Position = near, Position = near,
BeginStep = step, BeginStep = step,
EndStep = step + 1 EndStep = step + 1
@ -117,7 +123,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return stepNode; return stepNode;
} }
public void StartGroup(string description, ILInstruction near = null) public void StartGroup(string description, ILInstruction? near = null)
{ {
groups.Push(StepInternal(description, near)); groups.Push(StepInternal(description, near));
} }

8
ICSharpCode.Decompiler/TypeSystem/IAssembly.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Metadata;
@ -40,7 +42,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary> /// <summary>
/// Resolves this metadata module. /// Resolves this metadata module.
/// </summary> /// </summary>
IModule Resolve(ITypeResolveContext context); IModule? Resolve(ITypeResolveContext context);
} }
/// <summary> /// <summary>
@ -51,7 +53,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary> /// <summary>
/// Gets the underlying metadata file. May return null, if the IAssembly was not created from a PE file. /// Gets the underlying metadata file. May return null, if the IAssembly was not created from a PE file.
/// </summary> /// </summary>
PEFile PEFile { get; } PEFile? PEFile { get; }
/// <summary> /// <summary>
/// Gets whether this assembly is the main assembly of the compilation. /// Gets whether this assembly is the main assembly of the compilation.
@ -97,7 +99,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the type definition for a top-level type. /// Gets the type definition for a top-level type.
/// </summary> /// </summary>
/// <remarks>This method uses ordinal name comparison, not the compilation's name comparer.</remarks> /// <remarks>This method uses ordinal name comparison, not the compilation's name comparer.</remarks>
ITypeDefinition GetTypeDefinition(TopLevelTypeName topLevelTypeName); ITypeDefinition? GetTypeDefinition(TopLevelTypeName topLevelTypeName);
/// <summary> /// <summary>
/// Gets all non-nested types in the assembly. /// Gets all non-nested types in the assembly.

7
ICSharpCode.Decompiler/TypeSystem/IAttribute.cs

@ -16,12 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; #nullable enable
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using ICSharpCode.Decompiler.Semantics;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary> /// <summary>
@ -39,7 +38,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the constructor being used. /// Gets the constructor being used.
/// This property may return null if no matching constructor was found. /// This property may return null if no matching constructor was found.
/// </summary> /// </summary>
IMethod Constructor { get; } IMethod? Constructor { get; }
/// <summary> /// <summary>
/// Gets whether there were errors decoding the attribute. /// Gets whether there were errors decoding the attribute.

3
ICSharpCode.Decompiler/TypeSystem/ICodeContext.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
@ -34,4 +36,3 @@ namespace ICSharpCode.Decompiler.TypeSystem
bool IsWithinLambdaExpression { get; } bool IsWithinLambdaExpression { get; }
} }
} }

4
ICSharpCode.Decompiler/TypeSystem/ICompilation.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -63,7 +65,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// returns the global root namespace. /// returns the global root namespace.
/// If no alias with the specified name exists, this method returns null. /// If no alias with the specified name exists, this method returns null.
/// </remarks> /// </remarks>
INamespace GetNamespaceForExternAlias(string alias); INamespace? GetNamespaceForExternAlias(string? alias);
IType FindType(KnownTypeCode typeCode); IType FindType(KnownTypeCode typeCode);

5
ICSharpCode.Decompiler/TypeSystem/IDecompilerTypeSystem.cs

@ -16,10 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Immutable; #nullable enable
using System.Reflection.Metadata;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {

7
ICSharpCode.Decompiler/TypeSystem/IEntity.cs

@ -16,7 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; #nullable enable
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
@ -46,14 +47,14 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// For members, this is the class that contains the member. /// For members, this is the class that contains the member.
/// For nested classes, this is the outer class. For top-level entities, this property returns null. /// For nested classes, this is the outer class. For top-level entities, this property returns null.
/// </summary> /// </summary>
ITypeDefinition DeclaringTypeDefinition { get; } ITypeDefinition? DeclaringTypeDefinition { get; }
/// <summary> /// <summary>
/// Gets/Sets the declaring type (incl. type arguments, if any). /// Gets/Sets the declaring type (incl. type arguments, if any).
/// This property will return null for top-level entities. /// This property will return null for top-level entities.
/// If this is not a specialized member, the value returned is equal to <see cref="DeclaringTypeDefinition"/>. /// If this is not a specialized member, the value returned is equal to <see cref="DeclaringTypeDefinition"/>.
/// </summary> /// </summary>
IType DeclaringType { get; } IType? DeclaringType { get; }
/// <summary> /// <summary>
/// The module in which this entity is defined. /// The module in which this entity is defined.

8
ICSharpCode.Decompiler/TypeSystem/IEvent.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
public interface IEvent : IMember public interface IEvent : IMember
@ -24,8 +26,8 @@ namespace ICSharpCode.Decompiler.TypeSystem
bool CanRemove { get; } bool CanRemove { get; }
bool CanInvoke { get; } bool CanInvoke { get; }
IMethod AddAccessor { get; } IMethod? AddAccessor { get; }
IMethod RemoveAccessor { get; } IMethod? RemoveAccessor { get; }
IMethod InvokeAccessor { get; } IMethod? InvokeAccessor { get; }
} }
} }

2
ICSharpCode.Decompiler/TypeSystem/IField.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary> /// <summary>

2
ICSharpCode.Decompiler/TypeSystem/IFreezable.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
public interface IFreezable public interface IFreezable

30
ICSharpCode.Decompiler/TypeSystem/IInterningProvider.cs

@ -16,7 +16,10 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
@ -47,52 +50,57 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// ///
/// If the object is freezable, it will be frozen. /// If the object is freezable, it will be frozen.
/// </summary> /// </summary>
public abstract ISupportsInterning Intern(ISupportsInterning obj); [return: NotNullIfNotNull("obj")]
public abstract ISupportsInterning? Intern(ISupportsInterning? obj);
/// <summary> /// <summary>
/// Interns the specified object. /// Interns the specified object.
/// ///
/// If the object is freezable, it will be frozen. /// If the object is freezable, it will be frozen.
/// </summary> /// </summary>
public T Intern<T>(T obj) where T : class, ISupportsInterning [return: NotNullIfNotNull("obj")]
public T? Intern<T>(T? obj) where T : class, ISupportsInterning
{ {
ISupportsInterning input = obj; ISupportsInterning? input = obj;
return (T)Intern(input); return (T?)Intern(input);
} }
/// <summary> /// <summary>
/// Interns the specified string. /// Interns the specified string.
/// </summary> /// </summary>
public abstract string Intern(string text); [return: NotNullIfNotNull("text")]
public abstract string? Intern(string? text);
/// <summary> /// <summary>
/// Inters a boxed value type. /// Inters a boxed value type.
/// </summary> /// </summary>
public abstract object InternValue(object obj); [return: NotNullIfNotNull("obj")]
public abstract object? InternValue(object? obj);
/// <summary> /// <summary>
/// Interns the given list. Uses reference equality to compare the list elements. /// Interns the given list. Uses reference equality to compare the list elements.
/// </summary> /// </summary>
public abstract IList<T> InternList<T>(IList<T> list) where T : class; [return: NotNullIfNotNull("list")]
public abstract IList<T>? InternList<T>(IList<T>? list) where T : class;
sealed class DummyInterningProvider : InterningProvider sealed class DummyInterningProvider : InterningProvider
{ {
public override ISupportsInterning Intern(ISupportsInterning obj) public override ISupportsInterning? Intern(ISupportsInterning? obj)
{ {
return obj; return obj;
} }
public override string Intern(string text) public override string? Intern(string? text)
{ {
return text; return text;
} }
public override object InternValue(object obj) public override object? InternValue(object? obj)
{ {
return obj; return obj;
} }
public override IList<T> InternList<T>(IList<T> list) public override IList<T>? InternList<T>(IList<T>? list)
{ {
return list; return list;
} }

7
ICSharpCode.Decompiler/TypeSystem/IMember.cs

@ -16,7 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; #nullable enable
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
@ -40,7 +41,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <returns> /// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found. /// Returns the resolved member, or <c>null</c> if the member could not be found.
/// </returns> /// </returns>
IMember Resolve(ITypeResolveContext context); IMember? Resolve(ITypeResolveContext context);
} }
/// <summary> /// <summary>
@ -119,6 +120,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary> /// <summary>
/// Gets whether the members are considered equal when applying the specified type normalization. /// Gets whether the members are considered equal when applying the specified type normalization.
/// </summary> /// </summary>
bool Equals(IMember obj, TypeVisitor typeNormalization); bool Equals(IMember? obj, TypeVisitor typeNormalization);
} }
} }

7
ICSharpCode.Decompiler/TypeSystem/IMethod.cs

@ -16,7 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; #nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -86,7 +87,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// If this method is an accessor, returns the corresponding property/event. /// If this method is an accessor, returns the corresponding property/event.
/// Otherwise, returns null. /// Otherwise, returns null.
/// </summary> /// </summary>
IMember AccessorOwner { get; } IMember? AccessorOwner { get; }
/// <summary> /// <summary>
/// Gets the kind of accessor this is. /// Gets the kind of accessor this is.
@ -98,7 +99,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// A reduced method doesn't contain the extension method parameter. That means that it has one parameter less than its definition. /// A reduced method doesn't contain the extension method parameter. That means that it has one parameter less than its definition.
/// A local function doesn't contain compiler-generated method parameters at the end. /// A local function doesn't contain compiler-generated method parameters at the end.
/// </summary> /// </summary>
IMethod ReducedFrom { get; } IMethod? ReducedFrom { get; }
/// <summary> /// <summary>
/// Specializes this method with the given substitution. /// Specializes this method with the given substitution.

8
ICSharpCode.Decompiler/TypeSystem/INamespace.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
@ -49,7 +51,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the parent namespace. /// Gets the parent namespace.
/// Returns null if this is the root namespace. /// Returns null if this is the root namespace.
/// </summary> /// </summary>
INamespace ParentNamespace { get; } INamespace? ParentNamespace { get; }
/// <summary> /// <summary>
/// Gets the child namespaces in this namespace. /// Gets the child namespaces in this namespace.
@ -73,7 +75,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <remarks> /// <remarks>
/// This method uses the compilation's current string comparer. /// This method uses the compilation's current string comparer.
/// </remarks> /// </remarks>
INamespace GetChildNamespace(string name); INamespace? GetChildNamespace(string name);
/// <summary> /// <summary>
/// Gets the type with the specified short name and type parameter count. /// Gets the type with the specified short name and type parameter count.
@ -82,6 +84,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <remarks> /// <remarks>
/// This method uses the compilation's current string comparer. /// This method uses the compilation's current string comparer.
/// </remarks> /// </remarks>
ITypeDefinition GetTypeDefinition(string name, int typeParameterCount); ITypeDefinition? GetTypeDefinition(string name, int typeParameterCount);
} }
} }

4
ICSharpCode.Decompiler/TypeSystem/IParameter.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -90,6 +92,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the owner of this parameter. /// Gets the owner of this parameter.
/// May return null; for example when parameters belong to lambdas or anonymous methods. /// May return null; for example when parameters belong to lambdas or anonymous methods.
/// </summary> /// </summary>
IParameterizedMember Owner { get; } IParameterizedMember? Owner { get; }
} }
} }

1
ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs

@ -15,6 +15,7 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;

6
ICSharpCode.Decompiler/TypeSystem/IProperty.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary> /// <summary>
@ -26,8 +28,8 @@ namespace ICSharpCode.Decompiler.TypeSystem
bool CanGet { get; } bool CanGet { get; }
bool CanSet { get; } bool CanSet { get; }
IMethod Getter { get; } IMethod? Getter { get; }
IMethod Setter { get; } IMethod? Setter { get; }
bool IsIndexer { get; } bool IsIndexer { get; }

2
ICSharpCode.Decompiler/TypeSystem/ISupportsInterning.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary> /// <summary>

2
ICSharpCode.Decompiler/TypeSystem/ISymbol.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
public enum SymbolKind : byte public enum SymbolKind : byte

26
ICSharpCode.Decompiler/TypeSystem/IType.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -83,13 +85,13 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the underlying type definition. /// Gets the underlying type definition.
/// Can return null for types which do not have a type definition (for example arrays, pointers, type parameters). /// Can return null for types which do not have a type definition (for example arrays, pointers, type parameters).
/// </summary> /// </summary>
ITypeDefinition GetDefinition(); ITypeDefinition? GetDefinition();
/// <summary> /// <summary>
/// Gets the parent type, if this is a nested type. /// Gets the parent type, if this is a nested type.
/// Returns null for top-level types. /// Returns null for top-level types.
/// </summary> /// </summary>
IType DeclaringType { get; } IType? DeclaringType { get; }
/// <summary> /// <summary>
/// Gets the number of type parameters. /// Gets the number of type parameters.
@ -168,7 +170,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Base.GetNestedTypes() = { Base`1+Nested`1[`0, unbound] } /// Base.GetNestedTypes() = { Base`1+Nested`1[`0, unbound] }
/// </code> /// </code>
/// </example> /// </example>
IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition>? filter = null, GetMemberOptions options = GetMemberOptions.None);
// Note that we cannot 'leak' the additional type parameter as we leak the normal type parameters, because // Note that we cannot 'leak' the additional type parameter as we leak the normal type parameters, because
// the index might collide. For example, // the index might collide. For example,
@ -193,7 +195,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// and thus 'leaked' to the caller in the same way the GetMembers() method does not specialize members /// and thus 'leaked' to the caller in the same way the GetMembers() method does not specialize members
/// from an <see cref="ITypeDefinition"/> and 'leaks' type parameters in member signatures. /// from an <see cref="ITypeDefinition"/> and 'leaks' type parameters in member signatures.
/// </remarks> /// </remarks>
IEnumerable<IType> GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IType> GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all instance constructors for this type. /// Gets all instance constructors for this type.
@ -209,7 +211,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// and the appropriate <see cref="Implementation.SpecializedMethod"/> will be returned. /// and the appropriate <see cref="Implementation.SpecializedMethod"/> will be returned.
/// </para> /// </para>
/// </remarks> /// </remarks>
IEnumerable<IMethod> GetConstructors(Predicate<IMethod> filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers); IEnumerable<IMethod> GetConstructors(Predicate<IMethod>? filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers);
/// <summary> /// <summary>
/// Gets all methods that can be called on this type. /// Gets all methods that can be called on this type.
@ -236,7 +238,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// the ambiguity can be avoided. /// the ambiguity can be avoided.
/// </para> /// </para>
/// </remarks> /// </remarks>
IEnumerable<IMethod> GetMethods(Predicate<IMethod> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IMethod> GetMethods(Predicate<IMethod>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all generic methods that can be called on this type with the specified type arguments. /// Gets all generic methods that can be called on this type with the specified type arguments.
@ -257,7 +259,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// and the other overload's remarks about ambiguous signatures apply here as well. /// and the other overload's remarks about ambiguous signatures apply here as well.
/// </para> /// </para>
/// </remarks> /// </remarks>
IEnumerable<IMethod> GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IMethod> GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all properties that can be called on this type. /// Gets all properties that can be called on this type.
@ -269,7 +271,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// For properties on parameterized types, type substitution will be performed on the property signature, /// For properties on parameterized types, type substitution will be performed on the property signature,
/// and the appropriate <see cref="Implementation.SpecializedProperty"/> will be returned. /// and the appropriate <see cref="Implementation.SpecializedProperty"/> will be returned.
/// </remarks> /// </remarks>
IEnumerable<IProperty> GetProperties(Predicate<IProperty> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IProperty> GetProperties(Predicate<IProperty>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all fields that can be accessed on this type. /// Gets all fields that can be accessed on this type.
@ -281,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// For fields on parameterized types, type substitution will be performed on the field's return type, /// For fields on parameterized types, type substitution will be performed on the field's return type,
/// and the appropriate <see cref="Implementation.SpecializedField"/> will be returned. /// and the appropriate <see cref="Implementation.SpecializedField"/> will be returned.
/// </remarks> /// </remarks>
IEnumerable<IField> GetFields(Predicate<IField> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IField> GetFields(Predicate<IField>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all events that can be accessed on this type. /// Gets all events that can be accessed on this type.
@ -293,7 +295,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// For fields on parameterized types, type substitution will be performed on the event's return type, /// For fields on parameterized types, type substitution will be performed on the event's return type,
/// and the appropriate <see cref="Implementation.SpecializedEvent"/> will be returned. /// and the appropriate <see cref="Implementation.SpecializedEvent"/> will be returned.
/// </remarks> /// </remarks>
IEnumerable<IEvent> GetEvents(Predicate<IEvent> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IEvent> GetEvents(Predicate<IEvent>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all members that can be called on this type. /// Gets all members that can be called on this type.
@ -312,7 +314,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <see cref="GetMethods(Predicate{IMethod}, GetMemberOptions)"/> method apply here as well. /// <see cref="GetMethods(Predicate{IMethod}, GetMemberOptions)"/> method apply here as well.
/// </para> /// </para>
/// </remarks> /// </remarks>
IEnumerable<IMember> GetMembers(Predicate<IMember> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IMember> GetMembers(Predicate<IMember>? filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary> /// <summary>
/// Gets all accessors belonging to properties or events on this type. /// Gets all accessors belonging to properties or events on this type.
@ -323,7 +325,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <remarks> /// <remarks>
/// Accessors are not returned by GetMembers() or GetMethods(). /// Accessors are not returned by GetMembers() or GetMethods().
/// </remarks> /// </remarks>
IEnumerable<IMethod> GetAccessors(Predicate<IMethod> filter = null, GetMemberOptions options = GetMemberOptions.None); IEnumerable<IMethod> GetAccessors(Predicate<IMethod>? filter = null, GetMemberOptions options = GetMemberOptions.None);
} }
[Flags] [Flags]

4
ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
@ -60,7 +62,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets/Sets the declaring type (incl. type arguments, if any). /// Gets/Sets the declaring type (incl. type arguments, if any).
/// This property will return null for top-level types. /// This property will return null for top-level types.
/// </summary> /// </summary>
new IType DeclaringType { get; } // solves ambiguity between IType.DeclaringType and IEntity.DeclaringType new IType? DeclaringType { get; } // solves ambiguity between IType.DeclaringType and IEntity.DeclaringType
/// <summary> /// <summary>
/// Gets whether this type contains extension methods. /// Gets whether this type contains extension methods.

6
ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -43,7 +45,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// inner.TypeParameters[0].Owner will be the outer class, because the same /// inner.TypeParameters[0].Owner will be the outer class, because the same
/// ITypeParameter instance is used both on Outer`1 and Outer`1+Inner. /// ITypeParameter instance is used both on Outer`1 and Outer`1+Inner.
/// </remarks> /// </remarks>
IEntity Owner { get; } IEntity? Owner { get; }
/// <summary> /// <summary>
/// Gets the index of the type parameter in the type parameter list of the owning method/class. /// Gets the index of the type parameter in the type parameter list of the owning method/class.
@ -112,7 +114,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public IType Type { get; } public IType Type { get; }
public IReadOnlyList<IAttribute> Attributes { get; } public IReadOnlyList<IAttribute> Attributes { get; }
public TypeConstraint(IType type, IReadOnlyList<IAttribute> attributes = null) public TypeConstraint(IType type, IReadOnlyList<IAttribute>? attributes = null)
{ {
this.Type = type ?? throw new ArgumentNullException(nameof(type)); this.Type = type ?? throw new ArgumentNullException(nameof(type));
this.Attributes = attributes ?? EmptyList<IAttribute>.Instance; this.Attributes = attributes ?? EmptyList<IAttribute>.Instance;

14
ICSharpCode.Decompiler/TypeSystem/ITypeReference.cs

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary> /// <summary>
@ -53,19 +55,19 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the current module. /// Gets the current module.
/// This property may return null if this context does not specify any module. /// This property may return null if this context does not specify any module.
/// </summary> /// </summary>
IModule CurrentModule { get; } IModule? CurrentModule { get; }
/// <summary> /// <summary>
/// Gets the current type definition. /// Gets the current type definition.
/// </summary> /// </summary>
ITypeDefinition CurrentTypeDefinition { get; } ITypeDefinition? CurrentTypeDefinition { get; }
/// <summary> /// <summary>
/// Gets the current member. /// Gets the current member.
/// </summary> /// </summary>
IMember CurrentMember { get; } IMember? CurrentMember { get; }
ITypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition); ITypeResolveContext WithCurrentTypeDefinition(ITypeDefinition? typeDefinition);
ITypeResolveContext WithCurrentMember(IMember member); ITypeResolveContext WithCurrentMember(IMember? member);
} }
} }

3
ICSharpCode.Decompiler/TypeSystem/IVariable.cs

@ -15,6 +15,7 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
@ -42,6 +43,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// If this field is a constant, retrieves the value. /// If this field is a constant, retrieves the value.
/// For parameters, this is the default value. /// For parameters, this is the default value.
/// </summary> /// </summary>
object GetConstantValue(bool throwOnInvalidMetadata = false); object? GetConstantValue(bool throwOnInvalidMetadata = false);
} }
} }

7
ICSharpCode.Decompiler/TypeSystem/KnownTypeReference.cs

@ -15,6 +15,7 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -162,7 +163,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
{ {
internal const int KnownTypeCodeCount = (int)KnownTypeCode.Range + 1; internal const int KnownTypeCodeCount = (int)KnownTypeCode.Range + 1;
static readonly KnownTypeReference[] knownTypeReferences = new KnownTypeReference[KnownTypeCodeCount] { static readonly KnownTypeReference?[] knownTypeReferences = new KnownTypeReference?[KnownTypeCodeCount] {
null, // None null, // None
new KnownTypeReference(KnownTypeCode.Object, TypeKind.Class, "System", "Object", baseType: KnownTypeCode.None), new KnownTypeReference(KnownTypeCode.Object, TypeKind.Class, "System", "Object", baseType: KnownTypeCode.None),
new KnownTypeReference(KnownTypeCode.DBNull, TypeKind.Class, "System", "DBNull"), new KnownTypeReference(KnownTypeCode.DBNull, TypeKind.Class, "System", "DBNull"),
@ -231,7 +232,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the known type reference for the specified type code. /// Gets the known type reference for the specified type code.
/// Returns null for KnownTypeCode.None. /// Returns null for KnownTypeCode.None.
/// </summary> /// </summary>
public static KnownTypeReference Get(KnownTypeCode typeCode) public static KnownTypeReference? Get(KnownTypeCode typeCode)
{ {
return knownTypeReferences[(int)typeCode]; return knownTypeReferences[(int)typeCode];
} }
@ -299,7 +300,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the C# primitive type name from the known type code. /// Gets the C# primitive type name from the known type code.
/// Returns null if there is no primitive name for the specified type. /// Returns null if there is no primitive name for the specified type.
/// </summary> /// </summary>
public static string GetCSharpNameByTypeCode(KnownTypeCode knownTypeCode) public static string? GetCSharpNameByTypeCode(KnownTypeCode knownTypeCode)
{ {
switch (knownTypeCode) switch (knownTypeCode)
{ {

Loading…
Cancel
Save