Skip to content

Commit

Permalink
Fix OAuth Serializer (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions authored Jan 13, 2025
1 parent d12a2f7 commit 822196d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "OAuth Start",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_oauth",
"program": "${workspaceFolder}/samples/OAuth/bin/Debug/net9.0/OAuth.dll",
"args": [ "start" ],
"cwd": "${workspaceFolder}/samples/OAuth",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "FFSourceGen",
"type": "coreclr",
Expand Down
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
],
"problemMatcher": "$msCompile"
},
{
"label": "build_oauth",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/OAuth/OAuth.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build_bskycli",
"command": "dotnet",
Expand Down
2 changes: 1 addition & 1 deletion src/FishyFlip/OidcClient/Infrastructure/LogSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static string Serialize(object logObject)
private static string Serialize<T>(T logObject)
{
return Enabled ?
JsonSerializer.Serialize(logObject, (JsonTypeInfo<T>)SourceGenerationContext.Default.GetTypeInfo(typeof(T))!) :
JsonSerializer.Serialize(logObject, (JsonTypeInfo<T>)IdentityModel.OidcClient.OidcClientSourceGenerationContext.Default.GetTypeInfo(typeof(T))!) :
"Logging has been disabled";
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/FishyFlip/OidcClient/OidcClientSourceGenerationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="OidcClientSourceGenerationContext.cs" company="Drastic Actions">
// Copyright (c) Drastic Actions. All rights reserved.
// </copyright>

using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace IdentityModel.OidcClient
{
/// <summary>
/// Source generation context for OidcClient.
/// </summary>
[JsonSourceGenerationOptions(
WriteIndented = false,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
GenerationMode = JsonSourceGenerationMode.Metadata,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(AuthorizeState))]
[JsonSerializable(typeof(Dictionary<string, JsonElement>))]
[JsonSerializable(typeof(OidcClientOptions))]
internal partial class OidcClientSourceGenerationContext : JsonSerializerContext
{
}
}

0 comments on commit 822196d

Please sign in to comment.