Remove S.S.Permissions reference from S.C.ConfigurationManager (#82259)
authorSteve Harter <steveharter@users.noreply.github.com>
Wed, 8 Mar 2023 14:02:23 +0000 (08:02 -0600)
committerGitHub <noreply@github.com>
Wed, 8 Mar 2023 14:02:23 +0000 (08:02 -0600)
src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs
src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.csproj
src/libraries/System.Configuration.ConfigurationManager/src/System.Configuration.ConfigurationManager.csproj
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/DelegatingConfigHost.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/IInternalConfigHost.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigHost.cs
src/libraries/testPackages/packageSettings/System.Configuration.ConfigurationManager/netstandard/settings.targets [new file with mode: 0644]
src/libraries/testPackages/packageSettings/System.Runtime.Caching/netstandard/settings.targets [new file with mode: 0644]

index 6d21ab5..7ef3558 100644 (file)
@@ -1383,9 +1383,8 @@ namespace System.Configuration.Internal
         public virtual string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath) { throw null; }
         public virtual System.Type GetConfigType(string typeName, bool throwOnError) { throw null; }
         public virtual string GetConfigTypeName(System.Type t) { throw null; }
-#pragma warning disable SYSLIB0003
+        [System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
         public virtual void GetRestrictedPermissions(System.Configuration.Internal.IInternalConfigRecord configRecord, out System.Security.PermissionSet permissionSet, out bool isHostReady) { throw null; }
-#pragma warning restore SYSLIB0003
         public virtual string GetStreamName(string configPath) { throw null; }
         public virtual string GetStreamNameForConfigSource(string streamName, string configSource) { throw null; }
         public virtual object GetStreamVersion(string streamName) { throw null; }
@@ -1473,9 +1472,8 @@ namespace System.Configuration.Internal
         string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath);
         System.Type GetConfigType(string typeName, bool throwOnError);
         string GetConfigTypeName(System.Type t);
-#pragma warning disable SYSLIB0003
+        [System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
         void GetRestrictedPermissions(System.Configuration.Internal.IInternalConfigRecord configRecord, out System.Security.PermissionSet permissionSet, out bool isHostReady);
-#pragma warning restore SYSLIB0003
         string GetStreamName(string configPath);
         string GetStreamNameForConfigSource(string streamName, string configSource);
         object GetStreamVersion(string streamName);
index bd9eab3..cdd04d9 100644 (file)
@@ -3,6 +3,7 @@
     <TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
     <Nullable>disable</Nullable>
     <NoWarn>$(NoWarn);CS0618</NoWarn>
+    <IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
   </PropertyGroup>
 
   <ItemGroup>
@@ -12,8 +13,9 @@
     <Compile Include="System.Configuration.ConfigurationManager.netframework.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\ref\System.Security.Permissions.csproj" />
+  <!-- This reference is for the System.Security.PermissionSet class, which is implemented in corelib, so the reference is only necessary for netstandard. -->
+  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\ref\System.Security.Permissions.csproj" PrivateAssets="all" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
index dae0fa1..7463343 100644 (file)
@@ -6,6 +6,7 @@
     <!-- opt-out of trimming until it works https://github.com/dotnet/runtime/issues/49062 -->
     <IsTrimmable>false</IsTrimmable>
     <EnableAOTAnalyzer>false</EnableAOTAnalyzer>
+    <IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
     <IsPackable>true</IsPackable>
     <PackageDescription>Provides types that support using XML configuration files (app.config). This package exists only to support migrating existing .NET Framework code that already uses System.Configuration. When writing new code, use another configuration system instead, such as Microsoft.Extensions.Configuration.</PackageDescription>
   </PropertyGroup>
     <Compile Include="System\Diagnostics\TraceUtils.cs" />
   </ItemGroup>
 
-  <!-- Since this package is compatible with .NETStandard, it must also ensure its .NETFramework and .NETCoreApp behavior is compatible with its .NETStandard behavior.-->
-  <ItemGroup>
-    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\src\System.Security.Permissions.csproj" />
+  <!-- This reference is for the System.Security.PermissionSet class, which is implemented in corelib, so the reference is only necessary for netstandard. -->
+  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
+    <ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\src\System.Security.Permissions.csproj" PrivateAssets="all" />
   </ItemGroup>
 
   <ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
index 46e588c..5f26c3d 100644 (file)
@@ -231,12 +231,11 @@ namespace System.Configuration.Internal
 
         public virtual IDisposable Impersonate() => new DummyDisposable();
 
-#pragma warning disable SYSLIB0003 // Obsolete: CAS
+        [System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
         public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
         {
             permissionSet = new PermissionSet(null);
             isHostReady = true;
         }
-#pragma warning restore SYSLIB0003 // Obsolete: CAS
     }
 }
index b03989b..835e424 100644 (file)
@@ -103,8 +103,7 @@ namespace System.Configuration.Internal
 
         IDisposable Impersonate();
 
-#pragma warning disable SYSLIB0003 // Obsolete: CAS
+        [System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
         void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady);
-#pragma warning restore SYSLIB0003 // Obsolete: CAS
     }
 }
index 52a7360..a70d387 100644 (file)
@@ -304,12 +304,11 @@ namespace System.Configuration.Internal
 
         public IDisposable Impersonate() => new DummyDisposable();
 
-#pragma warning disable SYSLIB0003
+        [System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
         public void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
         {
             permissionSet = new PermissionSet(null);
             isHostReady = true;
         }
-#pragma warning restore SYSLIB0003
     }
 }
diff --git a/src/libraries/testPackages/packageSettings/System.Configuration.ConfigurationManager/netstandard/settings.targets b/src/libraries/testPackages/packageSettings/System.Configuration.ConfigurationManager/netstandard/settings.targets
new file mode 100644 (file)
index 0000000..2b22505
--- /dev/null
@@ -0,0 +1,6 @@
+<Project>
+  <ItemGroup>
+    <!-- intentional dangling ref -->
+    <IgnoredReference Include="System.Security.Permissions" />
+  </ItemGroup>
+</Project>
diff --git a/src/libraries/testPackages/packageSettings/System.Runtime.Caching/netstandard/settings.targets b/src/libraries/testPackages/packageSettings/System.Runtime.Caching/netstandard/settings.targets
new file mode 100644 (file)
index 0000000..9a2d7cd
--- /dev/null
@@ -0,0 +1,6 @@
+<Project>
+  <ItemGroup>
+    <!-- intentional dangling ref in System.Configuration.ConfigurationManager -->
+    <IgnoredReference Include="System.Security.Permissions" />
+  </ItemGroup>
+</Project>