Browse Source

Merge remote-tracking branch 'upstream/master' into mansheng

newNRvisualizers
Mansheng Yang 14 years ago
parent
commit
98674dba61
  1. 2
      ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs
  2. 15
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/AnonymousTypeTests.cs
  3. 8
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs
  4. 20
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs
  5. 2
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  6. 25
      ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs
  7. 2
      ICSharpCode.NRefactory/TypeSystem/IEvent.cs
  8. 2
      ICSharpCode.NRefactory/TypeSystem/IField.cs
  9. 2
      ICSharpCode.NRefactory/TypeSystem/IMember.cs
  10. 2
      ICSharpCode.NRefactory/TypeSystem/IMethod.cs
  11. 2
      ICSharpCode.NRefactory/TypeSystem/IProperty.cs
  12. 2
      ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs
  13. 15
      ICSharpCode.NRefactory/TypeSystem/KnownTypeReference.cs
  14. 2
      ICSharpCode.NRefactory/TypeSystem/SimpleTypeResolveContext.cs

2
ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs

@ -680,7 +680,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -680,7 +680,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
a.AccessorOwner = p;
a.Accessibility = GetAccessibility(accessor.Modifiers) ?? p.Accessibility;
a.IsAbstract = p.IsAbstract;
a.IsOverride = p.IsOverridable;
a.IsOverride = p.IsOverride;
a.IsSealed = p.IsSealed;
a.IsStatic = p.IsStatic;
a.IsSynthetic = p.IsSynthetic;

15
ICSharpCode.NRefactory.Tests/CSharp/Resolver/AnonymousTypeTests.cs

@ -81,5 +81,20 @@ class Test { @@ -81,5 +81,20 @@ class Test {
Assert.IsInstanceOf<InitializedObjectResolveResult>(target);
Assert.AreEqual(rr.Type, target.Type);
}
[Test]
public void NestingAnonymousTypesShouldWork()
{
string program = @"using System;
class TestClass {
void F() {
var o = $new { a = 0, b = 1, c = new { d = 2, e = 3, f = 4 } }$;
}
}";
var result = Resolve<InvocationResolveResult>(program);
Assert.That(result.Type.GetProperties().Select(p => p.Name), Is.EquivalentTo(new[] { "a", "b", "c" }));
Assert.That(result.Type.GetProperties().Single(p => p.Name == "c").ReturnType.GetProperties().Select(p => p.Name), Is.EquivalentTo(new[] { "d", "e", "f" }));
}
}
}

8
ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs

@ -236,4 +236,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.TestCase @@ -236,4 +236,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.TestCase
public static int Prop3 { get; set; }
public int Prop4 { get; set; }
}
public interface IInterfaceWithProperty {
int Prop { get; set; }
}
public class ClassWithVirtualProperty {
public virtual int Prop { get; set; }
}
}

20
ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs

@ -847,5 +847,25 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -847,5 +847,25 @@ namespace ICSharpCode.NRefactory.TypeSystem
Assert.AreEqual("add_Event3", normalEvent.AddAccessor.Name);
Assert.AreEqual("remove_Event3", normalEvent.RemoveAccessor.Name);
}
[Test]
public void InterfacePropertyAccessorsShouldNotBeOverrides() {
ITypeDefinition type = GetTypeDefinition(typeof(IInterfaceWithProperty));
var prop = type.Properties.Single(p => p.Name == "Prop");
Assert.That(prop.Getter.IsOverride, Is.False);
Assert.That(prop.Getter.IsOverridable, Is.True);
Assert.That(prop.Setter.IsOverride, Is.False);
Assert.That(prop.Setter.IsOverridable, Is.True);
}
[Test]
public void VirtualPropertyAccessorsShouldNotBeOverrides() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassWithVirtualProperty));
var prop = type.Properties.Single(p => p.Name == "Prop");
Assert.That(prop.Getter.IsOverride, Is.False);
Assert.That(prop.Getter.IsOverridable, Is.True);
Assert.That(prop.Setter.IsOverride, Is.False);
Assert.That(prop.Setter.IsOverridable, Is.True);
}
}
}

2
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -168,7 +168,6 @@ @@ -168,7 +168,6 @@
<Compile Include="TypeSystem\Implementation\SimpleCompilation.cs" />
<Compile Include="TypeSystem\Implementation\SimpleConstantValue.cs" />
<Compile Include="TypeSystem\Implementation\SimpleInterningProvider.cs" />
<Compile Include="TypeSystem\Implementation\SimpleTypeResolveContext.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedEvent.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedField.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedMember.cs" />
@ -200,6 +199,7 @@ @@ -200,6 +199,7 @@
<Compile Include="TypeSystem\ParameterizedType.cs" />
<Compile Include="TypeSystem\ParameterListComparer.cs" />
<Compile Include="TypeSystem\ReflectionNameParseException.cs" />
<Compile Include="TypeSystem\SimpleTypeResolveContext.cs" />
<Compile Include="TypeSystem\TypeKind.cs" />
<Compile Include="TypeSystem\TypeVisitor.cs" />
<Compile Include="TypeSystem\IVariable.cs" />

25
ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
public override bool Equals(object obj)
{
AnonymousTypeProperty p = obj as AnonymousTypeProperty;
return p != null && declaringType.Equals(p.declaringType) && this.Name == p.Name;
return p != null && this.Name == p.Name && declaringType.Equals(p.declaringType);
}
public override int GetHashCode()
@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
public override ITypeReference ToTypeReference()
{
throw new NotSupportedException();
return new AnonymousTypeReference(unresolvedProperties);
}
public override string Name {
@ -142,4 +142,25 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -142,4 +142,25 @@ namespace ICSharpCode.NRefactory.TypeSystem
return true;
}
}
/// <summary>
/// Anonymous type reference.
/// </summary>
[Serializable]
public class AnonymousTypeReference : ITypeReference
{
readonly IUnresolvedProperty[] unresolvedProperties;
public AnonymousTypeReference(IUnresolvedProperty[] properties)
{
if (properties == null)
throw new ArgumentNullException("properties");
this.unresolvedProperties = properties;
}
public IType Resolve(ITypeResolveContext context)
{
return new AnonymousType(context.Compilation, unresolvedProperties);
}
}
}

2
ICSharpCode.NRefactory/TypeSystem/IEvent.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the member. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.

2
ICSharpCode.NRefactory/TypeSystem/IField.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the member. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.

2
ICSharpCode.NRefactory/TypeSystem/IMember.cs

@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the member. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.

2
ICSharpCode.NRefactory/TypeSystem/IMethod.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the member. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.

2
ICSharpCode.NRefactory/TypeSystem/IProperty.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the member. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.

2
ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="context">
/// Context for looking up the type. The context must specify the current assembly.
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
/// </param>
/// <returns>
/// Returns the resolved type definition.

15
ICSharpCode.NRefactory/TypeSystem/KnownTypeReference.cs

@ -345,6 +345,21 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -345,6 +345,21 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
public static readonly KnownTypeReference IEnumeratorOfT = Get(KnownTypeCode.IEnumeratorOfT);
/// <summary>
/// Gets a type reference pointing to the <c>System.Collections.ICollection</c> type.
/// </summary>
public static readonly KnownTypeReference ICollection = Get(KnownTypeCode.ICollection);
/// <summary>
/// Gets a type reference pointing to the <c>System.Collections.Generic.ICollection{T}</c> type.
/// </summary>
public static readonly KnownTypeReference ICollectionOfT = Get(KnownTypeCode.ICollectionOfT);
/// <summary>
/// Gets a type reference pointing to the <c>System.Collections.IList</c> type.
/// </summary>
public static readonly KnownTypeReference IList = Get(KnownTypeCode.IList);
/// <summary>
/// Gets a type reference pointing to the <c>System.Collections.Generic.IList{T}</c> type.
/// </summary>

2
ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleTypeResolveContext.cs → ICSharpCode.NRefactory/TypeSystem/SimpleTypeResolveContext.cs

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
using System;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
namespace ICSharpCode.NRefactory.TypeSystem
{
/// <summary>
/// Default ITypeResolveContext implementation.
Loading…
Cancel
Save