Skip to content

Commit

Permalink
Fix nullability warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Jan 8, 2025
1 parent 0f5d1bd commit 59536a2
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/Destructurama.Attributed.Tests/MetadataTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,49 +160,54 @@ public void Private_Property_Should_Be_Handled()
}

#region Simple Metadata

/// <summary>
/// Simple Metadata Sample
/// </summary>
[MetadataType(typeof(DtoMetadata))]
private partial class Dto
{
public string Private { get; set; }
public string? Private { get; set; }

public string Public { get; set; }
public string? Public { get; set; }
}

private class DtoMetadata
{
[NotLogged]
public object Private { get; set; }
public object? Private { get; set; }
}

#endregion

#region Metadata with derived subclass

/// <summary>
/// Metadata Sample with derived subclass
/// </summary>
[MetadataType(typeof(DtoMetadataDerived))]
private partial class DtoWithDerived
{
public string Private { get; set; }
public string? Private { get; set; }

public string Public { get; set; }
public string? Public { get; set; }
}

private class DtoMetadataBase
{
public object Public { get; set; }
public object? Public { get; set; }
}

private class DtoMetadataDerived : DtoMetadataBase
{
[NotLogged]
public object Private { get; set; }
public object? Private { get; set; }
}

#endregion

#region Attributed With Mask in MetadataType

[MetadataType(typeof(AttributedWithMaskMetaData))]
private class AttributedWithMask
{
Expand All @@ -214,14 +219,16 @@ private class AttributedWithMask
private class AttributedWithMaskMetaData
{
[LogMasked(ShowFirst = 3)]
public object String { get; set; }
public object? String { get; set; }

[LogMasked(ShowFirst = 3)]
public object Object { get; set; }
public object? Object { get; set; }
}

#endregion

#region All Attributes visited
#region All Attributes visited

/// <summary>
/// Attribute on class in Metadatatype
/// </summary>
Expand Down Expand Up @@ -265,33 +272,33 @@ public class CustomizedMeta
public NotAScalar? NotAScalar { get; set; }

[NotLogged]
public object Ignored { get; set; }
public object? Ignored { get; set; }

[LogPropertyIgnore]
public object Ignored2 { get; set; }
public object? Ignored2 { get; set; }

[LogAsScalar]
public object ScalarAnyway { get; set; }
public object? ScalarAnyway { get; set; }
public UserAuthData? AuthData { get; set; }

[LogAsScalar]
public object Struct1 { get; set; }
public object? Struct1 { get; set; }

public object Struct2 { get; set; }
public object? Struct2 { get; set; }

[LogAsScalar(isMutable: true)]
public object StructReturningNull { get; set; }
public object? StructReturningNull { get; set; }

[LogAsScalar(isMutable: true)]
public object StructNull { get; set; }
public object? StructNull { get; set; }
}

public class UserAuthDataMeta
{
public object Username { get; set; }
public object? Username { get; set; }

[NotLogged]
public object Password { get; set; }
public object? Password { get; set; }
}

[MetadataType(typeof(UserAuthDataMeta))]
Expand Down Expand Up @@ -319,19 +326,22 @@ public struct StructReturningNull
public int SomeProperty { get; set; }
public override string ToString() => null!;
}

#endregion

#region Private

public class ClassWithPrivatePropertyMeta
{
[LogMasked]
private object Name { get; set; }
private object? Name { get; set; }
}

[MetadataType(typeof(ClassWithPrivatePropertyMeta))]
public class ClassWithPrivateProperty
{
private string? Name { get; set; } = "Tom";
}

#endregion
}

0 comments on commit 59536a2

Please sign in to comment.