Skip to content

Update pragma warning disables to SuppressMessage attributes#636

Merged
gregsdennis merged 8 commits into
json-everything:native-aotfrom
jevansaks:naot-suppressmessage
Jan 29, 2024
Merged

Update pragma warning disables to SuppressMessage attributes#636
gregsdennis merged 8 commits into
json-everything:native-aotfrom
jevansaks:naot-suppressmessage

Conversation

@jevansaks

Copy link
Copy Markdown
Contributor

The downstream AOT callers can't see our #pragma warning disables. Need to use attributes so that people compiled against the library don't get messages about things we suppressed.

@Sergio0694 can you take a peek too?

Comment thread Json.More/JsonSerializerOptionsExtensions.cs Outdated
Comment thread JsonSchema.CodeGeneration/JsonSchema.CodeGeneration.csproj Outdated
Comment thread Json.More/JsonSerializerOptionsExtensions.cs
Comment thread JsonSchema.OpenApi/DiscriminatorKeyword.cs
Comment thread JsonSchema.OpenApi/ExternalDocsKeyword.cs
Comment thread JsonSchema.OpenApi/XmlKeyword.cs
@gregsdennis gregsdennis merged commit 2ded6ab into json-everything:native-aot Jan 29, 2024
public static JsonConverter<T> GetConverter<T>(this JsonSerializerOptions options, JsonTypeInfo? typeInfo = null)
public static JsonConverter<T> GetConverter<T>(this JsonSerializerOptions options, JsonTypeInfo? typeInfo)
{
#if NET8_0_OR_GREATER

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that targets older than 8.0 ignore the typeInfo argument?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, .Net Standard's version doesn't have a .Converter property on JsonTypeInfo, so we need to just get it off of the options.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Would it make sense to add a debug assertion?

Debug.Assert(typeInfo is null || typeInfo.Options == options);

Or perhaps even make it a runtime check given that it's public API?

Comment thread Json.More/JsonSerializerOptionsExtensions.cs
@jevansaks jevansaks mentioned this pull request Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants