Skip to content

Trimming warning in JsonSerializationWriter due to call to 'System.Object.GetType()' #475

@andrueastman

Description

@andrueastman

The call to object.GetType() in the line below generates a trim warning.

foreach(var oProp in value.GetType().GetProperties())

The warning is as seen in this PR - microsoftgraph/msgraph-sdk-dotnet-core#939

ILC : Trim analysis error IL2075: Microsoft.Kiota.Serialization.Json.JsonSerializationWriter.WriteNonParsableObjectValue(String,!!0): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

The trim warning could be alleviated using typeof(T) instead of object.GetType(), however, this would break currently supported serialization of types unknown at compile time(such as when a non parsable object is placed in the AdditionalData bag.)

For now, we probably need to

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p2Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 daystype: bugA broken experience

    Type

    Projects

    Status

    New📃

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions