Browse Source

* ICSharpCode.NRefactory.csproj:

* IdStringProvider.cs:
* IDStringTests.cs:
* DocumentationComment.cs:
* IdStringMemberReference.cs:
* XmlDocumentationProvider.cs:
* IDStringConsistencyCheck.cs:
* CSharpCrefLookupTests.cs: Renamed IDString -> IdString to follow
  .NET naming guidelines.

* IDStringProvider.cs:
* IDStringMemberReference.cs:
newNRvisualizers
Mike Krüger 14 years ago
parent
commit
cb576fb78d
  1. 6
      ICSharpCode.NRefactory.ConsistencyCheck/IDStringConsistencyCheck.cs
  2. 40
      ICSharpCode.NRefactory.Tests/Documentation/CSharpCrefLookupTests.cs
  3. 14
      ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs
  4. 4
      ICSharpCode.NRefactory/Documentation/DocumentationComment.cs
  5. 12
      ICSharpCode.NRefactory/Documentation/IdStringMemberReference.cs
  6. 26
      ICSharpCode.NRefactory/Documentation/IdStringProvider.cs
  7. 4
      ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs
  8. 11
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

6
ICSharpCode.NRefactory.ConsistencyCheck/IDStringConsistencyCheck.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -44,10 +44,10 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -44,10 +44,10 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
static void Check(IEntity entity, ITypeResolveContext context, HashSet<string> idStrings)
{
string id = IDStringProvider.GetIDString(entity);
string id = IdStringProvider.GetIdString(entity);
if (!idStrings.Add(id))
throw new InvalidOperationException("Duplicate ID string " + id);
IEntity resolvedEntity = IDStringProvider.FindEntity(id, context);
IEntity resolvedEntity = IdStringProvider.FindEntity(id, context);
if (resolvedEntity != entity)
throw new InvalidOperationException(id);
}

40
ICSharpCode.NRefactory.Tests/Documentation/CSharpCrefLookupTests.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -75,7 +75,7 @@ class Impl<T> : IGeneric<List<string>[,], T> { @@ -75,7 +75,7 @@ class Impl<T> : IGeneric<List<string>[,], T> {
public void IntParse()
{
Assert.AreEqual("M:System.Int32.Parse(System.String)",
IDStringProvider.GetIDString(Lookup("int.Parse(string)")));
IdStringProvider.GetIdString(Lookup("int.Parse(string)")));
}
[Test]
@ -110,76 +110,76 @@ class Impl<T> : IGeneric<List<string>[,], T> { @@ -110,76 +110,76 @@ class Impl<T> : IGeneric<List<string>[,], T> {
public void M()
{
Assert.AreEqual("M:Test.M(System.String[0:,0:])",
IDStringProvider.GetIDString(Lookup("M")));
IdStringProvider.GetIdString(Lookup("M")));
}
[Test]
public void CurrentType()
{
Assert.AreEqual("T:Test",
IDStringProvider.GetIDString(Lookup("Test")));
IdStringProvider.GetIdString(Lookup("Test")));
}
[Test]
public void Constructor()
{
Assert.AreEqual("M:Test.#ctor",
IDStringProvider.GetIDString(Lookup("Test()")));
IdStringProvider.GetIdString(Lookup("Test()")));
}
[Test]
public void Overloaded()
{
Assert.AreEqual("M:Test.Overloaded(System.Int32)",
IDStringProvider.GetIDString(Lookup("Overloaded(int)")));
IdStringProvider.GetIdString(Lookup("Overloaded(int)")));
Assert.AreEqual("M:Test.Overloaded(System.String)",
IDStringProvider.GetIDString(Lookup("Overloaded(string)")));
IdStringProvider.GetIdString(Lookup("Overloaded(string)")));
Assert.AreEqual("M:Test.Overloaded(System.Int32@)",
IDStringProvider.GetIDString(Lookup("Overloaded(ref int)")));
IdStringProvider.GetIdString(Lookup("Overloaded(ref int)")));
}
[Test]
public void MethodInGenericInterface()
{
Assert.AreEqual("M:XmlDocTest.IGeneric`2.Test``1(``0[0:,0:]@)",
IDStringProvider.GetIDString(Lookup("IGeneric{X, Y}.Test")));
IdStringProvider.GetIdString(Lookup("IGeneric{X, Y}.Test")));
Assert.AreEqual("M:XmlDocTest.IGeneric`2.Test``1(``0[0:,0:]@)",
IDStringProvider.GetIDString(Lookup("IGeneric{X, Y}.Test{Z}")));
IdStringProvider.GetIdString(Lookup("IGeneric{X, Y}.Test{Z}")));
Assert.AreEqual("M:XmlDocTest.IGeneric`2.Test``1(``0[0:,0:]@)",
IDStringProvider.GetIDString(Lookup("IGeneric{X, Y}.Test{Z}(ref Z[,])")));
IdStringProvider.GetIdString(Lookup("IGeneric{X, Y}.Test{Z}(ref Z[,])")));
}
[Test]
public void Indexer()
{
Assert.AreEqual("P:Test.Item(System.Int32)",
IDStringProvider.GetIDString(Lookup("this")));
IdStringProvider.GetIdString(Lookup("this")));
Assert.AreEqual("P:Test.Item(System.Int32)",
IDStringProvider.GetIDString(Lookup("Test.this")));
IdStringProvider.GetIdString(Lookup("Test.this")));
Assert.AreEqual("P:Test.Item(System.Int32)",
IDStringProvider.GetIDString(Lookup("Test.this[int]")));
IdStringProvider.GetIdString(Lookup("Test.this[int]")));
}
[Test]
public void OperatorPlus()
{
Assert.AreEqual("M:Test.op_Addition(Test,System.Int32)",
IDStringProvider.GetIDString(Lookup("operator +")));
IdStringProvider.GetIdString(Lookup("operator +")));
Assert.AreEqual("M:Test.op_Addition(Test,System.Int32)",
IDStringProvider.GetIDString(Lookup("operator +(Test, int)")));
IdStringProvider.GetIdString(Lookup("operator +(Test, int)")));
Assert.AreEqual("M:Test.op_Addition(Test,System.Int32)",
IDStringProvider.GetIDString(Lookup("Test.operator +(Test, int)")));
IdStringProvider.GetIdString(Lookup("Test.operator +(Test, int)")));
}
[Test]
public void ImplicitOperator()
{
Assert.AreEqual("M:Test.op_Implicit(Test)~System.Int32",
IDStringProvider.GetIDString(Lookup("implicit operator int(Test)")));
IdStringProvider.GetIdString(Lookup("implicit operator int(Test)")));
Assert.AreEqual("M:Test.op_Implicit(System.Int32)~Test",
IDStringProvider.GetIDString(Lookup("implicit operator Test(int)")));
IdStringProvider.GetIdString(Lookup("implicit operator Test(int)")));
Assert.AreEqual("M:Test.op_Implicit(System.Int32)~Test",
IDStringProvider.GetIDString(Lookup("Test.implicit operator Test(int)")));
IdStringProvider.GetIdString(Lookup("Test.implicit operator Test(int)")));
}
}
}

14
ICSharpCode.NRefactory.Tests/Documentation/IDStringTests.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.Documentation
// Note: there's no mscorlib in the context.
// These tests only use primitive types from mscorlib, so the full name is known
// without resolving them.
return new DocumentationComment(IDStringProvider.GetIDString(entity), new SimpleTypeResolveContext(entity));
return new DocumentationComment(IdStringProvider.GetIdString(entity), new SimpleTypeResolveContext(entity));
}
}
@ -328,13 +328,13 @@ namespace Acme @@ -328,13 +328,13 @@ namespace Acme
{
var list = new SimpleCompilation(CecilLoaderTests.Mscorlib).FindType(typeof(List<>)).GetDefinition();
Assert.AreEqual("T:System.Collections.Generic.List`1",
IDStringProvider.GetIDString(list));
IdStringProvider.GetIdString(list));
Assert.AreEqual("M:System.Collections.Generic.List`1.Add(`0)",
IDStringProvider.GetIDString(list.Methods.Single(m => m.Name == "Add")));
IdStringProvider.GetIdString(list.Methods.Single(m => m.Name == "Add")));
Assert.AreEqual("M:System.Collections.Generic.List`1.AddRange(System.Collections.Generic.IEnumerable{`0})",
IDStringProvider.GetIDString(list.Methods.Single(m => m.Name == "AddRange")));
IdStringProvider.GetIdString(list.Methods.Single(m => m.Name == "AddRange")));
Assert.AreEqual("M:System.Collections.Generic.List`1.ConvertAll``1(System.Converter{`0,``0})",
IDStringProvider.GetIDString(list.Methods.Single(m => m.Name == "ConvertAll")));
IdStringProvider.GetIdString(list.Methods.Single(m => m.Name == "ConvertAll")));
}
[Test]
@ -353,7 +353,7 @@ class Impl<T> : IGeneric<string[,], T> { @@ -353,7 +353,7 @@ class Impl<T> : IGeneric<string[,], T> {
Assert.AreEqual(
"M:xxx.Impl`1.xxx#IGeneric{System#String[@]@T}#Test``1(``0@)",
IDStringProvider.GetIDString(method));
IdStringProvider.GetIdString(method));
}
}
}

4
ICSharpCode.NRefactory/Documentation/DocumentationComment.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.Documentation
public virtual IEntity ResolveCref(string cref)
{
try {
return IDStringProvider.FindEntity(cref, context);
return IdStringProvider.FindEntity(cref, context);
} catch (ReflectionNameParseException) {
return null;
}

12
ICSharpCode.NRefactory/Documentation/IDStringMemberReference.cs → ICSharpCode.NRefactory/Documentation/IdStringMemberReference.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -22,17 +22,17 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -22,17 +22,17 @@ using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.Documentation
{
[Serializable]
class IDStringMemberReference : IMemberReference
class IdStringMemberReference : IMemberReference
{
readonly ITypeReference declaringTypeReference;
readonly char memberType;
readonly string memberIDString;
readonly string memberIdString;
public IDStringMemberReference(ITypeReference declaringTypeReference, char memberType, string memberIDString)
public IdStringMemberReference(ITypeReference declaringTypeReference, char memberType, string memberIdString)
{
this.declaringTypeReference = declaringTypeReference;
this.memberType = memberType;
this.memberIDString = memberIDString;
this.memberIdString = memberIdString;
}
bool CanMatch(IUnresolvedMember member)
@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.Documentation
{
IType declaringType = declaringTypeReference.Resolve(context);
foreach (var member in declaringType.GetMembers(CanMatch, GetMemberOptions.IgnoreInheritedMembers)) {
if (IDStringProvider.GetIDString(member) == memberIDString)
if (IdStringProvider.GetIdString(member) == memberIdString)
return member;
}
return null;

26
ICSharpCode.NRefactory/Documentation/IDStringProvider.cs → ICSharpCode.NRefactory/Documentation/IdStringProvider.cs

@ -29,13 +29,13 @@ namespace ICSharpCode.NRefactory.Documentation @@ -29,13 +29,13 @@ namespace ICSharpCode.NRefactory.Documentation
/// Provides ID strings for entities. (C# 4.0 spec, §A.3.1)
/// ID strings are used to identify members in XML documentation files.
/// </summary>
public static class IDStringProvider
public static class IdStringProvider
{
#region GetIDString
/// <summary>
/// Gets the ID string (C# 4.0 spec, §A.3.1) for the specified entity.
/// </summary>
public static string GetIDString(IEntity entity)
public static string GetIdString(this IEntity entity)
{
StringBuilder b = new StringBuilder();
switch (entity.EntityType) {
@ -184,22 +184,22 @@ namespace ICSharpCode.NRefactory.Documentation @@ -184,22 +184,22 @@ namespace ICSharpCode.NRefactory.Documentation
/// <param name="memberIDString">The ID string representing the member (with "M:", "F:", "P:" or "E:" prefix).</param>
/// <returns>A member reference that represents the ID string.</returns>
/// <exception cref="ReflectionNameParseException">The syntax of the ID string is invalid</exception>
public static IMemberReference ParseMemberIDString(string memberIDString)
public static IMemberReference ParseMemberIdString(string memberIdString)
{
if (memberIDString == null)
if (memberIdString == null)
throw new ArgumentNullException("memberIDString");
if (memberIDString.Length < 2 || memberIDString[1] != ':')
if (memberIdString.Length < 2 || memberIdString[1] != ':')
throw new ReflectionNameParseException(0, "Missing type tag");
char typeChar = memberIDString[0];
int parenPos = memberIDString.IndexOf('(');
char typeChar = memberIdString[0];
int parenPos = memberIdString.IndexOf('(');
if (parenPos < 0)
parenPos = memberIDString.LastIndexOf('~');
parenPos = memberIdString.LastIndexOf('~');
if (parenPos < 0)
parenPos = memberIDString.Length;
int dotPos = memberIDString.LastIndexOf('.', parenPos - 1);
parenPos = memberIdString.Length;
int dotPos = memberIdString.LastIndexOf('.', parenPos - 1);
if (dotPos < 0)
throw new ReflectionNameParseException(0, "Could not find '.' separating type name from member name");
string typeName = memberIDString.Substring(0, dotPos);
string typeName = memberIdString.Substring(0, dotPos);
int pos = 2;
ITypeReference typeReference = ParseTypeName(typeName, ref pos);
if (pos != typeName.Length)
@ -209,7 +209,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -209,7 +209,7 @@ namespace ICSharpCode.NRefactory.Documentation
// if (pos > 0)
// memberName = memberName.Substring(0, pos);
// memberName = memberName.Replace('#', '.');
return new IDStringMemberReference(typeReference, typeChar, memberIDString);
return new IdStringMemberReference(typeReference, typeChar, memberIdString);
}
#endregion
@ -377,7 +377,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -377,7 +377,7 @@ namespace ICSharpCode.NRefactory.Documentation
if (idString.StartsWith("T:", StringComparison.Ordinal)) {
return ParseTypeName(idString.Substring(2)).Resolve(context).GetDefinition();
} else {
return ParseMemberIDString(idString).Resolve(context);
return ParseMemberIdString(idString).Resolve(context);
}
}
#endregion

4
ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// 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
@ -306,7 +306,7 @@ namespace ICSharpCode.NRefactory.Documentation @@ -306,7 +306,7 @@ namespace ICSharpCode.NRefactory.Documentation
/// <inheritdoc/>
public DocumentationComment GetDocumentation(IEntity entity)
{
string xmlDoc = GetDocumentation(IDStringProvider.GetIDString(entity));
string xmlDoc = GetDocumentation(IdStringProvider.GetIdString(entity));
if (xmlDoc != null) {
return new DocumentationComment(new StringTextSource(xmlDoc), new SimpleTypeResolveContext(entity));
} else {

11
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1026;-Microsoft.Security#CA2104</CodeAnalysisRules>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<DocumentationFile>bin\$(Configuration)\ICSharpCode.NRefactory.xml</DocumentationFile>
@ -46,6 +46,9 @@ @@ -46,6 +46,9 @@
<DebugSymbols>false</DebugSymbols>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -56,8 +59,6 @@ @@ -56,8 +59,6 @@
<Compile Include="Documentation\DocumentationComment.cs" />
<Compile Include="Documentation\GetPotentiallyNestedClassTypeReference.cs" />
<Compile Include="Documentation\IDocumentationProvider.cs" />
<Compile Include="Documentation\IDStringMemberReference.cs" />
<Compile Include="Documentation\IDStringProvider.cs" />
<Compile Include="Editor\IDocument.cs" />
<Compile Include="Editor\IDocumentLine.cs" />
<Compile Include="Editor\ISegment.cs" />
@ -220,10 +221,12 @@ @@ -220,10 +221,12 @@
<Compile Include="Completion\CompletionCategory.cs" />
<Compile Include="Completion\IParameterDataProvider.cs" />
<Compile Include="Completion\IVariableCompletionData.cs" />
<Compile Include="Documentation\IdStringProvider.cs" />
<Compile Include="Documentation\IdStringMemberReference.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Completion\" />
<Folder Include="TypeSystem\Implementation" />
<Folder Include="TypeSystem\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Mono.Cecil\Mono.Cecil.csproj">

Loading…
Cancel
Save