diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index b899296b9a..e61c5fdc50 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -1547,6 +1547,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.AddNamespace(lookup, curNs); } } + + if (node is AstType && node.Parent is Constraint) { + wrapper.AddCustom ("new()"); + } } IEnumerable HandleKeywordCompletion(int wordStart, string word) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs index c2cb814f54..5871e9f3d4 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs @@ -5925,5 +5925,27 @@ public class Testing Assert.IsTrue(provider == null || provider.Count == 0); }); } + + /// + ///Bug 9905 - Cannot type new() constraint + /// + [Test] + public void TestBug9905 () + { + + CombinedProviderTest( + @"using System; + +public class Testing +{ + public static void DoNothing() where T : class$, n$ + { + } +} + +", provider => { + Assert.IsNotNull(provider.Find("new()")); + }); + } } }