diff --git a/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/CombinationTest.cs b/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/CombinationTest.cs index 426ed1b2..cc90c72e 100644 --- a/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/CombinationTest.cs +++ b/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/CombinationTest.cs @@ -357,5 +357,69 @@ public void RequiredRuntimeAttribute() ToggleRule(UsingLocationRule.Name, enabled: true); Verify(source, expected); } + + [Fact] + public void Issue268() + { + var text = @" +using System.Collections.Generic; + +internal class C +{ + private void M() + { + Dictionary> dict = new Dictionary>(); + dict.TryGetValue(""key"", out Stack stack); + } +}"; + + Verify(text, expected:text); + } + + [Fact] + public void Issue272() + { + var text = @" +using System.Collections.Generic; + +internal class C +{ + + private object myVariable; + + private void M() + { + Dictionary dict = new Dictionary() + { + { ""key"", new object() } + }; + + dict.TryGetValue(""key"", out object myVariable); + + this.myVariable = myVariable; + } +}"; + var expected = @" +using System.Collections.Generic; + +internal class C +{ + private object _myVariable; + + private void M() + { + Dictionary dict = new Dictionary() + { + { ""key"", new object() } + }; + + dict.TryGetValue(""key"", out object myVariable); + + _myVariable = myVariable; + } +}"; + + Verify(text, expected); + } } } diff --git a/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/PrivateFieldNamingRuleTests.cs b/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/PrivateFieldNamingRuleTests.cs index 3a0404bb..20927d19 100644 --- a/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/PrivateFieldNamingRuleTests.cs +++ b/src/Microsoft.DotNet.CodeFormatting.Tests/Rules/PrivateFieldNamingRuleTests.cs @@ -211,6 +211,58 @@ int M(C p) Verify(text, expected); } + + [Fact] + public void Issue258() + { + var text = @" +class C +{ + private (string name, string value) myTuple; +} +"; + var expected = @" +class C +{ + private (string name, string value) _myTuple; +} +"; + + Verify(text, expected, runFormatter: false); + } + + [Fact] + public void Issue241() + { + var text = @" +class C +{ + private bool streamObjects; + + /// + /// A collection in which objects that are written using the WriteError + /// method are accumulated if is false. + /// + private List errors; + +} +"; + var expected = @" +class C +{ + private bool _streamObjects; + + /// + /// A collection in which objects that are written using the WriteError + /// method are accumulated if is false. + /// + private List _errors; + +} +"; + + Verify(text, expected, runFormatter: false); + } } public sealed class VisualBasicFields : PrivateFieldNamingRuleTests