Browse Source

focus on CS8769

pull/3287/head
apmoskevitz 9 months ago
parent
commit
c51ee93a85
  1. 6
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  2. 26
      ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs
  3. 54
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
  4. 6
      ICSharpCode.Decompiler/TypeSystem/GenericContext.cs
  5. 20
      ICSharpCode.Decompiler/TypeSystem/Implementation/DecoratedType.cs
  6. 19
      ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
  7. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs
  8. 6
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs
  9. 8
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs
  10. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs
  11. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs
  12. 44
      ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs
  13. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/NullabilityAnnotatedType.cs
  14. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/SyntheticRangeIndexer.cs
  15. 2
      ICSharpCode.Decompiler/Util/LazyInit.cs

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

@ -154,7 +154,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -154,7 +154,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return WithContext(context.WithCurrentMember(member));
}
ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember member)
ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember? member)
{
return WithCurrentMember(member);
}
@ -188,7 +188,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -188,7 +188,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// <summary>
/// Sets the current type definition.
/// </summary>
public CSharpResolver WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
public CSharpResolver WithCurrentTypeDefinition(ITypeDefinition? typeDefinition)
{
if (this.CurrentTypeDefinition == typeDefinition)
return this;
@ -203,7 +203,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -203,7 +203,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
checkForOverflow, isWithinLambdaExpression, newTypeDefinitionCache, localVariableStack, objectInitializerStack);
}
ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition? typeDefinition)
{
return WithCurrentTypeDefinition(typeDefinition);
}

26
ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics.CodeAnalysis;
using ICSharpCode.Decompiler.TypeSystem;
@ -25,10 +26,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -25,10 +26,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public sealed class CSharpTypeResolveContext : ITypeResolveContext
{
readonly IModule module;
readonly ResolvedUsingScope currentUsingScope;
readonly ITypeDefinition currentTypeDefinition;
readonly IMember currentMember;
readonly string[] methodTypeParameterNames;
readonly ResolvedUsingScope? currentUsingScope;
readonly ITypeDefinition? currentTypeDefinition;
readonly IMember? currentMember;
readonly string[]? methodTypeParameterNames;
public CSharpTypeResolveContext(IModule module, ResolvedUsingScope? usingScope = null, ITypeDefinition? typeDefinition = null, IMember? member = null)
{
@ -40,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -40,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.currentMember = member;
}
private CSharpTypeResolveContext(IModule module, ResolvedUsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames)
private CSharpTypeResolveContext(IModule module, ResolvedUsingScope? usingScope, ITypeDefinition? typeDefinition, IMember? member, string[]? methodTypeParameterNames)
{
this.module = module;
this.currentUsingScope = usingScope;
@ -49,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -49,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.methodTypeParameterNames = methodTypeParameterNames;
}
public ResolvedUsingScope CurrentUsingScope {
public ResolvedUsingScope? CurrentUsingScope {
get { return currentUsingScope; }
}
@ -61,30 +62,31 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -61,30 +62,31 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
get { return module; }
}
public ITypeDefinition CurrentTypeDefinition {
public ITypeDefinition? CurrentTypeDefinition {
get { return currentTypeDefinition; }
}
public IMember CurrentMember {
public IMember? CurrentMember {
get { return currentMember; }
}
public CSharpTypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
public CSharpTypeResolveContext WithCurrentTypeDefinition(ITypeDefinition? typeDefinition)
{
return new CSharpTypeResolveContext(module, currentUsingScope, typeDefinition, currentMember, methodTypeParameterNames);
}
ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition? typeDefinition)
{
return WithCurrentTypeDefinition(typeDefinition);
}
public CSharpTypeResolveContext WithCurrentMember(IMember member)
public CSharpTypeResolveContext WithCurrentMember(IMember? member)
{
return new CSharpTypeResolveContext(module, currentUsingScope, currentTypeDefinition, member, methodTypeParameterNames);
}
ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember member)
ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember? member)
{
return WithCurrentMember(member);
}

54
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -153,7 +153,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -153,7 +153,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Converts a Expression.Lambda call into an ILFunction.
/// If the conversion fails, null is returned.
/// </summary>
(Func<ILInstruction>, IType) ConvertLambda(CallInstruction instruction)
(Func<ILInstruction>?, IType) ConvertLambda(CallInstruction instruction)
{
if (instruction.Method.Name != "Lambda" || instruction.Arguments.Count != 2 || instruction.Method.ReturnType.FullName != "System.Linq.Expressions.Expression" || instruction.Method.ReturnType.TypeArguments.Count != 1)
return (null, SpecialType.UnknownType);
@ -198,7 +198,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -198,7 +198,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertQuote(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertQuote(CallInstruction invocation)
{
if (invocation.Arguments.Count != 1)
return (null, SpecialType.UnknownType);
@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertInstruction(ILInstruction instruction, IType? typeHint = null)
(Func<ILInstruction>?, IType) ConvertInstruction(ILInstruction instruction, IType? typeHint = null)
{
var (inst, type) = Convert();
@ -289,7 +289,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -289,7 +289,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
return (DoConvert, typeHint ?? type);
(Func<ILInstruction>, IType) Convert()
(Func<ILInstruction>?, IType) Convert()
{
switch (instruction)
{
@ -446,7 +446,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -446,7 +446,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return delegateType;
}
(Func<ILInstruction>, IType) ConvertArrayIndex(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertArrayIndex(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -473,7 +473,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -473,7 +473,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (Convert, type.ElementType);
}
(Func<ILInstruction>, IType) ConvertArrayLength(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertArrayLength(CallInstruction invocation)
{
if (invocation.Arguments.Count != 1)
return (null, SpecialType.UnknownType);
@ -483,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -483,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => new LdLen(StackType.I4, converted()), context.TypeSystem.FindType(KnownTypeCode.Int32));
}
(Func<ILInstruction>, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null)
(Func<ILInstruction>?, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -574,7 +574,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -574,7 +574,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
}
(Func<ILInstruction>, IType) ConvertCall(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertCall(CallInstruction invocation)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return converted;
}
(Func<ILInstruction>, IType) ConvertCast(CallInstruction invocation, bool isChecked)
(Func<ILInstruction>?, IType) ConvertCast(CallInstruction invocation, bool isChecked)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => new ExpressionTreeCast(targetType, expr(), isChecked), targetType);
}
(Func<ILInstruction>, IType) ConvertCoalesce(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertCoalesce(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -742,7 +742,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -742,7 +742,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}, targetType);
}
(Func<ILInstruction>, IType) ConvertComparison(CallInstruction invocation, ComparisonKind kind)
(Func<ILInstruction>?, IType) ConvertComparison(CallInstruction invocation, ComparisonKind kind)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -790,7 +790,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -790,7 +790,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => new Comp(kind, lifting, utype.GetStackType(), utype.GetSign(), left(), right()), resultType);
}
(Func<ILInstruction>, IType) ConvertCondition(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertCondition(CallInstruction invocation)
{
if (invocation.Arguments.Count != 3)
return (null, SpecialType.UnknownType);
@ -808,7 +808,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -808,7 +808,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => new IfInstruction(condition(), trueInst(), falseInst()), trueInstType);
}
(Func<ILInstruction>, IType) ConvertConstant(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertConstant(CallInstruction invocation)
{
if (!MatchConstantCall(invocation, out var value, out var type))
return (null, SpecialType.UnknownType);
@ -821,7 +821,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -821,7 +821,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => ConvertValue(value, invocation), type);
}
(Func<ILInstruction>, IType) ConvertElementInit(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertElementInit(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -849,7 +849,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -849,7 +849,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildCall, member.ReturnType);
}
(Func<ILInstruction>, IType) ConvertField(CallInstruction invocation, IType typeHint)
(Func<ILInstruction>?, IType) ConvertField(CallInstruction invocation, IType typeHint)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -896,7 +896,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -896,7 +896,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertInvoke(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertInvoke(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -922,7 +922,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -922,7 +922,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildCall, invokeMethod.ReturnType);
}
(Func<ILInstruction>, IType) ConvertListInit(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertListInit(CallInstruction invocation)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -978,7 +978,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -978,7 +978,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildBlock, ctor.DeclaringType);
}
(Func<ILInstruction>, IType) ConvertLogicOperator(CallInstruction invocation, bool and)
(Func<ILInstruction>?, IType) ConvertLogicOperator(CallInstruction invocation, bool and)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -1016,7 +1016,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1016,7 +1016,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertMemberInit(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertMemberInit(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -1064,7 +1064,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1064,7 +1064,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildBlock, ctor.DeclaringType);
}
(Func<ILInstruction>, IType) ConvertNewArrayBounds(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertNewArrayBounds(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -1085,7 +1085,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1085,7 +1085,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (() => new NewArr(type, indices.SelectArray(f => f())), new ArrayType(context.TypeSystem, type, arguments.Count));
}
(Func<ILInstruction>, IType) ConvertNewArrayInit(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertNewArrayInit(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -1154,7 +1154,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1154,7 +1154,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertNewObject(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertNewObject(CallInstruction invocation)
{
switch (invocation.Arguments.Count)
{
@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
}
(Func<ILInstruction>, IType) ConvertNotOperator(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertNotOperator(CallInstruction invocation)
{
if (invocation.Arguments.Count < 1)
return (null, SpecialType.UnknownType);
@ -1229,7 +1229,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1229,7 +1229,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
(Func<ILInstruction>, IType) ConvertProperty(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertProperty(CallInstruction invocation)
{
if (invocation.Arguments.Count < 2)
return (null, SpecialType.UnknownType);
@ -1272,7 +1272,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1272,7 +1272,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildProperty, member.ReturnType);
}
(Func<ILInstruction>, IType) ConvertTypeAs(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertTypeAs(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -1293,7 +1293,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1293,7 +1293,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (BuildTypeAs, type);
}
(Func<ILInstruction>, IType) ConvertTypeIs(CallInstruction invocation)
(Func<ILInstruction>?, IType) ConvertTypeIs(CallInstruction invocation)
{
if (invocation.Arguments.Count != 2)
return (null, SpecialType.UnknownType);
@ -1306,7 +1306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1306,7 +1306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
}
(Func<ILInstruction>, IType) ConvertUnaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null)
(Func<ILInstruction>?, IType) ConvertUnaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null)
{
if (invocation.Arguments.Count < 1)
return (null, SpecialType.UnknownType);

6
ICSharpCode.Decompiler/TypeSystem/GenericContext.cs

@ -25,10 +25,10 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -25,10 +25,10 @@ namespace ICSharpCode.Decompiler.TypeSystem
{
public readonly struct GenericContext
{
public readonly IReadOnlyList<ITypeParameter> ClassTypeParameters;
public readonly IReadOnlyList<ITypeParameter> MethodTypeParameters;
public readonly IReadOnlyList<ITypeParameter>? ClassTypeParameters;
public readonly IReadOnlyList<ITypeParameter>? MethodTypeParameters;
public GenericContext(IReadOnlyList<ITypeParameter> classTypeParameters)
public GenericContext(IReadOnlyList<ITypeParameter>? classTypeParameters)
{
this.ClassTypeParameters = classTypeParameters;
this.MethodTypeParameters = null;

20
ICSharpCode.Decompiler/TypeSystem/Implementation/DecoratedType.cs

@ -44,12 +44,12 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -44,12 +44,12 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public abstract bool Equals(IType other);
IEnumerable<IMethod> IType.GetAccessors(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetAccessors(Predicate<IMethod>? filter, GetMemberOptions options)
{
return baseType.GetAccessors(filter, options);
}
IEnumerable<IMethod> IType.GetConstructors(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetConstructors(Predicate<IMethod>? filter, GetMemberOptions options)
{
return baseType.GetConstructors(filter, options);
}
@ -64,42 +64,42 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -64,42 +64,42 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return baseType.GetDefinitionOrUnknown();
}
IEnumerable<IEvent> IType.GetEvents(Predicate<IEvent> filter, GetMemberOptions options)
IEnumerable<IEvent> IType.GetEvents(Predicate<IEvent>? filter, GetMemberOptions options)
{
return baseType.GetEvents(filter, options);
}
IEnumerable<IField> IType.GetFields(Predicate<IField> filter, GetMemberOptions options)
IEnumerable<IField> IType.GetFields(Predicate<IField>? filter, GetMemberOptions options)
{
return baseType.GetFields(filter, options);
}
IEnumerable<IMember> IType.GetMembers(Predicate<IMember> filter, GetMemberOptions options)
IEnumerable<IMember> IType.GetMembers(Predicate<IMember>? filter, GetMemberOptions options)
{
return baseType.GetMembers(filter, options);
}
IEnumerable<IMethod> IType.GetMethods(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetMethods(Predicate<IMethod>? filter, GetMemberOptions options)
{
return baseType.GetMethods(filter, options);
}
IEnumerable<IMethod> IType.GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod>? filter, GetMemberOptions options)
{
return baseType.GetMethods(typeArguments, filter, options);
}
IEnumerable<IType> IType.GetNestedTypes(Predicate<ITypeDefinition> filter, GetMemberOptions options)
IEnumerable<IType> IType.GetNestedTypes(Predicate<ITypeDefinition>? filter, GetMemberOptions options)
{
return baseType.GetNestedTypes(filter, options);
}
IEnumerable<IType> IType.GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options)
IEnumerable<IType> IType.GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition>? filter, GetMemberOptions options)
{
return baseType.GetNestedTypes(typeArguments, filter, options);
}
IEnumerable<IProperty> IType.GetProperties(Predicate<IProperty> filter, GetMemberOptions options)
IEnumerable<IProperty> IType.GetProperties(Predicate<IProperty>? filter, GetMemberOptions options)
{
return baseType.GetProperties(filter, options);
}

19
ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Reflection;
using System.Reflection.Metadata;
@ -94,7 +95,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -94,7 +95,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
string INamedElement.Namespace => DeclaringType?.Namespace;
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return Equals(obj);
}
@ -152,10 +153,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -152,10 +153,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool IMethod.HasBody => false;
public bool IsAccessor => AccessorOwner is not null;
public IMember AccessorOwner { get; set; }
public IMember? AccessorOwner { get; set; }
public MethodSemanticsAttributes AccessorKind { get; set; }
IMethod IMethod.ReducedFrom => null;
IMethod? IMethod.ReducedFrom => null;
public IReadOnlyList<IParameter> Parameters { get; set; } = EmptyList<IParameter>.Instance;
@ -195,11 +196,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -195,11 +196,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public bool CanGet => Getter is not null;
public bool CanSet => Setter is not null;
public IMethod Getter { get; set; }
public IMethod Setter { get; set; }
public IMethod? Getter { get; set; }
public IMethod? Setter { get; set; }
public bool IsIndexer { get; set; }
public bool ReturnTypeIsRefReadOnly => false;
public IReadOnlyList<IParameter> Parameters { get; set; }
public IReadOnlyList<IParameter> Parameters { get; set; } = ImmutableArray<IParameter>.Empty;
public override string ToString() =>
"FakeProperty " + ReturnType + " " + DeclaringType.Name + "." + Name +
@ -226,8 +227,8 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -226,8 +227,8 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public bool CanAdd => AddAccessor is not null;
public bool CanRemove => RemoveAccessor is not null;
public bool CanInvoke => InvokeAccessor is not null;
public IMethod AddAccessor { get; set; }
public IMethod RemoveAccessor { get; set; }
public IMethod InvokeAccessor { get; set; }
public IMethod? AddAccessor { get; set; }
public IMethod? RemoveAccessor { get; set; }
public IMethod? InvokeAccessor { get; set; }
}
}

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

@ -164,7 +164,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -164,7 +164,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public string ReflectionName => $"{DeclaringType?.ReflectionName}.{Name}";
public string Namespace => DeclaringType?.Namespace ?? string.Empty;
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is MetadataEvent ev)
{
@ -178,7 +178,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -178,7 +178,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return 0x7937039a ^ module.MetadataFile.GetHashCode() ^ handle.GetHashCode();
}
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return Equals(obj);
}

6
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs

@ -258,7 +258,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -258,7 +258,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
public object GetConstantValue(bool throwOnInvalidMetadata)
public object? GetConstantValue(bool throwOnInvalidMetadata)
{
object val = LazyInit.VolatileRead(ref this.constantValue);
if (val != null)
@ -295,7 +295,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -295,7 +295,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is MetadataField f)
{
@ -309,7 +309,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -309,7 +309,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return 0x11dda32b ^ module.MetadataFile.GetHashCode() ^ handle.GetHashCode();
}
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return Equals(obj);
}

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

@ -130,7 +130,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -130,7 +130,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public bool HasBody => module.metadata.GetMethodDefinition(handle).HasBody();
public IMember AccessorOwner {
public IMember? AccessorOwner {
get {
if (accessorOwner.IsNil)
return null;
@ -294,7 +294,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -294,7 +294,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
IMember IMember.MemberDefinition => this;
IMethod IMethod.ReducedFrom => null;
IMethod? IMethod.ReducedFrom => null;
TypeParameterSubstitution IMember.Substitution => TypeParameterSubstitution.Identity;
public ITypeDefinition DeclaringTypeDefinition {
@ -602,7 +602,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -602,7 +602,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public string ReflectionName => $"{DeclaringType?.ReflectionName}.{Name}";
public string Namespace => DeclaringType?.Namespace ?? string.Empty;
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is MetadataMethod m)
{
@ -616,7 +616,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -616,7 +616,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return 0x5a00d671 ^ module.MetadataFile.GetHashCode() ^ handle.GetHashCode();
}
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return Equals(obj);
}

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

@ -298,7 +298,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -298,7 +298,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public string ReflectionName => $"{DeclaringType?.ReflectionName}.{Name}";
public string Namespace => DeclaringType?.Namespace ?? string.Empty;
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is MetadataProperty p)
{
@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return 0x32b6a76c ^ module.MetadataFile.GetHashCode() ^ handle.GetHashCode();
}
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return Equals(obj);
}

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

@ -549,7 +549,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -549,7 +549,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return this;
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is MetadataTypeDefinition td)
{
@ -563,7 +563,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -563,7 +563,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return 0x2e0520f2 ^ module.MetadataFile.GetHashCode() ^ handle.GetHashCode();
}
bool IEquatable<IType>.Equals(IType other)
bool IEquatable<IType>.Equals(IType? other)
{
return Equals(other);
}

44
ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs

@ -62,13 +62,13 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -62,13 +62,13 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
string ISymbol.Name => "corlib";
SymbolKind ISymbol.SymbolKind => SymbolKind.Module;
Metadata.MetadataFile IModule.MetadataFile => null;
Metadata.MetadataFile? IModule.MetadataFile => null;
INamespace IModule.RootNamespace => rootNamespace;
public IEnumerable<ITypeDefinition> TopLevelTypeDefinitions => typeDefinitions.Where(td => td != null);
public IEnumerable<ITypeDefinition> TypeDefinitions => TopLevelTypeDefinitions;
public ITypeDefinition GetTypeDefinition(TopLevelTypeName topLevelTypeName)
public ITypeDefinition? GetTypeDefinition(TopLevelTypeName topLevelTypeName)
{
foreach (var typeDef in typeDefinitions)
{
@ -105,11 +105,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -105,11 +105,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
readonly MinimalCorlib corlib;
internal List<INamespace> childNamespaces = new List<INamespace>();
public INamespace ParentNamespace { get; }
public INamespace? ParentNamespace { get; }
public string FullName { get; }
public string Name { get; }
public CorlibNamespace(MinimalCorlib corlib, INamespace parentNamespace, string fullName, string name)
public CorlibNamespace(MinimalCorlib corlib, INamespace? parentNamespace, string fullName, string name)
{
this.corlib = corlib;
this.ParentNamespace = parentNamespace;
@ -127,7 +127,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -127,7 +127,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
SymbolKind ISymbol.SymbolKind => SymbolKind.Namespace;
ICompilation ICompilationProvider.Compilation => corlib.Compilation;
INamespace INamespace.GetChildNamespace(string name)
INamespace? INamespace.GetChildNamespace(string name)
{
return childNamespaces.FirstOrDefault(ns => ns.Name == name);
}
@ -148,7 +148,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -148,7 +148,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
this.corlib = corlib;
this.typeCode = typeCode;
KnownTypeReference ktr = KnownTypeReference.Get(typeCode);
KnownTypeReference? ktr = KnownTypeReference.Get(typeCode);
this.typeKind = ktr.typeKind;
this.MetadataName = ktr.Name + (ktr.TypeParameterCount > 0 ? "`" + ktr.TypeParameterCount : "");
}
@ -168,10 +168,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -168,10 +168,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public string MetadataName { get; }
ITypeDefinition IEntity.DeclaringTypeDefinition => null;
IType ITypeDefinition.DeclaringType => null;
IType IType.DeclaringType => null;
IType IEntity.DeclaringType => null;
ITypeDefinition? IEntity.DeclaringTypeDefinition => null;
IType? ITypeDefinition.DeclaringType => null;
IType? IType.DeclaringType => null;
IType? IEntity.DeclaringType => null;
bool ITypeDefinition.HasExtensionMethods => false;
bool ITypeDefinition.IsReadOnly => false;
@ -248,61 +248,61 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -248,61 +248,61 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
string INamedElement.Namespace => KnownTypeReference.Get(typeCode).Namespace;
bool IEquatable<IType>.Equals(IType other)
bool IEquatable<IType>.Equals(IType? other)
{
return this == other;
}
IEnumerable<IMethod> IType.GetAccessors(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetAccessors(Predicate<IMethod>? filter, GetMemberOptions options)
{
return EmptyList<IMethod>.Instance;
}
IEnumerable<IAttribute> IEntity.GetAttributes() => EmptyList<IAttribute>.Instance;
bool IEntity.HasAttribute(KnownAttribute attribute) => false;
IAttribute IEntity.GetAttribute(KnownAttribute attribute) => null;
IAttribute? IEntity.GetAttribute(KnownAttribute attribute) => null;
IEnumerable<IMethod> IType.GetConstructors(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetConstructors(Predicate<IMethod>? filter, GetMemberOptions options)
{
return EmptyList<IMethod>.Instance;
}
IEnumerable<IEvent> IType.GetEvents(Predicate<IEvent> filter, GetMemberOptions options)
IEnumerable<IEvent> IType.GetEvents(Predicate<IEvent>? filter, GetMemberOptions options)
{
return EmptyList<IEvent>.Instance;
}
IEnumerable<IField> IType.GetFields(Predicate<IField> filter, GetMemberOptions options)
IEnumerable<IField> IType.GetFields(Predicate<IField>? filter, GetMemberOptions options)
{
return EmptyList<IField>.Instance;
}
IEnumerable<IMember> IType.GetMembers(Predicate<IMember> filter, GetMemberOptions options)
IEnumerable<IMember> IType.GetMembers(Predicate<IMember>? filter, GetMemberOptions options)
{
return EmptyList<IMember>.Instance;
}
IEnumerable<IMethod> IType.GetMethods(Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetMethods(Predicate<IMethod>? filter, GetMemberOptions options)
{
return EmptyList<IMethod>.Instance;
}
IEnumerable<IMethod> IType.GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod> filter, GetMemberOptions options)
IEnumerable<IMethod> IType.GetMethods(IReadOnlyList<IType> typeArguments, Predicate<IMethod>? filter, GetMemberOptions options)
{
return EmptyList<IMethod>.Instance;
}
IEnumerable<IType> IType.GetNestedTypes(Predicate<ITypeDefinition> filter, GetMemberOptions options)
IEnumerable<IType> IType.GetNestedTypes(Predicate<ITypeDefinition>? filter, GetMemberOptions options)
{
return EmptyList<IType>.Instance;
}
IEnumerable<IType> IType.GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options)
IEnumerable<IType> IType.GetNestedTypes(IReadOnlyList<IType> typeArguments, Predicate<ITypeDefinition>? filter, GetMemberOptions options)
{
return EmptyList<IType>.Instance;
}
IEnumerable<IProperty> IType.GetProperties(Predicate<IProperty> filter, GetMemberOptions options)
IEnumerable<IProperty> IType.GetProperties(Predicate<IProperty>? filter, GetMemberOptions options)
{
return EmptyList<IProperty>.Instance;
}

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

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return visitor.VisitNullabilityAnnotatedType(this);
}
public override bool Equals(IType other)
public override bool Equals(IType? other)
{
return other is NullabilityAnnotatedType nat
&& nat.nullability == nullability

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

@ -105,7 +105,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -105,7 +105,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
string INamedElement.ReflectionName => underlyingMethod.ReflectionName;
string INamedElement.Namespace => underlyingMethod.Namespace;
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is SyntheticRangeIndexAccessor g
&& this.underlyingMethod.Equals(g.underlyingMethod)
@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return underlyingMethod.GetHashCode() ^ indexOrRangeType.GetHashCode();
}
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization)
bool IMember.Equals(IMember? obj, TypeVisitor typeNormalization)
{
return obj is SyntheticRangeIndexAccessor g
&& this.underlyingMethod.Equals(g.underlyingMethod, typeNormalization)

2
ICSharpCode.Decompiler/Util/LazyInit.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.Util @@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.Util
/// - If target is not null: returns target.
/// </summary>
[return: NotNullIfNotNull("newValue")]
public static T? GetOrSet<T>(ref T? target, T? newValue) where T : class
public static T? GetOrSet<T>([NotNullIfNotNull(nameof(newValue))] ref T? target, T? newValue) where T : class
{
T? oldValue = Interlocked.CompareExchange(ref target, newValue, null);
return oldValue ?? newValue;

Loading…
Cancel
Save