Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
safern committed Jun 4, 2019
1 parent 4adb4ab commit 6fa8467
Show file tree
Hide file tree
Showing 30 changed files with 41 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3521,19 +3521,19 @@ private static void AddProviderEnumKind(ManifestBuilder manifest, FieldInfo stat
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
Expand Down Expand Up @@ -3730,7 +3730,7 @@ private static int GetHelperCallFirstArg(MethodInfo method)
#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;)
{
Expand Down Expand Up @@ -5828,7 +5828,7 @@ private string CreateManifestString()
bool anyValuesWritten = false;
foreach (FieldInfo staticField in staticFields)
{
object constantValObj = staticField.GetRawConstantValue();
object? constantValObj = staticField.GetRawConstantValue();

if (constantValObj != null)
{
Expand Down
2 changes: 0 additions & 2 deletions src/System.Private.CoreLib/shared/System/Nullable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ public override int GetHashCode()
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public virtual Type[] GetTypes()

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public string FullName
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public CustomAttributeNamedArgument(MemberInfo memberInfo, CustomAttributeTypedA
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)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public CustomAttributeTypedArgument(object value)
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,9 @@ public override int GetHashCode()
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ protected FieldInfo() { }
[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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected MethodBase() { }
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected static void InlineIfPossibleOrElseQueue(Task task, bool needsProtectio
#if PROJECTN
[DependencyReductionRoot]
#endif
internal abstract Delegate[] GetDelegateContinuationsForDebugger();
internal abstract Delegate[]? GetDelegateContinuationsForDebugger();
}

/// <summary>Provides the standard implementation of a task continuation.</summary>
Expand Down Expand Up @@ -341,7 +341,6 @@ internal override void Run(Task completedTask, bool canInlineContinuationTask)
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)
Expand All @@ -351,7 +350,6 @@ internal override void Run(Task completedTask, bool canInlineContinuationTask)

return new Delegate[] { m_task.m_action };
}
#pragma warning restore CS8609

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ public TResult Result
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()
{
Expand All @@ -791,6 +790,5 @@ public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCaptu

return string.Empty;
}
#pragma warning restore CS8609
}
}
4 changes: 2 additions & 2 deletions src/System.Private.CoreLib/shared/System/Type.Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace System
{
//
//124
// This file collects a set of Enum-related apis that run when the Type is subclassed by an application.
// None of it runs on normal Type objects supplied by the runtime (as those types override these methods.)
//
Expand Down Expand Up @@ -121,7 +121,7 @@ private void GetEnumData(out string[] enumNames, out Array enumValues)
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal static AssemblyName GetFileInformationCore(string assemblyFile)
}

[MethodImpl(MethodImplOptions.InternalCall)]
private extern byte[] ComputePublicKeyToken();
private extern byte[]? ComputePublicKeyToken();

internal void SetProcArchIndex(PortableExecutableKinds pek, ImageFileMachine ifm)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeAs

// 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public override FileStream[] GetFiles(bool getResourceModules)
return InternalAssembly.GetType(name, throwOnError, ignoreCase);
}

public override Module? ManifestModule => _manifestModuleBuilder.InternalModule;
public override Module ManifestModule => _manifestModuleBuilder.InternalModule;

public override bool ReflectionOnly => InternalAssembly.ReflectionOnly;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,10 @@ public Module GetModule()
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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,10 @@ internal override byte[] GetLocalsSignature()
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)
{
Expand All @@ -770,10 +768,7 @@ 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)
{
Expand Down Expand Up @@ -839,12 +834,10 @@ internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr
}
}

#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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,7 @@ internal MethodBuilder(string name, MethodAttributes attributes, CallingConventi
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)
{
Expand Down Expand Up @@ -649,9 +640,7 @@ public override bool IsDefined(Type attributeType, bool inherit)

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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override Type 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public virtual void SetConstant(object? defaultValue)
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed class SymbolMethod : MethodInfo
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;
Expand All @@ -33,7 +33,7 @@ internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, str
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];
Expand Down Expand Up @@ -118,15 +118,15 @@ public override RuntimeMethodHandle MethodHandle
#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
{
return m_returnType;
}
}

#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
public override ICustomAttributeProvider? ReturnTypeCustomAttributes
{
get { return null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,7 @@ public override Type MakeGenericType(params Type[] typeArguments)
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override MethodInfo MakeGenericMethod(params Type[] typeArgs)

#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
Expand Down Expand Up @@ -110,12 +110,10 @@ internal override Type[] GetParameterTypes()
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; } }
Expand Down
Loading

0 comments on commit 6fa8467

Please sign in to comment.