Browse Source

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

newNRvisualizers
Mansheng Yang 14 years ago
parent
commit
d8aac6d657
  1. 6
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 24
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs
  3. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs
  4. 6
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs
  5. 42
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/InconsistentNamingIssue/InconsistentNamingIssue.cs
  6. 18
      ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs
  7. 23
      ICSharpCode.NRefactory.ConsistencyCheck/TypeSystemTests.cs
  8. 27
      ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreateFieldTests.cs
  9. 25
      ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/InconsistentNamingTests.cs
  10. 57
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs
  11. 47
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs
  12. 229
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs
  13. 1
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  14. 14
      ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs
  15. 46
      ICSharpCode.NRefactory/TypeSystem/ArrayType.cs
  16. 46
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  17. 3
      ICSharpCode.NRefactory/TypeSystem/EntityType.cs
  18. 15
      ICSharpCode.NRefactory/TypeSystem/IType.cs
  19. 6
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
  20. 8
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  21. 5
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs
  22. 51
      ICSharpCode.NRefactory/TypeSystem/Implementation/AccessorOwnerMemberReference.cs
  23. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMemberReference.cs
  24. 32
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs
  25. 10
      ICSharpCode.NRefactory/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs
  26. 28
      ICSharpCode.NRefactory/TypeSystem/Implementation/GetMembersHelper.cs
  27. 8
      ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs
  28. 5
      ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs
  29. 8
      ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs

6
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -173,10 +173,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -173,10 +173,10 @@ namespace ICSharpCode.NRefactory.CSharp
}
if (change.Offset < previousChange.Offset + previousChange.RemovalLength) {
#if DEBUG
Console.WriteLine ("change 1:" + change);
Console.WriteLine ("change 1:" + change + " at " + document.GetLocation (change.Offset));
Console.WriteLine (change.StackTrace);
Console.WriteLine ("change 2:" + change);
Console.WriteLine ("change 2:" + previousChange + " at " + document.GetLocation (previousChange.Offset));
Console.WriteLine (previousChange.StackTrace);
#endif
throw new InvalidOperationException ("Detected overlapping changes " + change + "/" + previousChange);
@ -1645,6 +1645,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1645,6 +1645,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (!anonymousMethodExpression.Body.IsNull) {
EnforceBraceStyle(policy.AnonymousMethodBraceStyle, anonymousMethodExpression.Body.LBraceToken, anonymousMethodExpression.Body.RBraceToken);
VisitBlockWithoutFixingBraces(anonymousMethodExpression.Body, policy.IndentBlocks);
return;
}
base.VisitAnonymousMethodExpression(anonymousMethodExpression);
}

24
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs

@ -46,20 +46,28 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -46,20 +46,28 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
public IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var identifier = context.GetNode<IdentifierExpression>();
if (identifier == null)
var expr = context.GetNode(n => n is IdentifierExpression || n is MemberReferenceExpression) as Expression;
if (expr == null)
yield break;
if (IsInvocationTarget(identifier))
if (expr is MemberReferenceExpression && !(((MemberReferenceExpression)expr).Target is ThisReferenceExpression))
yield break;
var propertyName = CreatePropertyAction.GetPropertyName(expr);
if (propertyName == null)
yield break;
if (IsInvocationTarget(expr))
yield break;
var statement = identifier.GetParent<Statement>();
var statement = expr.GetParent<Statement>();
if (statement == null)
yield break;
if (!(context.Resolve(identifier).IsError))
if (!(context.Resolve(expr).IsError))
yield break;
var guessedType = CreateFieldAction.GuessAstType(context, identifier);
var guessedType = CreateFieldAction.GuessAstType(context, expr);
if (guessedType == null)
yield break;
var state = context.GetResolverStateBefore(identifier);
var state = context.GetResolverStateBefore(expr);
if (state.CurrentMember == null || state.CurrentTypeDefinition == null)
yield break;
@ -73,7 +81,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -73,7 +81,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
yield return new CodeAction(context.TranslateString("Create field"), script => {
var decl = new FieldDeclaration() {
ReturnType = guessedType,
Variables = { new VariableInitializer(identifier.Identifier) }
Variables = { new VariableInitializer(propertyName) }
};
if (isStatic)
decl.Modifiers |= Modifiers.Static;

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs

@ -78,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -78,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
isStatic |= state.CurrentMember.IsStatic || state.CurrentTypeDefinition.IsStatic;
}
// var service = (NamingConventionService)context.GetService(typeof(NamingConventionService));
// var service = (NamingConventionService)context.GetService(typeof(NamingConventionService));
// if (service != null && !service.IsValidName(propertyName, AffectedEntity.Property, Modifiers.Private, isStatic)) {
// yield break;
// }
@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
});
}
static string GetPropertyName(Expression expr)
internal static string GetPropertyName(Expression expr)
{
if (expr is IdentifierExpression)
return ((IdentifierExpression)expr).Identifier;

6
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs

@ -35,9 +35,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -35,9 +35,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
public class CodeIssue
{
/// <summary>
/// Gets the desription of the issue.
/// Gets the description of the issue.
/// </summary>
public string Desription {
public string Description {
get;
private set;
}
@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
/// </param>
public CodeIssue(string description, TextLocation start, TextLocation end, IEnumerable<CodeAction> actions = null)
{
Desription = description;
Description = description;
Start = start;
End = end;
if (actions != null)

42
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/InconsistentNamingIssue/InconsistentNamingIssue.cs

@ -215,12 +215,52 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -215,12 +215,52 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
{
if (propertyDeclaration.Modifiers.HasFlag (Modifiers.Override))
return;
base.VisitPropertyDeclaration(propertyDeclaration);
CheckName(propertyDeclaration, AffectedEntity.Property, propertyDeclaration.NameToken, GetAccessibiltiy(propertyDeclaration, Modifiers.Private));
}
public override void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration)
{
if (indexerDeclaration.Modifiers.HasFlag(Modifiers.Override)) {
var rr = ctx.Resolve (indexerDeclaration) as MemberResolveResult;
if (rr == null)
return;
var baseType = rr.Member.DeclaringType.DirectBaseTypes.FirstOrDefault (t => t.Kind != TypeKind.Interface);
var method = baseType != null ? baseType.GetProperties (m => m.IsIndexer && m.IsOverridable && m.Parameters.Count == indexerDeclaration.Parameters.Count).FirstOrDefault () : null;
if (method == null)
return;
int i = 0;
foreach (var par in indexerDeclaration.Parameters) {
if (method.Parameters[i++].Name != par.Name) {
par.AcceptVisitor (this);
}
}
return;
}
base.VisitIndexerDeclaration(indexerDeclaration);
}
public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
if (methodDeclaration.Modifiers.HasFlag(Modifiers.Override)) {
var rr = ctx.Resolve (methodDeclaration) as MemberResolveResult;
if (rr == null)
return;
var baseType = rr.Member.DeclaringType.DirectBaseTypes.FirstOrDefault (t => t.Kind != TypeKind.Interface);
var method = baseType != null ? baseType.GetMethods (m => m.Name == rr.Member.Name && m.IsOverridable && m.Parameters.Count == methodDeclaration.Parameters.Count).FirstOrDefault () : null;
if (method == null)
return;
int i = 0;
foreach (var par in methodDeclaration.Parameters) {
if (method.Parameters[i++].Name != par.Name) {
par.AcceptVisitor (this);
}
}
return;
}
base.VisitMethodDeclaration(methodDeclaration);
CheckName(methodDeclaration, methodDeclaration.Modifiers.HasFlag(Modifiers.Async) ? AffectedEntity.AsyncMethod : AffectedEntity.Method, methodDeclaration.NameToken, GetAccessibiltiy(methodDeclaration, Modifiers.Private));
@ -262,6 +302,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -262,6 +302,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
if (eventDeclaration.Modifiers.HasFlag (Modifiers.Override))
return;
base.VisitCustomEventDeclaration(eventDeclaration);
CheckName(eventDeclaration, AffectedEntity.Event, eventDeclaration.NameToken, GetAccessibiltiy(eventDeclaration, Modifiers.Private));
}

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

@ -655,8 +655,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -655,8 +655,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
AddXmlDocumentation(p, indexerDeclaration);
ConvertParameters(p.Parameters, indexerDeclaration.Parameters);
p.Getter = ConvertAccessor(indexerDeclaration.Getter, p, "get_");
p.Setter = ConvertAccessor(indexerDeclaration.Setter, p, "set_");
if (!indexerDeclaration.PrivateImplementationType.IsNull) {
p.Accessibility = Accessibility.None;
@ -664,6 +662,8 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -664,6 +662,8 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
p.ExplicitInterfaceImplementations.Add(new DefaultMemberReference(
p.EntityType, indexerDeclaration.PrivateImplementationType.ToTypeReference(), p.Name, 0, GetParameterTypes(p.Parameters)));
}
p.Getter = ConvertAccessor(indexerDeclaration.Getter, p, "get_");
p.Setter = ConvertAccessor(indexerDeclaration.Setter, p, "set_");
currentTypeDefinition.Members.Add(p);
if (interningProvider != null) {
@ -677,6 +677,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -677,6 +677,7 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
if (accessor.IsNull)
return null;
var a = new DefaultUnresolvedMethod(currentTypeDefinition, prefix + p.Name);
a.EntityType = EntityType.Accessor;
a.AccessorOwner = p;
a.Accessibility = GetAccessibility(accessor.Modifiers) ?? p.Accessibility;
a.IsAbstract = p.IsAbstract;
@ -708,6 +709,15 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -708,6 +709,15 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
ConvertAttributes(a.Attributes, section);
}
}
if (p.IsExplicitInterfaceImplementation) {
a.IsExplicitInterfaceImplementation = true;
Debug.Assert(p.ExplicitInterfaceImplementations.Count == 1);
a.ExplicitInterfaceImplementations.Add(new DefaultMemberReference(
EntityType.Accessor,
p.ExplicitInterfaceImplementations[0].DeclaringTypeReference,
a.Name, 0, GetParameterTypes(a.Parameters)
));
}
return a;
}
#endregion
@ -756,11 +766,13 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -756,11 +766,13 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
DefaultUnresolvedMethod CreateDefaultEventAccessor(IUnresolvedEvent ev, string name, IUnresolvedParameter valueParameter)
{
var a = new DefaultUnresolvedMethod(currentTypeDefinition, name);
a.EntityType = EntityType.Accessor;
a.AccessorOwner = ev;
a.Region = ev.BodyRegion;
a.BodyRegion = ev.BodyRegion;
a.Accessibility = ev.Accessibility;
a.IsAbstract = ev.IsAbstract;
a.IsOverride = ev.IsOverridable;
a.IsOverride = ev.IsOverride;
a.IsSealed = ev.IsSealed;
a.IsStatic = ev.IsStatic;
a.IsSynthetic = ev.IsSynthetic;

23
ICSharpCode.NRefactory.ConsistencyCheck/TypeSystemTests.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
if (!typeDef.Equals(part.Resolve(assemblyContext)))
throw new InvalidOperationException();
}
foreach (var member in typeDef.Members) {
foreach (var member in IncludeAccessors(typeDef.Members)) {
var resolvedMember = member.UnresolvedMember.Resolve(assemblyContext);
if (!member.Equals(resolvedMember))
throw new InvalidOperationException();
@ -75,7 +75,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -75,7 +75,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
else
context = compilation.TypeResolveContext;
// Include (potentially specialized) inherited members when testing ToMemberReference()
foreach (var member in typeDef.GetMembers()) {
foreach (var member in IncludeAccessors(typeDef.GetMembers())) {
var resolvedMember = member.ToMemberReference().Resolve(context);
if (!member.Equals(resolvedMember))
throw new InvalidOperationException();
@ -83,5 +83,24 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -83,5 +83,24 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
}
}
}
static IEnumerable<IMember> IncludeAccessors(IEnumerable<IMember> members)
{
foreach (var member in members) {
yield return member;
IProperty p = member as IProperty;
if (p != null && p.CanGet)
yield return p.Getter;
if (p != null && p.CanSet)
yield return p.Setter;
IEvent e = member as IEvent;
if (e != null && e.CanAdd)
yield return e.AddAccessor;
if (e != null && e.CanRemove)
yield return e.RemoveAccessor;
if (e != null && e.CanInvoke)
yield return e.InvokeAccessor;
}
}
}
}

27
ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreateFieldTests.cs

@ -182,5 +182,32 @@ class Foo @@ -182,5 +182,32 @@ class Foo
");
}
[Test()]
public void TestThisMemberReferenceCreation ()
{
string result = RunContextAction (
new CreateFieldAction (),
"using System;" + Environment.NewLine +
"class TestClass" + Environment.NewLine +
"{" + Environment.NewLine +
" void Test ()" + Environment.NewLine +
" {" + Environment.NewLine +
" this.$foo = 0x10;" + Environment.NewLine +
" }" + Environment.NewLine +
"}"
);
Assert.AreEqual (
"using System;" + Environment.NewLine +
"class TestClass" + Environment.NewLine +
"{" + Environment.NewLine +
" int foo;" + Environment.NewLine +
" void Test ()" + Environment.NewLine +
" {" + Environment.NewLine +
" this.foo = 0x10;" + Environment.NewLine +
" }" + Environment.NewLine +
"}", result);
}
}
}

25
ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/InconsistentNamingTests.cs

@ -237,6 +237,31 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues @@ -237,6 +237,31 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues
var output = @"struct Str<TK> { TK k;}";
CheckNaming (input, output);
}
[Test]
public void TestOverrideMembers ()
{
var input = @"
class Base { public virtual int method (int Param) {} }
class MyClass : Base { public override int method (int Param) {} }";
TestRefactoringContext context;
var issues = GetIssues (new InconsistentNamingIssue (), input, out context);
Assert.AreEqual (2, issues.Count);
}
[Test]
public void TestOverrideMembersParameterNameCaseMismatch ()
{
var input = @"
class Base { public virtual int Method (int param) {} }
class MyClass : Base { public override int Method (int Param) {} }";
TestRefactoringContext context;
var issues = GetIssues (new InconsistentNamingIssue (), input, out context);
foreach (var issue in issues)
Console.WriteLine(issue.Description);
Assert.AreEqual (1, issues.Count);
}
}
[TestFixture]

57
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs

@ -61,63 +61,6 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -61,63 +61,6 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
Assert.AreEqual(compilation.FindType(KnownTypeCode.Array), typeRef.Resolve(compilation.TypeResolveContext));
}
[Test]
public void ExplicitDisposableImplementation()
{
ITypeDefinition disposable = GetTypeDefinition(typeof(NRefactory.TypeSystem.TestCase.ExplicitDisposableImplementation));
IMethod method = disposable.Methods.Single(m => m.Name == "Dispose");
Assert.IsTrue(method.IsExplicitInterfaceImplementation);
Assert.AreEqual("System.IDisposable.Dispose", method.ImplementedInterfaceMembers.Single().FullName);
}
[Test]
public void ExplicitGenericInterfaceImplementation()
{
ITypeDefinition impl = GetTypeDefinition(typeof(NRefactory.TypeSystem.TestCase.ExplicitGenericInterfaceImplementation));
IType genericInterfaceOfString = compilation.FindType(typeof(IGenericInterface<string>));
IMethod implMethod1 = impl.Methods.Single(m => m.Name == "Test" && !m.Parameters[1].IsRef);
IMethod implMethod2 = impl.Methods.Single(m => m.Name == "Test" && m.Parameters[1].IsRef);
Assert.IsTrue(implMethod1.IsExplicitInterfaceImplementation);
Assert.IsTrue(implMethod2.IsExplicitInterfaceImplementation);
IMethod interfaceMethod1 = (IMethod)implMethod1.ImplementedInterfaceMembers.Single();
Assert.AreEqual(genericInterfaceOfString, interfaceMethod1.DeclaringType);
Assert.IsTrue(!interfaceMethod1.Parameters[1].IsRef);
IMethod interfaceMethod2 = (IMethod)implMethod2.ImplementedInterfaceMembers.Single();
Assert.AreEqual(genericInterfaceOfString, interfaceMethod2.DeclaringType);
Assert.IsTrue(interfaceMethod2.Parameters[1].IsRef);
}
[Test]
public void ExplicitImplementationOfUnifiedMethods()
{
IType type = compilation.FindType(typeof(ExplicitGenericInterfaceImplementationWithUnifiableMethods<int, int>));
Assert.AreEqual(2, type.GetMethods(m => m.IsExplicitInterfaceImplementation).Count());
foreach (IMethod method in type.GetMethods(m => m.IsExplicitInterfaceImplementation)) {
Assert.AreEqual(1, method.ImplementedInterfaceMembers.Count, method.ToString());
Assert.AreEqual("System.Int32", method.Parameters.Single().Type.ReflectionName);
IMethod interfaceMethod = (IMethod)method.ImplementedInterfaceMembers.Single();
Assert.AreEqual("System.Int32", interfaceMethod.Parameters.Single().Type.ReflectionName);
var genericParamType = ((IMethod)method.MemberDefinition).Parameters.Single().Type;
var interfaceGenericParamType = ((IMethod)interfaceMethod.MemberDefinition).Parameters.Single().Type;
Assert.AreEqual(TypeKind.TypeParameter, genericParamType.Kind);
Assert.AreEqual(TypeKind.TypeParameter, interfaceGenericParamType.Kind);
Assert.AreEqual(genericParamType.ReflectionName, interfaceGenericParamType.ReflectionName);
}
}
[Test]
public void ExplicitImplementationOfUnifiedMethods_ToMemberReference()
{
IType type = compilation.FindType(typeof(ExplicitGenericInterfaceImplementationWithUnifiableMethods<int, int>));
Assert.AreEqual(2, type.GetMethods(m => m.IsExplicitInterfaceImplementation).Count());
foreach (IMethod method in type.GetMethods(m => m.IsExplicitInterfaceImplementation)) {
IMethod resolvedMethod = (IMethod)method.ToMemberReference().Resolve(compilation.TypeResolveContext);
Assert.AreEqual(method, resolvedMethod);
}
}
[Test]
public void PartialMethodWithImplementation()
{

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

@ -244,4 +244,51 @@ namespace ICSharpCode.NRefactory.TypeSystem.TestCase @@ -244,4 +244,51 @@ namespace ICSharpCode.NRefactory.TypeSystem.TestCase
public class ClassWithVirtualProperty {
public virtual int Prop { get; set; }
}
public class ClassThatImplementsProperty : IInterfaceWithProperty {
public int Prop { get; set; }
}
public class ClassThatImplementsPropertyExplicitly : IInterfaceWithProperty {
int IInterfaceWithProperty.Prop { get; set; }
}
public interface IInterfaceWithIndexers {
int this[int x] { get; set; }
int this[string x] { get; set; }
int this[int x, int y] { get; set; }
}
public interface IGenericInterfaceWithIndexer<T> {
int this[T x] { get; set; }
}
public class ClassThatImplementsIndexers : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int> {
public int this[int x] { get { return 0; } set {} }
public int this[string x] { get { return 0; } set {} }
public int this[int x, int y] { get { return 0; } set {} }
}
public class ClassThatImplementsIndexersExplicitly : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int> {
int IInterfaceWithIndexers.this[int x] { get { return 0; } set {} }
int IGenericInterfaceWithIndexer<int>.this[int x] { get { return 0; } set {} }
int IInterfaceWithIndexers.this[string x] { get { return 0; } set {} }
int IInterfaceWithIndexers.this[int x, int y] { get { return 0; } set {} }
}
public interface IHasEvent {
event EventHandler Event;
}
public class ClassThatImplementsEvent : IHasEvent {
public event EventHandler Event;
}
public class ClassThatImplementsEventWithCustomAccessors : IHasEvent {
public event EventHandler Event { add {} remove {} }
}
public class ClassThatImplementsEventExplicitly : IHasEvent {
event EventHandler IHasEvent.Event { add {} remove {} }
}
}

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

@ -241,7 +241,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -241,7 +241,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
[Test]
public void Specialized_GetIndex_ToTypeReference()
public void Specialized_GetIndex_ToMemberReference()
{
var method = compilation.FindType(typeof(GenericClass<string, object>)).GetMethods(m => m.Name == "GetIndex").Single();
Assert.AreSame(method.TypeParameters[0], method.Parameters[0].Type);
@ -347,6 +347,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -347,6 +347,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
var testClass = GetTypeDefinition(typeof(PropertyTest));
IProperty p = testClass.Properties.Single(pr => pr.IsIndexer);
Assert.IsTrue(p.CanGet);
Assert.AreEqual(EntityType.Accessor, p.Getter.EntityType);
Assert.AreEqual("get_Item", p.Getter.Name);
Assert.AreEqual(Accessibility.Public, p.Getter.Accessibility);
Assert.AreEqual(new[] { "index" }, p.Getter.Parameters.Select(x => x.Name).ToArray());
@ -360,6 +361,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -360,6 +361,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
var testClass = GetTypeDefinition(typeof(PropertyTest));
IProperty p = testClass.Properties.Single(pr => pr.IsIndexer);
Assert.IsTrue(p.CanSet);
Assert.AreEqual(EntityType.Accessor, p.Setter.EntityType);
Assert.AreEqual("set_Item", p.Setter.Name);
Assert.AreEqual(Accessibility.Public, p.Setter.Accessibility);
Assert.AreEqual(new[] { "index", "value" }, p.Setter.Parameters.Select(x => x.Name).ToArray());
@ -679,6 +681,63 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -679,6 +681,63 @@ namespace ICSharpCode.NRefactory.TypeSystem
Assert.AreEqual("ICSharpCode.NRefactory.TypeSystem.TestCase.OuterGeneric`1+Inner[[ICSharpCode.NRefactory.TypeSystem.TestCase.OuterGeneric`1+Inner[[`0]]]]", field3.Type.ReflectionName);
}
[Test]
public void FlagsOnInterfaceMembersAreCorrect() {
ITypeDefinition type = GetTypeDefinition(typeof(IInterfaceWithProperty));
var p = type.Properties.Single();
Assert.AreEqual(false, p.IsIndexer);
Assert.AreEqual(true, p.IsAbstract);
Assert.AreEqual(true, p.IsOverridable);
Assert.AreEqual(false, p.IsOverride);
Assert.AreEqual(true, p.IsPublic);
Assert.AreEqual(true, p.Getter.IsAbstract);
Assert.AreEqual(true, p.Getter.IsOverridable);
Assert.AreEqual(false, p.Getter.IsOverride);
Assert.AreEqual(true, p.Getter.IsPublic);
Assert.AreEqual(true, p.Setter.IsAbstract);
Assert.AreEqual(true, p.Setter.IsOverridable);
Assert.AreEqual(false, p.Setter.IsOverride);
Assert.AreEqual(true, p.Setter.IsPublic);
type = GetTypeDefinition(typeof(IInterfaceWithIndexers));
p = type.Properties.Single(x => x.Parameters.Count == 2);
Assert.AreEqual(true, p.IsIndexer);
Assert.AreEqual(true, p.IsAbstract);
Assert.AreEqual(true, p.IsOverridable);
Assert.AreEqual(false, p.IsOverride);
Assert.AreEqual(true, p.IsPublic);
Assert.AreEqual(true, p.Getter.IsAbstract);
Assert.AreEqual(true, p.Getter.IsOverridable);
Assert.AreEqual(false, p.Getter.IsOverride);
Assert.AreEqual(true, p.Getter.IsPublic);
Assert.AreEqual(true, p.Setter.IsAbstract);
Assert.AreEqual(true, p.Setter.IsOverridable);
Assert.AreEqual(false, p.Setter.IsOverride);
Assert.AreEqual(true, p.Setter.IsPublic);
type = GetTypeDefinition(typeof(IHasEvent));
var e = type.Events.Single();
Assert.AreEqual(true, e.IsAbstract);
Assert.AreEqual(true, e.IsOverridable);
Assert.AreEqual(false, e.IsOverride);
Assert.AreEqual(true, e.IsPublic);
Assert.AreEqual(true, e.AddAccessor.IsAbstract);
Assert.AreEqual(true, e.AddAccessor.IsOverridable);
Assert.AreEqual(false, e.AddAccessor.IsOverride);
Assert.AreEqual(true, e.AddAccessor.IsPublic);
Assert.AreEqual(true, e.RemoveAccessor.IsAbstract);
Assert.AreEqual(true, e.RemoveAccessor.IsOverridable);
Assert.AreEqual(false, e.RemoveAccessor.IsOverride);
Assert.AreEqual(true, e.RemoveAccessor.IsPublic);
type = GetTypeDefinition(typeof(IDisposable));
var m = type.Methods.Single();
Assert.AreEqual(true, m.IsAbstract);
Assert.AreEqual(true, m.IsOverridable);
Assert.AreEqual(false, m.IsOverride);
Assert.AreEqual(true, m.IsPublic);
}
[Test]
public void InnerClassInGenericClass_TypeParameterOwner()
{
@ -867,5 +926,173 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -867,5 +926,173 @@ namespace ICSharpCode.NRefactory.TypeSystem
Assert.That(prop.Setter.IsOverride, Is.False);
Assert.That(prop.Setter.IsOverridable, Is.True);
}
[Test]
public void PropertyAccessorsShouldBeReportedAsImplementingInterfaceAccessors() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsProperty));
var prop = type.Properties.Single(p => p.Name == "Prop");
Assert.That(prop.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.Prop" }));
Assert.That(prop.Getter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.get_Prop" }));
Assert.That(prop.Setter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.set_Prop" }));
}
[Test]
public void PropertyAccessorsShouldSupportToMemberReference()
{
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsProperty));
var prop = type.Properties.Single(p => p.Name == "Prop");
var mr = prop.Getter.ToMemberReference();
Assert.AreEqual(prop.Getter, mr.Resolve(compilation.TypeResolveContext));
}
[Test]
public void IndexerAccessorsShouldBeReportedAsImplementingTheCorrectInterfaceAccessors() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsIndexers));
var ix1 = type.Properties.Single(p => p.Parameters.Count == 1 && p.Parameters[0].Type.GetDefinition().KnownTypeCode == KnownTypeCode.Int32);
var ix2 = type.Properties.Single(p => p.Parameters.Count == 1 && p.Parameters[0].Type.GetDefinition().KnownTypeCode == KnownTypeCode.String);
var ix3 = type.Properties.Single(p => p.Parameters.Count == 2);
Assert.That(ix1.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EquivalentTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.Item", "ICSharpCode.NRefactory.TypeSystem.TestCase.IGenericInterfaceWithIndexer`1.Item" }));
Assert.That(ix1.ImplementedInterfaceMembers.All(p => ((IProperty)p).Parameters.Select(x => x.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32 })));
Assert.That(ix1.Getter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EquivalentTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.get_Item", "ICSharpCode.NRefactory.TypeSystem.TestCase.IGenericInterfaceWithIndexer`1.get_Item" }));
Assert.That(ix1.Getter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32 })));
Assert.That(ix1.Setter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EquivalentTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.set_Item", "ICSharpCode.NRefactory.TypeSystem.TestCase.IGenericInterfaceWithIndexer`1.set_Item" }));
Assert.That(ix1.Setter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32, KnownTypeCode.Int32 })));
Assert.That(ix2.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.Item" }));
Assert.That(ix2.ImplementedInterfaceMembers.All(p => ((IProperty)p).Parameters.Select(x => x.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.String })));
Assert.That(ix2.Getter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.get_Item" }));
Assert.That(ix2.Getter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.String })));
Assert.That(ix2.Setter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.set_Item" }));
Assert.That(ix2.Setter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.String, KnownTypeCode.Int32 })));
Assert.That(ix3.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.Item" }));
Assert.That(ix3.ImplementedInterfaceMembers.All(p => ((IProperty)p).Parameters.Select(x => x.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32, KnownTypeCode.Int32 })));
Assert.That(ix3.Getter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.get_Item" }));
Assert.That(ix3.Getter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32, KnownTypeCode.Int32 })));
Assert.That(ix3.Setter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithIndexers.set_Item" }));
Assert.That(ix3.Setter.ImplementedInterfaceMembers.All(m => ((IMethod)m).Parameters.Select(p => p.Type.GetDefinition().KnownTypeCode).SequenceEqual(new[] { KnownTypeCode.Int32, KnownTypeCode.Int32, KnownTypeCode.Int32 })));
}
[Test]
public void ExplicitIndexerImplementationReturnsTheCorrectMembers() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsIndexersExplicitly));
Assert.That(type.Properties.All(p => p.ImplementedInterfaceMembers.Count == 1));
Assert.That(type.Properties.All(p => p.Getter.ImplementedInterfaceMembers.Count == 1));
Assert.That(type.Properties.All(p => p.Setter.ImplementedInterfaceMembers.Count == 1));
}
[Test]
public void ExplicitlyImplementedPropertyAccessorsShouldSupportToMemberReference()
{
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsPropertyExplicitly));
var prop = type.Properties.Single();
var mr = prop.Getter.ToMemberReference();
Assert.AreEqual(prop.Getter, mr.Resolve(compilation.TypeResolveContext));
}
[Test]
public void ExplicitDisposableImplementation()
{
ITypeDefinition disposable = GetTypeDefinition(typeof(NRefactory.TypeSystem.TestCase.ExplicitDisposableImplementation));
IMethod method = disposable.Methods.Single(m => !m.IsConstructor);
Assert.IsTrue(method.IsExplicitInterfaceImplementation);
Assert.AreEqual("System.IDisposable.Dispose", method.ImplementedInterfaceMembers.Single().FullName);
}
[Test]
public void ExplicitImplementationOfUnifiedMethods()
{
IType type = compilation.FindType(typeof(ExplicitGenericInterfaceImplementationWithUnifiableMethods<int, int>));
Assert.AreEqual(2, type.GetMethods(m => m.IsExplicitInterfaceImplementation).Count());
foreach (IMethod method in type.GetMethods(m => m.IsExplicitInterfaceImplementation)) {
Assert.AreEqual(1, method.ImplementedInterfaceMembers.Count, method.ToString());
Assert.AreEqual("System.Int32", method.Parameters.Single().Type.ReflectionName);
IMethod interfaceMethod = (IMethod)method.ImplementedInterfaceMembers.Single();
Assert.AreEqual("System.Int32", interfaceMethod.Parameters.Single().Type.ReflectionName);
var genericParamType = ((IMethod)method.MemberDefinition).Parameters.Single().Type;
var interfaceGenericParamType = ((IMethod)interfaceMethod.MemberDefinition).Parameters.Single().Type;
Assert.AreEqual(TypeKind.TypeParameter, genericParamType.Kind);
Assert.AreEqual(TypeKind.TypeParameter, interfaceGenericParamType.Kind);
Assert.AreEqual(genericParamType.ReflectionName, interfaceGenericParamType.ReflectionName);
}
}
[Test]
public void ExplicitImplementationOfUnifiedMethods_ToMemberReference()
{
IType type = compilation.FindType(typeof(ExplicitGenericInterfaceImplementationWithUnifiableMethods<int, int>));
Assert.AreEqual(2, type.GetMethods(m => m.IsExplicitInterfaceImplementation).Count());
foreach (IMethod method in type.GetMethods(m => m.IsExplicitInterfaceImplementation)) {
IMethod resolvedMethod = (IMethod)method.ToMemberReference().Resolve(compilation.TypeResolveContext);
Assert.AreEqual(method, resolvedMethod);
}
}
[Test]
public void ExplicitGenericInterfaceImplementation()
{
ITypeDefinition impl = GetTypeDefinition(typeof(ExplicitGenericInterfaceImplementation));
IType genericInterfaceOfString = compilation.FindType(typeof(IGenericInterface<string>));
IMethod implMethod1 = impl.Methods.Single(m => !m.IsConstructor && !m.Parameters[1].IsRef);
IMethod implMethod2 = impl.Methods.Single(m => !m.IsConstructor && m.Parameters[1].IsRef);
Assert.IsTrue(implMethod1.IsExplicitInterfaceImplementation);
Assert.IsTrue(implMethod2.IsExplicitInterfaceImplementation);
IMethod interfaceMethod1 = (IMethod)implMethod1.ImplementedInterfaceMembers.Single();
Assert.AreEqual(genericInterfaceOfString, interfaceMethod1.DeclaringType);
Assert.IsTrue(!interfaceMethod1.Parameters[1].IsRef);
IMethod interfaceMethod2 = (IMethod)implMethod2.ImplementedInterfaceMembers.Single();
Assert.AreEqual(genericInterfaceOfString, interfaceMethod2.DeclaringType);
Assert.IsTrue(interfaceMethod2.Parameters[1].IsRef);
}
[Test]
public void ExplicitlyImplementedPropertiesShouldBeReportedAsBeingImplemented() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsPropertyExplicitly));
var prop = type.Properties.Single();
Assert.That(prop.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.Prop" }));
Assert.That(prop.Getter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.get_Prop" }));
Assert.That(prop.Setter.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IInterfaceWithProperty.set_Prop" }));
}
[Test]
public void ExplicitlyImplementedPropertiesShouldHaveExplicitlyImplementedAccessors() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsPropertyExplicitly));
var prop = type.Properties.Single();
Assert.IsTrue(prop.IsExplicitInterfaceImplementation);
Assert.IsTrue(prop.Getter.IsExplicitInterfaceImplementation);
Assert.IsTrue(prop.Setter.IsExplicitInterfaceImplementation);
}
[Test]
public void EventAccessorsShouldBeReportedAsImplementingInterfaceAccessors() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsEvent));
var evt = type.Events.Single(p => p.Name == "Event");
Assert.That(evt.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.Event" }));
Assert.That(evt.AddAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.add_Event" }));
Assert.That(evt.RemoveAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.remove_Event" }));
}
[Test]
public void EventAccessorsShouldBeReportedAsImplementingInterfaceAccessorsWhenCustomAccessorMethodsAreUsed() {
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsEventWithCustomAccessors));
var evt = type.Events.Single(p => p.Name == "Event");
Assert.That(evt.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.Event" }));
Assert.That(evt.AddAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.add_Event" }));
Assert.That(evt.RemoveAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.remove_Event" }));
}
[Test]
public void ExplicitlyImplementedEventsShouldBeReportedAsBeingImplemented()
{
ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsEventExplicitly));
var evt = type.Events.Single();
Assert.That(evt.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.Event" }));
Assert.That(evt.AddAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.add_Event" }));
Assert.That(evt.RemoveAccessor.ImplementedInterfaceMembers.Select(p => p.ReflectionName).ToList(), Is.EqualTo(new[] { "ICSharpCode.NRefactory.TypeSystem.TestCase.IHasEvent.remove_Event" }));
}
}
}

1
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -136,6 +136,7 @@ @@ -136,6 +136,7 @@
<Compile Include="TypeSystem\Implementation\AbstractType.cs" />
<Compile Include="TypeSystem\Implementation\AbstractUnresolvedEntity.cs" />
<Compile Include="TypeSystem\Implementation\AbstractUnresolvedMember.cs" />
<Compile Include="TypeSystem\Implementation\AccessorOwnerMemberReference.cs" />
<Compile Include="TypeSystem\Implementation\BaseTypeCollector.cs" />
<Compile Include="TypeSystem\Implementation\DefaultAssemblyReference.cs" />
<Compile Include="TypeSystem\Implementation\DefaultMemberReference.cs" />

14
ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs

@ -116,6 +116,20 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -116,6 +116,20 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
}
public override IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
for (int i = 0; i < unresolvedProperties.Length; i++) {
if (unresolvedProperties[i].CanGet) {
if (filter == null || filter(unresolvedProperties[i].Getter))
yield return resolvedProperties[i].Getter;
}
if (unresolvedProperties[i].CanSet) {
if (filter == null || filter(unresolvedProperties[i].Setter))
yield return resolvedProperties[i].Setter;
}
}
}
public override int GetHashCode()
{
unchecked {

46
ICSharpCode.NRefactory/TypeSystem/ArrayType.cs

@ -96,36 +96,34 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -96,36 +96,34 @@ namespace ICSharpCode.NRefactory.TypeSystem
public override IEnumerable<IMethod> GetMethods(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
return EmptyList<IMethod>.Instance;
else
return compilation.FindType(KnownTypeCode.Array).GetMethods(filter, options);
}
//static readonly DefaultUnresolvedParameter indexerParam = new DefaultUnresolvedParameter(KnownTypeReference.Int32, string.Empty);
public override IEnumerable<IMethod> GetMethods(IList<IType> typeArguments, Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
return EmptyList<IMethod>.Instance;
else
return compilation.FindType(KnownTypeCode.Array).GetMethods(typeArguments, filter, options);
}
public override IEnumerable<IProperty> GetProperties(Predicate<IUnresolvedProperty> filter = null, GetMemberOptions options = GetMemberOptions.None)
public override IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
ITypeDefinition arrayDef = compilation.FindType(KnownTypeCode.Array) as ITypeDefinition;
if (arrayDef != null) {
if ((options & GetMemberOptions.IgnoreInheritedMembers) == 0) {
foreach (IProperty p in arrayDef.GetProperties(filter, options)) {
yield return p;
}
}
/*DefaultUnresolvedProperty indexer = new DefaultUnresolvedProperty(arrayDef, "Items") {
EntityType = EntityType.Indexer,
ReturnType = elementType,
Accessibility = Accessibility.Public,
Getter = DefaultAccessor.GetFromAccessibility(Accessibility.Public),
Setter = DefaultAccessor.GetFromAccessibility(Accessibility.Public),
IsSynthetic = true
};
for (int i = 0; i < dimensions; i++) {
indexer.Parameters.Add(indexerParam);
}
indexer.Freeze();
if (filter == null || filter(indexer)) {
yield return indexer.CreateResolved(context);
}*/
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
return EmptyList<IMethod>.Instance;
else
return compilation.FindType(KnownTypeCode.Array).GetAccessors(filter, options);
}
public override IEnumerable<IProperty> GetProperties(Predicate<IUnresolvedProperty> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
return EmptyList<IProperty>.Instance;
else
return compilation.FindType(KnownTypeCode.Array).GetProperties(filter, options);
}
// NestedTypes, Events, Fields: System.Array doesn't have any; so we can use the AbstractType default implementation

46
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -1647,10 +1647,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1647,10 +1647,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
[CLSCompliant(false)]
public IUnresolvedMethod ReadMethod(MethodDefinition method, IUnresolvedTypeDefinition parentType, EntityType methodType = EntityType.Method)
{
return ReadMethod(method, parentType, null, methodType);
return ReadMethod(method, parentType, methodType, null);
}
IUnresolvedMethod ReadMethod(MethodDefinition method, IUnresolvedTypeDefinition parentType, IUnresolvedMember accessorOwner, EntityType methodType = EntityType.Method)
IUnresolvedMethod ReadMethod(MethodDefinition method, IUnresolvedTypeDefinition parentType, EntityType methodType, IUnresolvedMember accessorOwner)
{
if (method == null)
return null;
@ -1686,6 +1686,19 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1686,6 +1686,19 @@ namespace ICSharpCode.NRefactory.TypeSystem
m.IsExtensionMethod = true;
}
int lastDot = method.Name.LastIndexOf('.');
if (lastDot >= 0 && method.HasOverrides) {
// To be consistent with the parser-initialized type system, shorten the method name:
m.Name = method.Name.Substring(lastDot + 1);
m.IsExplicitInterfaceImplementation = true;
foreach (var or in method.Overrides) {
m.ExplicitInterfaceImplementations.Add(new DefaultMemberReference(
accessorOwner != null ? EntityType.Accessor : EntityType.Method,
ReadTypeReference(or.DeclaringType),
or.Name, or.GenericParameters.Count, m.Parameters.Select(p => p.Type).ToList()));
}
}
FinishReadMember(m, method);
return m;
}
@ -1870,6 +1883,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1870,6 +1883,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
#endregion
#region Read Property
[CLSCompliant(false)]
public IUnresolvedProperty ReadProperty(PropertyDefinition property, IUnresolvedTypeDefinition parentType, EntityType propertyType = EntityType.Property)
{
@ -1882,8 +1896,8 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1882,8 +1896,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
TranslateModifiers(property.GetMethod ?? property.SetMethod, p);
p.ReturnType = ReadTypeReference(property.PropertyType, typeAttributes: property);
p.Getter = ReadMethod(property.GetMethod, parentType, p);
p.Setter = ReadMethod(property.SetMethod, parentType, p);
p.Getter = ReadMethod(property.GetMethod, parentType, EntityType.Accessor, p);
p.Setter = ReadMethod(property.SetMethod, parentType, EntityType.Accessor, p);
if (property.HasParameters) {
foreach (ParameterDefinition par in property.Parameters) {
@ -1892,6 +1906,15 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1892,6 +1906,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
AddAttributes(property, p);
var accessor = p.Getter ?? p.Setter;
if (accessor != null && accessor.IsExplicitInterfaceImplementation) {
p.Name = property.Name.Substring(property.Name.LastIndexOf('.') + 1);
p.IsExplicitInterfaceImplementation = true;
foreach (var mr in accessor.ExplicitInterfaceImplementations) {
p.ExplicitInterfaceImplementations.Add(new AccessorOwnerMemberReference(mr));
}
}
FinishReadMember(p, property);
return p;
}
@ -1910,12 +1933,21 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -1910,12 +1933,21 @@ namespace ICSharpCode.NRefactory.TypeSystem
TranslateModifiers(ev.AddMethod, e);
e.ReturnType = ReadTypeReference(ev.EventType, typeAttributes: ev);
e.AddAccessor = ReadMethod(ev.AddMethod, parentType, e);
e.RemoveAccessor = ReadMethod(ev.RemoveMethod, parentType, e);
e.InvokeAccessor = ReadMethod(ev.InvokeMethod, parentType, e);
e.AddAccessor = ReadMethod(ev.AddMethod, parentType, EntityType.Accessor, e);
e.RemoveAccessor = ReadMethod(ev.RemoveMethod, parentType, EntityType.Accessor, e);
e.InvokeAccessor = ReadMethod(ev.InvokeMethod, parentType, EntityType.Accessor, e);
AddAttributes(ev, e);
var accessor = e.AddAccessor ?? e.RemoveAccessor ?? e.InvokeAccessor;
if (accessor != null && accessor.IsExplicitInterfaceImplementation) {
e.Name = ev.Name.Substring(ev.Name.LastIndexOf('.') + 1);
e.IsExplicitInterfaceImplementation = true;
foreach (var mr in accessor.ExplicitInterfaceImplementations) {
e.ExplicitInterfaceImplementations.Add(new AccessorOwnerMemberReference(mr));
}
}
FinishReadMember(e, ev);
return e;

3
ICSharpCode.NRefactory/TypeSystem/EntityType.cs

@ -31,6 +31,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -31,6 +31,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
Method,
Operator,
Constructor,
Destructor
Destructor,
Accessor
}
}

15
ICSharpCode.NRefactory/TypeSystem/IType.cs

@ -194,7 +194,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -194,7 +194,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// <para>
/// The result does not include constructors.
/// The result does not include constructors or accessors.
/// </para>
/// <para>
/// For methods on parameterized types, type substitution will be performed on the method signature,
@ -221,7 +221,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -221,7 +221,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// The filter is tested on the original method definitions (before specialization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// <para>The result does not include constructors.</para>
/// <para>The result does not include constructors or accessors.</para>
/// <para>
/// Type substitution will be performed on the method signature, creating a <see cref="Implementation.SpecializedMethod"/>
/// with the specified type arguments.
@ -288,6 +288,17 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -288,6 +288,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </para>
/// </remarks>
IEnumerable<IMember> GetMembers(Predicate<IUnresolvedMember> filter = null, GetMemberOptions options = GetMemberOptions.None);
/// <summary>
/// Gets all accessors belonging to properties or events on this type.
/// </summary>
/// <param name="filter">The filter used to select which members to return.
/// The filter is tested on the original member definitions (before specialization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// Accessors are not returned by GetMembers() or GetMethods().
/// </remarks>
IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None);
}
[Flags]

6
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs

@ -80,9 +80,13 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -80,9 +80,13 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return EmptyList<IMember>.Instance;
} else {
// TODO: implement interface member mappings correctly
return InheritanceHelper.GetBaseMembers(this, true)
var result = InheritanceHelper.GetBaseMembers(this, true)
.Where(m => m.DeclaringTypeDefinition != null && m.DeclaringTypeDefinition.Kind == TypeKind.Interface)
.ToArray();
result = result.Where(item => !DeclaringTypeDefinition.Members.Any(m => m.IsExplicitInterfaceImplementation && m.ImplementedInterfaceMembers.Contains(item))).ToArray();
return result;
}
}

8
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -294,6 +294,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -294,6 +294,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return GetMembersHelper.GetMembers(this, FilterNonStatic(filter), options);
}
public IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
return EmptyList<IMethod>.Instance;
else
return GetMembersHelper.GetAccessors(this, FilterNonStatic(filter), options);
}
static Predicate<T> FilterNonStatic<T>(Predicate<T> filter) where T : class, IUnresolvedMember
{
if (filter == null)

5
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs

@ -123,6 +123,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -123,6 +123,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
.Concat(GetEvents(filter, options));
}
public virtual IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter, GetMemberOptions options = GetMemberOptions.None)
{
return EmptyList<IMethod>.Instance;
}
public override sealed bool Equals(object obj)
{
return Equals(obj as IType);

51
ICSharpCode.NRefactory/TypeSystem/Implementation/AccessorOwnerMemberReference.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
/// <summary>
/// Given a reference to an accessor, returns the accessor's owner.
/// </summary>
[Serializable]
sealed class AccessorOwnerMemberReference : IMemberReference
{
readonly IMemberReference accessorReference;
public AccessorOwnerMemberReference(IMemberReference accessorReference)
{
if (accessorReference == null)
throw new ArgumentNullException("accessorReference");
this.accessorReference = accessorReference;
}
public ITypeReference DeclaringTypeReference {
get { return accessorReference.DeclaringTypeReference; }
}
public IMember Resolve(ITypeResolveContext context)
{
IMethod method = accessorReference.Resolve(context) as IMethod;
if (method != null)
return method.AccessorOwner;
else
return null;
}
}
}

4
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMemberReference.cs

@ -62,7 +62,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -62,7 +62,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
IType type = typeReference.Resolve(context);
IEnumerable<IMember> members;
if (entityType == EntityType.Method) {
if (entityType == EntityType.Accessor) {
members = type.GetAccessors(m => m.Name == name && !m.IsExplicitInterfaceImplementation);
} else if (entityType == EntityType.Method) {
members = type.GetMethods(
m => m.Name == name && m.EntityType == EntityType.Method
&& m.TypeParameters.Count == typeParameterCount && !m.IsExplicitInterfaceImplementation,

32
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs

@ -830,6 +830,38 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -830,6 +830,38 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return GetMembersHelper.GetMembers(this, filter, options);
}
}
public virtual IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers) {
return GetFilteredAccessors(filter);
} else {
return GetMembersHelper.GetAccessors(this, filter, options);
}
}
IEnumerable<IMethod> GetFilteredAccessors(Predicate<IUnresolvedMethod> filter)
{
var members = GetMemberList();
for (int i = 0; i < members.unresolvedMembers.Length; i++) {
IUnresolvedMember unresolved = members.unresolvedMembers[i];
var unresolvedProperty = unresolved as IUnresolvedProperty;
var unresolvedEvent = unresolved as IUnresolvedEvent;
if (unresolvedProperty != null) {
if (unresolvedProperty.CanGet && (filter == null || filter(unresolvedProperty.Getter)))
yield return ((IProperty)members[i]).Getter;
if (unresolvedProperty.CanSet && (filter == null || filter(unresolvedProperty.Setter)))
yield return ((IProperty)members[i]).Setter;
} else if (unresolvedEvent != null) {
if (unresolvedEvent.CanAdd && (filter == null || filter(unresolvedEvent.AddAccessor)))
yield return ((IEvent)members[i]).AddAccessor;
if (unresolvedEvent.CanRemove && (filter == null || filter(unresolvedEvent.RemoveAccessor)))
yield return ((IEvent)members[i]).RemoveAccessor;
if (unresolvedEvent.CanInvoke && (filter == null || filter(unresolvedEvent.InvokeAccessor)))
yield return ((IEvent)members[i]).InvokeAccessor;
}
}
}
#endregion
public bool Equals(IType other)

10
ICSharpCode.NRefactory/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
@ -58,9 +59,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -58,9 +59,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition()));
if (interfaceMember == null)
return null;
var members = declaringType.GetMembers(
IEnumerable<IMember> members;
if (interfaceMember.EntityType == EntityType.Accessor) {
members = declaringType.GetAccessors(
m => m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
} else {
members = declaringType.GetMembers(
m => m.EntityType == interfaceMember.EntityType && m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
}
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0]));
}
}

28
ICSharpCode.NRefactory/TypeSystem/Implementation/GetMembersHelper.cs

@ -142,6 +142,22 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -142,6 +142,22 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
#endregion
#region GetAccessors
public static IEnumerable<IMethod> GetAccessors(IType type, Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers) {
return GetAccessorsImpl(type, filter, options);
} else {
return type.GetNonInterfaceBaseTypes().SelectMany(t => GetAccessorsImpl(t, filter, options));
}
}
static IEnumerable<IMethod> GetAccessorsImpl(IType baseType, Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
return GetConstructorsOrAccessorsImpl(baseType, baseType.GetAccessors(filter, options | declaredMembers), filter, options);
}
#endregion
#region GetConstructors
public static IEnumerable<IMethod> GetConstructors(IType type, Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
@ -154,17 +170,21 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -154,17 +170,21 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
static IEnumerable<IMethod> GetConstructorsImpl(IType baseType, Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
IEnumerable<IMethod> declaredCtors = baseType.GetConstructors(filter, options | declaredMembers);
return GetConstructorsOrAccessorsImpl(baseType, baseType.GetConstructors(filter, options | declaredMembers), filter, options);
}
static IEnumerable<IMethod> GetConstructorsOrAccessorsImpl(IType baseType, IEnumerable<IMethod> declaredMembers, Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
if ((options & GetMemberOptions.ReturnMemberDefinitions) == GetMemberOptions.ReturnMemberDefinitions) {
return declaredCtors;
return declaredMembers;
}
ParameterizedType pt = baseType as ParameterizedType;
if (pt != null) {
var substitution = pt.GetSubstitution();
return declaredCtors.Select(m => new SpecializedMethod(m, substitution) { DeclaringType = pt });
return declaredMembers.Select(m => new SpecializedMethod(m, substitution) { DeclaringType = pt });
} else {
return declaredCtors;
return declaredMembers;
}
}
#endregion

8
ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs

@ -70,7 +70,13 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -70,7 +70,13 @@ namespace ICSharpCode.NRefactory.TypeSystem
if (baseType == member.DeclaringTypeDefinition)
continue;
foreach (IMember baseMember in baseType.GetMembers(m => m.Name == member.Name, GetMemberOptions.IgnoreInheritedMembers)) {
IEnumerable<IMember> baseMembers;
if (member.EntityType == EntityType.Accessor) {
baseMembers = baseType.GetAccessors(m => m.Name == member.Name && !m.IsExplicitInterfaceImplementation, GetMemberOptions.IgnoreInheritedMembers);
} else {
baseMembers = baseType.GetMembers(m => m.Name == member.Name && !m.IsExplicitInterfaceImplementation, GetMemberOptions.IgnoreInheritedMembers);
}
foreach (IMember baseMember in baseMembers) {
if (SignatureComparer.Ordinal.Equals(member, baseMember)) {
if (specializedMember != null)
yield return SpecializedMember.Create(baseMember, specializedMember.Substitution);

5
ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs

@ -162,6 +162,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -162,6 +162,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
return GetMembersHelper.GetMembers(this, FilterNonStatic(filter), options);
}
public override IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter, GetMemberOptions options)
{
return GetMembersHelper.GetAccessors(this, FilterNonStatic(filter), options);
}
static Predicate<T> FilterNonStatic<T>(Predicate<T> filter) where T : class, IUnresolvedMember
{
if (filter == null)

8
ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs

@ -259,6 +259,14 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -259,6 +259,14 @@ namespace ICSharpCode.NRefactory.TypeSystem
return GetMembersHelper.GetMembers(this, filter, options);
}
public IEnumerable<IMethod> GetAccessors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
if ((options & GetMemberOptions.ReturnMemberDefinitions) == GetMemberOptions.ReturnMemberDefinitions)
return genericType.GetAccessors(filter, options);
else
return GetMembersHelper.GetAccessors(this, filter, options);
}
public override bool Equals(object obj)
{
return Equals(obj as IType);

Loading…
Cancel
Save