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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Laval <jeremie.laval@gmail.com>2012-11-29 21:37:42 +0400
committerJeremie Laval <jeremie.laval@gmail.com>2012-11-29 21:40:15 +0400
commit3e8896c8a8aca58c953ecf8ea5f573fba11aa8b1 (patch)
tree03f9b7ba44ca512b94da0471150065f12e281351
parente5dc6574568794b1df582e7cd168f011089d982f (diff)
[monkeydoc] Robustify EcmaDesc equality checking and fix unit tests
-rw-r--r--mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaDesc.cs29
-rw-r--r--mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaUrlParser.jay4
-rw-r--r--mcs/tools/monkeydoc/Test/Monkeydoc.Ecma/EcmaUrlTests.cs41
3 files changed, 59 insertions, 15 deletions
diff --git a/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaDesc.cs b/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaDesc.cs
index 95a83d56b06..e8fa191b1ab 100644
--- a/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaDesc.cs
+++ b/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaDesc.cs
@@ -174,6 +174,7 @@ namespace Monkeydoc.Ecma
}
result += ')';
}
+
return result;
}
@@ -223,7 +224,7 @@ namespace Monkeydoc.Ecma
public override string ToString ()
{
- return string.Format ("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9}",
+ return string.Format ("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9} {10}",
Namespace,
TypeName,
FormatGenericArgsFull (GenericTypeArguments),
@@ -233,7 +234,8 @@ namespace Monkeydoc.Ecma
MemberArguments != null ? "(" + string.Join (",", MemberArguments.Select (m => m.ToString ())) + ")" : string.Empty,
ArrayDimensions != null && ArrayDimensions.Count > 0 ? ArrayDimensions.Select (dim => "[" + new string (',', dim - 1) + "]").Aggregate (string.Concat) : string.Empty,
DescKind.ToString ()[0],
- Etc != 0 ? '(' + Etc.ToString () + ')' : string.Empty);
+ Etc != 0 ? '(' + Etc.ToString () + ')' : string.Empty,
+ ExplicitImplMember != null ? "$" + ExplicitImplMember.ToString () : string.Empty);
}
@@ -245,11 +247,23 @@ namespace Monkeydoc.Ecma
public bool Equals (EcmaDesc other)
{
- return DescKind == other.DescKind
+ if (other == null)
+ return false;
+
+ if (NestedType == null ^ other.NestedType == null
+ || ArrayDimensions == null ^ other.ArrayDimensions == null
+ || GenericTypeArguments == null ^ other.GenericTypeArguments == null
+ || GenericMemberArguments == null ^ other.GenericMemberArguments == null
+ || MemberArguments == null ^ other.MemberArguments == null
+ || ExplicitImplMember == null ^ other.ExplicitImplMember == null)
+ return false;
+
+ return other != null
+ && DescKind == other.DescKind
&& TypeName == other.TypeName
&& Namespace == other.Namespace
&& MemberName == other.MemberName
- && NestedType == other.NestedType || NestedType.Equals (other.NestedType)
+ && (NestedType == null || NestedType.Equals (other.NestedType))
&& (ArrayDimensions == null || ArrayDimensions.SequenceEqual (other.ArrayDimensions))
&& (GenericTypeArguments == null || GenericTypeArguments.SequenceEqual (other.GenericTypeArguments))
&& (GenericMemberArguments == null || GenericMemberArguments.SequenceEqual (other.GenericMemberArguments))
@@ -274,6 +288,13 @@ namespace Monkeydoc.Ecma
return input;
}
+ bool WhatT (bool input)
+ {
+ if (input)
+ throw new Exception ("Not equal");
+ return input;
+ }
+
string FormatNamespace (EcmaDesc desc)
{
return string.IsNullOrEmpty (desc.Namespace) ? string.Empty : desc.Namespace + ".";
diff --git a/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaUrlParser.jay b/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaUrlParser.jay
index 1248a7942cf..bee281049a6 100644
--- a/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaUrlParser.jay
+++ b/mcs/tools/monkeydoc/Monkeydoc.Ecma/EcmaUrlParser.jay
@@ -119,7 +119,7 @@ type_expression_suffix
$$ = new EcmaDesc {
GenericTypeArguments = $1 as List<EcmaDesc>,
NestedType = nestedType,
- ArrayDimensions = $3 as IList<int>,
+ ArrayDimensions = SafeReverse ($3 as List<int>),
Etc = $4 != null ? ((Tuple<char, string>)$4).Item1 : nestedDescHasEtc ? nestedType.Etc : (char)0,
EtcFilter = $4 != null ? ((Tuple<char, string>)$4).Item2 : nestedDescHasEtc ? nestedType.EtcFilter : null
};
@@ -242,7 +242,7 @@ operator_expression
property_expression
: simple_member_expression opt_property_indexer {
var desc = $1 as EcmaDesc;
- desc.MemberArguments = SafeReverse ($2 as List<EcmaDesc>);
+ (desc.ExplicitImplMember ?? desc).MemberArguments = SafeReverse ($2 as List<EcmaDesc>);
$$ = desc;
}
diff --git a/mcs/tools/monkeydoc/Test/Monkeydoc.Ecma/EcmaUrlTests.cs b/mcs/tools/monkeydoc/Test/Monkeydoc.Ecma/EcmaUrlTests.cs
index 8a9f3a73cfa..611e1050ae7 100644
--- a/mcs/tools/monkeydoc/Test/Monkeydoc.Ecma/EcmaUrlTests.cs
+++ b/mcs/tools/monkeydoc/Test/Monkeydoc.Ecma/EcmaUrlTests.cs
@@ -165,7 +165,7 @@ namespace MonoTests.MonkeyDoc.Ecma
{
AssertValidUrl ("P:System.ComponentModel.PropertyDescriptorCollection.Item(int)");
AssertValidUrl ("P:System.ComponentModel.AttributeCollection.Item(Type)");
- AssertValidUrl ("P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item(int)");
+ AssertValidUrl ("P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item(System.Int32)");
AssertValidUrl ("P:System.Collections.Specialized.BitVector32.Item(System.Collections.Specialized.BitVector32+Section)");
}
@@ -211,6 +211,7 @@ namespace MonoTests.MonkeyDoc.Ecma
var generics = new[] {
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
+ Namespace = string.Empty,
TypeName = "T"
}
};
@@ -229,7 +230,8 @@ namespace MonoTests.MonkeyDoc.Ecma
var generics = new[] {
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
- TypeName = "T"
+ TypeName = "T",
+ Namespace = string.Empty
},
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
@@ -238,7 +240,8 @@ namespace MonoTests.MonkeyDoc.Ecma
GenericTypeArguments = new[] {
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
- TypeName = "V"
+ TypeName = "V",
+ Namespace = string.Empty
}
}
}
@@ -274,7 +277,8 @@ namespace MonoTests.MonkeyDoc.Ecma
},
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
- TypeName = "Int32"
+ TypeName = "Int32",
+ Namespace = string.Empty
}
};
var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Method,
@@ -302,11 +306,13 @@ namespace MonoTests.MonkeyDoc.Ecma
GenericTypeArguments = new[] {
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
- TypeName = "K"
+ TypeName = "K",
+ Namespace = string.Empty
},
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
- TypeName = "V"
+ TypeName = "V",
+ Namespace = string.Empty
}
}
}
@@ -316,6 +322,7 @@ namespace MonoTests.MonkeyDoc.Ecma
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
TypeName = "Action",
+ Namespace = string.Empty,
GenericTypeArguments = new[] {
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
@@ -325,6 +332,7 @@ namespace MonoTests.MonkeyDoc.Ecma
new EcmaDesc {
DescKind = EcmaDesc.Kind.Type,
TypeName = "int",
+ Namespace = string.Empty
},
}
}
@@ -355,9 +363,6 @@ namespace MonoTests.MonkeyDoc.Ecma
ExplicitImplMember = inner
};
AssertUrlDesc (ast, "M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
- var actual = parser.Parse ("M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
- Assert.IsNotNull (actual.ExplicitImplMember);
- Assert.AreEqual ("System.IDisposable.Dispose", ast.ToCompleteMemberName (EcmaDesc.Format.WithoutArgs));
}
[Test]
@@ -384,6 +389,24 @@ namespace MonoTests.MonkeyDoc.Ecma
AssertUrlDesc (ast, "T:System.Int32[,,][][]");
}
+ [Test]
+ public void ExplicitIndexerImplementation ()
+ {
+ var explicitImpl = new EcmaDesc {
+ Namespace = "System.Web.SessionState",
+ TypeName = "IHttpSessionState",
+ MemberName = "Item",
+ MemberArguments = new [] { new EcmaDesc { DescKind = EcmaDesc.Kind.Type, Namespace = "System", TypeName = "Int32" } },
+ };
+ var ast = new EcmaDesc {
+ DescKind = EcmaDesc.Kind.Property,
+ TypeName = "HttpSessionStateContainer",
+ Namespace = "System.Web.SessionState",
+ ExplicitImplMember = explicitImpl,
+ };
+ AssertUrlDesc (ast, "P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item(System.Int32)");
+ }
+
/* [Test]
public void TreeParsabilityTest ()
{