Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-10-30 19:19:50 +0300
committerGitHub <noreply@github.com>2017-10-30 19:19:50 +0300
commit2544e71349ce03259d0141486dc5e2d52716768b (patch)
treec239c0842d09186b488766537e5701757db4e80d /src
parent39566c3c02061db78c6068ed8310a55d4757866c (diff)
Disable reflection-based debugger System.Threading.Channels tests on uapaot (#24956)
Also remove the duplicated DebuggerAttributes.cs file.
Diffstat (limited to 'src')
-rw-r--r--src/System.Threading.Channels/tests/ChannelTestBase.cs1
-rw-r--r--src/System.Threading.Channels/tests/DebuggerAttributes.cs145
-rw-r--r--src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj4
-rw-r--r--src/System.Threading.Channels/tests/UnboundedChannelTests.cs1
4 files changed, 5 insertions, 146 deletions
diff --git a/src/System.Threading.Channels/tests/ChannelTestBase.cs b/src/System.Threading.Channels/tests/ChannelTestBase.cs
index 04967a74e9..17b5ba9c73 100644
--- a/src/System.Threading.Channels/tests/ChannelTestBase.cs
+++ b/src/System.Threading.Channels/tests/ChannelTestBase.cs
@@ -16,6 +16,7 @@ namespace System.Threading.Channels.Tests
protected virtual bool RequiresSingleWriter => false;
protected virtual bool BuffersItems => true;
+ [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Requires internal reflection on framework types.")]
[Fact]
public void ValidateDebuggerAttributes()
{
diff --git a/src/System.Threading.Channels/tests/DebuggerAttributes.cs b/src/System.Threading.Channels/tests/DebuggerAttributes.cs
deleted file mode 100644
index 02e12925a7..0000000000
--- a/src/System.Threading.Channels/tests/DebuggerAttributes.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-// 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 System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace System.Diagnostics
-{
- internal static class DebuggerAttributes
- {
- internal static object GetFieldValue(object obj, string fieldName) => GetField(obj, fieldName).GetValue(obj);
-
- internal static void ValidateDebuggerTypeProxyProperties(object obj)
- {
- // Get the DebuggerTypeProxyAttibute for obj
- CustomAttributeData[] attrs =
- obj.GetType().GetTypeInfo().CustomAttributes
- .Where(a => a.AttributeType == typeof(DebuggerTypeProxyAttribute))
- .ToArray();
- if (attrs.Length != 1)
- {
- throw new InvalidOperationException(
- string.Format("Expected one DebuggerTypeProxyAttribute on {0}.", obj));
- }
- CustomAttributeData cad = attrs[0];
-
- // Get the proxy type. As written, this only works if the proxy and the target type
- // have the same generic parameters, e.g. Dictionary<TKey,TValue> and Proxy<TKey,TValue>.
- // It will not work with, for example, Dictionary<TKey,TValue>.Keys and Proxy<TKey>,
- // as the former has two generic parameters and the latter only one.
- Type proxyType = cad.ConstructorArguments[0].ArgumentType == typeof(Type) ?
- (Type)cad.ConstructorArguments[0].Value :
- Type.GetType((string)cad.ConstructorArguments[0].Value);
- Type[] genericArguments = obj.GetType().GenericTypeArguments;
- if (genericArguments.Length > 0)
- {
- proxyType = proxyType.MakeGenericType(genericArguments);
- }
-
- // Create an instance of the proxy type, and make sure we can access all of the instance properties
- // on the type without exception
- object proxyInstance = Activator.CreateInstance(proxyType, obj);
- foreach (PropertyInfo pi in proxyInstance.GetType().GetTypeInfo().DeclaredProperties)
- {
- pi.GetValue(proxyInstance, null);
- }
- }
-
- internal static void ValidateDebuggerDisplayReferences(object obj)
- {
- // Get the DebuggerDisplayAttribute for obj
- CustomAttributeData[] attrs =
- obj.GetType().GetTypeInfo().CustomAttributes
- .Where(a => a.AttributeType == typeof(DebuggerDisplayAttribute))
- .ToArray();
- if (attrs.Length != 1)
- {
- throw new InvalidOperationException(
- string.Format("Expected one DebuggerDisplayAttribute on {0}.", obj));
- }
- CustomAttributeData cad = attrs[0];
-
- // Get the text of the DebuggerDisplayAttribute
- string attrText = (string)cad.ConstructorArguments[0].Value;
-
- // Parse the text for all expressions
- var references = new List<string>();
- int pos = 0;
- while (true)
- {
- int openBrace = attrText.IndexOf('{', pos);
- if (openBrace < pos)
- {
- break;
- }
-
- int closeBrace = attrText.IndexOf('}', openBrace);
- if (closeBrace < openBrace)
- {
- break;
- }
-
- string reference = attrText.Substring(openBrace + 1, closeBrace - openBrace - 1).Replace(",nq", "");
- pos = closeBrace + 1;
-
- references.Add(reference);
- }
- if (references.Count == 0)
- {
- throw new InvalidOperationException(
- string.Format("The DebuggerDisplayAttribute for {0} doesn't reference any expressions.", obj));
- }
-
- // Make sure that each referenced expression is a simple field or property name, and that we can
- // invoke the property's get accessor or read from the field.
- foreach (string reference in references)
- {
- PropertyInfo pi = GetProperty(obj, reference);
- if (pi != null)
- {
- object ignored = pi.GetValue(obj, null);
- continue;
- }
-
- FieldInfo fi = GetField(obj, reference);
- if (fi != null)
- {
- object ignored = fi.GetValue(obj);
- continue;
- }
-
- throw new InvalidOperationException(
- string.Format("The DebuggerDisplayAttribute for {0} contains the expression \"{1}\".", obj, reference));
- }
- }
-
- private static FieldInfo GetField(object obj, string fieldName)
- {
- for (Type t = obj.GetType(); t != null; t = t.GetTypeInfo().BaseType)
- {
- FieldInfo fi = t.GetTypeInfo().GetDeclaredField(fieldName);
- if (fi != null)
- {
- return fi;
- }
- }
- return null;
- }
-
- private static PropertyInfo GetProperty(object obj, string propertyName)
- {
- for (Type t = obj.GetType(); t != null; t = t.GetTypeInfo().BaseType)
- {
- PropertyInfo pi = t.GetTypeInfo().GetDeclaredProperty(propertyName);
- if (pi != null)
- {
- return pi;
- }
- }
- return null;
- }
- }
-}
diff --git a/src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj b/src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj
index b34fb28fc4..80f88a1d6d 100644
--- a/src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj
+++ b/src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj
@@ -11,11 +11,13 @@
<Compile Include="ChannelClosedExceptionTests.cs" />
<Compile Include="ChannelTestBase.cs" />
<Compile Include="ChannelTests.cs" />
- <Compile Include="DebuggerAttributes.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestExtensions.cs" />
<Compile Include="UnboundedChannelTests.cs" />
<Compile Include="UnbufferedChannelTests.cs" />
+ <Compile Include="$(CommonTestPath)\System\Diagnostics\DebuggerAttributes.cs">
+ <Link>Common\System\Diagnostics\DebuggerAttributes.cs</Link>
+ </Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
diff --git a/src/System.Threading.Channels/tests/UnboundedChannelTests.cs b/src/System.Threading.Channels/tests/UnboundedChannelTests.cs
index f3d6b67127..bd8fe73907 100644
--- a/src/System.Threading.Channels/tests/UnboundedChannelTests.cs
+++ b/src/System.Threading.Channels/tests/UnboundedChannelTests.cs
@@ -138,6 +138,7 @@ namespace System.Threading.Channels.Tests
{
protected override bool RequiresSingleReader => true;
+ [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Requires internal reflection on framework types.")]
[Fact]
public void ValidateInternalDebuggerAttributes()
{