Move XamlAccessLevel to System.Windows.Extensions.dll
authorVatsan Madhavan <vatsan.madhavan@microsoft.com>
Wed, 3 Jul 2019 23:27:05 +0000 (16:27 -0700)
committerJeremy Barton <jbarton@microsoft.com>
Wed, 3 Jul 2019 23:27:05 +0000 (16:27 -0700)
WPF needs continued access to XamlAccessLevel type. System.Xaml.Permissions.XamlLoadPermission also needs to use XamlAccessLevel.

WPF is trying to remove its references to System.Security.Permissions. In order to complete this work, XamlAccessLevel is being moved to System.Windows.Extensions.dll (while leaving XamlLoadPermission in System.Permission.dll as-is). This will allow WindowsDesktop.App to bundle System.Windows.Extensions.dll (but not carry System.Security.Permissions.dll).

Commit migrated from https://github.com/dotnet/corefx/commit/758b1bfe0693801c3ac3e1b3b103a3b5e64be14a

13 files changed:
src/libraries/System.Security.Permissions/ref/System.Security.Permissions.Forwards.cs
src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs
src/libraries/System.Security.Permissions/ref/System.Security.Permissions.csproj
src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs [new file with mode: 0644]
src/libraries/System.Security.Permissions/src/System.Security.Permissions.csproj
src/libraries/System.Security.Permissions/tests/PermissionTests.cs
src/libraries/System.Security.Permissions/tests/System.Security.Permissions.Tests.csproj
src/libraries/System.Security.Permissions/tests/XamlLoadPermissionTests.cs [new file with mode: 0644]
src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs
src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj
src/libraries/System.Windows.Extensions/src/System/Xaml/Permissions/XamlAccessLevel.cs [moved from src/libraries/System.Security.Permissions/src/System/Xaml/Permissions/XamlAccessLevel.cs with 96% similarity]
src/libraries/System.Windows.Extensions/tests/System.Windows.Extensions.Tests.csproj
src/libraries/System.Windows.Extensions/tests/XamlAccessLevelTests.cs [moved from src/libraries/System.Security.Permissions/tests/XamlAccessLevelTests.cs with 93% similarity]

index 6b9b7f4..6183ea3 100644 (file)
@@ -18,3 +18,4 @@
 [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.PermissionSet))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Permissions.PermissionState))]
 #endif
+
index f38b82c..e862fa2 100644 (file)
@@ -2091,33 +2091,4 @@ namespace System.Web
         Unrestricted = 600,
     }
 }
-namespace System.Xaml.Permissions
-{
-    public partial class XamlAccessLevel
-    {
-        internal XamlAccessLevel() { }
-        public System.Reflection.AssemblyName AssemblyAccessToAssemblyName { get { throw null; } }
-        public string PrivateAccessToTypeName { get { throw null; } }
-        public static System.Xaml.Permissions.XamlAccessLevel AssemblyAccessTo(System.Reflection.Assembly assembly) { throw null; }
-        public static System.Xaml.Permissions.XamlAccessLevel AssemblyAccessTo(System.Reflection.AssemblyName assemblyName) { throw null; }
-        public static System.Xaml.Permissions.XamlAccessLevel PrivateAccessTo(string assemblyQualifiedTypeName) { throw null; }
-        public static System.Xaml.Permissions.XamlAccessLevel PrivateAccessTo(System.Type type) { throw null; }
-    }
-    public sealed partial class XamlLoadPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
-    {
-        public XamlLoadPermission(System.Collections.Generic.IEnumerable<System.Xaml.Permissions.XamlAccessLevel> allowedAccess) { }
-        public XamlLoadPermission(System.Security.Permissions.PermissionState state) { }
-        public XamlLoadPermission(System.Xaml.Permissions.XamlAccessLevel allowedAccess) { }
-        public System.Collections.Generic.IList<System.Xaml.Permissions.XamlAccessLevel> AllowedAccess { get { throw null; } }
-        public override System.Security.IPermission Copy() { throw null; }
-        public override bool Equals(object obj) { throw null; }
-        public override void FromXml(System.Security.SecurityElement elem) { }
-        public override int GetHashCode() { throw null; }
-        public bool Includes(System.Xaml.Permissions.XamlAccessLevel requestedAccess) { throw null; }
-        public override System.Security.IPermission Intersect(System.Security.IPermission target) { throw null; }
-        public override bool IsSubsetOf(System.Security.IPermission target) { throw null; }
-        public bool IsUnrestricted() { throw null; }
-        public override System.Security.SecurityElement ToXml() { throw null; }
-        public override System.Security.IPermission Union(System.Security.IPermission other) { throw null; }
-    }
-}
+
index d2b4c99..4372861 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{07CAF142-B259-418E-86EF-C4BD8B50253E}</ProjectGuid>
     <IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
@@ -9,6 +9,9 @@
     <Compile Include="System.Security.Permissions.Forwards.cs" />
     <SuppressPackageTargetFrameworkCompatibility Include="$(UAPvNextTFM)" />
   </ItemGroup>
+  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
+    <Compile Include="System.Security.Permissions.netcoreapp.cs" />
+  </ItemGroup>
   <ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
     <Reference Include="mscorlib" />
     <Reference Include="System" />
@@ -39,4 +42,7 @@
     <ProjectReference Include="..\..\System.Text.RegularExpressions\ref\System.Text.RegularExpressions.csproj" />
     <ProjectReference Include="..\..\System.Threading\ref\System.Threading.csproj" />
   </ItemGroup>
+  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
+    <ProjectReference Include="..\..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj" />
+  </ItemGroup>
 </Project>
diff --git a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs
new file mode 100644 (file)
index 0000000..5d3c1d7
--- /dev/null
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+// ------------------------------------------------------------------------------
+// Changes to this file must follow the http://aka.ms/api-review process.
+// ------------------------------------------------------------------------------
+
+namespace System.Xaml.Permissions
+{
+    public sealed partial class XamlLoadPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
+    {
+        public XamlLoadPermission(System.Collections.Generic.IEnumerable<System.Xaml.Permissions.XamlAccessLevel> allowedAccess) { }
+        public XamlLoadPermission(System.Security.Permissions.PermissionState state) { }
+        public XamlLoadPermission(System.Xaml.Permissions.XamlAccessLevel allowedAccess) { }
+        public System.Collections.Generic.IList<System.Xaml.Permissions.XamlAccessLevel> AllowedAccess { get { throw null; } }
+        public override System.Security.IPermission Copy() { throw null; }
+        public override bool Equals(object obj) { throw null; }
+        public override void FromXml(System.Security.SecurityElement elem) { }
+        public override int GetHashCode() { throw null; }
+        public bool Includes(System.Xaml.Permissions.XamlAccessLevel requestedAccess) { throw null; }
+        public override System.Security.IPermission Intersect(System.Security.IPermission target) { throw null; }
+        public override bool IsSubsetOf(System.Security.IPermission target) { throw null; }
+        public bool IsUnrestricted() { throw null; }
+        public override System.Security.SecurityElement ToXml() { throw null; }
+        public override System.Security.IPermission Union(System.Security.IPermission other) { throw null; }
+    }
+}
index 9d3ca6e..7498d59 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{07390899-C8F6-4E83-A3A9-6867B8CB46A0}</ProjectGuid>
     <RootNamespace>System.Security.Permissions</RootNamespace>
     <Compile Include="System\Web\AspNetHostingPermission.cs" />
     <Compile Include="System\Web\AspNetHostingPermissionAttribute.cs" />
     <Compile Include="System\Web\AspNetHostingPermissionLevel.cs" />
-    <Compile Include="System\Xaml\Permissions\XamlAccessLevel.cs" />
+  </ItemGroup>
+  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
     <Compile Include="System\Xaml\Permissions\XamlLoadPermission.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
     <Reference Include="System.Threading" />
     <Reference Include="System.Threading.Thread" />
   </ItemGroup>
+  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
+    <Reference Include="System.Windows.Extensions" />
+  </ItemGroup>
 </Project>
index e1cf80f..8494d5c 100644 (file)
@@ -7,7 +7,6 @@ using System.Configuration;
 using System.DirectoryServices;
 using System.Reflection;
 using System.Web;
-using System.Xaml.Permissions;
 
 namespace System.Security.Permissions.Tests
 {
@@ -445,26 +444,6 @@ namespace System.Security.Permissions.Tests
         }
 
         [Fact]
-        public static void XamlLoadPermissionCallMethods()
-        {
-            XamlAccessLevel accessLevel = XamlAccessLevel.AssemblyAccessTo(Assembly.GetExecutingAssembly().GetName());
-            XamlLoadPermission xp = new XamlLoadPermission(accessLevel);
-            XamlLoadPermission xp2 = new XamlLoadPermission(PermissionState.Unrestricted);
-            XamlLoadPermission xp3 = new XamlLoadPermission(Array.Empty<XamlAccessLevel>());
-            bool testbool = xp.IsUnrestricted();
-            IPermission ip = xp.Copy();
-            IPermission ip2 = xp.Intersect(ip);
-            IPermission ip3 = xp.Union(ip);
-            testbool = xp.IsSubsetOf(ip);
-            testbool = xp.Equals(new object());
-            testbool = xp.Includes(accessLevel);
-            int hash = xp.GetHashCode();
-            SecurityElement se = new SecurityElement("");
-            xp.FromXml(se);
-            se = xp.ToXml();
-        }
-
-        [Fact]
         public static void ZoneIdentityPermissionCallMethods()
         {
             ZoneIdentityPermission zip = new ZoneIdentityPermission(new PermissionState());
index 402e93a..bf3edac 100644 (file)
@@ -18,6 +18,8 @@
     <Compile Include="PrincipalPermissionTests.cs" />
     <Compile Include="SecurityElementTests.cs" />
     <Compile Include="TrustManagerContextTests.cs" />
-    <Compile Include="XamlAccessLevelTests.cs" />
+  </ItemGroup>
+  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' And '$(TargetsWindows)' == 'true'">
+    <Compile Include="XamlLoadPermissionTests.cs"/>
   </ItemGroup>
 </Project>
diff --git a/src/libraries/System.Security.Permissions/tests/XamlLoadPermissionTests.cs b/src/libraries/System.Security.Permissions/tests/XamlLoadPermissionTests.cs
new file mode 100644 (file)
index 0000000..cb2e5c8
--- /dev/null
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using System.Configuration;
+using System.DirectoryServices;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Xaml.Permissions;
+
+namespace System.Xaml.Permissions.Tests
+{
+    public class XamlLoadPermissionTests
+    {
+        [Fact]
+        public static void XamlLoadPermissionCallMethods()
+        {
+            XamlAccessLevel accessLevel = XamlAccessLevel.AssemblyAccessTo(Assembly.GetExecutingAssembly().GetName());
+            XamlLoadPermission xp = new XamlLoadPermission(accessLevel);
+            XamlLoadPermission xp2 = new XamlLoadPermission(PermissionState.Unrestricted);
+            XamlLoadPermission xp3 = new XamlLoadPermission(Array.Empty<XamlAccessLevel>());
+            bool testbool = xp.IsUnrestricted();
+            IPermission ip = xp.Copy();
+            IPermission ip2 = xp.Intersect(ip);
+            IPermission ip3 = xp.Union(ip);
+            testbool = xp.IsSubsetOf(ip);
+            testbool = xp.Equals(new object());
+            testbool = xp.Includes(accessLevel);
+            int hash = xp.GetHashCode();
+            SecurityElement se = new SecurityElement("");
+            xp.FromXml(se);
+            se = xp.ToXml();
+        }
+    }
+}
index 581a779..41ebd7d 100644 (file)
@@ -133,3 +133,16 @@ namespace System.Security.Cryptography.X509Certificates
         MultiSelection = 1,
     }
 }
+namespace System.Xaml.Permissions
+{
+    public partial class XamlAccessLevel
+    {
+        internal XamlAccessLevel() { }
+        public System.Reflection.AssemblyName AssemblyAccessToAssemblyName { get { throw null; } }
+        public string PrivateAccessToTypeName { get { throw null; } }
+        public static System.Xaml.Permissions.XamlAccessLevel AssemblyAccessTo(System.Reflection.Assembly assembly) { throw null; }
+        public static System.Xaml.Permissions.XamlAccessLevel AssemblyAccessTo(System.Reflection.AssemblyName assemblyName) { throw null; }
+        public static System.Xaml.Permissions.XamlAccessLevel PrivateAccessTo(string assemblyQualifiedTypeName) { throw null; }
+        public static System.Xaml.Permissions.XamlAccessLevel PrivateAccessTo(System.Type type) { throw null; }
+    }
+}
index fc4a9bf..c45d8a1 100644 (file)
@@ -71,6 +71,7 @@
     <Compile Include="System\Media\SoundPlayer.cs" />
     <Compile Include="System\Media\SystemSound.cs" />
     <Compile Include="System\Media\SystemSounds.cs" />
+    <Compile Include="System\Xaml\Permissions\XamlAccessLevel.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
     <Reference Include="System.Buffers" />
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
index b0836e4..a7eeb64 100644 (file)
@@ -6,6 +6,7 @@
   <ItemGroup Condition="'$(TargetsWindows)' == 'true'">
     <Compile Include="X509Certificate2UITests.cs" />
     <Compile Include="X509Certificate2UIManualTests.cs" />
+    <Compile Include="XamlAccessLevelTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(CommonTestPath)\System\Drawing\Helpers.cs">
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.