diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index 25c42125d6..9a2a80fb0a 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -302,6 +302,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion false; foreach (var m in initializerType.GetMembers (m => m.EntityType == EntityType.Field)) { + var f = m as IField; + if (f != null && (f.IsReadOnly || f.IsConst)) + continue; if (lookup.IsAccessible (m, isProtectedAllowed)) contextList.AddMember(m); } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ObjectInitializerTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ObjectInitializerTests.cs index 59692a3873..27237c4a12 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ObjectInitializerTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ObjectInitializerTests.cs @@ -680,6 +680,31 @@ class C : S } + /// + /// Bug 9935 - MD shows decimal constants as fields which can be initalized + /// + [Test] + public void TestBug9935() + { + var provider = CodeCompletionBugTests.CreateCtrlSpaceProvider( + @"class Test +{ + + public static void Main(string [] args) + { + var mm = new decimal () { + $M$ + }; + + } +} + +"); + Assert.IsNull(provider.Find("MaxValue"), "'MaxValue' found."); + Assert.IsNull(provider.Find("MinValue"), "'MinValue' found."); + } + + }