}
[MethodImpl(MethodImplOptions.InternalCall)]
- private extern byte[] ComputePublicKeyToken();
+ private extern byte[]? ComputePublicKeyToken();
internal void SetProcArchIndex(PortableExecutableKinds pek, ImageFileMachine ifm)
{
// No pseudo attributes for RuntimeAssembly
- return GetCustomAttributes((RuntimeModule)target.ManifestModule!, RuntimeAssembly.GetToken(target.GetNativeHandle()));
+ return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
}
internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target)
return InternalAssembly.GetType(name, throwOnError, ignoreCase);
}
- public override Module? ManifestModule => _manifestModuleBuilder.InternalModule;
+ public override Module ManifestModule => _manifestModuleBuilder.InternalModule;
public override bool ReflectionOnly => InternalAssembly.ReflectionOnly;
return m_methodBuilder.GetModule();
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- // This always returns null. Is that what we want?
- internal override Type? GetReturnType()
+ internal override Type GetReturnType()
{
return m_methodBuilder.ReturnType;
}
-#pragma warning restore CS8609
public string Signature
{
return m_localSignature;
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
internal override byte[]? GetRawEHInfo()
{
return m_exceptionHeader;
}
-#pragma warning restore CS8609
internal override unsafe void GetEHInfo(int excNumber, void* exc)
{
}
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
internal override string? GetStringLiteral(int token) { return m_scope.GetString(token); }
-#pragma warning restore CS8609
-
internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
{
}
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
internal override byte[]? ResolveSignature(int token, int fromMethod)
{
return m_scope.ResolveSignature(token, fromMethod);
}
-#pragma warning restore CS8609
internal override MethodInfo GetDynamicMethod()
{
m_strName = name;
m_module = mod;
m_containingType = type;
-
-
- if (returnType == null)
- {
- m_returnType = typeof(void);
- }
- else
- {
- m_returnType = returnType;
- }
+ m_returnType = returnType ?? typeof(void);
if ((attributes & MethodAttributes.Static) == 0)
{
public override bool IsGenericMethod { get { return m_inst != null; } }
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- public override Type[]? GetGenericArguments() { return m_inst; }
-#pragma warning restore CS8609
+ public override Type[] GetGenericArguments() => m_inst ?? Array.Empty<Type>();
public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
{
}
}
- public override ParameterInfo ReturnParameter { get { throw new NotSupportedException(); } }
+ public override ParameterInfo? ReturnParameter { get { throw new NotSupportedException(); } }
public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException(); } }
public override MethodInfo GetBaseDefinition() { throw new NotSupportedException(); }
#endregion
TypeBuilder.SetConstantValue(
_methodBuilder.GetModuleBuilder(),
_token.Token,
- _position == 0 ? _methodBuilder.ReturnType! : _methodBuilder.m_parameterTypes![_position - 1],
+ _position == 0 ? _methodBuilder.ReturnType : _methodBuilder.m_parameterTypes![_position - 1],
defaultValue);
}
private Type m_containingType;
private string m_name;
private CallingConventions m_callingConvention;
- private Type? m_returnType;
+ private Type m_returnType;
private MethodToken m_mdMethod;
private Type[] m_parameterTypes;
private SignatureHelper m_signature;
m_mdMethod = token;
// The ParameterTypes are also a bit interesting in that they may be unbaked TypeBuilders.
- m_returnType = returnType;
+ m_returnType = returnType ?? typeof(void);
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
#endregion
#region MethodInfo Overrides
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- public override Type? ReturnType
+ public override Type ReturnType
{
get
{
}
}
+#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override ICustomAttributeProvider? ReturnTypeCustomAttributes
{
get { return null; }
return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- public override Type[]? GetGenericArguments() { return m_inst; }
-#pragma warning restore CS8609
+ public override Type[] GetGenericArguments() => m_inst ?? Array.Empty<Type>();
// If a TypeBuilder is generic, it must be a generic type definition
// All instantiated generic types are TypeBuilderInstantiation.
#region Public Abstract\Virtual Members
public override Type ReturnType { get { return m_method.ReturnType; } }
- public override ParameterInfo ReturnParameter { get { throw new NotSupportedException(); } }
+ public override ParameterInfo? ReturnParameter { get { throw new NotSupportedException(); } }
public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException(); } }
public override MethodInfo GetBaseDefinition() { throw new NotSupportedException(); }
#endregion
return m_ctor.GetParameterTypes();
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- internal override Type? GetReturnType()
+ internal override Type GetReturnType()
{
- return DeclaringType;
+ return m_type;
}
-#pragma warning restore CS8609
#region MemberInfo Overrides
public override MemberTypes MemberType { get { return m_ctor.MemberType; } }
public override bool IsSecuritySafeCritical { get { return DeclaringType!.IsSecuritySafeCritical; } }
public override bool IsSecurityTransparent { get { return DeclaringType!.IsSecurityTransparent; } }
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
public override object? GetValueDirect(TypedReference obj)
{
return GetValue(null);
}
-#pragma warning restore CS8609
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
return GetValue(false);
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override object? GetRawConstantValue() { return GetValue(true); }
-#pragma warning restore CS8609
private object? GetValue(bool raw)
{
public override object GetRawConstantValue() { throw new InvalidOperationException(); }
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
public override object? GetValueDirect(TypedReference obj)
return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType?)DeclaringType);
}
}
-#pragma warning restore CS8609
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
GetFlags() | AssemblyNameFlags.PublicKey,
null); // strong name key pair
- Module? manifestModule = ManifestModule;
+ Module manifestModule = ManifestModule;
if (manifestModule != null)
{
if (manifestModule.MDStreamVersion > 0x10000)
throw new PlatformNotSupportedException();
}
- public override Module? ManifestModule
+ public override Module ManifestModule
{
get
{
return RuntimeMethodHandle.InvokeMethod(obj, null, sig, false, wrapExceptions);
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override MethodBody? GetMethodBody()
{
RuntimeMethodBody? mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal);
mb._methodBase = this;
return mb;
}
-#pragma warning restore CS8609
public override bool IsSecurityCritical
{
}
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override MethodBody? GetMethodBody()
{
RuntimeMethodBody? mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal);
mb._methodBase = this;
return mb;
}
-#pragma warning restore CS8609
#endregion
get { return ReturnParameter; }
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
- public override ParameterInfo ReturnParameter
- {
- get
- {
- FetchReturnParameter();
- return (m_returnParameter as ParameterInfo)!;
- }
- }
-#pragma warning restore CS8609
+#pragma warning disable CS6809 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
+ public override ParameterInfo ReturnParameter => FetchReturnParameter();
+#pragma warning restore CS6809
public override bool IsCollectible => (RuntimeMethodHandle.GetIsCollectible(new RuntimeMethodHandleInternal(m_handle)) != Interop.BOOL.FALSE);
}
// ILHeader info
- internal abstract RuntimeType GetJitContext(out int securityControlFlags);
+ internal abstract RuntimeType? GetJitContext(out int securityControlFlags);
internal abstract byte[] GetCodeInfo(out int stackSize, out int initLocals, out int EHCount);
internal abstract byte[] GetLocalsSignature();
internal abstract unsafe void GetEHInfo(int EHNumber, void* exception);
- internal abstract byte[] GetRawEHInfo();
+ internal abstract byte[]? GetRawEHInfo();
// token resolution
- internal abstract string GetStringLiteral(int token);
+ internal abstract string? GetStringLiteral(int token);
internal abstract void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle);
- internal abstract byte[] ResolveSignature(int token, int fromMethod);
+ internal abstract byte[]? ResolveSignature(int token, int fromMethod);
//
internal abstract MethodInfo GetDynamicMethod();
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern int GetHashCodeOfPtr(IntPtr ptr);
- public override string ToString()
+ public override string? ToString()
{
return this.GetType().ToString();
}
if (!reflectionOnly && (staticFieldType == typeof(EventOpcode)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventOpcode)))
{
if (providerEnumKind != "Opcodes") goto Error;
- int value = (int)staticField.GetRawConstantValue();
+ int value = (int)staticField.GetRawConstantValue()!;
manifest.AddOpcode(staticField.Name, value);
}
else if (!reflectionOnly && (staticFieldType == typeof(EventTask)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventTask)))
{
if (providerEnumKind != "Tasks") goto Error;
- int value = (int)staticField.GetRawConstantValue();
+ int value = (int)staticField.GetRawConstantValue()!;
manifest.AddTask(staticField.Name, value);
}
else if (!reflectionOnly && (staticFieldType == typeof(EventKeywords)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventKeywords)))
{
if (providerEnumKind != "Keywords") goto Error;
- ulong value = unchecked((ulong)(long)staticField.GetRawConstantValue());
+ ulong value = unchecked((ulong)(long)staticField.GetRawConstantValue()!);
manifest.AddKeyword(staticField.Name, value);
}
#if FEATURE_MANAGED_ETW_CHANNELS && FEATURE_ADVANCED_MANAGED_ETW_CHANNELS
#if ES_BUILD_STANDALONE
(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert();
#endif
- byte[] instrs = method.GetMethodBody().GetILAsByteArray()!;
+ byte[] instrs = method.GetMethodBody()!.GetILAsByteArray()!;
int retVal = -1;
for (int idx = 0; idx < instrs.Length;)
{
bool anyValuesWritten = false;
foreach (FieldInfo staticField in staticFields)
{
- object constantValObj = staticField.GetRawConstantValue();
+ object? constantValObj = staticField.GetRawConstantValue();
if (constantValObj != null)
{
return hasValue ? value.GetHashCode() : 0;
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override string? ToString()
{
return hasValue ? value.ToString() : "";
}
-#pragma warning restore CS8609
[NonVersionable]
public static implicit operator Nullable<T>(T value)
public virtual event ModuleResolveEventHandler ModuleResolve { add { throw NotImplemented.ByDesign; } remove { throw NotImplemented.ByDesign; } }
- public virtual Module? ManifestModule { get { throw NotImplemented.ByDesign; } }
+ public virtual Module ManifestModule { get { throw NotImplemented.ByDesign; } }
public virtual Module? GetModule(string name) { throw NotImplemented.ByDesign; }
public Module[] GetModules() => GetModules(getResourceModules: false);
if (this.Name == null)
return string.Empty;
// Do not call GetPublicKeyToken() here - that latches the result into AssemblyName which isn't a side effect we want.
- byte[] pkt = _publicKeyToken ?? ComputePublicKeyToken();
+ byte[]? pkt = _publicKeyToken ?? ComputePublicKeyToken();
return AssemblyNameFormatter.ComputeDisplayName(Name, Version, CultureName, pkt, Flags, ContentType);
}
}
public override string ToString()
{
if (m_memberInfo == null)
- return base.ToString();
+ return base.ToString()!;
return string.Format("{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object)));
}
internal string ToString(bool typed)
{
if (m_argumentType == null)
- return base.ToString();
+ return base.ToString()!;
if (ArgumentType.IsEnum)
return string.Format(typed ? "{0}" : "({1}){0}", Value, ArgumentType.FullName);
return Value;
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override string? ToString()
{
return Name;
}
-#pragma warning restore CS8609
}
}
[CLSCompliant(false)]
public virtual void SetValueDirect(TypedReference obj, object value) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); }
[CLSCompliant(false)]
- public virtual object GetValueDirect(TypedReference obj) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); }
+ public virtual object? GetValueDirect(TypedReference obj) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); }
- public virtual object GetRawConstantValue() { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); }
+ public virtual object? GetRawConstantValue() { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); }
public virtual Type[] GetOptionalCustomModifiers() { throw NotImplemented.ByDesign; }
public virtual Type[] GetRequiredCustomModifiers() { throw NotImplemented.ByDesign; }
public abstract MethodAttributes Attributes { get; }
public virtual MethodImplAttributes MethodImplementationFlags => GetMethodImplementationFlags();
public abstract MethodImplAttributes GetMethodImplementationFlags();
- public virtual MethodBody GetMethodBody() { throw new InvalidOperationException(); }
+ public virtual MethodBody? GetMethodBody() { throw new InvalidOperationException(); }
public virtual CallingConventions CallingConvention => CallingConventions.Standard;
public bool IsAbstract => (Attributes & MethodAttributes.Abstract) != 0;
#if PROJECTN
[DependencyReductionRoot]
#endif
- internal abstract Delegate[] GetDelegateContinuationsForDebugger();
+ internal abstract Delegate[]? GetDelegateContinuationsForDebugger();
}
/// <summary>Provides the standard implementation of a task continuation.</summary>
else continuationTask.InternalCancel(false);
}
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
internal override Delegate[]? GetDelegateContinuationsForDebugger()
{
if (m_task.m_action == null)
return new Delegate[] { m_task.m_action };
}
-#pragma warning restore CS8609
}
public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext) =>
new ConfiguredValueTaskAwaitable<TResult>(new ValueTask<TResult>(_obj, _result, _token, continueOnCapturedContext));
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
/// <summary>Gets a string-representation of this <see cref="ValueTask{TResult}"/>.</summary>
public override string? ToString()
{
return string.Empty;
}
-#pragma warning restore CS8609
}
}
for (int i = 0; i < flds.Length; i++)
{
names[i] = flds[i].Name;
- values[i] = flds[i].GetRawConstantValue();
+ values[i] = flds[i].GetRawConstantValue()!;
}
// Insertion Sort these values in ascending order.