Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed code completion exception.

  • Loading branch information...
commit 3eff925c8f8414e00744b292930d27a8c30b4f7f 1 parent 14ca306
@mkrueger mkrueger authored
View
2  ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs
@@ -173,6 +173,8 @@ public IParameterDataProvider GetParameterDataProvider(int offset, char completi
}
if (invoke.Node is ObjectCreateExpression) {
var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type, invoke.Unit);
+ if (createType.Item1.Type.Kind == TypeKind.Unknown)
+ return null;
return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), createType.Item1.Type);
}
View
20 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs
@@ -4951,5 +4951,25 @@ class TestClass
}");
Assert.IsTrue(provider == null || provider.Count == 0);
}
+
+ /// <summary>
+ /// Bug 4323 - Parameter completion exception while attempting to instantiate unknown class
+ /// </summary>
+ [Test()]
+ public void TestBug4323()
+ {
+ // just test for exception
+ ParameterCompletionTests.CreateProvider(
+@"namespace Test
+{
+ class TestClass
+ {
+ public static void Main(string[] args)
+ {
+ $object foo = new Foo($
+ }
+ }
+}");
+ }
}
}
View
10 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ParameterCompletionTests.cs
@@ -212,9 +212,9 @@ public bool AllowParameterList (int overload)
}
#region IParameterCompletionDataFactory implementation
- public IParameterDataProvider CreateConstructorProvider (int startOffset, ICSharpCode.NRefactory.TypeSystem.IType type)
+ public IParameterDataProvider CreateConstructorProvider(int startOffset, ICSharpCode.NRefactory.TypeSystem.IType type)
{
-
+ Assert.IsTrue(type.Kind != TypeKind.Unknown);
return new Provider () {
Data = type.GetConstructors (m => m.Accessibility == Accessibility.Public)
};
@@ -227,15 +227,17 @@ public IParameterDataProvider CreateMethodDataProvider (int startOffset, IEnumer
};
}
- public IParameterDataProvider CreateDelegateDataProvider (int startOffset, ICSharpCode.NRefactory.TypeSystem.IType type)
+ public IParameterDataProvider CreateDelegateDataProvider(int startOffset, ICSharpCode.NRefactory.TypeSystem.IType type)
{
+ Assert.IsTrue(type.Kind != TypeKind.Unknown);
return new Provider () {
Data = new [] { type.GetDelegateInvokeMethod () }
};
}
- public IParameterDataProvider CreateIndexerParameterDataProvider (int startOffset, IType type, AstNode resolvedNode)
+ public IParameterDataProvider CreateIndexerParameterDataProvider(int startOffset, IType type, AstNode resolvedNode)
{
+ Assert.IsTrue(type.Kind != TypeKind.Unknown);
if (type.Kind == TypeKind.Array)
return new ArrayProvider ();
return new IndexerProvider () {
Please sign in to comment.
Something went wrong with that request. Please try again.