Skip to content

Commit

Permalink
Fix contructor attributes nullability in S.R.E.CustomAttributeBuilder (
Browse files Browse the repository at this point in the history
…#34556)

* Fix contructor attributes nullability in S.R.E.CustomAttributeBuilder

Fixes #819

* Finalise nullable

* Updates ref
  • Loading branch information
marcusturewicz authored Apr 6, 2020
1 parent 9a58ab8 commit f0e5bcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs)
// public constructor to form the custom attribute with constructor, constructor
// parameters and named properties.
public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
PropertyInfo[] namedProperties, object[] propertyValues)
PropertyInfo[] namedProperties, object?[] propertyValues)
{
InitCustomAttributeBuilder(con, constructorArgs, namedProperties,
propertyValues, Array.Empty<FieldInfo>(), Array.Empty<object>());
Expand All @@ -43,7 +43,7 @@ public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
// public constructor to form the custom attribute with constructor and constructor
// parameters.
public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
FieldInfo[] namedFields, object[] fieldValues)
FieldInfo[] namedFields, object?[] fieldValues)
{
InitCustomAttributeBuilder(con, constructorArgs, Array.Empty<PropertyInfo>(),
Array.Empty<object>(), namedFields, fieldValues);
Expand All @@ -52,8 +52,8 @@ public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
// public constructor to form the custom attribute with constructor and constructor
// parameters.
public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
PropertyInfo[] namedProperties, object[] propertyValues,
FieldInfo[] namedFields, object[] fieldValues)
PropertyInfo[] namedProperties, object?[] propertyValues,
FieldInfo[] namedFields, object?[] fieldValues)
{
InitCustomAttributeBuilder(con, constructorArgs, namedProperties,
propertyValues, namedFields, fieldValues);
Expand Down Expand Up @@ -97,8 +97,8 @@ private bool ValidateType(Type t)
}

internal void InitCustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs,
PropertyInfo[] namedProperties, object[] propertyValues,
FieldInfo[] namedFields, object[] fieldValues)
PropertyInfo[] namedProperties, object?[] propertyValues,
FieldInfo[] namedFields, object?[] fieldValues)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
Expand Down Expand Up @@ -183,7 +183,7 @@ internal void InitCustomAttributeBuilder(ConstructorInfo con, object?[] construc

// Allow null for non-primitive types only.
Type propType = property.PropertyType;
object propertyValue = propertyValues[i];
object? propertyValue = propertyValues[i];
if (propertyValue == null && propType.IsValueType)
throw new ArgumentNullException("propertyValues[" + i + "]");

Expand Down Expand Up @@ -241,7 +241,7 @@ internal void InitCustomAttributeBuilder(ConstructorInfo con, object?[] construc

// Allow null for non-primitive types only.
Type fldType = namedField.FieldType;
object fieldValue = fieldValues[i];
object? fieldValue = fieldValues[i];
if (fieldValue == null && fldType.IsValueType)
throw new ArgumentNullException("fieldValues[" + i + "]");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace System.Reflection.Emit
public partial class CustomAttributeBuilder
{
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues) { }
public CustomAttributeBuilder(System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { }
}
public partial class ILGenerator
{
Expand Down

0 comments on commit f0e5bcd

Please sign in to comment.