다음을 통해 공유


SYSLIB1039: JsonSourceGenerator에서 JsonSourceGenerationMode.Serialization을 사용하도록 설정된 JsonDerivedTypeAttribute 주석이 발견됨

JsonDerivedTypeAttribute 주석은 원본 생성에 지원되지만 JsonSourceGenerationMode.Serialization 주석이 추가된 컨텍스트에는 지원되지 않습니다. 즉, 특성은 메타데이터 원본 생성기에서 작동하지만 빠른 경로 메서드에서는 작동하지 않습니다.

해결 방법

특성을 제거하거나 직렬화 컨텍스트에서 JsonSourceGenerationMode.Serialization 주석을 제거합니다.

경고 표시 안 함

가능한 경우 해결 방법 중 하나를 사용하는 것이 좋습니다. 그러나 코드를 변경할 수 없는 경우 #pragma 지시문 또는 <NoWarn> 프로젝트 설정을 통해 경고를 표시하지 않을 수 있습니다. SYSLIB1XXX 소스 생성기 진단이 오류로 표시되지 않으면 코드 또는 프로젝트 파일에서 경고를 표시하지 않을 수 있습니다.

코드에서 경고를 표시하지 않으려면 다음을 수행합니다.

// Disable the warning.
#pragma warning disable SYSLIB1006

// Code that generates compiler diagnostic.
// ...

// Re-enable the warning.
#pragma warning restore SYSLIB1006

프로젝트 파일에서 경고를 표시하지 않으려면 다음을 수행합니다.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   <TargetFramework>net6.0</TargetFramework>
   <!-- NoWarn below suppresses SYSLIB1002 project-wide -->
   <NoWarn>$(NoWarn);SYSLIB1002</NoWarn>
   <!-- To suppress multiple warnings, you can use multiple NoWarn elements -->
   <NoWarn>$(NoWarn);SYSLIB1002</NoWarn>
   <NoWarn>$(NoWarn);SYSLIB1006</NoWarn>
   <!-- Alternatively, you can suppress multiple warnings by using a semicolon-delimited list -->
   <NoWarn>$(NoWarn);SYSLIB1002;SYSLIB1006;SYSLIB1007</NoWarn>
  </PropertyGroup>
</Project>