Browse Source

SharedTypes: add comment why we don't void,int, etc.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
8dc189dac7
  1. 3
      ICSharpCode.NRefactory/TypeSystem/IType.cs
  2. 11
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs
  3. 18
      ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs

3
ICSharpCode.NRefactory/TypeSystem/IType.cs

@ -23,6 +23,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -23,6 +23,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Gets the element type of array or pointer types.
/// </summary>
/// <exception cref="InvalidOperationException">
/// This type is not an array or pointer type.
/// </exception>
IType GetElementType();
/// <summary>

11
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs

@ -386,10 +386,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -386,10 +386,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
if (other == null)
return false;
if (declaringTypeDefinition != null) {
return declaringTypeDefinition.Equals(other.DeclaringTypeDefinition) && this.Name == other.Name && this.TypeParameterCount == other.TypeParameterCount;
return declaringTypeDefinition.Equals(other.DeclaringTypeDefinition)
&& this.Name == other.Name
&& this.TypeParameterCount == other.TypeParameterCount;
} else {
return other.DeclaringTypeDefinition == null && this.ProjectContent == other.ProjectContent
&& this.Namespace == other.Namespace && this.Name == other.Name && this.TypeParameterCount == other.TypeParameterCount;
return other.DeclaringTypeDefinition == null
&& this.ProjectContent == other.ProjectContent
&& this.Namespace == other.Namespace
&& this.Name == other.Name
&& this.TypeParameterCount == other.TypeParameterCount;
}
}

18
ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs

@ -22,5 +22,23 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -22,5 +22,23 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "It's immutable")]
public readonly static IType Null = new NullType();
/*
* I'd like to define static instances for common types like
* void, int, etc.; but there are two problems with this:
*
* SharedTypes.Void.GetDefinition().ProjectContent should return mscorlib, but
* we can't do that without providing a context.
* Assuming we add a context parameter to GetDefinition():
*
* SharedType.Void.Equals(SharedType.Void.GetDefinition(x))
* SharedType.Void.GetDefinition(y).Equals(SharedType.Void)
* should both return true.
* But if the type can have multiple definitions (multiple mscorlib versions loaded),
* then this is not possible without violating transitivity of Equals():
*
* SharedType.Void.GetDefinition(x).Equals(SharedType.Void.GetDefinition(y))
* would have to return true even though these are two distinct definitions.
*/
}
}

Loading…
Cancel
Save