summaryrefslogtreecommitdiff
path: root/tests/src/Regressions/common
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-03-21 15:40:51 -0700
committerJan Kotas <jkotas@microsoft.com>2015-03-21 15:40:51 -0700
commit725d6a91fffdf4603c8a9c74e15cbc83ebf0e3d6 (patch)
treefcb60d394c01d951c870c9c9b6bb2a1ad9250314 /tests/src/Regressions/common
parent4b3c47ac23abc7526204eaf001c2e9564eb6ab75 (diff)
downloadcoreclr-725d6a91fffdf4603c8a9c74e15cbc83ebf0e3d6.tar.gz
coreclr-725d6a91fffdf4603c8a9c74e15cbc83ebf0e3d6.tar.bz2
coreclr-725d6a91fffdf4603c8a9c74e15cbc83ebf0e3d6.zip
Add host flag to disable transparency checks in CoreCLR
A lot of security transparency annotations in corefx is missing or inconsistent. People keep running into MethodAccessExceptions because of that. It is not easy (nor cheap) to fix the annotations to make them consistent, and they are not actually required for any of the .NET Core scenarios. This change is introducing a hosting flag to disable security transparency checks on CoreCLR, and adds this flag to all .NET Core hosts. The .NET Core hosts outside of the CoreCLR tree (e.g. ASP.NET 5) will need this flag added as well. [tfs-changeset: 1437325]
Diffstat (limited to 'tests/src/Regressions/common')
-rw-r--r--tests/src/Regressions/common/DisableTransparencyEnforcement.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/src/Regressions/common/DisableTransparencyEnforcement.cs b/tests/src/Regressions/common/DisableTransparencyEnforcement.cs
new file mode 100644
index 0000000000..c6265b7c86
--- /dev/null
+++ b/tests/src/Regressions/common/DisableTransparencyEnforcement.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+// This test is verifying that security transparency violations are ignored in CoreCLR
+
+using System;
+using System.Security;
+
+[assembly:AllowPartiallyTrustedCallers]
+
+[SecurityCritical]
+class CriticalType
+{
+ [SecurityCritical]
+ public CriticalType()
+ {
+ }
+}
+
+class My {
+ static int Main() {
+
+ new CriticalType().ToString();
+
+ // GC.Collect(int) is marked as security critical in CoreCLR for historic reasons.
+ // Verify that the transparency violations are ignored by calling it from here.
+ GC.Collect(1);
+
+ TestLibrary.TestFramework.LogInformation("PASS");
+
+ return 100;
+ }
+}