Browse Source

Make CSharpResolveVisitor internal and expose CSharpAstResolver instead.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
73438b7288
  1. 2
      ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
  2. 20
      ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs
  3. 1
      ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
  4. 29
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  5. 128
      ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs
  6. 4
      ICSharpCode.NRefactory.CSharp/Resolver/CompositeResolveVisitorNavigator.cs
  7. 5
      ICSharpCode.NRefactory.CSharp/Resolver/FindReferenceSearchScope.cs
  8. 43
      ICSharpCode.NRefactory.CSharp/Resolver/FindReferences.cs
  9. 1
      ICSharpCode.NRefactory.CSharp/Resolver/IResolveVisitorNavigator.cs
  10. 8
      ICSharpCode.NRefactory.CSharp/Resolver/NodeListResolveVisitorNavigator.cs
  11. 12
      ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
  12. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
  13. 1
      ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs
  14. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs
  15. 86
      ICSharpCode.NRefactory.Demo/CSDemo.cs
  16. 8
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/UsingDeclarationTests.cs
  17. 6
      ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs
  18. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseUtil.cs
  19. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/PropertyDeclarationTests.cs
  20. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs
  21. 2
      ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs
  22. 4
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/MemberLookupTests.cs
  23. 14
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs
  24. 4
      ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs
  25. 31
      ICSharpCode.NRefactory.Tests/TypeSystem/GetMembersTests.cs
  26. 11
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  27. 2
      ICSharpCode.NRefactory/PatternMatching/INode.cs
  28. 4
      ICSharpCode.NRefactory/TextLocation.cs
  29. 3
      ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs
  30. 3
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  31. 13
      ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
  32. 5
      ICSharpCode.NRefactory/TypeSystem/IAssembly.cs
  33. 5
      ICSharpCode.NRefactory/TypeSystem/ICompilation.cs
  34. 5
      ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs
  35. 2
      ICSharpCode.NRefactory/TypeSystem/INamedElement.cs
  36. 2
      ICSharpCode.NRefactory/TypeSystem/IParameter.cs
  37. 35
      ICSharpCode.NRefactory/TypeSystem/IType.cs
  38. 2
      ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs
  39. 8
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  40. 1
      ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
  41. 7
      ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleCompilation.cs
  42. 3
      ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs
  43. 2
      ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs
  44. 10
      ICSharpCode.NRefactory/TypeSystem/TypeKind.cs

2
ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs

@ -169,7 +169,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -169,7 +169,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
throw new NotImplementedException();
}
public IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, ResolveVisitor resolveVisitor)
internal IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, ResolveVisitor resolveVisitor)
{
if (statement == null)
throw new ArgumentNullException("statement");

20
ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// CompilationUnit.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -25,12 +25,13 @@ @@ -25,12 +25,13 @@
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
public class CompilationUnit : AstNode
public class CompilationUnit : AstNode
{
public static readonly Role<AstNode> MemberRole = new Role<AstNode>("Member", AstNode.Null);
@ -40,6 +41,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,6 +41,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Gets/Sets the file name of this compilation unit.
/// </summary>
public string FileName { get; set; }
List<Error> errors = new List<Error> ();
public List<Error> Errors {
@ -72,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -72,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp
yield return (TypeDeclaration)curNode;
foreach (var child in curNode.Children) {
if (!(child is Statement || child is Expression) &&
(child.Role != TypeDeclaration.MemberRole || (child is TypeDeclaration && includeInnerTypes)))
(child.Role != TypeDeclaration.MemberRole || (child is TypeDeclaration && includeInnerTypes)))
nodeStack.Push (child);
}
}
@ -92,9 +98,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -92,9 +98,13 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Converts this compilation unit into a parsed file that can be stored in the type system.
/// </summary>
public CSharpParsedFile ToTypeSystem(string fileName)
public CSharpParsedFile ToTypeSystem()
{
return new TypeSystemConvertVisitor(fileName).Convert(this);
if (string.IsNullOrEmpty(this.FileName))
throw new InvalidOperationException("Cannot use ToTypeSystem() on a compilation unit without file name.");
var v = new TypeSystemConvertVisitor(this.FileName);
v.VisitCompilationUnit(this, null);
return v.ParsedFile;
}
}
}

1
ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj

@ -273,6 +273,7 @@ @@ -273,6 +273,7 @@
<Compile Include="Resolver\CompositeResolveVisitorNavigator.cs" />
<Compile Include="Resolver\ConversionResolveResult.cs" />
<Compile Include="Resolver\Conversions.cs" />
<Compile Include="Resolver\CSharpAstResolver.cs" />
<Compile Include="Resolver\CSharpInvocationResolveResult.cs" />
<Compile Include="Resolver\CSharpOperators.cs" />
<Compile Include="Resolver\CSharpResolver.cs" />

29
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -3379,7 +3379,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3379,7 +3379,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public CompilationUnit Parse (TextReader reader, int line = 0)
public CompilationUnit Parse (TextReader reader, string fileName, int lineModifier = 0)
{
// TODO: can we optimize this to avoid the text->stream->text roundtrip?
using (MemoryStream stream = new MemoryStream ()) {
@ -3390,21 +3390,21 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3390,21 +3390,21 @@ namespace ICSharpCode.NRefactory.CSharp
w.Write (buffer, 0, read);
w.Flush (); // we can't close the StreamWriter because that would also close the MemoryStream
stream.Position = 0;
return Parse (stream, line);
return Parse (stream, fileName, lineModifier);
}
}
public static void AdjustLineLocations (AstNode node, int line)
public static void AdjustLineLocations (AstNode node, int lineModifier)
{
if (node is IRelocatable) {
((IRelocatable)node).SetStartLocation (new TextLocation (node.StartLocation.Line + line, node.StartLocation.Column));
((IRelocatable)node).SetStartLocation (new TextLocation (node.StartLocation.Line + lineModifier, node.StartLocation.Column));
}
foreach (var child in node.Children) {
AdjustLineLocations (child, line);
AdjustLineLocations (child, lineModifier);
}
}
public CompilationUnit Parse (CompilerCompilationUnit top, int line)
public CompilationUnit Parse (CompilerCompilationUnit top, string fileName, int lineModifier = 0)
{
if (top == null)
return null;
@ -3414,10 +3414,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3414,10 +3414,11 @@ namespace ICSharpCode.NRefactory.CSharp
InsertComments (top, conversionVisitor);
if (CompilationUnitCallback != null)
CompilationUnitCallback (top);
if (line != 0)
AdjustLineLocations (conversionVisitor.Unit, line);
if (lineModifier != 0)
AdjustLineLocations (conversionVisitor.Unit, lineModifier);
if (top.LastYYValue is Mono.CSharp.Expression)
conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept (conversionVisitor) as AstNode;
conversionVisitor.Unit.FileName = fileName;
return conversionVisitor.Unit;
}
@ -3436,17 +3437,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3436,17 +3437,17 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public CompilationUnit Parse (string program)
public CompilationUnit Parse (string program, string fileName)
{
return Parse (new StringReader (program));
return Parse (new StringReader (program), fileName);
}
public CompilationUnit Parse (Stream stream, int line = 0)
public CompilationUnit Parse (Stream stream, string fileName, int lineModifier = 0)
{
lock (CompilerCallableEntryPoint.parseLock) {
errorReportPrinter = new ErrorReportPrinter ("");
CompilerCompilationUnit top = CompilerCallableEntryPoint.ParseFile (CompilerArguments, stream, "parsed.cs", errorReportPrinter);
var unit = Parse (top, line);
CompilerCompilationUnit top = CompilerCallableEntryPoint.ParseFile (CompilerArguments, stream, fileName, errorReportPrinter);
var unit = Parse (top, fileName, lineModifier);
unit.Errors.AddRange (errorReportPrinter.Errors);
return unit;
}
@ -3455,7 +3456,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3455,7 +3456,7 @@ namespace ICSharpCode.NRefactory.CSharp
public IEnumerable<AttributedNode> ParseTypeMembers (TextReader reader, int lineModifier = 0)
{
string code = "unsafe partial class MyClass { " + Environment.NewLine + reader.ReadToEnd () + "}";
var cu = Parse (new StringReader (code), -1 + lineModifier);
var cu = Parse (new StringReader (code), "parsed.cs", lineModifier - 1);
if (cu == null)
return Enumerable.Empty<AttributedNode> ();
var td = cu.Children.FirstOrDefault () as TypeDeclaration;

128
ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs

@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
// 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;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.Resolver
{
/// <summary>
/// Resolves C# AST nodes.
/// </summary>
public class CSharpAstResolver
{
readonly CSharpResolver initialResolverState;
readonly AstNode rootNode;
readonly CSharpParsedFile parsedFile;
ResolveVisitor resolveVisitor;
/// <summary>
/// Creates a new C# AST resolver.
/// </summary>
/// <param name="compilation">The current compilation.</param>
/// <param name="parsedFile">
/// Result of the <see cref="TypeSystemConvertVisitor"/> for the file being passed. This is used for setting up the context on the resolver. The parsed file must be registered in the compilation.
/// </param>
/// <param name="compilationUnit">The compilation unit corresponding to the specified parsed file.</param>
public CSharpAstResolver(ICompilation compilation, CompilationUnit compilationUnit, CSharpParsedFile parsedFile)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (parsedFile == null)
throw new ArgumentNullException("parsedFile");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
this.initialResolverState = new CSharpResolver(compilation);
this.rootNode = compilationUnit;
this.parsedFile = parsedFile;
}
/// <summary>
/// Creates a new C# AST resolver.
/// </summary>
/// <param name="resolver">The resolver state at the root node.</param>
/// <param name="rootNode">The root node of the resolved tree.</param>
/// <param name="parsedFile">The parsed file for the nodes being resolved. This parameter is used only
/// when the root node is on the type level; it is not necessary when an expression is passed.
/// This parameter may be null.</param>
public CSharpAstResolver(CSharpResolver resolver, AstNode rootNode, CSharpParsedFile parsedFile = null)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
if (rootNode == null)
throw new ArgumentNullException("rootNode");
this.initialResolverState = resolver.Clone();
this.rootNode = rootNode;
this.parsedFile = parsedFile;
}
/// <summary>
/// Applies a resolver navigator. This will resolve the nodes requested by the navigator, and will inform the
/// navigator of the results.
/// This method must be called as the first operation on the CSharpAstResolver, it is invalid to apply a navigator
/// after a portion of the file was already resolved.
/// </summary>
public void ApplyNavigator(IResolveVisitorNavigator navigator)
{
if (resolveVisitor != null)
throw new InvalidOperationException("Applying a navigator is only valid as the first operation on the CSharpAstResolver.");
resolveVisitor = new ResolveVisitor(initialResolverState, parsedFile, navigator);
lock (resolveVisitor)
resolveVisitor.Scan(rootNode);
}
/// <summary>
/// Resolves the specified node.
/// </summary>
public ResolveResult Resolve(AstNode node)
{
if (resolveVisitor == null) {
resolveVisitor = new ResolveVisitor(initialResolverState, parsedFile);
resolveVisitor.Scan(rootNode);
}
lock (resolveVisitor)
return resolveVisitor.GetResolveResult(node);
}
/// <summary>
/// Gets the expected type for the specified node. This is the type being that a node is being converted to.
/// </summary>
public IType GetExpectedType(Expression expr)
{
throw new NotImplementedException();
}
/// <summary>
/// Gets the conversion that is being applied to the specified expression.
/// </summary>
public Conversion GetConversion(Expression expr)
{
throw new NotImplementedException();
}
/// <summary>
/// Gets whether the specified node is unresolvable.
/// </summary>
public static bool IsUnresolvableNode(AstNode node)
{
return (node.NodeType == NodeType.Whitespace || node is ArraySpecifier || node is NamedArgumentExpression);
}
}
}

4
ICSharpCode.NRefactory.CSharp/Resolver/CompositeResolveVisitorNavigator.cs

@ -31,6 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -31,6 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
if (navigators == null)
throw new ArgumentNullException("navigators");
this.navigators = navigators;
foreach (var n in navigators) {
if (n == null)
throw new ArgumentException("Array must not contain nulls.");
}
}
public ResolveVisitorNavigationMode Scan(AstNode node)

5
ICSharpCode.NRefactory.CSharp/Resolver/FindReferenceSearchScope.cs

@ -26,6 +26,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -26,6 +26,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// </summary>
public interface IFindReferenceSearchScope
{
/// <summary>
/// Gets the parent compilation for this search scope.
/// </summary>
ICompilation Compilation { get; }
/// <summary>
/// Gets the search term. Only files that contain this identifier need to be parsed.
/// Can return null if all files need to be parsed.

43
ICSharpCode.NRefactory.CSharp/Resolver/FindReferences.cs

@ -96,11 +96,16 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -96,11 +96,16 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
abstract class SearchScope : IResolveVisitorNavigator, IFindReferenceSearchScope
{
protected string searchTerm;
internal ICompilation compilation;
internal Accessibility accessibility;
internal ITypeDefinition topLevelTypeDefinition;
FoundReferenceCallback callback;
ICompilation IFindReferenceSearchScope.Compilation {
get { return compilation; }
}
IResolveVisitorNavigator IFindReferenceSearchScope.GetNavigator(FoundReferenceCallback callback)
{
SearchScope n = (SearchScope)MemberwiseClone();
@ -203,10 +208,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -203,10 +208,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
}
if (scope.accessibility == Accessibility.None)
scope.accessibility = effectiveAccessibility;
scope.compilation = entity.Compilation;
scope.topLevelTypeDefinition = topLevelTypeDefinition;
if (additionalScope != null) {
if (additionalScope.accessibility == Accessibility.None)
additionalScope.accessibility = effectiveAccessibility;
additionalScope.compilation = entity.Compilation;
additionalScope.topLevelTypeDefinition = topLevelTypeDefinition;
return new[] { scope, additionalScope };
} else {
@ -277,7 +284,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -277,7 +284,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// <param name="context">The type resolve context to use for resolving the file.</param>
/// <param name="callback">Callback used to report the references that were found.</param>
public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
FoundReferenceCallback callback, CancellationToken cancellationToken)
FoundReferenceCallback callback, CancellationToken cancellationToken)
{
if (searchScope == null)
throw new ArgumentNullException("searchScope");
@ -290,8 +297,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -290,8 +297,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// <param name="searchScopes">The search scopes for which to look.</param>
/// <param name="parsedFile">The type system representation of the file being searched.</param>
/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
/// <param name="context">The type resolve context to use for resolving the file.</param>
/// <param name="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
FoundReferenceCallback callback, CancellationToken cancellationToken)
{
@ -301,24 +308,26 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -301,24 +308,26 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
throw new ArgumentNullException("parsedFile");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
throw new NotImplementedException();
/*
if (context == null)
throw new ArgumentNullException("context");
if (searchScopes.Count == 0)
return;
using (var ctx = context.Synchronize()) {
IResolveVisitorNavigator navigator;
if (searchScopes.Count == 1)
navigator = searchScopes[0].GetNavigator(callback);
else
navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray());
navigator = new DetectSkippableNodesNavigator(navigator, compilationUnit);
CSharpResolver resolver = new CSharpResolver(ctx, this.CancellationToken);
ResolveVisitor v = new ResolveVisitor(resolver, parsedFile, navigator);
v.Scan(compilationUnit);
}*/
ICompilation compilation = searchScopes[0].Compilation;
IResolveVisitorNavigator navigator;
if (searchScopes.Count == 1) {
navigator = searchScopes[0].GetNavigator(callback);
} else {
IResolveVisitorNavigator[] navigators = new IResolveVisitorNavigator[searchScopes.Count];
for (int i = 0; i < navigators.Length; i++) {
if (searchScopes[i].Compilation != compilation)
throw new InvalidOperationException("All search scopes must belong to the same compilation");
navigators[i] = searchScopes[i].GetNavigator(callback);
}
navigator = new CompositeResolveVisitorNavigator(navigators);
}
navigator = new DetectSkippableNodesNavigator(navigator, compilationUnit);
CSharpAstResolver resolver = new CSharpAstResolver(compilation, compilationUnit, parsedFile);
resolver.ApplyNavigator(navigator);
}
#endregion

1
ICSharpCode.NRefactory.CSharp/Resolver/IResolveVisitorNavigator.cs

@ -83,7 +83,6 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -83,7 +83,6 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
this.targetForResolveCalls = targetForResolveCalls;
}
ResolveVisitorNavigationMode IResolveVisitorNavigator.Scan(AstNode node)
{
return mode;

8
ICSharpCode.NRefactory.CSharp/Resolver/NodeListResolveVisitorNavigator.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -27,7 +27,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// <see cref="IResolveVisitorNavigator"/> implementation that resolves a list of nodes.
/// We will skip all nodes which are not the target nodes or ancestors of the target nodes.
/// </summary>
public sealed class NodeListResolveVisitorNavigator : IResolveVisitorNavigator
public class NodeListResolveVisitorNavigator : IResolveVisitorNavigator
{
readonly Dictionary<AstNode, ResolveVisitorNavigationMode> dict = new Dictionary<AstNode, ResolveVisitorNavigationMode>();
@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
}
/// <inheritdoc/>
public ResolveVisitorNavigationMode Scan(AstNode node)
public virtual ResolveVisitorNavigationMode Scan(AstNode node)
{
ResolveVisitorNavigationMode mode;
if (dict.TryGetValue(node, out mode)) {
@ -65,11 +65,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -65,11 +65,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
}
}
void IResolveVisitorNavigator.Resolved(AstNode node, ResolveResult result)
public virtual void Resolved(AstNode node, ResolveResult result)
{
}
void IResolveVisitorNavigator.ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
public virtual void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
{
}
}

12
ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// Moreover, there is the <c>ResolveAll</c> mode - it works similar to resolving mode, but will not switch back to scanning mode.
/// The whole subtree will be resolved without notifying the navigator.
/// </remarks>
public sealed class ResolveVisitor : IAstVisitor<object, ResolveResult>
sealed class ResolveVisitor : IAstVisitor<object, ResolveResult>
{
// The ResolveVisitor is also responsible for handling lambda expressions.
@ -359,7 +359,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -359,7 +359,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// </summary>
public ResolveResult GetResolveResult(AstNode node)
{
if (IsUnresolvableNode(node))
if (CSharpAstResolver.IsUnresolvableNode(node))
return null;
MergeUndecidedLambdas();
@ -397,14 +397,6 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -397,14 +397,6 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
return null;
}
/// <summary>
/// Gets whether the specified node is unresolvable.
/// </summary>
public static bool IsUnresolvableNode(AstNode node)
{
return (node.NodeType == NodeType.Whitespace || node is ArraySpecifier || node is NamedArgumentExpression);
}
/// <summary>
/// Gets the resolve result for the specified node.
/// If the node was not resolved by the navigator, this method will return null.

6
ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs

@ -194,6 +194,12 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -194,6 +194,12 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
}
}
public IEnumerable<ITypeDefinition> TopLevelTypeDefinitions {
get {
return GetTypes().Values;
}
}
sealed class NS : INamespace
{
readonly CSharpAssembly assembly;

1
ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs

@ -35,7 +35,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -35,7 +35,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
{
readonly CSharpTypeResolveContext parentContext;
readonly UsingScope usingScope;
readonly CSharpResolver resolver;
internal readonly ConcurrentDictionary<string, ResolveResult> ResolveCache = new ConcurrentDictionary<string, ResolveResult>();
internal List<List<IMethod>> AllExtensionMethods;

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

@ -78,12 +78,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem @@ -78,12 +78,6 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
this.currentTypeDefinition = currentTypeDefinition;
}
public CSharpParsedFile Convert(AstNode node)
{
node.AcceptVisitor(this, null);
return parsedFile;
}
public CSharpParsedFile ParsedFile {
get { return parsedFile; }
}

86
ICSharpCode.NRefactory.Demo/CSDemo.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.Demo @@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.Demo
void CSharpParseButtonClick(object sender, EventArgs e)
{
CSharpParser parser = new CSharpParser();
compilationUnit = parser.Parse(new StringReader(csharpCodeTextBox.Text));
compilationUnit = parser.Parse(new StringReader(csharpCodeTextBox.Text), "dummy.cs");
csharpTreeView.Nodes.Clear();
foreach (var element in compilationUnit.Children) {
csharpTreeView.Nodes.Add(MakeTreeNode(element));
@ -200,36 +200,73 @@ namespace ICSharpCode.NRefactory.Demo @@ -200,36 +200,73 @@ namespace ICSharpCode.NRefactory.Demo
void ResolveButtonClick(object sender, EventArgs e)
{
IProjectContent project = new CSharpProjectContent();
var parsedFile = compilationUnit.ToTypeSystem("dummy.cs");
var parsedFile = compilationUnit.ToTypeSystem();
project = project.UpdateProjectContent(null, parsedFile);
project = project.AddAssemblyReferences(builtInLibs.Value);
ICompilation compilation = project.CreateCompilation();
CSharpResolver resolver = new CSharpResolver(compilation);
IResolveVisitorNavigator navigator = null;
StoreInDictionaryNavigator navigator;
if (csharpTreeView.SelectedNode != null) {
navigator = new NodeListResolveVisitorNavigator(new[] { (AstNode)csharpTreeView.SelectedNode.Tag });
navigator = new StoreInDictionaryNavigator((AstNode)csharpTreeView.SelectedNode.Tag);
} else {
navigator = new StoreInDictionaryNavigator();
}
ResolveVisitor visitor = new ResolveVisitor(resolver, parsedFile, navigator);
visitor.Scan(compilationUnit);
CSharpAstResolver resolver = new CSharpAstResolver(compilation, compilationUnit, parsedFile);
resolver.ApplyNavigator(navigator);
csharpTreeView.BeginUpdate();
ShowResolveResultsInTree(csharpTreeView.Nodes, visitor);
ShowResolveResultsInTree(csharpTreeView.Nodes, navigator);
csharpTreeView.EndUpdate();
}
void ShowResolveResultsInTree(TreeNodeCollection c, ResolveVisitor v)
sealed class StoreInDictionaryNavigator : NodeListResolveVisitorNavigator
{
internal Dictionary<AstNode, ResolveResult> resolveResults = new Dictionary<AstNode, ResolveResult>();
internal Dictionary<AstNode, Conversion> conversions = new Dictionary<AstNode, Conversion>();
internal Dictionary<AstNode, IType> conversionTargetTypes = new Dictionary<AstNode, IType>();
bool resolveAll;
public StoreInDictionaryNavigator(params AstNode[] nodes)
: base(nodes)
{
resolveAll = (nodes.Length == 0);
}
public override ResolveVisitorNavigationMode Scan(AstNode node)
{
if (resolveAll)
return ResolveVisitorNavigationMode.Resolve;
else
return base.Scan(node);
}
public override void Resolved(AstNode node, ResolveResult result)
{
resolveResults.Add(node, result);
}
public override void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
{
conversions.Add(expression, conversion);
conversionTargetTypes.Add(expression, targetType);
}
}
void ShowResolveResultsInTree(TreeNodeCollection c, StoreInDictionaryNavigator n)
{
foreach (TreeNode t in c) {
AstNode node = t.Tag as AstNode;
if (node != null) {
ResolveResult rr = v.GetResolveResultIfResolved(node);
if (rr != null)
t.Text = GetNodeTitle(node) + " " + rr.ToString();
else
t.Text = GetNodeTitle(node);
ResolveResult rr;
string text = GetNodeTitle(node);
if (n.resolveResults.TryGetValue(node, out rr))
text += " " + rr.ToString();
if (n.conversions.ContainsKey(node)) {
text += " [" + n.conversions[node] + " to " + n.conversionTargetTypes[node] + "]";
}
t.Text = text;
}
ShowResolveResultsInTree(t.Nodes, v);
ShowResolveResultsInTree(t.Nodes, n);
}
}
@ -253,20 +290,17 @@ namespace ICSharpCode.NRefactory.Demo @@ -253,20 +290,17 @@ namespace ICSharpCode.NRefactory.Demo
return;
IProjectContent project = new CSharpProjectContent();
var parsedFile = compilationUnit.ToTypeSystem("dummy.cs");
var parsedFile = compilationUnit.ToTypeSystem();
project = project.UpdateProjectContent(null, parsedFile);
project = project.AddAssemblyReferences(builtInLibs.Value);
ICompilation compilation = project.CreateCompilation();
CSharpResolver resolver = new CSharpResolver(compilation);
CSharpAstResolver resolver = new CSharpAstResolver(compilation, compilationUnit, parsedFile);
AstNode node = (AstNode)csharpTreeView.SelectedNode.Tag;
IResolveVisitorNavigator navigator = new NodeListResolveVisitorNavigator(new[] { node });
ResolveVisitor visitor = new ResolveVisitor(resolver, parsedFile, navigator);
visitor.Scan(compilationUnit);
IEntity entity;
MemberResolveResult mrr = visitor.GetResolveResult(node) as MemberResolveResult;
TypeResolveResult trr = visitor.GetResolveResult(node) as TypeResolveResult;
MemberResolveResult mrr = resolver.Resolve(node) as MemberResolveResult;
TypeResolveResult trr = resolver.Resolve(node) as TypeResolveResult;
if (mrr != null) {
entity = mrr.Member;
} else if (trr != null) {
@ -282,13 +316,7 @@ namespace ICSharpCode.NRefactory.Demo @@ -282,13 +316,7 @@ namespace ICSharpCode.NRefactory.Demo
};
var searchScopes = fr.GetSearchScopes(entity);
navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray());
visitor = new ResolveVisitor(resolver, parsedFile, navigator);
visitor.Scan(compilationUnit);
csharpTreeView.BeginUpdate();
ShowResolveResultsInTree(csharpTreeView.Nodes, visitor);
csharpTreeView.EndUpdate();
fr.FindReferencesInFile(searchScopes, parsedFile, compilationUnit, callback, CancellationToken.None);
MessageBox.Show("Found " + referenceCount + " references to " + entity.FullName);
}

8
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/UsingDeclarationTests.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
{
string program = "using\n";
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse (program);
CompilationUnit cu = parser.Parse (program, "parsed.cs");
Assert.AreEqual(0, cu.Children.Count());
Assert.IsTrue(parser.HasErrors);
}
@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
string program = "using System;\n" +
"using My.Name.Space;\n";
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse(new StringReader(program));
CompilationUnit cu = parser.Parse(new StringReader(program), "parsed.cs");
Assert.IsFalse(parser.HasErrors);
Assert.AreEqual(2, cu.Children.Count());
@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
"using myAlias=My.Name.Space;\n" +
"using StringCollection = System.Collections.Generic.List<string>;\n";
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse(new StringReader(program));
CompilationUnit cu = parser.Parse(new StringReader(program), "parsed.cs");
Assert.IsFalse(parser.HasErrors);
Assert.AreEqual(3, cu.Children.Count());
@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
"using myAlias=global::My.Name.Space;\n" +
"using a::b.c;\n";
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse(new StringReader(program));
CompilationUnit cu = parser.Parse(new StringReader(program), "parsed.cs");
Assert.IsFalse(parser.HasErrors);
Assert.AreEqual(3, cu.Children.Count());

6
ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs

@ -52,9 +52,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -52,9 +52,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
foreach (string fileName in fileNames) {
CompilationUnit cu;
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.SequentialScan)) {
cu = parser.Parse(fs);
cu = parser.Parse(fs, fileName);
}
var parsedFile = cu.ToTypeSystem(fileName);
var parsedFile = cu.ToTypeSystem();
foreach (var td in parsedFile.GetAllTypeDefinitions()) {
Assert.AreSame(parsedFile, td.ParsedFile);
foreach (var member in td.Members) {
@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
CSharpParser parser = new CSharpParser();
foreach (string fileName in fileNames) {
this.currentDocument = new ReadOnlyDocument(File.ReadAllText(fileName));
CompilationUnit cu = parser.Parse(currentDocument.CreateReader());
CompilationUnit cu = parser.Parse(currentDocument.CreateReader(), fileName);
if (parser.HasErrors)
continue;
this.currentFileName = fileName;

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseUtil.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
public static T ParseGlobal<T>(string code, bool expectErrors = false) where T : AstNode
{
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse(new StringReader(code));
CompilationUnit cu = parser.Parse(new StringReader(code), "parsed.cs");
if (parser.HasErrors)
parser.ErrorPrinter.Errors.ForEach (err => Console.WriteLine (err.Message));

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/PropertyDeclarationTests.cs

@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
int line4Pos = code.IndexOf("\t\tset");
CSharpParser parser = new CSharpParser();
CompilationUnit cu = parser.Parse(new StringReader(code));
CompilationUnit cu = parser.Parse(new StringReader(code), "parsed.cs");
PropertyDeclaration pd = (PropertyDeclaration)cu.Children.Single().GetChildByRole(TypeDeclaration.MemberRole);
Assert.AreEqual(new TextLocation(2, code.IndexOf("{\n\t\tget") - line2Pos + 1), pd.GetChildByRole(AstNode.Roles.LBrace).StartLocation);
Assert.AreEqual(new TextLocation(5, 3), pd.EndLocation);

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

@ -41,10 +41,10 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -41,10 +41,10 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
CSharpParser parser = new CSharpParser();
CompilationUnit cu;
using (Stream s = typeof(TypeSystemTests).Assembly.GetManifestResourceStream(typeof(TypeSystemTests), fileName)) {
cu = parser.Parse(s);
cu = parser.Parse(s, fileName);
}
var parsedFile = cu.ToTypeSystem(fileName);
var parsedFile = cu.ToTypeSystem();
return new CSharpProjectContent()
.UpdateProjectContent(null, parsedFile)
.AddAssemblyReferences(new[] { CecilLoaderTests.Mscorlib })

2
ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs

@ -63,7 +63,7 @@ namespace OtherNS { @@ -63,7 +63,7 @@ namespace OtherNS {
{
pc = new CSharpProjectContent();
pc = pc.SetAssemblyName("MyAssembly");
parsedFile = new CSharpParser().Parse(new StringReader(program)).ToTypeSystem("program.cs");
parsedFile = new CSharpParser().Parse(new StringReader(program), "program.cs").ToTypeSystem();
pc = pc.UpdateProjectContent(null, parsedFile);
pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });

4
ICSharpCode.NRefactory.Tests/CSharp/Resolver/MemberLookupTests.cs

@ -40,8 +40,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -40,8 +40,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
CSharpParsedFile Parse(string program)
{
CompilationUnit cu = new CSharpParser().Parse(new StringReader(program));
CSharpParsedFile parsedFile = cu.ToTypeSystem("test.cs");
CompilationUnit cu = new CSharpParser().Parse(new StringReader(program), "test.cs");
CSharpParsedFile parsedFile = cu.ToTypeSystem();
project = project.UpdateProjectContent(null, parsedFile);
compilation = project.CreateCompilation();
return parsedFile;

14
ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs

@ -151,14 +151,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -151,14 +151,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
protected ResolveResult Resolve(string code)
{
CompilationUnit cu = new CSharpParser().Parse(new StringReader(code.Replace("$", "")));
CompilationUnit cu = new CSharpParser().Parse(new StringReader(code.Replace("$", "")), "code.cs");
TextLocation[] dollars = FindDollarSigns(code).ToArray();
Assert.AreEqual(2, dollars.Length, "Expected 2 dollar signs marking start+end of desired node");
SetUp();
CSharpParsedFile parsedFile = cu.ToTypeSystem("code.cs");
CSharpParsedFile parsedFile = cu.ToTypeSystem();
project = project.UpdateProjectContent(null, parsedFile);
compilation = project.CreateCompilation();
@ -169,10 +169,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -169,10 +169,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
Debug.WriteLine(new string('=', 70));
Debug.WriteLine("Starting new resolver for " + fnv.ResultNode);
var navigator = new NodeListResolveVisitorNavigator(new[] { fnv.ResultNode });
ResolveVisitor rv = new ResolveVisitor(new CSharpResolver(compilation), parsedFile, navigator);
rv.Scan(cu);
ResolveResult rr = rv.GetResolveResult(fnv.ResultNode);
CSharpAstResolver resolver = new CSharpAstResolver(compilation, cu, parsedFile);
ResolveResult rr = resolver.Resolve(fnv.ResultNode);
Assert.IsNotNull(rr, "ResolveResult is null - did something go wrong while navigating to the target node?");
Debug.WriteLine("ResolveResult is " + rr);
return rr;
@ -212,14 +210,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -212,14 +210,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
protected ResolveResult ResolveAtLocation(string code)
{
CompilationUnit cu = new CSharpParser().Parse(new StringReader(code.Replace("$", "")));
CompilationUnit cu = new CSharpParser().Parse(new StringReader(code.Replace("$", "")), "test.cs");
TextLocation[] dollars = FindDollarSigns(code).ToArray();
Assert.AreEqual(1, dollars.Length, "Expected 1 dollar signs marking the location");
SetUp();
CSharpParsedFile parsedFile = cu.ToTypeSystem("test.cs");
CSharpParsedFile parsedFile = cu.ToTypeSystem();
project = project.UpdateProjectContent(null, parsedFile);
compilation = project.CreateCompilation();

4
ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
var adapter = new ReadOnlyDocument (input);
var visitor = new AstFormattingVisitor (policy, adapter, factory);
var compilationUnit = new CSharpParser ().Parse (new StringReader (input));
var compilationUnit = new CSharpParser ().Parse (new StringReader (input), "test.cs");
compilationUnit.AcceptVisitor (visitor, null);
return new ReadOnlyDocument(ApplyChanges (input, visitor.Changes));
@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
{
var visitior = new AstFormattingVisitor (policy, document, factory);
var compilationUnit = new CSharpParser ().Parse (new StringReader (document.Text));
var compilationUnit = new CSharpParser ().Parse (new StringReader (document.Text), "test.cs");
compilationUnit.AcceptVisitor (visitior, null);
string newText = ApplyChanges (document.Text, visitior.Changes);
if (expectedOutput != newText) {

31
ICSharpCode.NRefactory.Tests/TypeSystem/GetMembersTests.cs

@ -58,37 +58,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -58,37 +58,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
Assert.AreEqual(1, resolvedC.GetMethods(m => m.Name == "ToString").Count());
}
[Test, Ignore]
public void ArrayType()
{
IType arrayType = compilation.FindType(typeof(string[]));
// Array inherits ToString() from System.Object
Assert.AreEqual("System.Object.ToString", arrayType.GetMethods(m => m.Name == "ToString").Single().FullName);
Assert.AreEqual("System.Array.GetLowerBound", arrayType.GetMethods(m => m.Name == "GetLowerBound").Single().FullName);
Assert.AreEqual("System.Array.Length", arrayType.GetProperties(p => p.Name == "Length").Single().FullName);
// test indexer
IProperty indexer = arrayType.GetProperties(p => p.IsIndexer).Single();
Assert.AreEqual("System.Array.Items", indexer.FullName);
Assert.AreEqual("System.String", indexer.ReturnType.ReflectionName);
Assert.AreEqual(1, indexer.Parameters.Count);
Assert.AreEqual("System.Int32", indexer.Parameters[0].Type.ReflectionName);
}
[Test, Ignore]
public void MultidimensionalArrayType()
{
IType arrayType = compilation.FindType(typeof(string[,][]));
// test indexer
IProperty indexer = arrayType.GetProperties(p => p.IsIndexer).Single();
Assert.AreEqual("System.Array.Items", indexer.FullName);
Assert.AreEqual("System.String[]", indexer.ReturnType.ReflectionName);
Assert.AreEqual(2, indexer.Parameters.Count);
Assert.AreEqual("System.Int32", indexer.Parameters[0].Type.ReflectionName);
Assert.AreEqual("System.Int32", indexer.Parameters[1].Type.ReflectionName);
}
[Test]
public void GetNestedTypesOfUnboundGenericClass()
{

11
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -20,12 +20,14 @@ @@ -20,12 +20,14 @@
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<DocumentationFile>bin\Release\ICSharpCode.NRefactory.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>465371136</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@ -33,23 +35,22 @@ @@ -33,23 +35,22 @@
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@ -98,6 +99,7 @@ @@ -98,6 +99,7 @@
<Compile Include="Semantics\UnknownMemberResolveResult.cs" />
<Compile Include="TextLocation.cs" />
<Compile Include="TypeSystem\Accessibility.cs" />
<Compile Include="TypeSystem\AnonymousType.cs" />
<Compile Include="TypeSystem\ArrayType.cs" />
<Compile Include="TypeSystem\ByReferenceType.cs" />
<Compile Include="TypeSystem\CecilLoader.cs" />
@ -125,7 +127,6 @@ @@ -125,7 +127,6 @@
<Compile Include="TypeSystem\Implementation\AbstractType.cs" />
<Compile Include="TypeSystem\Implementation\AbstractUnresolvedEntity.cs" />
<Compile Include="TypeSystem\Implementation\AbstractUnresolvedMember.cs" />
<Compile Include="TypeSystem\Implementation\AnonymousType.cs" />
<Compile Include="TypeSystem\Implementation\BaseTypeCollector.cs" />
<Compile Include="TypeSystem\Implementation\DefaultAssemblyReference.cs" />
<Compile Include="TypeSystem\Implementation\DefaultMemberReference.cs" />

2
ICSharpCode.NRefactory/PatternMatching/INode.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.PatternMatching @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.PatternMatching
/// <c>this</c> is the pattern, <paramref name="other"/> is the AST that is being matched.
/// </summary>
/// <returns>
/// A match object. Check <see cref="Match.Success"/> to see whether the match was successful.
/// A match object. Check <see cref="PatternMatching.Match.Success"/> to see whether the match was successful.
/// </returns>
/// <remarks>
/// Patterns are ASTs that contain special pattern nodes (from the PatternMatching namespace).

4
ICSharpCode.NRefactory/TextLocation.cs

@ -26,8 +26,8 @@ namespace ICSharpCode.NRefactory @@ -26,8 +26,8 @@ namespace ICSharpCode.NRefactory
/// Text editor lines/columns are counted started from one.
/// </summary>
/// <remarks>
/// The document provides the methods <see cref="IDocument.GetLocation"/> and
/// <see cref="IDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// The document provides the methods <see cref="Editor.IDocument.GetLocation"/> and
/// <see cref="Editor.IDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// </remarks>
[Serializable]
public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>

3
ICSharpCode.NRefactory/TypeSystem/Implementation/AnonymousType.cs → ICSharpCode.NRefactory/TypeSystem/AnonymousType.cs

@ -19,9 +19,10 @@ @@ -19,9 +19,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
namespace ICSharpCode.NRefactory.TypeSystem
{
/// <summary>
/// Anonymous type.

3
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -152,7 +152,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -152,7 +152,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Loads a type from Cecil.
/// </summary>
/// <param name="typeDefinition">The Cecil TypeDefinition.</param>
/// <param name="projectContent">The project content used as parent for the new type.</param>
/// <returns>ITypeDefinition representing the Cecil type.</returns>
[CLSCompliant(false)]
public IUnresolvedTypeDefinition LoadType(TypeDefinition typeDefinition)
@ -234,8 +233,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -234,8 +233,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// a type system type reference.</param>
/// <param name="typeAttributes">Attributes associated with the Cecil type reference.
/// This is used to support the 'dynamic' type.</param>
/// <param name="entity">The entity that owns this type reference.
/// Used for generic type references.</param>
[CLSCompliant(false)]
public ITypeReference ReadTypeReference(TypeReference type, ICustomAttributeProvider typeAttributes = null)
{

13
ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Gets all base types.
/// </summary>
/// <remarks>This is the reflexive and transitive closure of <see cref="IType.GetBaseTypes"/>.
/// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
/// Note that this method does not return all supertypes - doing so is impossible due to contravariance
/// (and undesirable for covariance as the list could become very large).
///
@ -183,6 +183,17 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -183,6 +183,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
return TreeTraversal.PreOrder(file.TopLevelTypeDefinitions, t => t.NestedTypes);
}
public static IEnumerable<ITypeDefinition> GetAllTypeDefinitions (this IAssembly assembly)
{
return TreeTraversal.PreOrder(assembly.TopLevelTypeDefinitions, t => t.NestedTypes);
}
public static IEnumerable<ITypeDefinition> GetAllTypeDefinitions (this ICompilation compilation)
{
return compilation.MainAssembly.GetAllTypeDefinitions()
.Concat(compilation.ReferencedAssemblies.SelectMany(a => a.GetAllTypeDefinitions()));
}
/// <summary>
/// Gets the type (potentially a nested type) defined at the specified location.
/// Returns null if no type is defined at that location.

5
ICSharpCode.NRefactory/TypeSystem/IAssembly.cs

@ -105,5 +105,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -105,5 +105,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the type definition for the specified unresolved type.
/// </summary>
ITypeDefinition GetTypeDefinition(IUnresolvedTypeDefinition unresolved);
/// <summary>
/// Gets all non-nested types in the assembly.
/// </summary>
IEnumerable<ITypeDefinition> TopLevelTypeDefinitions { get; }
}
}

5
ICSharpCode.NRefactory/TypeSystem/ICompilation.cs

@ -50,11 +50,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -50,11 +50,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
INamespace GetNamespaceForExternAlias(string alias);
/// <summary>
/// Gets all type defininitions in this compilation, including nested types.
/// </summary>
IEnumerable<ITypeDefinition> GetAllTypeDefinitions();
IType FindType(KnownTypeCode typeCode);
/// <summary>

5
ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs

@ -30,8 +30,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -30,8 +30,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Resolves the value of this constant.
/// </summary>
/// <param name="compilation">Compilation context where the constant value will be used.</param>
/// <returns>Resolve result representing the constant value.</returns>
/// <param name="context">Context where the constant value will be used.</param>
/// <returns>Resolve result representing the constant value.
/// This method never returns null; in case of errors, an ErrorResolveResult will be returned.</returns>
ResolveResult Resolve(ITypeResolveContext context);
}
}

2
ICSharpCode.NRefactory/TypeSystem/INamedElement.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <remarks>
/// For types, the reflection name can be parsed back into a ITypeReference by using
/// <see cref="ReflectionHelper.ParseReflectionName(string,IEntity)"/>.
/// <see cref="ReflectionHelper.ParseReflectionName(string)"/>.
/// </remarks>
/// <returns>
/// "System.Int32[]" for int[]<br/>

2
ICSharpCode.NRefactory/TypeSystem/IParameter.cs

@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Gets whether this parameter is optional.
/// The default value is given by the <see cref="ConstantValue"/> property.
/// The default value is given by the <see cref="IVariable.ConstantValue"/> property.
/// </summary>
bool IsOptional { get; }
}

35
ICSharpCode.NRefactory/TypeSystem/IType.cs

@ -28,23 +28,23 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -28,23 +28,23 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <remarks>
/// <para>
/// A type is potentially
/// - a type definition (<see cref="ITypeDefiniton"/>, i.e. a class, struct, interface, delegate, or built-in primitive type)
/// - a type definition (<see cref="ITypeDefinition"/>, i.e. a class, struct, interface, delegate, or built-in primitive type)
/// - a parameterized type (<see cref="ParameterizedType"/>, e.g. List&lt;int>)
/// - a type parameter (<see cref="ITypeParameter"/>, e.g. T)
/// - an array (<see cref="ArrayType"/>)
/// - a pointer (<see cref="PointerType"/>)
/// - a managed reference (<see cref="ByReferenceType"/>)
/// - one of the special types (<see cref="SharedTypes.UnknownType"/>, <see cref="SharedTypes.Null"/>,
/// <see cref="SharedTypes.Dynamic"/>, <see cref="SharedTypes.UnboundTypeArgument"/>)
/// - one of the special types (<see cref="SpecialType.UnknownType"/>, <see cref="SpecialType.NullType"/>,
/// <see cref="SpecialType.Dynamic"/>, <see cref="SpecialType.UnboundTypeArgument"/>)
///
/// The <see cref="IType.Kind"/> property can be used to switch on the kind of a type.
/// </para>
/// <para>
/// IType uses the null object pattern: <see cref="SharedTypes.UnknownType"/> serves as the null object.
/// IType uses the null object pattern: <see cref="SpecialType.UnknownType"/> serves as the null object.
/// Methods or properties returning IType never return null unless documented otherwise.
/// </para>
/// <para>
/// Types should be compared for equality using the <see cref="IType.Equals(IType)"/> method.
/// Types should be compared for equality using the <see cref="IEquatable{IType}.Equals(IType)"/> method.
/// Identical types do not necessarily use the same object reference.
/// </para>
/// </remarks>
@ -117,10 +117,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -117,10 +117,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which types to return.
/// The filter is tested on the original type definitions (before parameterization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// <para>
/// If the nested type is generic, this method will return a parameterized type,
/// where the additional type parameters are set to <see cref="SharedType.UnboundTypeArgument"/>.
/// where the additional type parameters are set to <see cref="SpecialType.UnboundTypeArgument"/>.
/// </para>
/// <para>
/// Type parameters belonging to the outer class will have the value copied from the outer type
@ -160,6 +161,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -160,6 +161,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <param name="typeArguments">The type arguments passed to the inner class</param>
/// <param name="filter">The filter used to select which types to return.
/// The filter is tested on the original type definitions (before parameterization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// Type parameters belonging to the outer class will have the value copied from the outer type
/// if it is a parameterized type. Otherwise, those existing type parameters will be self-parameterized,
@ -173,11 +175,12 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -173,11 +175,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which constructors to return.
/// 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 in base classes or static constructors.</para>
/// <para>
/// For methods on parameterized types, type substitution will be performed on the method signature,
/// and the appropriate <see cref="SpecializedMethod"/> will be returned.
/// and the appropriate <see cref="Implementation.SpecializedMethod"/> will be returned.
/// </para>
/// </remarks>
IEnumerable<IMethod> GetConstructors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers);
@ -187,13 +190,14 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -187,13 +190,14 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which methods to return.
/// 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>
/// For methods on parameterized types, type substitution will be performed on the method signature,
/// and the appropriate <see cref="SpecializedMethod"/> will be returned.
/// and the appropriate <see cref="Implementation.SpecializedMethod"/> will be returned.
/// </para>
/// <para>
/// If the method being returned is generic, and this type is a parameterized type where the type
@ -214,10 +218,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -214,10 +218,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <param name="typeArguments">The type arguments used for the method call.</param>
/// <param name="filter">The filter used to select which methods to return.
/// 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>
/// Type substitution will be performed on the method signature, creating a <see cref="SpecializedMethod"/>
/// Type substitution will be performed on the method signature, creating a <see cref="Implementation.SpecializedMethod"/>
/// with the specified type arguments.
/// </para>
/// <para>
@ -233,9 +238,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -233,9 +238,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which properties to return.
/// The filter is tested on the original property definitions (before specialization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// For properties on parameterized types, type substitution will be performed on the property signature,
/// and the appropriate <see cref="SpecializedProperty"/> will be returned.
/// and the appropriate <see cref="Implementation.SpecializedProperty"/> will be returned.
/// </remarks>
IEnumerable<IProperty> GetProperties(Predicate<IUnresolvedProperty> filter = null, GetMemberOptions options = GetMemberOptions.None);
@ -244,9 +250,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -244,9 +250,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which constructors to return.
/// The filter is tested on the original field definitions (before specialization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// For fields on parameterized types, type substitution will be performed on the field's return type,
/// and the appropriate <see cref="SpecializedField"/> will be returned.
/// and the appropriate <see cref="Implementation.SpecializedField"/> will be returned.
/// </remarks>
IEnumerable<IField> GetFields(Predicate<IUnresolvedField> filter = null, GetMemberOptions options = GetMemberOptions.None);
@ -255,9 +262,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -255,9 +262,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <param name="filter">The filter used to select which events to return.
/// The filter is tested on the original event definitions (before specialization).</param>
/// <param name="options">Specified additional options for the GetMembers() operation.</param>
/// <remarks>
/// For fields on parameterized types, type substitution will be performed on the event's return type,
/// and the appropriate <see cref="SpecializedEvent"/> will be returned.
/// and the appropriate <see cref="Implementation.SpecializedEvent"/> will be returned.
/// </remarks>
IEnumerable<IEvent> GetEvents(Predicate<IUnresolvedEvent> filter = null, GetMemberOptions options = GetMemberOptions.None);
@ -266,6 +274,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -266,6 +274,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </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>
/// <para>
/// The resulting list is the union of GetFields(), GetProperties(), GetMethods() and GetEvents().
@ -274,7 +283,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -274,7 +283,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </para>
/// <para>
/// For generic methods, the remarks about ambiguous signatures from the
/// <see cref="GetMethods(ITypeResolveContext, Predicate{IMethod})"/> method apply here as well.
/// <see cref="GetMethods(Predicate{IUnresolvedMethod}, GetMemberOptions)"/> method apply here as well.
/// </para>
/// </remarks>
IEnumerable<IMember> GetMembers(Predicate<IUnresolvedMember> filter = null, GetMemberOptions options = GetMemberOptions.None);

2
ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <returns>
/// Returns the resolved type.
/// In case of an error, returns <see cref="SharedTypes.UnknownType"/>.
/// In case of an error, returns <see cref="SpecialType.UnknownType"/>.
/// Never returns null.
/// </returns>
IType Resolve(ITypeResolveContext context);

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

@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public bool InternalsVisibleTo(IAssembly assembly)
{
throw new NotImplementedException();
return assembly == this;
}
public ITypeDefinition GetTypeDefinition(string ns, string name, int typeParameterCount)
@ -276,6 +276,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -276,6 +276,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
}
public IEnumerable<ITypeDefinition> TopLevelTypeDefinitions {
get {
return unresolved.TopLevelTypeDefinitions.Select(t => GetTypeDefinition(t));
}
}
sealed class NS : INamespace
{
readonly DefaultResolvedAssembly assembly;

1
ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs

@ -38,6 +38,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -38,6 +38,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
/// <summary>
/// Creates a new merged root namespace.
/// </summary>
/// <param name="compilation">The main compilation.</param>
/// <param name="namespaces">The individual namespaces being merged.</param>
/// <param name="externAlias">The extern alias for this namespace.</param>
public MergedNamespace(ICompilation compilation, INamespace[] namespaces, string externAlias = null)

7
ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleCompilation.cs

@ -107,13 +107,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -107,13 +107,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
return null;
}
public IEnumerable<ITypeDefinition> GetAllTypeDefinitions()
{
return TreeTraversal.PreOrder(this.RootNamespace, ns => ns.ChildNamespaces)
.SelectMany(ns => TreeTraversal.PreOrder(ns.Types, t => t.NestedTypes));
}
public IType FindType(KnownTypeCode typeCode)
{
return knownTypeCache.FindType(typeCode);

3
ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs

@ -68,7 +68,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -68,7 +68,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Creates a reference to the specified type.
/// </summary>
/// <param name="type">The type to be converted.</param>
/// <param name="entity">The parent entity, used to fetch the ITypeParameter for generic types.</param>
/// <returns>Returns the type reference.</returns>
public static ITypeReference ToTypeReference(this Type type)
{
@ -195,8 +194,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -195,8 +194,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Parses a reflection name into a type reference.
/// </summary>
/// <param name="reflectionTypeName">The reflection name of the type.</param>
/// <param name="parentEntity">Parent entity, used to find the type parameters for open types.
/// If no entity is provided, type parameters are converted to <see cref="SharedTypes.UnknownType"/>.</param>
/// <exception cref="ReflectionNameParseException">The syntax of the reflection type name is invalid</exception>
/// <returns>A type reference that represents the reflection name.</returns>
public static ITypeReference ParseReflectionName(string reflectionTypeName)

2
ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// A type used for unbound type arguments in partially parameterized types.
/// </summary>
/// <see cref="IType.GetNestedTypes"/>
/// <see cref="IType.GetNestedTypes(Predicate{ITypeDefinition}, GetMemberOptions)"/>
public readonly static SpecialType UnboundTypeArgument = new SpecialType(TypeKind.UnboundTypeArgument, "", isReferenceType: null);
readonly TypeKind kind;

10
ICSharpCode.NRefactory/TypeSystem/TypeKind.cs

@ -47,17 +47,17 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -47,17 +47,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <see cref="KnownTypeReference.Void"/>
Void,
/// <see cref="SharedTypes.UnknownType"/>
/// <see cref="SpecialType.UnknownType"/>
Unknown,
/// <summary>The type of the null literal.</summary>
/// <see cref="SharedTypes.NullType"/>
/// <see cref="SpecialType.NullType"/>
Null,
/// <summary>Type representing the C# 'dynamic' type.</summary>
/// <see cref="SharedTypes.DynamicType"/>
/// <see cref="SpecialType.Dynamic"/>
Dynamic,
/// <summary>Represents missing type arguments in partially parameterized types.</summary>
/// <see cref="SharedTypes.UnboundTypeArgument"/>
/// <see cref="IType.GetNestedTypes"/>
/// <see cref="SpecialType.UnboundTypeArgument"/>
/// <see cref="IType.GetNestedTypes(Predicate{ITypeDefinition}, GetMemberOptions)"/>
UnboundTypeArgument,
/// <summary>The type is a type parameter.</summary>

Loading…
Cancel
Save