/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; namespace dnSpy.Debugger.DotNet.Metadata { /// /// A .NET constructor /// public abstract class DmdConstructorInfo : DmdMethodBase, IEquatable { /// /// Gets the member type /// public sealed override DmdMemberTypes MemberType => DmdMemberTypes.Constructor; /// /// Resolves a constructor reference /// /// true to throw if it doesn't exist, false to return null if it doesn't exist /// public sealed override DmdMemberInfo? ResolveMember(bool throwOnError) => Resolve(throwOnError); /// /// Resolves a constructor reference /// /// true to throw if it doesn't exist, false to return null if it doesn't exist /// public sealed override DmdMethodBase? ResolveMethodBase(bool throwOnError) => Resolve(throwOnError); /// /// Resolves a constructor reference and throws if it doesn't exist /// /// public DmdConstructorInfo Resolve() => Resolve(throwOnError: true)!; /// /// Resolves a constructor reference and returns null if it doesn't exist /// /// public DmdConstructorInfo? ResolveNoThrow() => Resolve(throwOnError: false); /// /// Resolves a constructor reference /// /// true to throw if it doesn't exist, false to return null if it doesn't exist /// public abstract DmdConstructorInfo? Resolve(bool throwOnError); /// /// true if it contains generic parameters /// public override bool ContainsGenericParameters => DeclaringType!.ContainsGenericParameters; /// /// Calls the method /// /// Evaluation context /// Parameters /// public object? Invoke(object? context, object?[] parameters) => Invoke(context, DmdBindingFlags.Default, parameters); /// /// Calls the method /// /// Evaluation context /// Binding flags /// Parameters /// public abstract object? Invoke(object? context, DmdBindingFlags invokeAttr, object?[] parameters); #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public static bool operator ==(DmdConstructorInfo? left, DmdConstructorInfo? right) => DmdMemberInfoEqualityComparer.DefaultMember.Equals(left, right); public static bool operator !=(DmdConstructorInfo? left, DmdConstructorInfo? right) => !DmdMemberInfoEqualityComparer.DefaultMember.Equals(left, right); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member /// /// Equals() /// /// /// public bool Equals(DmdConstructorInfo? other) => DmdMemberInfoEqualityComparer.DefaultMember.Equals(this, other); /// /// Equals() /// /// /// public override bool Equals(object? obj) => Equals(obj as DmdConstructorInfo); /// /// GetHashCode() /// /// public override int GetHashCode() => DmdMemberInfoEqualityComparer.DefaultMember.GetHashCode(this); /// /// Gets the name of instance constructors /// public static readonly string ConstructorName = ".ctor"; /// /// Gets the name of type initializers /// public static readonly string TypeConstructorName = ".cctor"; } }