Skip to content

Commit b84bca5

Browse files
committed
Fix nullable annotations for IPropertyDescriptor.GetCustomAttribute
1 parent 96e1988 commit b84bca5

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

YamlDotNet/Serialization/IPropertyDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface IPropertyDescriptor
3333
int Order { get; set; }
3434
ScalarStyle ScalarStyle { get; set; }
3535

36-
T GetCustomAttribute<T>() where T : Attribute;
36+
T? GetCustomAttribute<T>() where T : Attribute;
3737

3838
IObjectDescriptor Read(object target);
3939
void Write(object target, object? value);

YamlDotNet/Serialization/PropertyDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void Write(object target, object? value)
6262
baseDescriptor.Write(target, value);
6363
}
6464

65-
public T GetCustomAttribute<T>() where T : Attribute
65+
public T? GetCustomAttribute<T>() where T : Attribute
6666
{
6767
return baseDescriptor.GetCustomAttribute<T>();
6868
}

YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public void Write(object target, object? value)
7070
fieldInfo.SetValue(target, value);
7171
}
7272

73-
public T GetCustomAttribute<T>() where T : Attribute
73+
public T? GetCustomAttribute<T>() where T : Attribute
7474
{
7575
var attributes = fieldInfo.GetCustomAttributes(typeof(T), true);
76-
return (T)attributes.FirstOrDefault();
76+
return (T?)attributes.FirstOrDefault();
7777
}
7878

7979
public IObjectDescriptor Read(object target)

YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public void Write(object target, object? value)
8484
propertyInfo.SetValue(target, value, null);
8585
}
8686

87-
public T GetCustomAttribute<T>() where T : Attribute
87+
public T? GetCustomAttribute<T>() where T : Attribute
8888
{
8989
var attributes = propertyInfo.GetAllCustomAttributes<T>();
90-
return (T)attributes.FirstOrDefault();
90+
return (T?)attributes.FirstOrDefault();
9191
}
9292

9393
public IObjectDescriptor Read(object target)

YamlDotNet/Serialization/TypeInspectors/WritablePropertiesTypeInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ public void Write(object target, object? value)
8585
propertyInfo.SetValue(target, value, null);
8686
}
8787

88-
public T GetCustomAttribute<T>() where T : Attribute
88+
public T? GetCustomAttribute<T>() where T : Attribute
8989
{
9090
var attributes = propertyInfo.GetAllCustomAttributes<T>();
91-
return (T)attributes.FirstOrDefault();
91+
return (T?)attributes.FirstOrDefault();
9292
}
9393

9494
public IObjectDescriptor Read(object target)

YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void Write(object target, object? value)
9595
baseDescriptor.Write(target, value);
9696
}
9797

98-
public T GetCustomAttribute<T>() where T : Attribute
98+
public T? GetCustomAttribute<T>() where T : Attribute
9999
{
100100
var attr = overrides.GetAttribute<T>(classType, Name);
101101
return attr ?? baseDescriptor.GetCustomAttribute<T>();

0 commit comments

Comments
 (0)