원클릭으로
dotnet-json-polymorphic
Configures polymorphic JSON serialization with [JsonPolymorphic] and [JsonDerivedType] attributes
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Configures polymorphic JSON serialization with [JsonPolymorphic] and [JsonDerivedType] attributes
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Analyzes and configures a .NET project or solution for Native AOT compatibility. Orchestrates source generator skills and applies AOT settings.
Converts a .NET solution to use Central Package Management (CPM). Use when the user wants to centralize, consolidate, or unify NuGet package versions across projects.
Enables tab autocomplete for the dotnet CLI. Use when the user wants to set up shell completion for dotnet commands.
Enables the Microsoft Testing Platform runner in global.json. Use when the user wants to enable or migrate to the new .NET testing platform.
Configures System.Text.Json source generation for AOT-compatible JSON serialization
Converts logging to use the LoggerMessage source generator for high-performance, AOT-compatible logging. Use when the user wants to optimize logging or organize log messages.
| name | dotnet-json-polymorphic |
| description | Configures polymorphic JSON serialization with [JsonPolymorphic] and [JsonDerivedType] attributes |
| license | MIT |
| metadata | {"author":"Im5tu","version":"1.0","repositoryUrl":"https://github.com/im5tu/dotnet-skills"} |
| allowed-tools | Bash(dotnet:*) Read Glob Grep AskUserQuestion |
Configure polymorphic JSON serialization using [JsonPolymorphic] and [JsonDerivedType] attributes for type-safe inheritance hierarchies.
TypeNameHandling with modern attributesAsk scope:
Search for existing [JsonPolymorphic] attributes:
TypeDiscriminatorPropertyName values foundExtract discriminator conventions:
TypeDiscriminatorPropertyName in existing attributesFind polymorphic candidates:
Ask about discriminator property name:
$type, Found: [list existing])"Check for consistency:
Apply attributes to base types:
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(DerivedA), typeDiscriminator: "DerivedA")]
[JsonDerivedType(typeof(DerivedB), typeDiscriminator: "DerivedB")]
public abstract class BaseClass
{
}
"WeatherForecastWithCity")Add using directive:
using System.Text.Json.Serialization; is presentVerify with build:
dotnet build
Report results:
Before:
public abstract class Notification
{
public string Message { get; set; }
}
public class EmailNotification : Notification
{
public string EmailAddress { get; set; }
}
public class SmsNotification : Notification
{
public string PhoneNumber { get; set; }
}
After:
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(EmailNotification), typeDiscriminator: "EmailNotification")]
[JsonDerivedType(typeof(SmsNotification), typeDiscriminator: "SmsNotification")]
public abstract class Notification
{
public string Message { get; set; }
}
public class EmailNotification : Notification
{
public string EmailAddress { get; set; }
}
public class SmsNotification : Notification
{
public string PhoneNumber { get; set; }
}
JSON Output:
{
"$type": "EmailNotification",
"message": "Hello",
"emailAddress": "user@example.com"
}
JsonSerializer.Serialize<Notification>(emailNotification))[JsonPolymorphic] attribute if it has derived types[JsonPolymorphic] when they define the contract for serialization