From 12d85325c644b404625a499cd04d9095357d6f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9F=D0=B0=D0=BD=D0=B0=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 11 Aug 2026 17:04:08 +0300 Subject: [PATCH] Define the polyfills of DynamicallyAccessedMembers only where they are missing Both DynamicallyAccessedMembersAttribute and DynamicallyAccessedMemberTypes were compiled for every target framework below .NET 8. Both types exist since .NET 5, so compiling the sources for .NET 6 or .NET 7 fails with CS0433, because the type exists in PdfSharp.Shared and in System.Runtime. They are now compiled for .NET Framework 4.6.2 and .NET Standard 2.0 only, which is where they are really missing. The target frameworks PDFsharp is built for are not affected. --- .../src/shared/src/PdfSharp.Shared/dotnet/CodeAnalysis.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/foundation/src/shared/src/PdfSharp.Shared/dotnet/CodeAnalysis.cs b/src/foundation/src/shared/src/PdfSharp.Shared/dotnet/CodeAnalysis.cs index 116c6a85..899baff5 100644 --- a/src/foundation/src/shared/src/PdfSharp.Shared/dotnet/CodeAnalysis.cs +++ b/src/foundation/src/shared/src/PdfSharp.Shared/dotnet/CodeAnalysis.cs @@ -3,7 +3,10 @@ namespace System.Diagnostics.CodeAnalysis { -#if !NET8_0_OR_GREATER +// These types exist since .NET 5, so they must only be defined for the frameworks that do not have them. +// A build for .NET 6 or .NET 7 fails with CS0433 (type exists in two assemblies) if the condition is +// '!NET8_0_OR_GREATER'. +#if NET462 || NETSTANDARD2_0 /// /// Indicates that certain members on a specified are accessed dynamically, /// for example through .