16 changed files with 0 additions and 2664 deletions
@ -1,94 +0,0 @@
@@ -1,94 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Reflection;
|
||||
//using System.Text;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// SD2-1199. Tests the available overrides for the
|
||||
// /// System.Collections.ObjectModel.Collection class.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class CollectionClassOverridesTestFixture
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// PropertyService.InitializeServiceForUnitTests();
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// This shows how to get the list of overridable methods in the
|
||||
// /// Collection class using reflection only.
|
||||
// /// </summary>
|
||||
// public void GetMethodsThroughReflection()
|
||||
// {
|
||||
// Assembly a = Assembly.Load("mscorlib");
|
||||
// Type t = a.GetType("System.Collections.ObjectModel.Collection`1");
|
||||
//
|
||||
// List<string> methodNames = new List<string>();
|
||||
// BindingFlags bindingFlags = BindingFlags.Instance |
|
||||
// BindingFlags.NonPublic |
|
||||
// BindingFlags.DeclaredOnly |
|
||||
// BindingFlags.Public;
|
||||
//
|
||||
// foreach (MethodInfo m in t.GetMethods(bindingFlags)) {
|
||||
// if (m.IsVirtual && !m.IsSpecialName && !m.IsFinal) {
|
||||
// methodNames.Add(m.Name);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<string> expectedMethodNames = new List<string>();
|
||||
// expectedMethodNames.Add("ClearItems");
|
||||
// expectedMethodNames.Add("InsertItem");
|
||||
// expectedMethodNames.Add("RemoveItem");
|
||||
// expectedMethodNames.Add("SetItem");
|
||||
//
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// foreach (string s in methodNames.ToArray()) {
|
||||
// sb.AppendLine(s);
|
||||
// }
|
||||
// Assert.AreEqual(expectedMethodNames.ToArray(), methodNames.ToArray(), sb.ToString());
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Tests that the IsSealed property is set for methods that are
|
||||
// /// flagged as final. The ReflectionMethod class was not setting
|
||||
// /// this correctly.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void ExpectedMethodsFromProjectContent()
|
||||
// {
|
||||
// ProjectContentRegistry registry = new ProjectContentRegistry();
|
||||
// IProjectContent mscorlibProjectContent = registry.Mscorlib;
|
||||
// IClass c = mscorlibProjectContent.GetClass("System.Collections.ObjectModel.Collection", 1);
|
||||
//
|
||||
// List<string> methodNames = new List<string>();
|
||||
// foreach (IMethod m in c.Methods) {
|
||||
// if (m.IsVirtual && !m.IsSealed) {
|
||||
// methodNames.Add(m.Name);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<string> expectedMethodNames = new List<string>();
|
||||
// expectedMethodNames.Add("ClearItems");
|
||||
// expectedMethodNames.Add("InsertItem");
|
||||
// expectedMethodNames.Add("RemoveItem");
|
||||
// expectedMethodNames.Add("SetItem");
|
||||
//
|
||||
// methodNames.Sort();
|
||||
// expectedMethodNames.Sort();
|
||||
//
|
||||
// Assert.AreEqual(expectedMethodNames.ToArray(), methodNames.ToArray());
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Reflection;
|
||||
//using System.Text;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests the available overrides for the
|
||||
// /// System.Exception class.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class ExceptionClassOverridesTestFixture
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// PropertyService.InitializeServiceForUnitTests();
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// This shows how to get the list of overridable properties in the
|
||||
// /// Exception class using reflection only.
|
||||
// /// </summary>
|
||||
// public void GetPropertiesThroughReflection()
|
||||
// {
|
||||
// Assembly a = Assembly.Load("mscorlib");
|
||||
// Type t = a.GetType("System.Exception");
|
||||
//
|
||||
// List<string> propertyNames = new List<string>();
|
||||
// BindingFlags bindingFlags = BindingFlags.Instance |
|
||||
// BindingFlags.NonPublic |
|
||||
// BindingFlags.DeclaredOnly |
|
||||
// BindingFlags.Public;
|
||||
//
|
||||
// foreach (PropertyInfo p in t.GetProperties(bindingFlags)) {
|
||||
// MethodInfo m = p.GetGetMethod(true);
|
||||
// if (m.IsVirtual && !m.IsPrivate && !m.IsFinal) {
|
||||
// propertyNames.Add(p.Name);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<string> expectedPropertyNames = new List<string>();
|
||||
// expectedPropertyNames.Add("Data");
|
||||
// expectedPropertyNames.Add("HelpLink");
|
||||
// expectedPropertyNames.Add("Message");
|
||||
// expectedPropertyNames.Add("Source");
|
||||
// expectedPropertyNames.Add("StackTrace");
|
||||
//
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// foreach (string s in propertyNames.ToArray()) {
|
||||
// sb.AppendLine(s);
|
||||
// }
|
||||
// Assert.AreEqual(expectedPropertyNames.ToArray(), propertyNames.ToArray(), sb.ToString());
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Tests that the IsSealed property is set for properties that are
|
||||
// /// flagged as final. The ReflectionProperty class was not setting
|
||||
// /// this correctly.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void ExpectedPropertiesFromProjectContent()
|
||||
// {
|
||||
// ProjectContentRegistry registry = new ProjectContentRegistry();
|
||||
// IProjectContent mscorlibProjectContent = registry.Mscorlib;
|
||||
// IClass c = mscorlibProjectContent.GetClass("System.Exception", 0);
|
||||
//
|
||||
// List<string> propertyNames = new List<string>();
|
||||
// foreach (IProperty p in c.Properties) {
|
||||
// if (p.IsVirtual && !p.IsSealed) {
|
||||
// propertyNames.Add(p.Name);
|
||||
// }
|
||||
// }
|
||||
// propertyNames.Sort();
|
||||
//
|
||||
// List<string> expectedPropertyNames = new List<string>();
|
||||
// expectedPropertyNames.Add("Data");
|
||||
// expectedPropertyNames.Add("HelpLink");
|
||||
// expectedPropertyNames.Add("Message");
|
||||
// expectedPropertyNames.Add("Source");
|
||||
// expectedPropertyNames.Add("StackTrace");
|
||||
//
|
||||
// Assert.AreEqual(expectedPropertyNames.ToArray(), propertyNames.ToArray());
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,86 +0,0 @@
@@ -1,86 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Linq;
|
||||
//using ICSharpCode.NRefactory.Ast;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//using NUnit.Framework;
|
||||
//using System.Text;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Description of GenerateOverrideMethod.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class GenerateOverrideMethodTests
|
||||
// {
|
||||
// NRefactoryResolverTests helper = new NRefactoryResolverTests();
|
||||
//
|
||||
// void Run(string input, string expectedOutput)
|
||||
// {
|
||||
// ISyntaxTree cu = helper.Parse("a.cs", input + "\nclass DerivedClass {\n \n}");
|
||||
// Assert.AreEqual(2, cu.Classes.Count);
|
||||
// Assert.AreEqual(1, cu.Classes[0].Methods.Count + cu.Classes[0].Properties.Count);
|
||||
// IMember virtualMember;
|
||||
// if (cu.Classes[0].Properties.Count > 0)
|
||||
// virtualMember = cu.Classes[0].Properties[0];
|
||||
// else
|
||||
// virtualMember = cu.Classes[0].Methods[0];
|
||||
// CSharpCodeGenerator ccg = new CSharpCodeGenerator();
|
||||
// AttributedNode result = ccg.GetOverridingMethod(virtualMember, new ClassFinder(cu.Classes[1], 3, 1));
|
||||
// Assert.IsNotNull(result);
|
||||
// string output = ccg.GenerateCode(result, "");
|
||||
// Assert.AreEqual(expectedOutput, NormalizeWhitespace(output));
|
||||
// }
|
||||
//
|
||||
// string NormalizeWhitespace(string t)
|
||||
// {
|
||||
// StringBuilder b = new StringBuilder();
|
||||
// bool wasWhitespace = true;
|
||||
// foreach (char c in t) {
|
||||
// if (char.IsWhiteSpace(c)) {
|
||||
// if (!wasWhitespace) {
|
||||
// wasWhitespace = true;
|
||||
// b.Append(' ');
|
||||
// }
|
||||
// } else {
|
||||
// b.Append(c);
|
||||
// wasWhitespace = false;
|
||||
// }
|
||||
// }
|
||||
// return b.ToString().Trim();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReadonlyVirtualProperty()
|
||||
// {
|
||||
// Run("class BaseClass { public virtual int Prop { get { return 0; } } }",
|
||||
// "public override int Prop { get { return base.Prop; } }");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReadonlyAbstractProperty()
|
||||
// {
|
||||
// Run("class BaseClass { public abstract int Prop { get; } }",
|
||||
// "public override int Prop { get { throw new NotImplementedException(); } }");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReadWriteProperty()
|
||||
// {
|
||||
// Run("class BaseClass { public virtual int Prop { get { return 0; } set { } } }",
|
||||
// "public override int Prop { get { return base.Prop; } set { base.Prop = value; } }");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void PublicReadProtectedWriteProperty()
|
||||
// {
|
||||
// Run("class BaseClass { public virtual int Prop { get { return 0; } protected set { } } }",
|
||||
// "public override int Prop { get { return base.Prop; } protected set { base.Prop = value; } }");
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,629 +0,0 @@
@@ -1,629 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class GenericResolverTests
|
||||
// {
|
||||
// #region Test helper methods
|
||||
// NRefactoryResolverTests nrrt = new NRefactoryResolverTests();
|
||||
//
|
||||
// ResolveResult Resolve(string program, string expression, int line)
|
||||
// {
|
||||
// return nrrt.Resolve(program, expression, line);
|
||||
// }
|
||||
//
|
||||
// RR Resolve<RR>(string program, string expression, int line) where RR : ResolveResult
|
||||
// {
|
||||
// return nrrt.Resolve<RR>(program, expression, line);
|
||||
// }
|
||||
//
|
||||
// RR Resolve<RR>(string program, string expression, int line, int column) where RR : ResolveResult
|
||||
// {
|
||||
// return nrrt.Resolve<RR>(program, expression, line, column, ExpressionContext.Default);
|
||||
// }
|
||||
//
|
||||
// RR ResolveVB<RR>(string program, string expression, int line) where RR : ResolveResult
|
||||
// {
|
||||
// return nrrt.ResolveVB<RR>(program, expression, line);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// #region Generic references
|
||||
// const string listProgram = @"using System.Collections.Generic;
|
||||
//class TestClass {
|
||||
// void Method() {
|
||||
// List<TestClass> list = new List<TestClass>();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// T CloneIt<T>(T source) where T : ICloneable {
|
||||
// if (source == null) return new TestClass();
|
||||
// return source.Clone();
|
||||
// }
|
||||
//
|
||||
// public int PublicField;
|
||||
//}
|
||||
//";
|
||||
//
|
||||
// [Test]
|
||||
// public void ListAddTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "list.Add(new A())", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
|
||||
// Assert.AreEqual(1, m.Parameters.Count);
|
||||
// Assert.AreEqual("TestClass", m.Parameters[0].ReturnType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ListAddRangeTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "list.AddRange(new A[0])", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
|
||||
// Assert.AreEqual(1, m.Parameters.Count);
|
||||
// Assert.IsTrue(m.Parameters[0].ReturnType is ConstructedReturnType);
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable", m.Parameters[0].ReturnType.FullyQualifiedName);
|
||||
// Assert.AreEqual("TestClass", ((ConstructedReturnType)m.Parameters[0].ReturnType).TypeArguments[0].FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ListToArrayTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "list.ToArray()", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
|
||||
// Assert.AreEqual("TestClass", m.ReturnType.FullyQualifiedName);
|
||||
// Assert.AreEqual(1, m.ReturnType.CastToArrayReturnType().ArrayDimensions);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ClassReferenceTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "List<string>", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("System.Collections.Generic.List", ((TypeResolveResult)result).ResolvedClass.FullyQualifiedName);
|
||||
// Assert.IsTrue(result.ResolvedType is ConstructedReturnType);
|
||||
// Assert.AreEqual("System.String", ((ConstructedReturnType)result.ResolvedType).TypeArguments[0].FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericMethodCallTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "CloneIt<TestClass>(null)", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("TestClass", result.ResolvedType.FullyQualifiedName);
|
||||
// MemberResolveResult mrr = (MemberResolveResult) result;
|
||||
// Assert.AreEqual("TestClass.CloneIt", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FieldReferenceOnGenericMethodTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "CloneIt<TestClass>(null).PublicField", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("System.Int32", result.ResolvedType.FullyQualifiedName);
|
||||
// MemberResolveResult mrr = (MemberResolveResult) result;
|
||||
// Assert.AreEqual("TestClass.PublicField", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TypeInferredGenericMethodCallTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "CloneIt(new TestClass())", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("TestClass", result.ResolvedType.FullyQualifiedName);
|
||||
// MemberResolveResult mrr = (MemberResolveResult) result;
|
||||
// Assert.AreEqual("TestClass.CloneIt", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FieldReferenceOnTypeInferredGenericMethodCallTest()
|
||||
// {
|
||||
// ResolveResult result = Resolve(listProgram, "CloneIt(new TestClass()).PublicField", 5);
|
||||
// Assert.IsNotNull(result);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("System.Int32", result.ResolvedType.FullyQualifiedName);
|
||||
// MemberResolveResult mrr = (MemberResolveResult) result;
|
||||
// Assert.AreEqual("TestClass.PublicField", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ImportAliasClassResolveTest()
|
||||
// {
|
||||
// string program = @"using COL = System.Collections.Generic.List<string>;
|
||||
//class TestClass {
|
||||
// void Test() {
|
||||
// COL a = new COL();
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// TypeResolveResult rr = Resolve(program, "COL", 4) as TypeResolveResult;
|
||||
// Assert.AreEqual("System.Collections.Generic.List", rr.ResolvedClass.FullyQualifiedName, "COL");
|
||||
// Assert.AreEqual("System.Collections.Generic.List{System.String}", rr.ResolvedType.DotNetName, "COL");
|
||||
// LocalResolveResult lr = Resolve(program, "a", 5) as LocalResolveResult;
|
||||
// Assert.AreEqual("System.Collections.Generic.List{System.String}", lr.ResolvedType.DotNetName, "a");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InheritFromGenericClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class BaseClass<T> {
|
||||
// public T value;
|
||||
//}
|
||||
//class DerivedClass : BaseClass<string> {
|
||||
//
|
||||
//}";
|
||||
// MemberResolveResult rr = Resolve(program, "value", 6) as MemberResolveResult;
|
||||
// Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InheritFromGenericClass2()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Test {
|
||||
// void M(DerivedClass d) {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//class BaseClass<T> {
|
||||
// public T value;
|
||||
//}
|
||||
//class DerivedClass : BaseClass<string> {
|
||||
//
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult rr = Resolve(program, "d.value", 4) as MemberResolveResult;
|
||||
// Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InheritFromGenericClass3()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Test {
|
||||
// void M(DerivedClass<string> d) {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//class BaseClass<T> {
|
||||
// public T value;
|
||||
//}
|
||||
//class DerivedClass<T> : BaseClass<T> {
|
||||
//
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult rr = Resolve(program, "d.value", 4) as MemberResolveResult;
|
||||
// Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CrossTypeParametersInheritance()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class BaseClass<A,B> {
|
||||
// public A a;
|
||||
// public B b;
|
||||
//}
|
||||
//class DerivedClass<A,B> : BaseClass<B,A> {
|
||||
//
|
||||
//}";
|
||||
// MemberResolveResult rr = Resolve(program, "a", 7) as MemberResolveResult;
|
||||
// Assert.AreEqual("B", rr.ResolvedType.Name);
|
||||
// rr = Resolve(program, "b", 7) as MemberResolveResult;
|
||||
// Assert.AreEqual("A", rr.ResolvedType.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void PropertyOnGenericClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class T {
|
||||
// void M() {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult rr = Resolve(program, "System.Collections.Generic.Comparer<string>.Default", 4) as MemberResolveResult;
|
||||
// Assert.AreEqual("System.Collections.Generic.Comparer.Default", rr.ResolvedMember.FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Collections.Generic.Comparer<string>",
|
||||
// (new Dom.CSharp.CSharpAmbience { ConversionFlags = ConversionFlags.UseFullyQualifiedTypeNames } )
|
||||
// .Convert(rr.ResolvedType));
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// #region CodeCompletion inside generic classes
|
||||
// const string genericClass = @"using System;
|
||||
//public class GenericClass<T> where T : IDisposable {
|
||||
// void Method<G>(T par1, G par2) where G : IConvertible, IFormattable {
|
||||
// T var1; G var2;
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
//
|
||||
// [Test]
|
||||
// public void ClassTypeParameterResolveType()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "T", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is TypeResolveResult);
|
||||
// Assert.IsNull((rr as TypeResolveResult).ResolvedClass);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ClassTypeParameterResolveVariable()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "var1", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is LocalResolveResult);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ClassTypeParameterResolveParameter()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "par1", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is LocalResolveResult);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MethodTypeParameterResolveType()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "G", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is TypeResolveResult);
|
||||
// Assert.IsNull((rr as TypeResolveResult).ResolvedClass);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MethodTypeParameterResolveVariable()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "var2", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is LocalResolveResult);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MethodTypeParameterResolveParameter()
|
||||
// {
|
||||
// ResolveResult rr = Resolve(genericClass, "par2", 5);
|
||||
// Assert.IsNotNull(rr);
|
||||
// Assert.IsTrue(rr is LocalResolveResult);
|
||||
// Assert.IsTrue(rr.ResolvedType is GenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ResolveGenericClassInDeclarationLine()
|
||||
// {
|
||||
// const string program = @"using System;
|
||||
//public abstract class Sorter { }
|
||||
//public abstract class Sorter<T> : Sorter, IComparer<T> { }
|
||||
//";
|
||||
//
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "Sorter", 3, 37);
|
||||
// Assert.AreEqual(0, trr.ResolvedClass.TypeParameters.Count);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// #region Generic methods
|
||||
// [Test]
|
||||
// public void GenericMethodInstanciation()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//using System.Collections.Generic;
|
||||
//class TestClass {
|
||||
// void Main() {
|
||||
//
|
||||
// }
|
||||
// static T First<T>(IEnumerable<T> input) {
|
||||
// foreach (T e in input) return e;
|
||||
// throw new EmptyCollectionException();
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult mrr = Resolve<MemberResolveResult>(program, "First(new string[0])", 5);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedType.FullyQualifiedName);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedMember.ReturnType.FullyQualifiedName);
|
||||
//
|
||||
// IMethod genericMethod = mrr.ResolvedMember.DeclaringType.Methods[1];
|
||||
// Assert.AreEqual("T", genericMethod.ReturnType.FullyQualifiedName);
|
||||
//
|
||||
// // ensure that the reference pointing to the specialized method is seen as a reference
|
||||
// // to the generic method.
|
||||
// Assert.IsTrue(mrr.IsReferenceTo(genericMethod));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void BothGenericAndNonGenericMethod()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class TestClass {
|
||||
// void Main() {
|
||||
//
|
||||
// }
|
||||
// static object GetSomething() {
|
||||
// return null;
|
||||
// }
|
||||
// static T GetSomething<T>() {
|
||||
// return default(T);
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
//
|
||||
// MemberResolveResult mrr = Resolve<MemberResolveResult>(program, "GetSomething()", 4);
|
||||
//
|
||||
// IMethod nonGenericMethod = mrr.ResolvedMember.DeclaringType.Methods[1];
|
||||
// Assert.AreEqual("System.Object", nonGenericMethod.ReturnType.FullyQualifiedName);
|
||||
//
|
||||
// IMethod genericMethod = mrr.ResolvedMember.DeclaringType.Methods[2];
|
||||
// Assert.AreEqual("T", genericMethod.ReturnType.FullyQualifiedName);
|
||||
//
|
||||
// Assert.AreSame(nonGenericMethod, mrr.ResolvedMember);
|
||||
//
|
||||
// Assert.IsTrue(mrr.IsReferenceTo(nonGenericMethod));
|
||||
// Assert.IsFalse(mrr.IsReferenceTo(genericMethod));
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "GetSomething<int>()", 4);
|
||||
// Assert.AreEqual("System.Int32", mrr.ResolvedType.FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Int32", mrr.ResolvedMember.ReturnType.FullyQualifiedName);
|
||||
//
|
||||
// Assert.IsTrue(mrr.IsReferenceTo(genericMethod));
|
||||
// Assert.IsFalse(mrr.IsReferenceTo(nonGenericMethod));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OverrideGenericMethodTest()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Program {
|
||||
// public static void Main() {
|
||||
// D d = new D();
|
||||
//
|
||||
// d.T<char, int>('a', 1);
|
||||
// d.T<int, char>('a', 2);
|
||||
// }
|
||||
// public virtual void T<A, B>(A a, B b) {
|
||||
// }
|
||||
// public virtual void T<X, Y>(Y a, X b) {
|
||||
// }
|
||||
//}
|
||||
//class D : Program {
|
||||
// public override void T<X, Y>(X a, Y b) {
|
||||
// // overrides T<A,B> - type arguments are identified by position
|
||||
// }
|
||||
//}";
|
||||
// IAmbience ambience = new Dom.CSharp.CSharpAmbience();
|
||||
// ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedMemberNames | ConversionFlags.ShowTypeParameterList;
|
||||
// MemberResolveResult mrr;
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "d.T<int, char>('a', 2)", 5);
|
||||
// Assert.AreEqual("Program.T<X, Y>", ambience.Convert((IMethod)mrr.ResolvedMember));
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "d.T<char, int>('a', 1)", 6);
|
||||
// Assert.AreEqual("D.T<X, Y>", ambience.Convert((IMethod)mrr.ResolvedMember));
|
||||
//
|
||||
// IMember baseMember = MemberLookupHelper.FindBaseMember(mrr.ResolvedMember);
|
||||
// Assert.IsNotNull(baseMember);
|
||||
// Assert.AreEqual("Program.T<A, B>", ambience.Convert((IMethod)baseMember));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void PassGenericArgumentOnToOtherGenericMethod()
|
||||
// {
|
||||
// string program = @"class T {
|
||||
// static void Test<ValueT>(ValueT v, int iKey) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// class TestClass<T> {
|
||||
// public static bool Equals(T a, T b) { return false; }
|
||||
// }";
|
||||
//
|
||||
// MemberResolveResult mrr;
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "TestClass<ValueT>.Equals(v, default(ValueT))", 3);
|
||||
// Assert.AreEqual("TestClass.Equals", mrr.ResolvedMember.FullyQualifiedName);
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "TestClass<int>.Equals(v, default(ValueT))", 3);
|
||||
// Assert.AreEqual("System.Object.Equals", mrr.ResolvedMember.FullyQualifiedName);
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "TestClass<ValueT>.Equals(v, default(object))", 3);
|
||||
// Assert.AreEqual("System.Object.Equals", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OfTypeExtensionMethod()
|
||||
// {
|
||||
// string program = @"using System.Collections; using System.Collections.Generic;
|
||||
// class T {
|
||||
// static void Test(IEnumerable a) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// static class ExtensionMethods {
|
||||
// public static IEnumerable<T> OfType<T>(this IEnumerable input) { }
|
||||
// }";
|
||||
//
|
||||
// MemberResolveResult mrr;
|
||||
// mrr = Resolve<MemberResolveResult>(program, "a.OfType<string>()", 4);
|
||||
// Assert.AreEqual("ExtensionMethods.OfType", mrr.ResolvedMember.FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.String}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SD2_1528()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
// class TestClass {
|
||||
// static void Test(IRuleBuilder<TestClass, string> ruleBuilder) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// interface IRuleBuilder<T> { }
|
||||
// interface IRuleBuilder<T, P> : IRuleBuilder<T> { }
|
||||
// static class ExtensionMethods {
|
||||
// public static IRuleBuilderOptions<T, TProperty> LessThan<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder, Func<T, TProperty> valueToCompare) where TProperty: IComparable<TProperty> {}
|
||||
// }";
|
||||
// var rr = Resolve<LocalResolveResult>(program, "ruleBuilder", 4);
|
||||
// rr.GetCompletionData(rr.CallingClass.ProjectContent);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// #region C# 3.0 Type Inference
|
||||
// MemberResolveResult ResolveInSelectProgram(string expression)
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//using System.Collections.Generic;
|
||||
//delegate R Func<A, R>(A arg);
|
||||
//static class TestClass {
|
||||
// static void Main() {
|
||||
// {XXX};
|
||||
// }
|
||||
// static IEnumerable<TResult> Select<TSource,TResult>(
|
||||
// this IEnumerable<TSource> source, Func<TSource,TResult> selector)
|
||||
// {
|
||||
// foreach (TSource element in source) yield return selector(element);
|
||||
// }
|
||||
// static double StringToDouble(string s) { return double.Parse(s); }
|
||||
//}
|
||||
//";
|
||||
// return Resolve<MemberResolveResult>(program.Replace("{XXX}", expression), expression, 6, 3);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithExplicitDelegate()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new string[0], new Func<string, double>(StringToDouble))");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Double}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithArgumentIgnoringAnonymousMethod()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new string[0], delegate { return DateTime.MinValue; })");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.DateTime}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithExplicitlyTypedLambda()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new string[0], (string s) => s.Length)");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Int32}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithImplicitlyTypedLambda()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new string[0], s => s.Length)");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Int32}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithImplicitlyTypedLambdaCalledAsExtensionMethod()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("(new string[0]).Select(s => s.Length)");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Int32}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithImplicitlyTypedLambdaPassingGenericList()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new List<string>(), s => s.Length)");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Int32}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SelectWithImplicitlyTypedLambdaPassingGenericDictionary()
|
||||
// {
|
||||
// MemberResolveResult mrr = ResolveInSelectProgram("Select(new Dictionary<double, string>(), s => s.Key)");
|
||||
// Assert.AreEqual("System.Collections.Generic.IEnumerable{System.Double}", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MultipleOverloadsWithDifferentParameterCounts()
|
||||
// {
|
||||
// string program = @"class MainClass {
|
||||
// void Main() {
|
||||
// M(x=>x.ToUpper());
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// T M<T>(Func<string, T> f){ /* whatever ... */ }
|
||||
// T M<T>(Func<string, T> f, T g){ /* whatever ... */ }
|
||||
//}";
|
||||
// var mrr = nrrt.Resolve<MemberResolveResult>(program, "M(x=>x.ToUpper())", 3, 3, ExpressionContext.Default);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedType.DotNetName);
|
||||
// Assert.AreEqual(1, ((IMethod)mrr.ResolvedMember).Parameters.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MultipleOverloadsWithDifferentParameterCountsAsExtensionMethod()
|
||||
// {
|
||||
// string program = @"class MainClass {
|
||||
// static void Main() {
|
||||
// (string.Empty).M(x=>x.ToUpper());
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// static T M<X, T>(this X x, Func<X, T> f){ /* whatever ... */ }
|
||||
// static T M<X, T>(this X x, Func<X, T> f, T g){ /* whatever ... */ }
|
||||
//}";
|
||||
// var mrr = nrrt.Resolve<MemberResolveResult>(program, "(string.Empty).M(x=>x.ToUpper())", 3, 3, ExpressionContext.Default);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedType.DotNetName);
|
||||
// Assert.AreEqual(2, ((IMethod)mrr.ResolvedMember).Parameters.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void EnsureApplicabilityIsTestedAfterTypeInference()
|
||||
// {
|
||||
// string program = @"class TestClass {
|
||||
// static void Main() {
|
||||
//
|
||||
// }
|
||||
// static void G(object obj1, object obj2) {}
|
||||
// static void G<T>(T a, T b) {}
|
||||
//}
|
||||
// ";
|
||||
// var mrr = Resolve<MemberResolveResult>(program, "G(1, 2)", 3);
|
||||
// Assert.AreEqual("TestClass.G<int>(int a, int b)", ToCSharp(mrr.ResolvedMember));
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "G(1, 2.2)", 3);
|
||||
// Assert.AreEqual("TestClass.G<double>(double a, double b)", ToCSharp(mrr.ResolvedMember));
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "G(1, \"a\")", 3);
|
||||
// Assert.AreEqual("TestClass.G(object obj1, object obj2)", ToCSharp(mrr.ResolvedMember));
|
||||
// }
|
||||
//
|
||||
// string ToCSharp(IEntity entity)
|
||||
// {
|
||||
// return (new Dom.CSharp.CSharpAmbience {
|
||||
// ConversionFlags = ConversionFlags.UseFullyQualifiedMemberNames
|
||||
// | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames
|
||||
// | ConversionFlags.ShowTypeParameterList
|
||||
// }).Convert(entity);
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
@ -1,59 +0,0 @@
@@ -1,59 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Reflection;
|
||||
//
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class GetElementByReflectionNameTests
|
||||
// {
|
||||
// IProjectContent mscorlib = AssemblyParserService.DefaultProjectContentRegistry.Mscorlib;
|
||||
//
|
||||
// void TestClass(Type type)
|
||||
// {
|
||||
// Assert.AreSame(typeof(object).Assembly, type.Assembly);
|
||||
// IClass c = (IClass)mscorlib.GetClassByReflectionName(type.FullName, false);
|
||||
// Assert.AreEqual(type.FullName, c.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TestClasses()
|
||||
// {
|
||||
// TestClass(typeof(object));
|
||||
// TestClass(typeof(Nullable));
|
||||
// TestClass(typeof(Nullable<>));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TestNestedClass()
|
||||
// {
|
||||
// TestClass(typeof(Environment.SpecialFolder));
|
||||
// TestClass(typeof(Dictionary<,>.ValueCollection));
|
||||
// }
|
||||
//
|
||||
// void TestMember(string className, string memberName)
|
||||
// {
|
||||
// IClass c = mscorlib.GetClassByReflectionName(className, false);
|
||||
// Assert.IsNotNull(c);
|
||||
// AbstractMember m = (AbstractMember)DefaultProjectContent.GetMemberByReflectionName(c, memberName);
|
||||
// Assert.AreEqual(className + "." + memberName, m.DocumentationTag.Substring(2));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TestConstructor()
|
||||
// {
|
||||
// TestMember("System.Collections.ObjectModel.KeyedCollection`2", "#ctor");
|
||||
// TestMember("System.Collections.ObjectModel.KeyedCollection`2", "#ctor(System.Collections.Generic.IEqualityComparer{`0},System.Int32)");
|
||||
// TestMember("System.Runtime.InteropServices.CurrencyWrapper", "#ctor(System.Decimal)");
|
||||
// TestMember("System.Runtime.InteropServices.CurrencyWrapper", "#ctor(System.Object)");
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,479 +0,0 @@
@@ -1,479 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class InnerClassesResolverTests
|
||||
// {
|
||||
// #region Test helper methods
|
||||
// NRefactoryResolverTests nrrt = new NRefactoryResolverTests();
|
||||
//
|
||||
// ResolveResult Resolve(string program, string expression, int line)
|
||||
// {
|
||||
// return nrrt.Resolve(program, expression, line);
|
||||
// }
|
||||
//
|
||||
// T Resolve<T>(string program, string expression, int line) where T : ResolveResult
|
||||
// {
|
||||
// return nrrt.Resolve<T>(program, expression, line);
|
||||
// }
|
||||
//
|
||||
// T ResolveVB<T>(string program, string expression, int line) where T : ResolveResult
|
||||
// {
|
||||
// return nrrt.ResolveVB<T>(program, expression, line);
|
||||
// }
|
||||
//
|
||||
// List<ICompletionEntry> CtrlSpace(string program, int line)
|
||||
// {
|
||||
// return nrrt.CtrlSpaceResolveCSharp(program, line, ExpressionContext.Default);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// #region Ctrl-Space tests
|
||||
// [Test]
|
||||
// public void CtrlSpaceIncludesInnerClass()
|
||||
// {
|
||||
// string program = @"class A {
|
||||
// class Inner { }
|
||||
//
|
||||
// }";
|
||||
// Assert.IsTrue(IsInnerClassVisible(CtrlSpace(program, 3)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CtrlSpaceIncludesInheritedInnerClass()
|
||||
// {
|
||||
// string program = @"class A : Outer {
|
||||
//
|
||||
// }
|
||||
// class Outer { protected class Inner { } }
|
||||
//";
|
||||
// Assert.IsTrue(IsInnerClassVisible(CtrlSpace(program, 2)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CtrlSpaceDoesNotIncludeInheritedPrivateInnerClass()
|
||||
// {
|
||||
// string program = @"class A : Outer {
|
||||
//
|
||||
// }
|
||||
// class Outer { class Inner { } }
|
||||
//";
|
||||
// Assert.IsFalse(IsInnerClassVisible(CtrlSpace(program, 2)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CtrlSpaceIncludesInnerClassFromOtherPart()
|
||||
// {
|
||||
// string program = @"partial class A {
|
||||
//
|
||||
// }
|
||||
// partial class A { class Inner { } }
|
||||
//";
|
||||
// Assert.IsTrue(IsInnerClassVisible(CtrlSpace(program, 2)));
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassTest()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class A {
|
||||
//
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve<TypeResolveResult>(program, "Environment.SpecialFolder", 3);
|
||||
// Assert.AreEqual("System.Environment.SpecialFolder", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SimpleInnerClass()
|
||||
// {
|
||||
// string program = @"class A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
// class B { }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B", 3);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassWithStaticFieldOfSameType()
|
||||
// {
|
||||
// string program = @"class A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
// class B {
|
||||
// public static B Instance;
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B.Instance", 3);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassWithStaticFieldOfSameTypeInPartialClass1()
|
||||
// {
|
||||
// string program = @"partial class A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//partial class A {
|
||||
// class B {
|
||||
// public static B Instance;
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B.Instance", 3);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassWithStaticFieldOfSameTypeInPartialClass2()
|
||||
// {
|
||||
// string program = @"partial class A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
// class B {
|
||||
// public static B Instance;
|
||||
// }
|
||||
//}
|
||||
//partial class A {
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B.Instance", 3);
|
||||
// Assert.IsTrue(result is MemberResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReflectionInnerClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "Environment.SpecialFolder", 3);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("System.Environment.SpecialFolder", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OuterclassPrivateFieldCtrlSpaceTest()
|
||||
// {
|
||||
// string program = @"class A
|
||||
//{
|
||||
// int myField;
|
||||
// class B
|
||||
// {
|
||||
// void MyMethod(A a)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "a", 8);
|
||||
// Assert.IsNotNull(result, "result");
|
||||
// Assert.IsTrue(result is LocalResolveResult, "result is LocalResolveResult");
|
||||
// var arr = result.GetCompletionData(nrrt.lastPC);
|
||||
// Assert.IsNotNull(arr, "arr");
|
||||
// foreach (object o in arr) {
|
||||
// if (o is IField) {
|
||||
// Assert.AreEqual("myField", ((IField)o).Name);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// Assert.Fail("private field not visible from inner class");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OuterclassStaticFieldResolveTest()
|
||||
// {
|
||||
// string program = @"class A
|
||||
//{
|
||||
// static int myField;
|
||||
// class B
|
||||
// {
|
||||
// void MyMethod()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult result = Resolve<MemberResolveResult>(program, "myField", 8);
|
||||
// Assert.AreEqual("A.myField", result.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OuterclassStaticMethodCallResolveTest()
|
||||
// {
|
||||
// string program = @"class A
|
||||
//{
|
||||
// static void Test(int arg);
|
||||
// class B
|
||||
// {
|
||||
// void MyMethod()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult result = Resolve<MemberResolveResult>(program, "Test(4)", 8);
|
||||
// Assert.AreEqual("A.Test", result.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InheritedInnerClass()
|
||||
// {
|
||||
// string program = @"class A {
|
||||
// protected class B { }
|
||||
//}
|
||||
//class C : A {
|
||||
// void Main() {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B", 6);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
//
|
||||
// result = Resolve(program, "C.B", 6);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
//
|
||||
// result = Resolve(program, "C", 6);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("C", result.ResolvedType.FullyQualifiedName);
|
||||
// foreach (object o in result.GetCompletionData(nrrt.lastPC)) {
|
||||
// if (o is IClass) {
|
||||
// Assert.AreEqual("A.B", ((IClass)o).FullyQualifiedName);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// Assert.Fail("Inherited inner class not visible.");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NestedClassHidingHidesAllMethods()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class A {
|
||||
// static void Test(int arg) {}
|
||||
// static void Test(string arg) {}
|
||||
// class B {
|
||||
// void MyMethod() {
|
||||
//
|
||||
// }
|
||||
// static void Test(long arg) {}
|
||||
// }
|
||||
//}";
|
||||
// MemberResolveResult result = Resolve<MemberResolveResult>(program, "Test(4)", 7);
|
||||
// Assert.AreEqual("A.B.Test", result.ResolvedMember.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NestedInnerClasses()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//public sealed class GL {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public class Enums
|
||||
// {
|
||||
// public enum BeginMode {QUADS, LINES }
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "GL.Enums.BeginMode", 4);
|
||||
// Assert.AreEqual("GL.Enums.BeginMode", trr.ResolvedClass.FullyQualifiedName);
|
||||
//
|
||||
// trr = Resolve<TypeResolveResult>(program, "Enums.BeginMode", 4);
|
||||
// Assert.AreEqual("GL.Enums.BeginMode", trr.ResolvedClass.FullyQualifiedName);
|
||||
//
|
||||
// MemberResolveResult mrr = Resolve<MemberResolveResult>(program, "GL.Enums.BeginMode.LINES", 4);
|
||||
// Assert.AreEqual("GL.Enums.BeginMode.LINES", mrr.ResolvedMember.FullyQualifiedName);
|
||||
//
|
||||
// mrr = Resolve<MemberResolveResult>(program, "Enums.BeginMode.LINES", 4);
|
||||
// Assert.AreEqual("GL.Enums.BeginMode.LINES", mrr.ResolvedMember.FullyQualifiedName);
|
||||
//
|
||||
// // ensure that GetClass works correctly:
|
||||
// IClass c = trr.ResolvedClass.ProjectContent.GetClass("GL.Enums.BeginMode", 0);
|
||||
// Assert.IsNotNull(c);
|
||||
// Assert.AreEqual("GL.Enums.BeginMode", c.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DoNotShowInaccessibleInnerClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class C {
|
||||
//
|
||||
//}
|
||||
//class Outer { private class Inner { } }
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "Outer", 3);
|
||||
// var l = trr.GetCompletionData(trr.ResolvedClass.ProjectContent);
|
||||
// Assert.IsFalse(IsInnerClassVisible(l));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ShowProtectedInnerClassFromDerivedClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Derived : Outer {
|
||||
//
|
||||
//}
|
||||
//class Outer { protected class Inner {} }
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "Outer", 3);
|
||||
// var l = trr.GetCompletionData(trr.ResolvedClass.ProjectContent);
|
||||
// Assert.IsTrue(IsInnerClassVisible(l));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ShowProtectedInnerClassThroughForeignDerivedClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Derived : Outer {
|
||||
//
|
||||
//}
|
||||
//class Derived2 : Outer { }
|
||||
//class Outer { protected class Inner {} }
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "Derived2", 3);
|
||||
// var l = trr.GetCompletionData(trr.ResolvedClass.ProjectContent);
|
||||
// Assert.IsTrue(IsInnerClassVisible(l));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DoNotShowProtectedInnerClassThroughUnrelatedClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Unrelated {
|
||||
//
|
||||
//}
|
||||
//class Derived : Outer { }
|
||||
//class Outer { protected class Inner {} }
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "Derived", 3);
|
||||
// var l = trr.GetCompletionData(trr.ResolvedClass.ProjectContent);
|
||||
// Assert.IsFalse(IsInnerClassVisible(l));
|
||||
// }
|
||||
//
|
||||
// bool IsInnerClassVisible(IEnumerable l)
|
||||
// {
|
||||
// foreach (object o in l) {
|
||||
// IClass c = o as IClass;
|
||||
// if (c != null && c.Name == "Inner")
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericInnerClassOrNonGenericOuterClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Test {
|
||||
//
|
||||
// class TheClass<T> {}
|
||||
//}
|
||||
//class TheClass { }
|
||||
//";
|
||||
// TypeResolveResult trr = Resolve<TypeResolveResult>(program, "TheClass<string>", 3);
|
||||
// Assert.AreEqual("Test.TheClass", trr.ResolvedClass.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericInnerClassOrNonGenericOuterClass2()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Test {
|
||||
// TheClass<string> x;
|
||||
//
|
||||
// class TheClass<T> {}
|
||||
//}
|
||||
//class TheClass { }
|
||||
//";
|
||||
// MemberResolveResult rr = Resolve<MemberResolveResult>(program, "x", 3);
|
||||
// Assert.AreEqual("Test.TheClass", rr.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericInnerClassOrNonGenericInnerClass()
|
||||
// {
|
||||
// string program = @"using System;
|
||||
//class Test {
|
||||
// TheClass<string> x1;
|
||||
// TheClass x2;
|
||||
// Test.TheClass<string> y1;
|
||||
// Test.TheClass y2;
|
||||
// global::Test.TheClass<string> z1;
|
||||
// global::Test.TheClass z2;
|
||||
//
|
||||
// public class TheClass { }
|
||||
// public class TheClass<T> {}
|
||||
//}
|
||||
//";
|
||||
// MemberResolveResult rr = Resolve<MemberResolveResult>(program, "x1", 3);
|
||||
// Assert.AreEqual(1, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
//
|
||||
// rr = Resolve<MemberResolveResult>(program, "y1", 3);
|
||||
// Assert.AreEqual(1, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
//
|
||||
// rr = Resolve<MemberResolveResult>(program, "z1", 3);
|
||||
// Assert.AreEqual(1, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
//
|
||||
// rr = Resolve<MemberResolveResult>(program, "x2", 3);
|
||||
// Assert.AreEqual(0, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
//
|
||||
// rr = Resolve<MemberResolveResult>(program, "y2", 3);
|
||||
// Assert.AreEqual(0, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
//
|
||||
// rr = Resolve<MemberResolveResult>(program, "z2", 3);
|
||||
// Assert.AreEqual(0, rr.ResolvedType.GetUnderlyingClass().TypeParameters.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SimpleInnerClassInStruct()
|
||||
// {
|
||||
// string program = @"struct A {
|
||||
// void Test() {
|
||||
//
|
||||
// }
|
||||
// class B { }
|
||||
//}
|
||||
//";
|
||||
// ResolveResult result = Resolve(program, "B", 3);
|
||||
// Assert.IsTrue(result is TypeResolveResult);
|
||||
// Assert.AreEqual("A.B", result.ResolvedType.FullyQualifiedName);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,150 +0,0 @@
@@ -1,150 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Text;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class OverloadFinding
|
||||
// {
|
||||
// [Test] public void Simple()
|
||||
// {
|
||||
// Test("(\"Hallo\")", 0, "(string a)", "(int b)");
|
||||
// Test("(2)", 1, "(string a)", "(int b)");
|
||||
// }
|
||||
//
|
||||
// [Test] public void WinForms()
|
||||
// {
|
||||
// string[] overloads = {"(object a)", "(TextBoxBase a)", "(Control a)", "(RichTextBox a)"};
|
||||
// Test("(new RichTextBox())", 3, overloads);
|
||||
// Test("(new Control())", 2, overloads);
|
||||
// Test("(new TextBox())", 1, overloads);
|
||||
// Test("(new Button())", 2, overloads);
|
||||
// Test("(3)", 0, overloads);
|
||||
// }
|
||||
//
|
||||
// [Test] public void Params()
|
||||
// {
|
||||
// string[] overloads = {"(params int[] a)", "(int a, params int[] b)"};
|
||||
// Test("()", 0, overloads);
|
||||
// Test("(1)", 1, overloads);
|
||||
// Test("(1, 2)", 1, overloads);
|
||||
// }
|
||||
//
|
||||
// [Test] public void IntegerConversion()
|
||||
// {
|
||||
// string[] overloads = {"<T>(T a)", "(int a)"};
|
||||
// Test("(1)", 1, overloads);
|
||||
// Test("(short.MaxValue)", 0, overloads);
|
||||
// Test("(long.MaxValue)", 0, overloads);
|
||||
// }
|
||||
//
|
||||
// [Test] public void NullForReferenceTypes()
|
||||
// {
|
||||
// string[] overloads = {"(int a)", "(string a)"};
|
||||
// Test("(null)", 1, overloads);
|
||||
// }
|
||||
//
|
||||
// [Test] public void NullForNullableType()
|
||||
// {
|
||||
// string[] overloads = {"(int a)", "(int? a)"};
|
||||
// Test("(null)", 1, overloads);
|
||||
// }
|
||||
//
|
||||
// [Test] public void Generic()
|
||||
// {
|
||||
// string program = "class T<A> {} class T<A, B> {}";
|
||||
// string[] overloads = {"(T<int> a)", "(T<int, string> a)", "(T<char, string> a)"};
|
||||
// Test("(new T<int>())", program, 0, overloads);
|
||||
// Test("(new T<int, string>())", program, 1, overloads);
|
||||
// Test("(new T<char, string>())", program, 2, overloads);
|
||||
// }
|
||||
//
|
||||
// NRefactoryResolverTests nrrt = new NRefactoryResolverTests();
|
||||
//
|
||||
// void Test(string callExpr, int num, params string[] signatures)
|
||||
// {
|
||||
// Test(callExpr, "", num, signatures);
|
||||
// }
|
||||
//
|
||||
// void Test(string callExpr, string extraCode, int num, params string[] signatures)
|
||||
// {
|
||||
// StringBuilder b = new StringBuilder();
|
||||
// int lineNumber = 0;
|
||||
// ++lineNumber; b.AppendLine("using System;");
|
||||
// ++lineNumber; b.AppendLine("using System.Windows.Forms;");
|
||||
// ++lineNumber; b.AppendLine("class TestClass {");
|
||||
// ++lineNumber; b.AppendLine(" void callingMethod() {");
|
||||
// ++lineNumber; b.AppendLine(" ");
|
||||
// int callPosition = lineNumber;
|
||||
// ++lineNumber; b.AppendLine(" }");
|
||||
// int[] positions = new int[signatures.Length];
|
||||
// for (int i = 0; i < signatures.Length; i++) {
|
||||
// b.Append(" void Method");
|
||||
// b.Append(signatures[i]);
|
||||
// ++lineNumber; b.AppendLine(" {");
|
||||
// positions[i] = lineNumber;
|
||||
// ++lineNumber; b.AppendLine(" }");
|
||||
// }
|
||||
// b.AppendLine("}");
|
||||
// b.Append(extraCode);
|
||||
// MemberResolveResult mrr = nrrt.Resolve<MemberResolveResult>(b.ToString(), "Method" + callExpr, callPosition);
|
||||
// string msg = "wrong overload: ";
|
||||
// for (int i = 0; i < positions.Length; i++) {
|
||||
// if (positions[i] == mrr.ResolvedMember.Region.BeginLine)
|
||||
// msg += signatures[i];
|
||||
// }
|
||||
// Assert.AreEqual(positions[num], mrr.ResolvedMember.Region.BeginLine, msg);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MultipleOverloadsWithImplicitLambda()
|
||||
// {
|
||||
// string program = @"class MainClass {
|
||||
// void Main() {
|
||||
// M(x=>x.ToUpper());
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// int M(Func<int, int> f){ /* whatever ... */ }
|
||||
// string M(Func<string, string> f){ /* whatever ... */ }
|
||||
//}";
|
||||
// var mrr = nrrt.Resolve<MemberResolveResult>(program, "M(x=>x.ToUpper())", 3, 3, ExpressionContext.Default);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MultipleOverloadsWithImplicitLambda2()
|
||||
// {
|
||||
// string program = @"class MainClass {
|
||||
// void Main() {
|
||||
// M(x=>x.Length);
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// int M(Func<int, int> f){ /* whatever ... */ }
|
||||
// string M(Func<string, int> f){ /* whatever ... */ }
|
||||
//}";
|
||||
// var mrr = nrrt.Resolve<MemberResolveResult>(program, "M(x=>x.Length)", 3, 3, ExpressionContext.Default);
|
||||
// Assert.AreEqual("System.String", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MultipleOverloadsWithImplicitLambda3()
|
||||
// {
|
||||
// string program = @"class MainClass {
|
||||
// void Main() {
|
||||
// M(x=>x+x);
|
||||
// }
|
||||
// delegate R Func<T, R>(T arg);
|
||||
// string M(Func<string, int> f){ /* whatever ... */ }
|
||||
// int M(Func<int, int> f){ /* whatever ... */ }
|
||||
//}";
|
||||
// var mrr = nrrt.Resolve<MemberResolveResult>(program, "M(x=>x+x)", 3, 3, ExpressionContext.Default);
|
||||
// Assert.AreEqual("System.Int32", mrr.ResolvedType.DotNetName);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,137 +0,0 @@
@@ -1,137 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests the OverrideCompletionDataProvider GetOverridableMethods.
|
||||
// /// This method should be added to the IClass interface.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class OverridableMethodsTestFixture
|
||||
// {
|
||||
// MockClass c;
|
||||
// MockDefaultReturnType returnType;
|
||||
// List<IMethod> expectedMethods;
|
||||
// MockClass declaringType;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void SetUp()
|
||||
// {
|
||||
// expectedMethods = new List<IMethod>();
|
||||
// c = new MockClass("MyClass");
|
||||
// declaringType = new MockClass("MyDeclaringType");
|
||||
// returnType = new MockDefaultReturnType();
|
||||
// c.DefaultReturnType = returnType;
|
||||
// }
|
||||
//
|
||||
// IMethod[] GetOverridableMethods(IClass baseClass)
|
||||
// {
|
||||
// return OverrideCompletionItemProvider.GetOverridableMethods(new MockClass("DerivedClass") { BaseType = baseClass.DefaultReturnType });
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Add one overridable method to the return type and this
|
||||
// /// should be returned in the list of overridable methods.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OneOverridableMethodReturned()
|
||||
// {
|
||||
// MockMethod method = new MockMethod("Run");
|
||||
// method.DeclaringType = declaringType;
|
||||
// method.IsOverridable = true;
|
||||
// returnType.Methods.Add(method);
|
||||
//
|
||||
// expectedMethods.Add(method);
|
||||
//
|
||||
// IMethod[] methods = GetOverridableMethods(c);
|
||||
//
|
||||
// AssertAreMethodsEqual(expectedMethods, methods);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Make sure that an overridable method is not returned when
|
||||
// /// it is part of the class being considered.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridableMethodPartOfClass()
|
||||
// {
|
||||
// MockMethod method = new MockMethod("Run");
|
||||
// method.DeclaringType = c;
|
||||
// method.IsOverridable = true;
|
||||
// returnType.Methods.Add(method);
|
||||
//
|
||||
// IMethod[] methods = OverrideCompletionItemProvider.GetOverridableMethods(c);
|
||||
//
|
||||
// AssertAreMethodsEqual(expectedMethods, methods);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// An overridable but const method should not be returned.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridableConstMethodNotReturned()
|
||||
// {
|
||||
// MockMethod method = new MockMethod("Run");
|
||||
// method.DeclaringType = declaringType;
|
||||
// method.IsOverridable = true;
|
||||
// method.IsConst = true;
|
||||
// returnType.Methods.Add(method);
|
||||
//
|
||||
// IMethod[] methods = GetOverridableMethods(c);
|
||||
//
|
||||
// AssertAreMethodsEqual(expectedMethods, methods);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// An overridable but private method should not be returned.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridablePrivateMethodNotReturned()
|
||||
// {
|
||||
// MockMethod method = new MockMethod("Run");
|
||||
// method.DeclaringType = declaringType;
|
||||
// method.IsOverridable = true;
|
||||
// method.IsPrivate = true;
|
||||
// returnType.Methods.Add(method);
|
||||
//
|
||||
// IMethod[] methods = GetOverridableMethods(c);
|
||||
//
|
||||
// AssertAreMethodsEqual(expectedMethods, methods);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// [ExpectedException(typeof(ArgumentException))]
|
||||
// public void NullArgument()
|
||||
// {
|
||||
// OverrideCompletionItemProvider.GetOverridableMethods(null);
|
||||
// }
|
||||
//
|
||||
// void AssertAreMethodsEqual(List<IMethod> expectedMethods, IMethod[] methods)
|
||||
// {
|
||||
// // Get a list of expected method names.
|
||||
// List<string> expectedMethodNames = new List<string>();
|
||||
// foreach (IMethod expectedMethod in expectedMethods) {
|
||||
// expectedMethodNames.Add(expectedMethod.Name);
|
||||
// }
|
||||
//
|
||||
// // Get a list of actual method names.
|
||||
// List<string> methodNames = new List<string>();
|
||||
// foreach (IMethod m in methods) {
|
||||
// methodNames.Add(m.Name);
|
||||
// }
|
||||
//
|
||||
// // Compare the two arrays.
|
||||
// Assert.AreEqual(expectedMethodNames.ToArray(), methodNames.ToArray());
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,137 +0,0 @@
@@ -1,137 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests the OverrideCompletionDataProvider GetOverridableProperties.
|
||||
// /// This property should be added to the IClass interface.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class OverridablePropertiesTestFixture
|
||||
// {
|
||||
// MockClass c;
|
||||
// MockDefaultReturnType returnType;
|
||||
// List<IProperty> expectedProperties;
|
||||
// MockClass declaringType;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void SetUp()
|
||||
// {
|
||||
// expectedProperties = new List<IProperty>();
|
||||
// c = new MockClass("MyClass");
|
||||
// declaringType = new MockClass("MyDeclaringType");
|
||||
// returnType = new MockDefaultReturnType();
|
||||
// c.DefaultReturnType = returnType;
|
||||
// }
|
||||
//
|
||||
// IProperty[] GetOverridableProperties(IClass baseClass)
|
||||
// {
|
||||
// return OverrideCompletionItemProvider.GetOverridableProperties(new MockClass("DerivedClass") { BaseType = baseClass.DefaultReturnType });
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Add one overridable property to the return type and this
|
||||
// /// should be returned in the list of overridable properties.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OneOverridablePropertyReturned()
|
||||
// {
|
||||
// MockProperty property = new MockProperty("IsRunning");
|
||||
// property.DeclaringType = declaringType;
|
||||
// property.IsOverridable = true;
|
||||
// returnType.Properties.Add(property);
|
||||
//
|
||||
// expectedProperties.Add(property);
|
||||
//
|
||||
// IProperty[] properties = GetOverridableProperties(c);
|
||||
//
|
||||
// AssertArePropertiesEqual(expectedProperties, properties);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Make sure that an overridable property is not returned when
|
||||
// /// it is part of the class being considered.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridablePropertyPartOfClass()
|
||||
// {
|
||||
// MockProperty property = new MockProperty("IsRunning");
|
||||
// property.DeclaringType = c;
|
||||
// property.IsOverridable = true;
|
||||
// returnType.Properties.Add(property);
|
||||
//
|
||||
// IProperty[] properties = OverrideCompletionItemProvider.GetOverridableProperties(c);
|
||||
//
|
||||
// AssertArePropertiesEqual(expectedProperties, properties);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// An overridable but const property should not be returned.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridableConstPropertyNotReturned()
|
||||
// {
|
||||
// MockProperty property = new MockProperty("IsRunning");
|
||||
// property.DeclaringType = declaringType;
|
||||
// property.IsOverridable = true;
|
||||
// property.IsConst = true;
|
||||
// returnType.Properties.Add(property);
|
||||
//
|
||||
// IProperty[] properties = GetOverridableProperties(c);
|
||||
//
|
||||
// AssertArePropertiesEqual(expectedProperties, properties);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// An overridable but private property should not be returned.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void OverridablePrivatePropertyNotReturned()
|
||||
// {
|
||||
// MockProperty property = new MockProperty("Run");
|
||||
// property.DeclaringType = declaringType;
|
||||
// property.IsOverridable = true;
|
||||
// property.IsPrivate = true;
|
||||
// returnType.Properties.Add(property);
|
||||
//
|
||||
// IProperty[] properties = GetOverridableProperties(c);
|
||||
//
|
||||
// AssertArePropertiesEqual(expectedProperties, properties);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// [ExpectedException(typeof(ArgumentException))]
|
||||
// public void NullArgument()
|
||||
// {
|
||||
// OverrideCompletionItemProvider.GetOverridableProperties(null);
|
||||
// }
|
||||
//
|
||||
// void AssertArePropertiesEqual(List<IProperty> expectedProperties, IProperty[] properties)
|
||||
// {
|
||||
// // Get a list of expected property names.
|
||||
// List<string> expectedPropertyNames = new List<string>();
|
||||
// foreach (IProperty expectedProperty in expectedProperties) {
|
||||
// expectedPropertyNames.Add(expectedProperty.Name);
|
||||
// }
|
||||
//
|
||||
// // Get a list of actual property names.
|
||||
// List<string> propertyNames = new List<string>();
|
||||
// foreach (IProperty p in properties) {
|
||||
// propertyNames.Add(p.Name);
|
||||
// }
|
||||
//
|
||||
// // Compare the two arrays.
|
||||
// Assert.AreEqual(expectedPropertyNames.ToArray(), propertyNames.ToArray());
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections;
|
||||
//using System.IO;
|
||||
//using NUnit.Framework;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// //[TestFixture]
|
||||
// public class RefactoringTests
|
||||
// {
|
||||
// const string code = @"using System;
|
||||
//abstract class BaseClass {
|
||||
// protected abstract void FirstMethod();
|
||||
//
|
||||
// protected virtual void SecondMethod()
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
//class DerivedClass : BaseClass
|
||||
//{
|
||||
// protected override void FirstMethod()
|
||||
// {
|
||||
// SecondMethod();
|
||||
// }
|
||||
//}
|
||||
//class SecondDerivedClass : DerivedClass
|
||||
//{
|
||||
// protected override void FirstMethod()
|
||||
// {
|
||||
// Console.Beep();
|
||||
// }
|
||||
// protected override void SecondMethod()
|
||||
// {
|
||||
// FirstMethod();
|
||||
// }
|
||||
//}
|
||||
//";
|
||||
//
|
||||
// // TODO: Write unit tests for find references / find overrides / go to base class.
|
||||
// }
|
||||
//}
|
@ -1,444 +0,0 @@
@@ -1,444 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.CSharp;
|
||||
//using ICSharpCode.SharpDevelop.Dom.ReflectionLayer;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//[assembly: ICSharpCode.SharpDevelop.Tests.TypeTestAttribute(
|
||||
// 42, typeof(System.Action<>), typeof(IDictionary<string, IList<TestAttribute>>))]
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// public class TypeTestAttribute : Attribute
|
||||
// {
|
||||
// public TypeTestAttribute(int a1, Type a2, Type a3) {}
|
||||
// }
|
||||
//
|
||||
// [TestFixture]
|
||||
// public class ReflectionLayerTests : ReflectionOrCecilLayerTests
|
||||
// {
|
||||
// public ReflectionLayerTests()
|
||||
// {
|
||||
// mscorlib = AssemblyParserService.DefaultProjectContentRegistry.Mscorlib;
|
||||
// }
|
||||
//
|
||||
// protected override IClass GetClass(Type type)
|
||||
// {
|
||||
// ISyntaxTree cu = new ReflectionProjectContent("TestName", "testlocation", new DomAssemblyName[0], AssemblyParserService.DefaultProjectContentRegistry).AssemblySyntaxTree;
|
||||
// ((ReflectionProjectContent)cu.ProjectContent).AddReferencedContent(mscorlib);
|
||||
// IClass c = new ReflectionClass(cu, type, type.FullName, null);
|
||||
// cu.ProjectContent.AddClassToNamespaceList(c);
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// protected override IEnumerable<IAttribute> GetAssemblyAttributes(Assembly assembly)
|
||||
// {
|
||||
// var pc = new ReflectionProjectContent("TestName", "testlocation", new DomAssemblyName[0], AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// pc.AddAssemblyAttributes(assembly);
|
||||
// return pc.GetAssemblyAttributes();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestFixture]
|
||||
// public class ReflectionWithRoundTripLayerTests : ReflectionOrCecilLayerTests
|
||||
// {
|
||||
// public ReflectionWithRoundTripLayerTests()
|
||||
// {
|
||||
// mscorlib = AssemblyParserService.DefaultProjectContentRegistry.Mscorlib;
|
||||
//
|
||||
// MemoryStream memory = new MemoryStream();
|
||||
// DomPersistence.WriteProjectContent((ReflectionProjectContent)mscorlib, memory);
|
||||
// memory.Position = 0;
|
||||
// mscorlib = DomPersistence.LoadProjectContent(memory, AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// }
|
||||
//
|
||||
// protected override IClass GetClass(Type type)
|
||||
// {
|
||||
// ISyntaxTree cu = new ReflectionProjectContent("TestName", "testlocation", new DomAssemblyName[0], AssemblyParserService.DefaultProjectContentRegistry).AssemblySyntaxTree;
|
||||
// IClass c = new ReflectionClass(cu, type, type.FullName, null);
|
||||
// cu.ProjectContent.AddClassToNamespaceList(c);
|
||||
//
|
||||
// MemoryStream memory = new MemoryStream();
|
||||
// DomPersistence.WriteProjectContent((ReflectionProjectContent)c.ProjectContent, memory);
|
||||
//
|
||||
// memory.Position = 0;
|
||||
// ReflectionProjectContent loadedPC = DomPersistence.LoadProjectContent(memory, AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// loadedPC.AddReferencedContent(mscorlib);
|
||||
// return loadedPC.Classes.Single();
|
||||
// }
|
||||
//
|
||||
// protected override IEnumerable<IAttribute> GetAssemblyAttributes(Assembly assembly)
|
||||
// {
|
||||
// var pc = new ReflectionProjectContent("TestName", "testlocation", new DomAssemblyName[0], AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// pc.AddAssemblyAttributes(assembly);
|
||||
//
|
||||
// MemoryStream memory = new MemoryStream();
|
||||
// DomPersistence.WriteProjectContent(pc, memory);
|
||||
//
|
||||
// memory.Position = 0;
|
||||
// return DomPersistence.LoadProjectContent(memory, AssemblyParserService.DefaultProjectContentRegistry).GetAssemblyAttributes();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestFixture]
|
||||
// public class CecilLayerTests : ReflectionOrCecilLayerTests
|
||||
// {
|
||||
// public CecilLayerTests()
|
||||
// {
|
||||
// mscorlib = CecilReader.LoadAssembly(typeof(object).Assembly.Location, AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// }
|
||||
//
|
||||
// IProjectContent LoadAssembly(Assembly assembly)
|
||||
// {
|
||||
// var pc = CecilReader.LoadAssembly(assembly.Location, AssemblyParserService.DefaultProjectContentRegistry);
|
||||
// Assert.IsNotNull(pc);
|
||||
// pc.AddReferencedContent(mscorlib);
|
||||
// return pc;
|
||||
// }
|
||||
//
|
||||
// protected override IClass GetClass(Type type)
|
||||
// {
|
||||
// IClass c = LoadAssembly(type.Assembly).GetClassByReflectionName(type.FullName, false);
|
||||
// Assert.IsNotNull(c);
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// protected override IEnumerable<IAttribute> GetAssemblyAttributes(Assembly assembly)
|
||||
// {
|
||||
// return LoadAssembly(assembly).GetAssemblyAttributes();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public abstract class ReflectionOrCecilLayerTests
|
||||
// {
|
||||
// protected IProjectContent mscorlib;
|
||||
//
|
||||
// [Test]
|
||||
// public void InheritanceTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.SystemException", 0);
|
||||
// IClass c2 = mscorlib.GetClass("System.Exception", 0);
|
||||
// Assert.IsNotNull(c, "c is null");
|
||||
// Assert.IsNotNull(c2, "c2 is null");
|
||||
// //Assert.AreEqual(3, c.BaseTypes.Count); // Inherited interfaces are not reported by Cecil
|
||||
// // which matches the behaviour of our C#/VB parsers
|
||||
// Assert.AreEqual("System.Exception", c.BaseTypes[0].FullyQualifiedName);
|
||||
// Assert.AreSame(c2, c.BaseClass);
|
||||
//
|
||||
// List<IClass> subClasses = new List<IClass>();
|
||||
// foreach (IClass subClass in c.ClassInheritanceTree) {
|
||||
// subClasses.Add(subClass);
|
||||
// }
|
||||
// Assert.AreEqual(5, subClasses.Count, "ClassInheritanceTree length");
|
||||
// Assert.AreEqual("System.SystemException", subClasses[0].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Exception", subClasses[1].FullyQualifiedName);
|
||||
// if (subClasses[2].FullyQualifiedName == "System.Object") {
|
||||
// Assert.AreEqual("System.Object", subClasses[2].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Runtime.Serialization.ISerializable", subClasses[3].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Runtime.InteropServices._Exception", subClasses[4].FullyQualifiedName);
|
||||
// } else {
|
||||
// Assert.AreEqual("System.Runtime.Serialization.ISerializable", subClasses[2].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Runtime.InteropServices._Exception", subClasses[3].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Object", subClasses[4].FullyQualifiedName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericPropertyTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Collections.Generic.Comparer", 1);
|
||||
// IProperty def = c.Properties.First(p => p.Name == "Default");
|
||||
// ConstructedReturnType crt = def.ReturnType.CastToConstructedReturnType();
|
||||
// Assert.AreEqual("System.Collections.Generic.Comparer", crt.FullyQualifiedName);
|
||||
// Assert.IsTrue(crt.TypeArguments[0].IsGenericReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void PointerTypeTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.IntPtr", 1);
|
||||
// IMethod toPointer = c.Methods.First(p => p.Name == "ToPointer");
|
||||
// Assert.AreEqual("System.Void*", toPointer.ReturnType.DotNetName);
|
||||
// PointerReturnType prt = toPointer.ReturnType.CastToDecoratingReturnType<PointerReturnType>();
|
||||
// Assert.AreEqual("System.Void", prt.BaseType.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DateTimeDefaultConstructor()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.DateTime", 0);
|
||||
// Assert.IsFalse(c.Methods.Any(p => p.IsConstructor && p.Parameters.Count == 0));
|
||||
// Assert.IsTrue(c.AddDefaultConstructorIfRequired);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NoEncodingInfoDefaultConstructor()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Text.EncodingInfo", 0);
|
||||
// Assert.IsFalse(c.Methods.Any(p => p.IsConstructor)); // EncodingInfo only has an internal constructor
|
||||
// Assert.IsFalse(c.AddDefaultConstructorIfRequired);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ParameterComparisonTest()
|
||||
// {
|
||||
// DefaultParameter p1 = new DefaultParameter("a", mscorlib.GetClass("System.String", 0).DefaultReturnType, DomRegion.Empty);
|
||||
// DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(mscorlib, "System.String", 0), DomRegion.Empty);
|
||||
// IList<IParameter> a1 = new List<IParameter>();
|
||||
// IList<IParameter> a2 = new List<IParameter>();
|
||||
// a1.Add(p1);
|
||||
// a2.Add(p2);
|
||||
// Assert.AreEqual(0, DiffUtility.Compare(a1, a2));
|
||||
// }
|
||||
//
|
||||
// DefaultMethod GetMethod(IClass c, string name)
|
||||
// {
|
||||
// IMethod result = c.Methods.FirstOrDefault(m => m.Name == name);
|
||||
// Assert.IsNotNull(result, "Method " + name + " not found");
|
||||
// return (DefaultMethod)result;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenericDocumentationTagNamesTest()
|
||||
// {
|
||||
// DefaultClass c = (DefaultClass)mscorlib.GetClass("System.Collections.Generic.List", 1);
|
||||
// Assert.AreEqual("T:System.Collections.Generic.List`1",
|
||||
// c.DocumentationTag);
|
||||
// Assert.AreEqual("M:System.Collections.Generic.List`1.Add(`0)",
|
||||
// GetMethod(c, "Add").DocumentationTag);
|
||||
// Assert.AreEqual("M:System.Collections.Generic.List`1.AddRange(System.Collections.Generic.IEnumerable{`0})",
|
||||
// GetMethod(c, "AddRange").DocumentationTag);
|
||||
// Assert.AreEqual("M:System.Collections.Generic.List`1.ConvertAll``1(System.Converter{`0,``0})",
|
||||
// GetMethod(c, "ConvertAll").DocumentationTag);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StaticModifierTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Environment", 0);
|
||||
// Assert.IsNotNull(c, "System.Environment not found");
|
||||
// Assert.IsTrue(c.IsAbstract, "class should be abstract");
|
||||
// Assert.IsTrue(c.IsSealed, "class should be sealed");
|
||||
// Assert.IsTrue(c.IsStatic, "class should be static");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassReferenceTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Environment", 0);
|
||||
// Assert.IsNotNull(c, "System.Environment not found");
|
||||
// IReturnType rt = GetMethod(c, "GetFolderPath").Parameters[0].ReturnType;
|
||||
// Assert.IsNotNull(rt, "ReturnType is null");
|
||||
// Assert.AreEqual("System.Environment.SpecialFolder", rt.FullyQualifiedName);
|
||||
// IClass inner = rt.GetUnderlyingClass();
|
||||
// Assert.IsNotNull(inner, "UnderlyingClass");
|
||||
// Assert.AreEqual("System.Environment.SpecialFolder", inner.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void InnerClassesTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Environment.SpecialFolder", 0);
|
||||
// Assert.IsNotNull(c, "c is null");
|
||||
// Assert.AreEqual("System.Environment.SpecialFolder", c.FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void VoidTest()
|
||||
// {
|
||||
// IClass c = mscorlib.GetClass("System.Void", 0);
|
||||
// Assert.IsNotNull(c, "System.Void not found");
|
||||
// Assert.AreSame(c.DefaultReturnType, mscorlib.SystemTypes.Void, "pc.SystemTypes.Void is c.DefaultReturnType");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NestedClassInGenericClassTest()
|
||||
// {
|
||||
// IClass dictionary = mscorlib.GetClass("System.Collections.Generic.Dictionary", 2);
|
||||
// Assert.IsNotNull(dictionary);
|
||||
// IClass valueCollection = mscorlib.GetClass("System.Collections.Generic.Dictionary.ValueCollection", 2);
|
||||
// Assert.IsNotNull(valueCollection);
|
||||
// var dictionaryRT = new ConstructedReturnType(dictionary.DefaultReturnType, new[] { mscorlib.SystemTypes.String, mscorlib.SystemTypes.Int32 });
|
||||
// IProperty valueProperty = dictionaryRT.GetProperties().Find(p => p.Name == "Values");
|
||||
// Assert.AreSame(valueCollection, valueProperty.ReturnType.GetUnderlyingClass());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ValueCollectionCountModifiers()
|
||||
// {
|
||||
// IClass valueCollection = mscorlib.GetClass("System.Collections.Generic.Dictionary.ValueCollection", 2);
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, valueCollection.Modifiers);
|
||||
// IProperty count = valueCollection.Properties.Single(p => p.Name == "Count");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, count.Modifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MathAcosModifiers()
|
||||
// {
|
||||
// IClass math = mscorlib.GetClass("System.Math", 0);
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract | ModifierEnum.Sealed | ModifierEnum.Static, math.Modifiers);
|
||||
// IMethod acos = math.Methods.Single(p => p.Name == "Acos");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Static, acos.Modifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void EncodingModifiers()
|
||||
// {
|
||||
// IClass encoding = mscorlib.GetClass("System.Text.Encoding", 0);
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract, encoding.Modifiers);
|
||||
// IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Virtual, getDecoder.Modifiers);
|
||||
// IMethod getMaxByteCount = encoding.Methods.Single(p => p.Name == "GetMaxByteCount");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract, getMaxByteCount.Modifiers);
|
||||
// IProperty encoderFallback = encoding.Properties.Single(p => p.Name == "EncoderFallback");
|
||||
// Assert.AreEqual(ModifierEnum.Public, encoderFallback.Modifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void UnicodeEncodingModifiers()
|
||||
// {
|
||||
// IClass encoding = mscorlib.GetClass("System.Text.UnicodeEncoding", 0);
|
||||
// Assert.AreEqual(ModifierEnum.Public, encoding.Modifiers);
|
||||
// IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Override, getDecoder.Modifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void UTF32EncodingModifiers()
|
||||
// {
|
||||
// IClass encoding = mscorlib.GetClass("System.Text.UTF32Encoding", 0);
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, encoding.Modifiers);
|
||||
// IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
|
||||
// Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Override, getDecoder.Modifiers);
|
||||
// }
|
||||
//
|
||||
// public class TestClass<A, B> where A : B {
|
||||
// public void TestMethod<K, V>(string param) where V: K where K: IComparable {}
|
||||
//
|
||||
// public void GetIndex<T>(T element) where T: IEquatable<T> {}
|
||||
//
|
||||
// public int Property { get; protected set; }
|
||||
// public dynamic ReadOnlyPropertyWithPrivateSetter { get; private set; }
|
||||
//
|
||||
// public List<dynamic> DynamicGenerics1(Action<object, dynamic[], object> param) { return null; }
|
||||
// public void DynamicGenerics2(Action<object, dynamic, object> param) { }
|
||||
// public void DynamicGenerics3(Action<int, dynamic, object> param) { }
|
||||
// public void DynamicGenerics4(Action<int[], dynamic, object> param) { }
|
||||
// public void DynamicGenerics5(Action<int*[], dynamic, object> param) { }
|
||||
// }
|
||||
//
|
||||
// protected abstract IClass GetClass(Type type);
|
||||
// protected abstract IEnumerable<IAttribute> GetAssemblyAttributes(Assembly assembly);
|
||||
//
|
||||
// IClass testClass;
|
||||
//
|
||||
// [TestFixtureSetUp]
|
||||
// public void FixtureSetUp()
|
||||
// {
|
||||
// testClass = GetClass(typeof(TestClass<,>));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TestClassTypeParameters()
|
||||
// {
|
||||
// Assert.AreSame(testClass, testClass.TypeParameters[0].Class);
|
||||
// Assert.AreSame(testClass, testClass.TypeParameters[1].Class);
|
||||
// Assert.AreSame(testClass.TypeParameters[1], ((GenericReturnType)testClass.TypeParameters[0].Constraints[0]).TypeParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void TestMethod()
|
||||
// {
|
||||
// IMethod m = testClass.Methods.Single(me => me.Name == "TestMethod");
|
||||
// Assert.AreEqual("K", m.TypeParameters[0].Name);
|
||||
// Assert.AreEqual("V", m.TypeParameters[1].Name);
|
||||
// Assert.AreSame(m, m.TypeParameters[0].Method);
|
||||
// Assert.AreSame(m, m.TypeParameters[1].Method);
|
||||
//
|
||||
// Assert.AreEqual("IComparable", m.TypeParameters[0].Constraints[0].Name);
|
||||
// GenericReturnType kConst = (GenericReturnType)m.TypeParameters[1].Constraints[0];
|
||||
// Assert.AreSame(m.TypeParameters[0], kConst.TypeParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetIndex()
|
||||
// {
|
||||
// IMethod m = testClass.Methods.Single(me => me.Name == "GetIndex");
|
||||
// Assert.AreEqual("T", m.TypeParameters[0].Name);
|
||||
// Assert.AreSame(m, m.TypeParameters[0].Method);
|
||||
//
|
||||
// Assert.AreEqual("IEquatable", m.TypeParameters[0].Constraints[0].Name);
|
||||
// Assert.AreEqual(1, m.TypeParameters[0].Constraints[0].TypeArgumentCount);
|
||||
// Assert.AreEqual(1, m.TypeParameters[0].Constraints[0].CastToConstructedReturnType().TypeArguments.Count);
|
||||
// GenericReturnType grt = (GenericReturnType)m.TypeParameters[0].Constraints[0].CastToConstructedReturnType().TypeArguments[0];
|
||||
// Assert.AreSame(m.TypeParameters[0], grt.TypeParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Property()
|
||||
// {
|
||||
// IProperty p = testClass.Properties.Single(pr => pr.Name == "Property");
|
||||
// Assert.AreEqual(ModifierEnum.Public, p.Modifiers);
|
||||
// Assert.AreEqual(ModifierEnum.None, p.GetterModifiers);
|
||||
// Assert.AreEqual(ModifierEnum.Protected, p.SetterModifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CannotSetReadOnlyProperty()
|
||||
// {
|
||||
// IProperty p = testClass.Properties.Single(pr => pr.Name == "ReadOnlyPropertyWithPrivateSetter");
|
||||
// Assert.AreEqual(ModifierEnum.Public, p.Modifiers);
|
||||
// Assert.AreEqual(ModifierEnum.None, p.GetterModifiers);
|
||||
// Assert.IsFalse(p.CanSet);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DynamicType()
|
||||
// {
|
||||
// IProperty p = testClass.Properties.Single(pr => pr.Name == "ReadOnlyPropertyWithPrivateSetter");
|
||||
// Assert.IsInstanceOf(typeof(DynamicReturnType), p.ReturnType);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DynamicTypeInGenerics()
|
||||
// {
|
||||
// CSharpAmbience a = new CSharpAmbience();
|
||||
// a.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterList;
|
||||
// Assert.AreEqual("List<dynamic> DynamicGenerics1(Action<object, dynamic[], object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics1")));
|
||||
// Assert.AreEqual("void DynamicGenerics2(Action<object, dynamic, object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics2")));
|
||||
// Assert.AreEqual("void DynamicGenerics3(Action<int, dynamic, object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics3")));
|
||||
// Assert.AreEqual("void DynamicGenerics4(Action<int[], dynamic, object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics4")));
|
||||
// Assert.AreEqual("void DynamicGenerics5(Action<Int32*[], dynamic, object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics5")));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AssemblyAttribute()
|
||||
// {
|
||||
// var attributes = GetAssemblyAttributes(typeof(TypeTestAttribute).Assembly);
|
||||
// var typeTest = attributes.First(a => a.AttributeType.FullyQualifiedName == typeof(TypeTestAttribute).FullName);
|
||||
// Assert.AreEqual(3, typeTest.PositionalArguments.Count);
|
||||
// // first argument is (int)42
|
||||
// Assert.AreEqual(42, (int)typeTest.PositionalArguments[0]);
|
||||
// // second argument is typeof(System.Action<>)
|
||||
// IReturnType rt = (IReturnType)typeTest.PositionalArguments[1];
|
||||
// Assert.IsNull(rt.CastToConstructedReturnType()); // rt must not be constructed - it's just an unbound type
|
||||
// Assert.AreEqual("System.Action", rt.FullyQualifiedName);
|
||||
// Assert.AreEqual(1, rt.TypeArgumentCount);
|
||||
// // third argument is typeof(IDictionary<string, IList<TestAttribute>>)
|
||||
// ConstructedReturnType crt = ((IReturnType)typeTest.PositionalArguments[2]).CastToConstructedReturnType();
|
||||
// Assert.AreEqual("System.Collections.Generic.IDictionary", crt.FullyQualifiedName);
|
||||
// Assert.AreEqual("System.String", crt.TypeArguments[0].FullyQualifiedName);
|
||||
// Assert.AreEqual("System.Collections.Generic.IList{NUnit.Framework.TestAttribute}", crt.TypeArguments[1].DotNetName);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,173 +0,0 @@
@@ -1,173 +0,0 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class SearchClassTests
|
||||
// {
|
||||
// ProjectContentRegistry projectContentRegistry = AssemblyParserService.DefaultProjectContentRegistry;
|
||||
//
|
||||
// #region Helper methods
|
||||
// ISyntaxTree Prepare(LanguageProperties language)
|
||||
// {
|
||||
// DefaultProjectContent pc = new DefaultProjectContent();
|
||||
// pc.ReferencedContents.Add(projectContentRegistry.Mscorlib);
|
||||
// pc.Language = language;
|
||||
// DefaultSyntaxTree cu = new DefaultSyntaxTree(pc);
|
||||
// if (language == LanguageProperties.VBNet)
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "syStEm"));
|
||||
// else
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "System"));
|
||||
// return cu;
|
||||
// }
|
||||
//
|
||||
// IUsing CreateUsing(IProjectContent pc, string @namespace)
|
||||
// {
|
||||
// DefaultUsing @using = new DefaultUsing(pc);
|
||||
// @using.Usings.Add(@namespace);
|
||||
// return @using;
|
||||
// }
|
||||
//
|
||||
// IReturnType SearchType(string type)
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp);
|
||||
// IReturnType c = cu.ProjectContent.SearchType(new SearchTypeRequest(type, 0, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c, type + "not found");
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// IReturnType SearchTypeVB(string type)
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.VBNet);
|
||||
// IReturnType c = cu.ProjectContent.SearchType(new SearchTypeRequest(type, 0, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c, type + "not found");
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// void CheckNamespace(string @namespace, string className)
|
||||
// {
|
||||
// CheckNamespace(@namespace, className, LanguageProperties.CSharp);
|
||||
// }
|
||||
//
|
||||
// void CheckNamespaceVB(string @namespace, string className)
|
||||
// {
|
||||
// CheckNamespace(@namespace, className, LanguageProperties.VBNet);
|
||||
// }
|
||||
//
|
||||
// void CheckNamespace(string @namespace, string className, LanguageProperties language)
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(language);
|
||||
// string ns = cu.ProjectContent.SearchType(new SearchTypeRequest(@namespace, 0, null, cu, 1, 1)).NamespaceResult;
|
||||
// Assert.IsNotNull(ns, @namespace + " not found");
|
||||
// foreach (object o in cu.ProjectContent.GetNamespaceContents(ns)) {
|
||||
// IClass c = o as IClass;
|
||||
// if (c != null && c.Name == className)
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchFullyQualifiedClass()
|
||||
// {
|
||||
// Assert.AreEqual("System.Reflection.Assembly", SearchType("System.Reflection.Assembly").FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchFullyQualifiedClassVB()
|
||||
// {
|
||||
// Assert.AreEqual("System.Reflection.Assembly", SearchTypeVB("SYStem.RefleCtion.asSembly").FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchFullyQualifiedNamespace()
|
||||
// {
|
||||
// CheckNamespace("System.Collections.Generic", "KeyNotFoundException");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchFullyQualifiedNamespaceVB()
|
||||
// {
|
||||
// CheckNamespaceVB("SyStem.COllEctions.GeNEric", "KeyNotFoundException");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchEnvironment()
|
||||
// {
|
||||
// Assert.AreEqual("System.Environment", SearchType("Environment").FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchEnvironmentVB()
|
||||
// {
|
||||
// Assert.AreEqual("System.Environment", SearchTypeVB("EnVIroNmEnt").FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchArrayList()
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp);
|
||||
// IReturnType c = cu.ProjectContent.SearchType(new SearchTypeRequest("Collections.ArrayList", 0, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNull(c, "Namespaces should not be imported in C#");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchArrayListVB()
|
||||
// {
|
||||
// Assert.AreEqual("System.Collections.ArrayList", SearchTypeVB("CoLLections.ArrAyLiSt").FullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchNestedNamespace()
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp);
|
||||
// string ns = cu.ProjectContent.SearchType(new SearchTypeRequest("Collections.Generic", 0, null, cu, 1, 1)).NamespaceResult;
|
||||
// Assert.IsNull(ns, "Nested namespaces should not be found in C#");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchNestedNamespaceVB()
|
||||
// {
|
||||
// CheckNamespaceVB("COllEctions.GeNEric", "KeyNotFoundException");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchClassPreferVisible()
|
||||
// {
|
||||
// ISyntaxTree ref1 = Prepare(LanguageProperties.CSharp);
|
||||
// ref1.ProjectContent.AddClassToNamespaceList(new DefaultClass(ref1, "ClassName") { Modifiers = ModifierEnum.Internal });
|
||||
// ISyntaxTree ref2 = Prepare(LanguageProperties.CSharp);
|
||||
// ref2.ProjectContent.AddClassToNamespaceList(new DefaultClass(ref2, "ClassName") { Modifiers = ModifierEnum.Public });
|
||||
//
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp);
|
||||
// cu.ProjectContent.ReferencedContents.Add(ref1.ProjectContent);
|
||||
// cu.ProjectContent.ReferencedContents.Add(ref2.ProjectContent);
|
||||
//
|
||||
// SearchTypeResult r = cu.ProjectContent.SearchType(new SearchTypeRequest("ClassName", 0, null, cu, 1, 1));
|
||||
// Assert.AreEqual(ModifierEnum.Public, r.Result.GetUnderlyingClass().Modifiers);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SearchClassDifferentNamespacePreferVisible()
|
||||
// {
|
||||
// ISyntaxTree ref1 = Prepare(LanguageProperties.CSharp);
|
||||
// ref1.ProjectContent.AddClassToNamespaceList(new DefaultClass(ref1, "NS1.ClassName") { Modifiers = ModifierEnum.Internal });
|
||||
// ISyntaxTree ref2 = Prepare(LanguageProperties.CSharp);
|
||||
// ref2.ProjectContent.AddClassToNamespaceList(new DefaultClass(ref2, "NS2.ClassName") { Modifiers = ModifierEnum.Public });
|
||||
//
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp);
|
||||
// cu.ProjectContent.ReferencedContents.Add(ref1.ProjectContent);
|
||||
// cu.ProjectContent.ReferencedContents.Add(ref2.ProjectContent);
|
||||
// cu.UsingScope.Usings.Add(new DefaultUsing(cu.ProjectContent) { Usings = { "NS1", "NS2" } });
|
||||
//
|
||||
// SearchTypeResult r = cu.ProjectContent.SearchType(new SearchTypeRequest("ClassName", 0, null, cu, 1, 1));
|
||||
// Assert.AreEqual(ModifierEnum.Public, r.Result.GetUnderlyingClass().Modifiers);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,118 +0,0 @@
@@ -1,118 +0,0 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using NUnit.Framework;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class SearchGenericClassTests
|
||||
// {
|
||||
// ProjectContentRegistry projectContentRegistry = AssemblyParserService.DefaultProjectContentRegistry;
|
||||
//
|
||||
// #region Helper methods
|
||||
// // usingMode: 0 = one using-statement for each namespace (correctly cased)
|
||||
// // 1 = mixture of using statements and default imports (incorrectly cased)
|
||||
// // 2 = all default imports (incorrectly cased)
|
||||
// ISyntaxTree Prepare(LanguageProperties language, int usingMode)
|
||||
// {
|
||||
// DefaultProjectContent pc = new DefaultProjectContent();
|
||||
// pc.ReferencedContents.Add(projectContentRegistry.Mscorlib);
|
||||
// pc.Language = language;
|
||||
// DefaultSyntaxTree cu = new DefaultSyntaxTree(pc);
|
||||
// if (usingMode == 1) {
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "syStEm.coLLectIons"));
|
||||
// pc.DefaultImports = new DefaultUsing(pc);
|
||||
// pc.DefaultImports.Usings.Add("syStEm");
|
||||
// pc.DefaultImports.Usings.Add("syStEm.coLLEctionS.GeNeRic");
|
||||
// } else if (usingMode == 2) {
|
||||
// pc.DefaultImports = new DefaultUsing(pc);
|
||||
// pc.DefaultImports.Usings.Add("syStEm");
|
||||
// pc.DefaultImports.Usings.Add("syStEm.coLLEctioNs");
|
||||
// pc.DefaultImports.Usings.Add("syStEm.coLLEctionS.GeNeRic");
|
||||
// } else { // usingMode == 0
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "System"));
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "System.Collections"));
|
||||
// cu.UsingScope.Usings.Add(CreateUsing(pc, "System.Collections.Generic"));
|
||||
// }
|
||||
// return cu;
|
||||
// }
|
||||
//
|
||||
// IUsing CreateUsing(IProjectContent pc, string @namespace)
|
||||
// {
|
||||
// DefaultUsing @using = new DefaultUsing(pc);
|
||||
// @using.Usings.Add(@namespace);
|
||||
// return @using;
|
||||
// }
|
||||
//
|
||||
// IReturnType SearchType(string type, int typeParameterCount)
|
||||
// {
|
||||
// ISyntaxTree cu = Prepare(LanguageProperties.CSharp, 0);
|
||||
// IReturnType c = cu.ProjectContent.SearchType(new SearchTypeRequest(type, typeParameterCount, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c, type + "not found");
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// IReturnType SearchTypeVB(string type, int typeParameterCount)
|
||||
// {
|
||||
// ISyntaxTree cu;
|
||||
// cu = Prepare(LanguageProperties.VBNet, 0);
|
||||
// IReturnType c0 = cu.ProjectContent.SearchType(new SearchTypeRequest(type, typeParameterCount, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c0, type + "not found for mode=0");
|
||||
//
|
||||
// cu = Prepare(LanguageProperties.VBNet, 1);
|
||||
// IReturnType c1 = cu.ProjectContent.SearchType(new SearchTypeRequest(type, typeParameterCount, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c1, type + "not found for mode=1");
|
||||
//
|
||||
// cu = Prepare(LanguageProperties.VBNet, 2);
|
||||
// IReturnType c2 = cu.ProjectContent.SearchType(new SearchTypeRequest(type, typeParameterCount, null, cu, 1, 1)).Result;
|
||||
// Assert.IsNotNull(c2, type + "not found for mode=2");
|
||||
//
|
||||
// Assert.IsTrue(c0.Equals(c1) && c0.Equals(c2));
|
||||
//
|
||||
// return c0;
|
||||
// }
|
||||
//
|
||||
// void CheckType(string shortName, string vbShortName, string fullType, int typeParameterCount)
|
||||
// {
|
||||
// IReturnType type = SearchType(shortName, typeParameterCount);
|
||||
// Assert.AreEqual(fullType, type.FullyQualifiedName);
|
||||
// Assert.AreEqual(typeParameterCount, type.TypeArgumentCount);
|
||||
// type = SearchTypeVB(vbShortName, typeParameterCount);
|
||||
// Assert.AreEqual(fullType, type.FullyQualifiedName);
|
||||
// Assert.AreEqual(typeParameterCount, type.TypeArgumentCount);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// // EventHandler vs. EventHandler<TEventArgs>
|
||||
// // both mscorlib, both namespace System
|
||||
// [Test] public void FindEventHandler() {
|
||||
// CheckType("EventHandler", "EvEnThAndler", "System.EventHandler", 0);
|
||||
// }
|
||||
// [Test] public void FindGenericEventHandler() {
|
||||
// CheckType("EventHandler", "EvEnThAndler", "System.EventHandler", 1);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// [Test] public void FindNullableClass() {
|
||||
// CheckType("Nullable", "NuLLable", "System.Nullable", 0);
|
||||
// }
|
||||
// [Test] public void FindNullableStruct() {
|
||||
// CheckType("Nullable", "NuLLable", "System.Nullable", 1);
|
||||
// }
|
||||
//
|
||||
// // ICollection vs. ICollection<T>
|
||||
// // both mscorlib, different namespaces
|
||||
// [Test] public void FindCollection() {
|
||||
// CheckType("ICollection", "IColLEction", "System.Collections.ICollection", 0);
|
||||
// }
|
||||
// [Test] public void FindGenericCollection() {
|
||||
// CheckType("ICollection", "IColLEction", "System.Collections.Generic.ICollection", 1);
|
||||
// }
|
||||
// }
|
||||
//}
|
Loading…
Reference in new issue