Browse Source

Merge NRefactory ff0393ce92e1adf0 into SharpDevelop

pull/517/head
Daniel Grunwald 12 years ago
parent
commit
2ecbb83c34
  1. 4
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/Opportunities/ConvertToLambdaExpressionIssue.cs
  2. 10
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs
  3. 19
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs
  4. 20
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs
  5. 12
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs
  6. 3
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs
  7. 8
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs
  8. 3
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs
  9. 11
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
  10. 8
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs
  11. 7
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
  12. 9
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs
  13. 12
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
  14. 1
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Cecil/CecilLoader.cs
  15. 30
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Cecil/ICSharpCode.NRefactory.Cecil.csproj
  16. 35
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs
  17. 29
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs
  18. 18
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/ConvertToLambdaExpressionIssueTests.cs
  19. 7
      src/Libraries/NRefactory/ICSharpCode.NRefactory.Xml/ICSharpCode.NRefactory.Xml.csproj
  20. 7
      src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  21. 21
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs
  22. 12
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  23. 28
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs

4
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/Opportunities/ConvertToLambdaExpressionIssue.cs

@ -72,6 +72,10 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
} }
if (returnTypes.Count > 1) if (returnTypes.Count > 1)
return; return;
// can't convert return statements without expression.
var returnExpr = node as ReturnStatement;
if (returnExpr != null && returnExpr.Expression.IsNull)
return;
AddIssue(new CodeIssue( AddIssue(new CodeIssue(
node, node,

10
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs

@ -292,17 +292,11 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
} }
start = new TextLocation(line, col); start = new TextLocation(line, col);
} }
col++;
if (ch == '}' &&!start.IsEmpty) { if (ch == '}' &&!start.IsEmpty) {
char next = i + 1 < expr.LiteralValue.Length ? expr.LiteralValue [i + 1] : '\0'; Colorize(start, new TextLocation(line, col + 1), stringFormatItemColor);
if (next == '}') {
i++;
col += 2;
continue;
}
Colorize(start, new TextLocation(line, col), stringFormatItemColor);
start = TextLocation.Empty; start = TextLocation.Empty;
} }
col++;
} }
} }

19
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs

@ -622,6 +622,11 @@ namespace ICSharpCode.NRefactory.CSharp
VisitChildren (namedExpression); VisitChildren (namedExpression);
} }
public virtual void VisitErrorNode(AstNode errorNode)
{
VisitChildren(errorNode);
}
public virtual void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) public virtual void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{ {
VisitChildren (placeholder); VisitChildren (placeholder);
@ -1223,7 +1228,12 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
return VisitChildren (namedExpression); return VisitChildren (namedExpression);
} }
public virtual T VisitErrorNode(AstNode errorNode)
{
return VisitChildren(errorNode);
}
public virtual T VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) public virtual T VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{ {
return VisitChildren (placeholder); return VisitChildren (placeholder);
@ -1825,7 +1835,12 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
return VisitChildren (namedExpression, data); return VisitChildren (namedExpression, data);
} }
public virtual S VisitErrorNode(AstNode errorNode, T data)
{
return VisitChildren(errorNode, data);
}
public virtual S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data) public virtual S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data)
{ {
return VisitChildren (placeholder, data); return VisitChildren (placeholder, data);

20
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs

@ -57,22 +57,22 @@ namespace ICSharpCode.NRefactory.CSharp
public ErrorNode () public ErrorNode ()
{ {
} }
public override void AcceptVisitor (IAstVisitor visitor) public override void AcceptVisitor(IAstVisitor visitor)
{ {
visitor.VisitErrorNode(this);
} }
public override T AcceptVisitor<T> (IAstVisitor<T> visitor) public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{ {
return default (T); return visitor.VisitErrorNode(this);
} }
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{ {
// nothing return visitor.VisitErrorNode(this, data);
return default (S);
} }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{ {
var o = other as ErrorNode; var o = other as ErrorNode;

12
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs

@ -106,21 +106,19 @@ namespace ICSharpCode.NRefactory.CSharp
public override void AcceptVisitor (IAstVisitor visitor) public override void AcceptVisitor (IAstVisitor visitor)
{ {
// nothing visitor.VisitErrorNode(this);
} }
public override T AcceptVisitor<T> (IAstVisitor<T> visitor) public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{ {
// nothing return visitor.VisitErrorNode(this);
return default (T);
} }
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{ {
// nothing return visitor.VisitErrorNode(this, data);
return default(S);
} }
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
{ {
var o = other as ErrorExpression; var o = other as ErrorExpression;

3
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs

@ -148,6 +148,7 @@ namespace ICSharpCode.NRefactory.CSharp
void VisitIdentifier(Identifier identifier); void VisitIdentifier(Identifier identifier);
void VisitNullNode(AstNode nullNode); void VisitNullNode(AstNode nullNode);
void VisitErrorNode(AstNode errorNode);
void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern); void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
} }
@ -279,6 +280,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifier(Identifier identifier); S VisitIdentifier(Identifier identifier);
S VisitNullNode(AstNode nullNode); S VisitNullNode(AstNode nullNode);
S VisitErrorNode(AstNode errorNode);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern); S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
} }
@ -410,6 +412,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifier(Identifier identifier, T data); S VisitIdentifier(Identifier identifier, T data);
S VisitNullNode(AstNode nullNode, T data); S VisitNullNode(AstNode nullNode, T data);
S VisitErrorNode(AstNode errorNode, T data);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data); S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
} }
} }

8
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs

@ -48,7 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp
void IAstVisitor.VisitNullNode(AstNode nullNode) void IAstVisitor.VisitNullNode(AstNode nullNode)
{ {
} }
void IAstVisitor.VisitErrorNode(AstNode nullNode)
{
}
public event Action<SyntaxTree> EnterSyntaxTree, LeaveSyntaxTree; public event Action<SyntaxTree> EnterSyntaxTree, LeaveSyntaxTree;
void IAstVisitor.VisitSyntaxTree(SyntaxTree unit) void IAstVisitor.VisitSyntaxTree(SyntaxTree unit)
@ -614,7 +618,7 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
Visit(EnterDirectionExpression, LeaveDirectionExpression, directionExpression); Visit(EnterDirectionExpression, LeaveDirectionExpression, directionExpression);
} }
public event Action<MemberReferenceExpression> EnterMemberReferenceExpression, LeaveMemberReferenceExpression; public event Action<MemberReferenceExpression> EnterMemberReferenceExpression, LeaveMemberReferenceExpression;
void IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) void IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)

3
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs

@ -170,7 +170,8 @@ namespace ICSharpCode.NRefactory.CSharp
builder.Append(options.EolMarker); builder.Append(options.EolMarker);
} }
var offset = document.GetOffset(newLineInsertPosition); var offset = document.GetOffset(newLineInsertPosition);
AddChange(offset, 0, builder.ToString()); if (offset >= 0)
AddChange(offset, 0, builder.ToString());
} else if (currentNewLineCount == targetMinimumNewLineCount && node is NewLineNode){ } else if (currentNewLineCount == targetMinimumNewLineCount && node is NewLineNode){
// // Check to see if there are any newlines to remove // // Check to see if there are any newlines to remove
// var endNode = node.GetNextSibling(n => !(n is NewLineNode || n is WhitespaceNode)); // var endNode = node.GetNextSibling(n => !(n is NewLineNode || n is WhitespaceNode));

11
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{53DCA265-3C3C-42F9-B647-F72BA678122B}</ProjectGuid> <ProjectGuid>{53DCA265-3C3C-42F9-B647-F72BA678122B}</ProjectGuid>
@ -11,7 +11,7 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
@ -21,6 +21,8 @@
<DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.CSharp.xml</DocumentationFile> <DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.CSharp.xml</DocumentationFile>
<NoWarn>1591,1587,1570</NoWarn> <NoWarn>1591,1587,1570</NoWarn>
<OutputPath>..\bin\$(Configuration)\</OutputPath> <OutputPath>..\bin\$(Configuration)\</OutputPath>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -38,9 +40,10 @@
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE;FULL_AST;NET_4_0</DefineConstants> <DefineConstants>TRACE;FULL_AST;NET_4_0</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>PdbOnly</DebugType>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<OutputPath>..\bin\Release\</OutputPath> <OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup> </PropertyGroup>
@ -414,4 +417,4 @@
<Folder Include="PatternMatching\" /> <Folder Include="PatternMatching\" />
<Folder Include="IndentEngine\" /> <Folder Include="IndentEngine\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

8
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -2223,8 +2223,14 @@ namespace ICSharpCode.NRefactory.CSharp
void IAstVisitor.VisitNullNode(AstNode nullNode) void IAstVisitor.VisitNullNode(AstNode nullNode)
{ {
} }
void IAstVisitor.VisitErrorNode(AstNode errorNode)
{
StartNode(errorNode);
EndNode(errorNode);
}
#endregion #endregion
#region Pattern Nodes #region Pattern Nodes
public void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) public void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{ {

7
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs

@ -218,7 +218,12 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
return null; return null;
} }
CodeObject IAstVisitor<CodeObject>.VisitErrorNode(AstNode errorNode)
{
return null;
}
CodeObject IAstVisitor<CodeObject>.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression) CodeObject IAstVisitor<CodeObject>.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression)
{ {
return MakeSnippetExpression(anonymousMethodExpression); return MakeSnippetExpression(anonymousMethodExpression);

9
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs

@ -147,6 +147,15 @@ namespace ICSharpCode.NRefactory.CSharp
needsIndent = true; needsIndent = true;
isAtStartOfLine = true; isAtStartOfLine = true;
break; break;
case CommentType.MultiLineDocumentation:
textWriter.Write("/**");
textWriter.Write(content);
textWriter.Write("*/");
column += 3;
UpdateEndLocation(content, ref line, ref column);
column += 2;
isAtStartOfLine = false;
break;
default: default:
textWriter.Write(content); textWriter.Write(content);
column += content.Length; column += content.Length;

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

@ -809,10 +809,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
{ {
CSharpResolver oldResolver = resolver; CSharpResolver oldResolver = resolver;
try { try {
IMember member; IMember member = null;
if (unresolvedFile != null) { if (unresolvedFile != null) {
member = GetMemberFromLocation(memberDeclaration); member = GetMemberFromLocation(memberDeclaration);
} else { }
if (member == null) {
// Re-discover the method: // Re-discover the method:
SymbolKind symbolKind = memberDeclaration.SymbolKind; SymbolKind symbolKind = memberDeclaration.SymbolKind;
var parameterTypes = TypeSystemConvertVisitor.GetParameterTypes(memberDeclaration.GetChildrenByRole(Roles.Parameter), InterningProvider.Dummy); var parameterTypes = TypeSystemConvertVisitor.GetParameterTypes(memberDeclaration.GetChildrenByRole(Roles.Parameter), InterningProvider.Dummy);
@ -3960,7 +3961,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
{ {
return null; return null;
} }
ResolveResult IAstVisitor<ResolveResult>.VisitErrorNode(AstNode errorNode)
{
return null;
}
ResolveResult IAstVisitor<ResolveResult>.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern) ResolveResult IAstVisitor<ResolveResult>.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern)
{ {
return null; return null;

1
src/Libraries/NRefactory/ICSharpCode.NRefactory.Cecil/CecilLoader.cs

@ -74,6 +74,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Warning: if delay-loading is used and the type system is accessed by multiple threads, /// Warning: if delay-loading is used and the type system is accessed by multiple threads,
/// the callback may be invoked concurrently on multiple threads. /// the callback may be invoked concurrently on multiple threads.
/// </remarks> /// </remarks>
[CLSCompliant(false)]
public Action<IUnresolvedEntity, MemberReference> OnEntityLoaded { get; set; } public Action<IUnresolvedEntity, MemberReference> OnEntityLoaded { get; set; }
/// <summary> /// <summary>

30
src/Libraries/NRefactory/ICSharpCode.NRefactory.Cecil/ICSharpCode.NRefactory.Cecil.csproj

@ -11,21 +11,27 @@
<AssemblyName>ICSharpCode.NRefactory.Cecil</AssemblyName> <AssemblyName>ICSharpCode.NRefactory.Cecil</AssemblyName>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DocumentationFile>bin\$(Configuration)\ICSharpCode.NRefactory.Cecil.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>PdbOnly</DebugType>
<Optimize>true</Optimize> <Optimize>True</Optimize>
<OutputPath>bin\Release</OutputPath> <OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -37,7 +43,6 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
@ -52,6 +57,23 @@
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>DEBUG;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'net_4_5_Debug' ">
<DefineConstants>DEBUG;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

35
src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs

@ -77,7 +77,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
public string GetColor(TextLocation loc) public string GetColor(TextLocation loc)
{ {
foreach (var color in colors) { foreach (var color in colors) {
if (color.Item1.IsInside (loc)) if (color.Item1.Contains (loc))
return color.Item2; return color.Item2;
} }
return null; return null;
@ -466,6 +466,39 @@ class TestClass
} }
}", stringFormatItemColor); }", stringFormatItemColor);
} }
/// <summary>
///Bug 22247 - Wrong colouring of escaped string formater
/// </summary>
[Test]
public void TestBug22247()
{
TestColor (@"
class X
{
public static void Main ()
{
var l = string.Format(""{{{0:d}$}$}"", 100);
}
}", defaultTextColor);
}
[Test]
public void TestStringFormatClosingBrace()
{
TestColor (@"
using System.Text;
class TestClass
{
void Foo(StringBuilder sb)
{
sb.AppendFormat(""{0$}"", 1, 2);
}
}", stringFormatItemColor);
}
} }
} }

29
src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

@ -6350,6 +6350,35 @@ class Foo<T1> where T1 : new()
} }
/// <summary>
/// Bug 21902 - Completion does not recognise new context for member access on parameter
/// </summary>
[Test]
public void TestBug21902 ()
{
CombinedProviderTest(
@"using System;
using System.Collections.Generic;
class C
{
public List<int> Prop;
}
class MainClass
{
public static void Main ()
{
}
void Foo (C c)
{
$c.Prop = new $
}
}
", provider => Assert.IsNotNull(provider.Find("List<int>")));
}
} }
} }

18
src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/ConvertToLambdaExpressionIssueTests.cs

@ -195,6 +195,24 @@ class TestClass
} }
/// <summary>
/// Bug 22106 - Applying suggested fix causes error
/// </summary>
[Test]
public void TestBug22106 ()
{
TestWrongContext<ConvertToLambdaExpressionIssue> (@"
class TestClass
{
void TestMethod ()
{
alert.SetPositiveButton(""OK"", (sender, e) =>
{
return;
});
}
}");
}
} }
} }

7
src/Libraries/NRefactory/ICSharpCode.NRefactory.Xml/ICSharpCode.NRefactory.Xml.csproj

@ -11,7 +11,7 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
@ -20,6 +20,8 @@
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<OutputPath>..\bin\$(Configuration)\</OutputPath> <OutputPath>..\bin\$(Configuration)\</OutputPath>
<DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.Xml.xml</DocumentationFile> <DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.Xml.xml</DocumentationFile>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -37,9 +39,10 @@
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE;FULL_AST;NET_4_0</DefineConstants> <DefineConstants>TRACE;FULL_AST;NET_4_0</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>PdbOnly</DebugType>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<OutputPath>..\bin\Release\</OutputPath> <OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup> </PropertyGroup>

7
src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -12,7 +12,7 @@
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<RunCodeAnalysis>False</RunCodeAnalysis> <RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1000;-Microsoft.Design#CA1004;-Microsoft.Design#CA1005;-Microsoft.Design#CA1006;-Microsoft.Design#CA1026;-Microsoft.Design#CA1033;-Microsoft.Design#CA1051;-Microsoft.Design#CA1063;-Microsoft.Naming#CA1702;-Microsoft.Naming#CA1704;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1720;-Microsoft.Performance#CA1800;-Microsoft.Security#CA2104</CodeAnalysisRules> <CodeAnalysisRules>-Microsoft.Design#CA1000;-Microsoft.Design#CA1004;-Microsoft.Design#CA1005;-Microsoft.Design#CA1006;-Microsoft.Design#CA1026;-Microsoft.Design#CA1033;-Microsoft.Design#CA1051;-Microsoft.Design#CA1063;-Microsoft.Naming#CA1702;-Microsoft.Naming#CA1704;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1720;-Microsoft.Performance#CA1800;-Microsoft.Security#CA2104</CodeAnalysisRules>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
@ -23,6 +23,8 @@
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
<OutputPath>..\bin\$(Configuration)\</OutputPath> <OutputPath>..\bin\$(Configuration)\</OutputPath>
<DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.xml</DocumentationFile> <DocumentationFile>..\bin\$(Configuration)\ICSharpCode.NRefactory.xml</DocumentationFile>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -41,6 +43,7 @@
<Optimize>True</Optimize> <Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>full</DebugType>
@ -48,7 +51,7 @@
<OutputPath>..\bin\Debug\</OutputPath> <OutputPath>..\bin\Debug\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>PdbOnly</DebugType>
<OutputPath>..\bin\Release\</OutputPath> <OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'net_4_5_Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'net_4_5_Debug' ">

21
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs

@ -151,12 +151,31 @@ namespace ICSharpCode.NRefactory.TypeSystem
(line != BeginLine || column >= BeginColumn) && (line != BeginLine || column >= BeginColumn) &&
(line != EndLine || column <= EndColumn); (line != EndLine || column <= EndColumn);
} }
public bool IsInside(TextLocation location) public bool IsInside(TextLocation location)
{ {
return IsInside(location.Line, location.Column); return IsInside(location.Line, location.Column);
} }
/// <remarks>
/// Returns true, if the given coordinates (line, column) are in the region.
/// This method assumes that for an unknown end the end line is == -1
/// </remarks>
public bool Contains(int line, int column)
{
if (IsEmpty)
return false;
return line >= BeginLine &&
(line <= EndLine || EndLine == -1) &&
(line != BeginLine || column >= BeginColumn) &&
(line != EndLine || column < EndColumn);
}
public bool Contains(TextLocation location)
{
return Contains(location.Line, location.Column);
}
public bool IntersectsWith (DomRegion region) public bool IntersectsWith (DomRegion region)
{ {
return region.Begin <= End && region.End >= Begin; return region.Begin <= End && region.End >= Begin;

12
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs

@ -344,10 +344,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
ITypeReference typeRef; ITypeReference typeRef;
if (unresolvedAssembly.typeDefinitions.TryGetValue(topLevelTypeName, out td)) if (unresolvedAssembly.typeDefinitions.TryGetValue(topLevelTypeName, out td))
return GetTypeDefinition(td); return GetTypeDefinition(td);
else if (unresolvedAssembly.typeForwarders.TryGetValue(topLevelTypeName, out typeRef)) if (unresolvedAssembly.typeForwarders.TryGetValue(topLevelTypeName, out typeRef)) {
return typeRef.Resolve(compilation.TypeResolveContext).GetDefinition(); // Protect against cyclic type forwarders:
else using (var busyLock = BusyManager.Enter(typeRef)) {
return null; if (busyLock.Success)
return typeRef.Resolve(compilation.TypeResolveContext).GetDefinition();
}
}
return null;
} }
ITypeDefinition GetTypeDefinition(IUnresolvedTypeDefinition unresolved) ITypeDefinition GetTypeDefinition(IUnresolvedTypeDefinition unresolved)

28
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs

@ -18,6 +18,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {
@ -87,7 +88,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public string Name { get { return fullTypeName.Name; } } public string Name { get { return fullTypeName.Name; } }
[Obsolete("Use the FullTypeName property instead. GetClassTypeReference now supports nested types, where the Namespace/Name/TPC tripel isn't sufficient for identifying the type.")] [Obsolete("Use the FullTypeName property instead. GetClassTypeReference now supports nested types, where the Namespace/Name/TPC tripel isn't sufficient for identifying the type.")]
public int TypeParameterCount { get { return fullTypeName.TypeParameterCount; } } public int TypeParameterCount { get { return fullTypeName.TypeParameterCount; } }
IType ResolveInAllAssemblies(ITypeResolveContext context)
{
var compilation = context.Compilation;
foreach (var asm in compilation.Assemblies) {
IType type = asm.GetTypeDefinition(fullTypeName);
if (type != null)
return type;
}
return null;
}
public IType Resolve(ITypeResolveContext context) public IType Resolve(ITypeResolveContext context)
{ {
if (context == null) if (context == null)
@ -95,21 +107,23 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
IType type = null; IType type = null;
if (assembly == null) { if (assembly == null) {
// No assembly specified: look in all assemblies, but prefer the current assembly
if (context.CurrentAssembly != null) { if (context.CurrentAssembly != null) {
type = context.CurrentAssembly.GetTypeDefinition(fullTypeName); type = context.CurrentAssembly.GetTypeDefinition(fullTypeName);
} }
if (type == null) { if (type == null) {
var compilation = context.Compilation; type = ResolveInAllAssemblies(context);
foreach (var asm in compilation.Assemblies) {
type = asm.GetTypeDefinition(fullTypeName);
if (type != null)
break;
}
} }
} else { } else {
// Assembly specified: only look in the specified assembly.
// But if that's not loaded in the compilation, allow fall back to other assemblies.
// (the non-loaded assembly might be a facade containing type forwarders -
// for example, when referencing a portable library from a non-portable project)
IAssembly asm = assembly.Resolve(context); IAssembly asm = assembly.Resolve(context);
if (asm != null) { if (asm != null) {
type = asm.GetTypeDefinition(fullTypeName); type = asm.GetTypeDefinition(fullTypeName);
} else {
type = ResolveInAllAssemblies(context);
} }
} }
return type ?? new UnknownType(fullTypeName); return type ?? new UnknownType(fullTypeName);

Loading…
Cancel
Save