diff --git a/build/Rulesets/NonShippingProject_BuildRules.ruleset b/build/Rulesets/NonShippingProject_BuildRules.ruleset index dd7be998953e341f4a873dc3ce221ef40c7ed1c5..3256dc134e1ac807a322874e45f07405750a9df9 100644 --- a/build/Rulesets/NonShippingProject_BuildRules.ruleset +++ b/build/Rulesets/NonShippingProject_BuildRules.ruleset @@ -26,4 +26,9 @@ + + + + + \ No newline at end of file diff --git a/build/Rulesets/Roslyn_BuildRules.ruleset b/build/Rulesets/Roslyn_BuildRules.ruleset index 80a582eb370aa5c9456bb799be9add9d41591531..2f58c4035905f6cd56420b7fbeda8ae81764906a 100644 --- a/build/Rulesets/Roslyn_BuildRules.ruleset +++ b/build/Rulesets/Roslyn_BuildRules.ruleset @@ -36,15 +36,15 @@ - - - + + + - - + + @@ -94,7 +94,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -110,7 +110,7 @@ - + diff --git a/build/Targets/Packages.props b/build/Targets/Packages.props index 61fd14ebfaa2e6ca44c0c654c19c46d1e3c70428..24eb4674f00680b11209cc7ca58366f2fa5f6d63 100644 --- a/build/Targets/Packages.props +++ b/build/Targets/Packages.props @@ -46,7 +46,7 @@ 1.0.0-beta1-61531-03 8.0.0.0-alpha 2.3.0-beta3-61821-14 - 2.0.0-beta1-61628-06 + 2.3.0-beta1 1.1.0 2.3.0-beta3-61821-14 5.0.0 diff --git a/build/Targets/Settings.props b/build/Targets/Settings.props index 3592746db700591ef54f1c8468bef995048100a7..02c96994120adcff464a1142626e19c28d7b983a 100644 --- a/build/Targets/Settings.props +++ b/build/Targets/Settings.props @@ -15,7 +15,7 @@ RoslynTools.Microsoft.VSIXExpInstaller 0.2.1-beta $(MicrosoftNetRoslynDiagnosticsVersion) - $(NuGetPackageRoot)\Microsoft.Net.RoslynDiagnostics\$(RoslynDiagnosticsNugetPackageVersion)\build\Microsoft.Net.RoslynDiagnostics.props + $(NuGetPackageRoot)\Microsoft.Net.RoslynDiagnostics\$(RoslynDiagnosticsNugetPackageVersion)\roslyn\Microsoft.Net.RoslynDiagnostics.props $(NuGetPackageRoot)\Roslyn.Build.Util\0.9.4-portable\lib\dotnet\Roslyn.MSBuild.Util.dll win7-x64 strict,IOperation diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs index ba6d16ad0d0f457feadcfd40d5f2f511bbeece84..851c3d59297bbe6acfce8dfc9b8402419d903af2 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs @@ -11,8 +11,8 @@ namespace Microsoft.CodeAnalysis.CSharp { internal static partial class ErrorFacts { - private static readonly string s_titleSuffix = "_Title"; - private static readonly string s_descriptionSuffix = "_Description"; + private const string s_titleSuffix = "_Title"; + private const string s_descriptionSuffix = "_Description"; private static readonly Lazy> s_helpLinksMap = new Lazy>(CreateHelpLinks); private static readonly Lazy> s_categoriesMap = new Lazy>(CreateCategoriesMap); diff --git a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineStates.cs b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineStates.cs index 00a2d45bb96d622ecfdcd5e5477ebb137a532d96..2aef46c94bd0d110b85a7a9bf9ef4ec17a20937b 100644 --- a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineStates.cs +++ b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineStates.cs @@ -4,8 +4,8 @@ namespace Microsoft.CodeAnalysis.CSharp { internal static class StateMachineStates { - internal readonly static int FinishedStateMachine = -2; - internal readonly static int NotStartedStateMachine = -1; - internal readonly static int FirstUnusedState = 0; + internal const int FinishedStateMachine = -2; + internal const int NotStartedStateMachine = -1; + internal const int FirstUnusedState = 0; } } diff --git a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs index fc757497b866a5fd43fc69331a74a3942fae9ad2..23b0e90a085f40a91492c1c327eff81519658e35 100644 --- a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs @@ -28,7 +28,7 @@ internal abstract partial class TypeSymbol : NamespaceOrTypeSymbol, ITypeSymbol // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // TODO (tomat): Consider changing this to an empty name. This name shouldn't ever leak to the user in error messages. - internal static readonly string ImplicitTypeName = ""; + internal const string ImplicitTypeName = ""; // InterfaceInfo for a common case of a type not implementing anything directly or indirectly. private static readonly InterfaceInfo s_noInterfaces = new InterfaceInfo(); diff --git a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxToken.cs b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxToken.cs index 54a3cd05cd33ae692da4fb02cc8db63ab82dedbc..674a265a0969f7e656deb7a17e23fe857063932f 100644 --- a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxToken.cs +++ b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxToken.cs @@ -131,8 +131,8 @@ internal static SyntaxToken CreateMissing(SyntaxKind kind, GreenNode leading, Gr return new MissingTokenWithTrivia(kind, leading, trailing); } - internal static readonly SyntaxKind FirstTokenWithWellKnownText = SyntaxKind.TildeToken; - internal static readonly SyntaxKind LastTokenWithWellKnownText = SyntaxKind.EndOfFileToken; + internal const SyntaxKind FirstTokenWithWellKnownText = SyntaxKind.TildeToken; + internal const SyntaxKind LastTokenWithWellKnownText = SyntaxKind.EndOfFileToken; // TODO: eliminate the blank space before the first interesting element? private static readonly ArrayElement[] s_tokensWithNoTrivia = new ArrayElement[(int)LastTokenWithWellKnownText + 1]; diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs index 0b0803d88ab6280752f1e8b10befacdc217f6b65..fd44df25a50db65eabf4afb303cf394ff82042ef 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests { public class MetadataMemberTests : CSharpTestBase { - private static readonly string VTableGapClassIL = @" + private const string VTableGapClassIL = @" .class public auto ansi beforefieldinit Class extends [mscorlib]System.Object { diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Retargeting/NoPia.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Retargeting/NoPia.cs index b4a56a94392258ef30c2344d7487259530a993ec..f8cff8a57d3fb43f5e167141a24c36832602bac8 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Retargeting/NoPia.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Retargeting/NoPia.cs @@ -17,7 +17,7 @@ public class NoPia : CSharpTestBase /// Translation of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\Pia1.vb /// Disassembly of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\Pia1.dll /// - private static readonly string s_sourcePia1 = + private const string s_sourcePia1 = @" using System; using System.Reflection; @@ -58,7 +58,7 @@ public struct S2 /// /// Disassembly of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes1.dll /// - private static readonly string s_sourceLocalTypes1_IL = + private const string s_sourceLocalTypes1_IL = @" using System; using System.Runtime.CompilerServices; @@ -91,7 +91,7 @@ public interface I2 /// /// Translation of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes1.vb /// - private static readonly string s_sourceLocalTypes1 = + private const string s_sourceLocalTypes1 = @" using NS1; @@ -106,7 +106,7 @@ public void Test1(I1 x, I2 y) /// /// Disassembly of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes2.dll /// - private static readonly string s_sourceLocalTypes2_IL = + private const string s_sourceLocalTypes2_IL = @" using NS1; using System; @@ -139,7 +139,7 @@ public struct S2 /// /// Translation of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes2.vb /// - private static readonly string s_sourceLocalTypes2 = + private const string s_sourceLocalTypes2 = @" using NS1; @@ -154,7 +154,7 @@ public void Test2(S1 x, S2 y) /// /// Disassembly of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes3.dll /// - private static readonly string s_sourceLocalTypes3_IL = + private const string s_sourceLocalTypes3_IL = @" using System; using System.Reflection; @@ -219,7 +219,7 @@ public List Test6() /// /// Translation of Roslyn\Main\Open\Compilers\Test\Resources\Core\SymbolsTests\NoPia\LocalTypes3.vb /// - private static readonly string s_sourceLocalTypes3 = + private const string s_sourceLocalTypes3 = @" using System; using System.Collections.Generic; diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/SourcePlusMetadataTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/SourcePlusMetadataTests.cs index 364a3584451689a45c6191b05dc46d155b80aacc..a9be81221ef999f44e936f29cdd0723222323bfa 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/SourcePlusMetadataTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/SourcePlusMetadataTests.cs @@ -171,7 +171,7 @@ struct Name5 {} } [WorkItem(527531, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/527531")] - [Fact] + [Fact(Skip = "https://github.com/dotnet/roslyn/issues/18985")] public void InterfaceName() { var text = @" diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs index 872faea30658b0d29961a387e06491c26d4a56bc..be625b7a9792101d2eb35f3ae544cf5e29042781 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs @@ -7841,7 +7841,7 @@ public static int Main() new ErrorDescription { Code = (int)ErrorCode.ERR_CantOverrideNonVirtual, Line = 13, Column = 29 }); } - private static readonly string s_typeWithMixedProperty = @" + private const string s_typeWithMixedProperty = @" .class public auto ansi beforefieldinit Base_VirtGet_Set extends [mscorlib]System.Object { diff --git a/src/Compilers/Core/Portable/CodeGen/PermissionSetAttribute.cs b/src/Compilers/Core/Portable/CodeGen/PermissionSetAttribute.cs index 8ea84cb8462270495ff095cd0b30ffea801379d5..818f9e1c9a579afa74211189de821a02637a63c0 100644 --- a/src/Compilers/Core/Portable/CodeGen/PermissionSetAttribute.cs +++ b/src/Compilers/Core/Portable/CodeGen/PermissionSetAttribute.cs @@ -29,8 +29,8 @@ internal class PermissionSetAttributeWithFileReference : Cci.ICustomAttribute { private readonly Cci.ICustomAttribute _sourceAttribute; private readonly string _resolvedPermissionSetFilePath; - internal static readonly string FilePropertyName = "File"; - internal static readonly string HexPropertyName = "Hex"; + internal const string FilePropertyName = "File"; + internal const string HexPropertyName = "Hex"; public PermissionSetAttributeWithFileReference(Cci.ICustomAttribute sourceAttribute, string resolvedPermissionSetFilePath) { diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index 541839df84c0c00395f2794cd206c768a6607aa2..50b214a779f12d268ab23980bb3c91105a5a9517 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -1094,7 +1094,7 @@ protected static ImmutableArray CheckTupleElementNames(int cardinality, #region Diagnostics - internal static readonly CompilationStage DefaultDiagnosticsStage = CompilationStage.Compile; + internal const CompilationStage DefaultDiagnosticsStage = CompilationStage.Compile; /// /// Gets the diagnostics produced during the parsing stage. diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs index 389a91980dbb5bb9431872c59ff60a381fa88d2e..afba57f178af9166b9810c1984441dd8e151b9a1 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs @@ -51,7 +51,7 @@ internal abstract partial class AnalyzerDriver : IDisposable /// This mode should always guarantee that analyzer action callbacks are enabled for generated code, i.e. is set. /// However, the default diagnostic reporting mode is liable to change in future. /// - internal static readonly GeneratedCodeAnalysisFlags DefaultGeneratedCodeAnalysisFlags = GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics; + internal const GeneratedCodeAnalysisFlags DefaultGeneratedCodeAnalysisFlags = GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics; /// /// Map from non-concurrent analyzers to the gate guarding callback into the analyzer. diff --git a/src/Compilers/Core/Portable/FileSystem/PathUtilities.cs b/src/Compilers/Core/Portable/FileSystem/PathUtilities.cs index e4f881e38362d5eec7cd7260b13f15993dacf226..dd9aa762754b055c9ea689a3ab979cac938254e3 100644 --- a/src/Compilers/Core/Portable/FileSystem/PathUtilities.cs +++ b/src/Compilers/Core/Portable/FileSystem/PathUtilities.cs @@ -17,9 +17,9 @@ internal static class PathUtilities // We consider '/' a directory separator on Unix like systems. // On Windows both / and \ are equally accepted. internal static readonly char DirectorySeparatorChar = PlatformInformation.IsUnix ? '/' : '\\'; - internal static readonly char AltDirectorySeparatorChar = '/'; - internal static readonly string ParentRelativeDirectory = ".."; - internal static readonly string ThisDirectory = "."; + internal const char AltDirectorySeparatorChar = '/'; + internal const string ParentRelativeDirectory = ".."; + internal const string ThisDirectory = "."; internal static readonly string DirectorySeparatorStr = new string(DirectorySeparatorChar, 1); internal const char VolumeSeparatorChar = ':'; internal static bool IsUnixLikePlatform => PlatformInformation.IsUnix; diff --git a/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs b/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs index 6467b43ce27dc3495ff82b5ecbfb341845c6f3b0..d302c46117d5ff3b2fab04bc60bc61503fb0c166 100644 --- a/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs +++ b/src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs @@ -455,8 +455,8 @@ private bool IsMinimalDelta // Well known dummy cor library types whose refs are used for attaching assembly attributes off within net modules // There is no guarantee the types actually exist in a cor library - internal static readonly string dummyAssemblyAttributeParentNamespace = "System.Runtime.CompilerServices"; - internal static readonly string dummyAssemblyAttributeParentName = "AssemblyAttributesGoHere"; + internal const string dummyAssemblyAttributeParentNamespace = "System.Runtime.CompilerServices"; + internal const string dummyAssemblyAttributeParentName = "AssemblyAttributesGoHere"; internal static readonly string[,] dummyAssemblyAttributeParentQualifier = { { "", "M" }, { "S", "SM" } }; private readonly TypeReferenceHandle[,] _dummyAssemblyAttributeParent = { { default(TypeReferenceHandle), default(TypeReferenceHandle) }, { default(TypeReferenceHandle), default(TypeReferenceHandle) } }; diff --git a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs index f56bf93935c5e84ead075a0bcc3c718ed6b392cb..28ace1848dfaa1753654702ffc2b70c7314784a7 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs @@ -842,22 +842,22 @@ static ObjectWriter() /// /// byte marker mask for encoding compressed uint /// - internal static readonly byte ByteMarkerMask = 3 << 6; + internal const byte ByteMarkerMask = 3 << 6; /// /// byte marker bits for uint encoded in 1 byte. /// - internal static readonly byte Byte1Marker = 0; + internal const byte Byte1Marker = 0; /// /// byte marker bits for uint encoded in 2 bytes. /// - internal static readonly byte Byte2Marker = 1 << 6; + internal const byte Byte2Marker = 1 << 6; /// /// byte marker bits for uint encoded in 4 bytes. /// - internal static readonly byte Byte4Marker = 2 << 6; + internal const byte Byte4Marker = 2 << 6; internal enum EncodingKind : byte { diff --git a/src/Compilers/Core/Portable/Symbols/Attributes/WellKnownAttributeData.cs b/src/Compilers/Core/Portable/Symbols/Attributes/WellKnownAttributeData.cs index f7fa18aaab386e6239836348c325ecd2057104fc..e9765a58c5068d02dbdc20d616f72070dc2dff5a 100644 --- a/src/Compilers/Core/Portable/Symbols/Attributes/WellKnownAttributeData.cs +++ b/src/Compilers/Core/Portable/Symbols/Attributes/WellKnownAttributeData.cs @@ -16,7 +16,7 @@ internal abstract class WellKnownAttributeData /// For some well-known attributes, the latter case will return string stored in /// field. /// - public static readonly string StringMissingValue = nameof(StringMissingValue); + public const string StringMissingValue = nameof(StringMissingValue); #if DEBUG private bool _isSealed; diff --git a/src/Compilers/VisualBasic/Portable/Compilation/LookupSymbolsInfo.vb b/src/Compilers/VisualBasic/Portable/Compilation/LookupSymbolsInfo.vb index e46bc0b4daf3a85941cf19df1416fbc75de909b8..869f108013ab063577c3bb9502345f85b7e9dc9b 100644 --- a/src/Compilers/VisualBasic/Portable/Compilation/LookupSymbolsInfo.vb +++ b/src/Compilers/VisualBasic/Portable/Compilation/LookupSymbolsInfo.vb @@ -8,7 +8,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Inherits AbstractLookupSymbolsInfo(Of Symbol) ' TODO: tune pool size - Private Shared ReadOnly s_poolSize As Integer = 64 + Private Const s_poolSize As Integer = 64 Private Shared ReadOnly s_pool As New ObjectPool(Of LookupSymbolsInfo)(Function() New LookupSymbolsInfo(), s_poolSize) Private Sub New() diff --git a/src/Compilers/VisualBasic/Portable/Lowering/StateMachineRewriter/StateMachineStates.vb b/src/Compilers/VisualBasic/Portable/Lowering/StateMachineRewriter/StateMachineStates.vb index 5e29c5354847ae8250410b8cc738c8cdd55f35c6..627ea78d1f8445e7b520e34a05d6c2994145ea3a 100644 --- a/src/Compilers/VisualBasic/Portable/Lowering/StateMachineRewriter/StateMachineStates.vb +++ b/src/Compilers/VisualBasic/Portable/Lowering/StateMachineRewriter/StateMachineStates.vb @@ -8,9 +8,9 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic Friend Module StateMachineStates - Public ReadOnly FinishedStateMachine As Integer = -2 - Public ReadOnly NotStartedStateMachine As Integer = -1 - Public ReadOnly FirstUnusedState As Integer = 0 + Public FinishedStateMachine As Integer = -2 + Public NotStartedStateMachine As Integer = -1 + Public FirstUnusedState As Integer = 0 End Module End Namespace diff --git a/src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb index 81ccaa6b30742e0ac8a5859ca3a6191503b75407..ca4911e6c5bf62ca7b3db65b934047024af492ba 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb @@ -26,7 +26,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' TODO (tomat): Consider changing this to an empty name. This name shouldn't ever leak to the user in error messages. - Friend Shared ReadOnly ImplicitTypeName As String = "" + Friend Const ImplicitTypeName As String = "" Private Shared ReadOnly s_EmptyTypeSymbols() As TypeSymbol = Array.Empty(Of TypeSymbol) diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Conditional.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Conditional.vb index 97936df4825584a5ea276b294c7502417002e9c5..53bab71788b1d66153d085f973985d10a712845d 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Conditional.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Conditional.vb @@ -546,7 +546,7 @@ End Class End Module ]]>.Value - Private Shared ReadOnly s_commonExpectedOutput_ConditionalMethodsTest As String = + Private Const s_commonExpectedOutput_ConditionalMethodsTest As String = "Z.PreservedCalls_AppliedConditional_Method" & vbCrLf & "Z.PreservedCalls_InheritedConditional_Method" & vbCrLf & "Z.PreservedCalls_MultipleConditional_Method" & vbCrLf & diff --git a/src/Compilers/VisualBasic/Test/Semantic/Semantics/Conversions.vb b/src/Compilers/VisualBasic/Test/Semantic/Semantics/Conversions.vb index f486a8e98bdc8f1df1a2773809ba5b551e3cca30..9fcb95c6673fbdf94311a9c1bff2092906fec208 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Semantics/Conversions.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Semantics/Conversions.vb @@ -18,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics Public Class ConversionsTests Inherits BasicTestBase - Private Shared ReadOnly s_noConversion As ConversionKind = Nothing + Private Const s_noConversion As ConversionKind = Nothing Public Sub TryCastDirectCastConversions() diff --git a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs index fad815bcb08378d8ffed99eff2b42dd3e711a8d4..99340c64988373e0cac3bf759ec4c79d20493a09 100644 --- a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs +++ b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs @@ -1431,7 +1431,9 @@ void Method() public async Task TestSimpleSystemUnsortedUsings1() { await TestAsync( -@"using B; +@" +using C; +using B; using System; class Class @@ -1451,7 +1453,9 @@ public static void Bar() } } }", -@"using B; +@" +using C; +using B; using System; using A; @@ -1636,7 +1640,9 @@ void Method() public async Task TestSimpleSystemUnsortedUsings4() { await TestAsync( -@"using System; +@" +using C; +using System; using B; class Class @@ -1656,7 +1662,9 @@ public static void Bar() } } }", -@"using System; +@" +using C; +using System; using B; using A; @@ -4671,6 +4679,111 @@ private void GetEvaluationRuleNames() IEnumerable < Int32 > return ImmutableArray.CreateRange(); } +}"); + } + + [WorkItem(19796, "https://github.com/dotnet/roslyn/issues/19796")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)] + public async Task TestWhenInRome1() + { + // System is set to be sorted first, but the actual file shows it at the end. + // Keep things sorted, but respect that 'System' is at the end. + await TestAsync( +@" +using B; +using System; + +class Class +{ + void Method() + { + [|Foo|].Bar(); + } +} + +namespace A +{ + class Foo + { + public static void Bar() + { + } + } +}", +@" +using A; +using B; +using System; + +class Class +{ + void Method() + { + Foo.Bar(); + } +} + +namespace A +{ + class Foo + { + public static void Bar() + { + } + } +}", +systemSpecialCase: true); + } + + [WorkItem(19796, "https://github.com/dotnet/roslyn/issues/19796")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)] + public async Task TestWhenInRome2() + { + // System is set to not be sorted first, but the actual file shows it sorted first. + // Keep things sorted, but respect that 'System' is at the beginning. + await TestAsync( +@" +using System; +using B; + +class Class +{ + void Method() + { + [|Foo|].Bar(); + } +} + +namespace A +{ + class Foo + { + public static void Bar() + { + } + } +}", +@" +using System; +using A; +using B; + +class Class +{ + void Method() + { + Foo.Bar(); + } +} + +namespace A +{ + class Foo + { + public static void Bar() + { + } + } }"); } } diff --git a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs index 7b14ed0fdeca37f452121d4e5689e91707119e2d..27ae081efb97893789f2d8871dccc47c254c2654 100644 --- a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs +++ b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs @@ -180,7 +180,7 @@ class Class : IInterface }"); } - private static readonly string s_tupleElementNamesAttribute = + private const string s_tupleElementNamesAttribute = @"namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Event )] diff --git a/src/EditorFeatures/Core/EditorFeatures.csproj b/src/EditorFeatures/Core/EditorFeatures.csproj index c0dc0785d75936a10eb54173b5646f8846037b1c..83abd997c435c60606f643d4bd45ca0014b9541e 100644 --- a/src/EditorFeatures/Core/EditorFeatures.csproj +++ b/src/EditorFeatures/Core/EditorFeatures.csproj @@ -127,6 +127,14 @@ + + + + + + + + diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/CustomCommitCompletion.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/CustomCommitCompletion.cs index f294256ea1c431ac52ea9b2b9e3dc094676e4079..7e90dfb75ff7f7eaf54188c9e0297cfb9c0a6d2a 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/CustomCommitCompletion.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Presentation/CustomCommitCompletion.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion.P { internal sealed class CustomCommitCompletion : Completion3, ICustomCommit { - private static readonly string s_glyphCompletionWarning = "GlyphCompletionWarning"; + private const string s_glyphCompletionWarning = "GlyphCompletionWarning"; private readonly CompletionPresenterSession _completionPresenterSession; internal readonly CompletionItem CompletionItem; private readonly ImageMoniker _imageMoniker; diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb index 2bf3d1297cb9c2b82f5dd1db830fc74ef95f04dc..290ae719e1cfa0041a6bfabfb8fbc1bbaf126a5c 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb @@ -3,6 +3,7 @@ Imports Microsoft.CodeAnalysis.CodeActions Imports Microsoft.CodeAnalysis.CodeFixes Imports Microsoft.CodeAnalysis.Diagnostics +Imports Microsoft.CodeAnalysis.Editing Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics Imports Microsoft.CodeAnalysis.Remote Imports Microsoft.CodeAnalysis.Test.Utilities.RemoteHost @@ -17,9 +18,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp expectedMarkup As String, Optional index As Integer = 0, Optional ignoreTrivia As Boolean = True, - Optional priority As CodeActionPriority? = Nothing) As Task - Await TestAsync(initialMarkup, expectedMarkup, index, ignoreTrivia, priority, outOfProcess:=False) - Await TestAsync(initialMarkup, expectedMarkup, index, ignoreTrivia, priority, outOfProcess:=True) + Optional priority As CodeActionPriority? = Nothing, + Optional placeSystemFirst As Boolean = True) As Task + Await TestAsync(initialMarkup, expectedMarkup, index, ignoreTrivia, priority, placeSystemFirst, outOfProcess:=False) + Await TestAsync(initialMarkup, expectedMarkup, index, ignoreTrivia, priority, placeSystemFirst, outOfProcess:=True) End Function Friend Overloads Async Function TestAsync(initialMarkup As String, @@ -27,10 +29,13 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp index As Integer, ignoreTrivia As Boolean, priority As CodeActionPriority?, + placeSystemFirst As Boolean, outOfProcess As Boolean) As Task Await TestInRegularAndScript1Async( initialMarkup, expectedMarkup, index, ignoreTrivia, priority, - parameters:=New TestParameters(fixProviderData:=outOfProcess)) + parameters:=New TestParameters( + options:=[Option](GenerationOptions.PlaceSystemNamespaceFirst, placeSystemFirst), + fixProviderData:=outOfProcess)) End Function End Class @@ -2355,6 +2360,64 @@ Namespace Y End Module End Namespace") End Function + + + + Public Async Function TestWhenInRome1() As Task + Await TestAsync( +" +Imports System +Imports B + +Class Class1 + Dim v As [|AType|] +End Class +Namespace A + Public Class AType + End Class +End Namespace", +" +Imports System +Imports A +Imports B + +Class Class1 + Dim v As AType +End Class +Namespace A + Public Class AType + End Class +End Namespace", placeSystemFirst:=False) + End Function + + + + Public Async Function TestWhenInRome2() As Task + Await TestAsync( +" +Imports B +Imports System + +Class Class1 + Dim v As [|AType|] +End Class +Namespace A + Public Class AType + End Class +End Namespace", +" +Imports A +Imports B +Imports System + +Class Class1 + Dim v As AType +End Class +Namespace A + Public Class AType + End Class +End Namespace", placeSystemFirst:=True) + End Function End Class Public Class AddImportTestsWithAddImportDiagnosticProvider diff --git a/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb b/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb index 645f71020b07b639d292e990b659acb8978a65a8..10c5232666712b6fdde83b23041b3a0222dd619b 100644 --- a/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb @@ -219,7 +219,7 @@ End structure", Imports System Imports System.Collections.Generic -Structure Program +structure Program Implements IEquatable(Of Program) Public s As String @@ -231,7 +231,7 @@ Structure Program Public Function Equals(other As Program) As Boolean Implements IEquatable(Of Program).Equals Return s = other.s End Function -End Structure", +End structure", chosenSymbols:=Nothing, optionsCallback:=Sub(Options) EnableOption(Options, ImplementIEquatableId), ignoreTrivia:=False) diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs index 4774a54096285d41aff2a0d9519876d455fcd8d8..e4c2a2246cd28a8ed224732475ea8a46bcafdef0 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -#pragma warning disable RS0007 // Avoid zero-length array allocations. +#pragma warning disable CA1825 // Avoid zero-length array allocations. using System; using System.Collections.ObjectModel; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs index f9302e9246a465d30886c4e97f5b54f4b63a56ce..c4d656b31b4781a7148b0dda71cb4fd1158ac87d 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/ArrayBuilder.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -#pragma warning disable RS0007 // Avoid zero-length array allocations. +#pragma warning disable CA1825 // Avoid zero-length array allocations. using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs index 122421bf60d15ec355042cc9a527ab6f5cae7b4c..80a84709d5ab5ee4c5d7cb0fbecec75b6b593e8c 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -#pragma warning disable RS0007 // Avoid zero-length array allocations. +#pragma warning disable CA1825 // Avoid zero-length array allocations. using System; using System.Collections.ObjectModel; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.shproj b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.shproj index 3ddaba08615ba8c1c9232e400c043cf6ad0a67d7..c86dd8281304c7fd41772a2818960a7b5964e1f2 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.shproj +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.shproj @@ -8,7 +8,6 @@ - \ No newline at end of file diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj index b24ef0f9cd2dd5a5101b7e2fc48a8327932b957e..29f9a81d11778394222d97c086b6f78145f0b884 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj @@ -12,6 +12,7 @@ Roslyn.ExpressionEvaluator.ResultProvider.Test.Utilities true v4.6 + $(NoWarn);CA1825 diff --git a/src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs b/src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs index f6830ef7fd4f3f136b4dd45a35f9d923bcd83ac3..0e07996e79c731104eae795a50377eb9525653b5 100644 --- a/src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs +++ b/src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs @@ -399,7 +399,7 @@ private CompletionItemRules GetRules(string displayText) } } - private static readonly string InsertionTextProperty = "insertionText"; + private const string InsertionTextProperty = "insertionText"; protected override Task GetTextChangeAsync(CompletionItem selectedItem, char? ch, CancellationToken cancellationToken) { diff --git a/src/Features/CSharp/Portable/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs index afed98fce25743e3d388116822dd55b51ed3e8b0..073ce63b18eac0d9164221b4449da0174eac0478 100644 --- a/src/Features/CSharp/Portable/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs @@ -10,7 +10,8 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeMethodSynchronous { - [ExportCodeFixProvider(LanguageNames.CSharp), Shared] + [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.MakeMethodSynchronous), Shared] + [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddImport)] internal class CSharpMakeMethodSynchronousCodeFixProvider : AbstractMakeMethodSynchronousCodeFixProvider { private const string CS1998 = nameof(CS1998); // This async method lacks 'await' operators and will run synchronously. diff --git a/src/Features/Core/Portable/AddImport/References/SymbolReference.cs b/src/Features/Core/Portable/AddImport/References/SymbolReference.cs index e4d30baa6f076448ecae1d8ff7dc71360005c8ba..27fc0b1a8caed11e0ea0758ca83f89fc4e066952 100644 --- a/src/Features/Core/Portable/AddImport/References/SymbolReference.cs +++ b/src/Features/Core/Portable/AddImport/References/SymbolReference.cs @@ -98,7 +98,7 @@ public override int GetHashCode() document, node, placeSystemNamespaceFirst, hasExistingImport, cancellationToken).ConfigureAwait(false); return GetFixData( - document, textChanges.ToImmutableArray(), description, + document, textChanges, description, GetTags(document), GetPriority(document)); } diff --git a/src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs b/src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs index 163f9170418c77e4bf5141c55bf2d8adb5708cd8..4e1919ecde2d52191523b64c0934c456401c3028 100644 --- a/src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs +++ b/src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs @@ -32,6 +32,7 @@ internal static class PredefinedCodeFixProviderNames public const string ImplementAbstractClass = nameof(ImplementAbstractClass); public const string ImplementInterface = nameof(ImplementInterface); public const string InsertMissingCast = nameof(InsertMissingCast); + public const string MakeMethodSynchronous = nameof(MakeMethodSynchronous); public const string MoveToTopOfFile = nameof(MoveToTopOfFile); public const string PopulateSwitch = nameof(PopulateSwitch); public const string QualifyMemberAccess = nameof(QualifyMemberAccess); diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs index 4d7ccbf25a678fc4388f01ac2d600a18e950fe7f..f0d3729c998eec85e819d201f6161e0b2b5df921 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs @@ -19,8 +19,8 @@ namespace Microsoft.CodeAnalysis.CodeFixes.Suppression internal abstract partial class AbstractSuppressionCodeFixProvider : ISuppressionFixProvider { public const string SuppressMessageAttributeName = "System.Diagnostics.CodeAnalysis.SuppressMessage"; - private static readonly string s_globalSuppressionsFileName = "GlobalSuppressions"; - private static readonly string s_suppressionsFileCommentTemplate = + private const string s_globalSuppressionsFileName = "GlobalSuppressions"; + private const string s_suppressionsFileCommentTemplate = @" {0} This file is used by Code Analysis to maintain SuppressMessage {0} attributes that are applied to this project. diff --git a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs index ac9bd2949b6f1d21fb1a2180176ef8f270dad872..b63ac8ed1e2b7e8607e9f6d3f1a748b38fdfd5a3 100644 --- a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs +++ b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs @@ -19,7 +19,7 @@ internal struct SerializableDocumentHighlights public ImmutableArray HighlightSpans; public DocumentHighlights Rehydrate(Solution solution) - => new DocumentHighlights(solution.GetDocument(DocumentId), HighlightSpans.ToImmutableArray()); + => new DocumentHighlights(solution.GetDocument(DocumentId), HighlightSpans); public static SerializableDocumentHighlights Dehydrate(DocumentHighlights highlights) => new SerializableDocumentHighlights diff --git a/src/Features/Core/Portable/FeaturesResources.Designer.cs b/src/Features/Core/Portable/FeaturesResources.Designer.cs index 5505e8518aa6928d4550b97e6c1d3910fa4b27fd..b9a7ac271c7b39c95d3c19d34c81b0b99f0c4431 100644 --- a/src/Features/Core/Portable/FeaturesResources.Designer.cs +++ b/src/Features/Core/Portable/FeaturesResources.Designer.cs @@ -1891,7 +1891,7 @@ internal class FeaturesResources { } /// - /// Looks up a localized string similar to Make method synchronous.. + /// Looks up a localized string similar to Make method synchronous. /// internal static string Make_method_synchronous { get { diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index d00dccb2c347f711654adc4f65fa4418fc466272..4b93d5f68b1febf4509e74b2754ea73a2a8fb46c 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -886,7 +886,7 @@ Do you want to continue? Unable to load Analyzer assembly {0}: {1} - Make method synchronous. + Make method synchronous Add 'this' or 'Me' qualification. diff --git a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.DocCommentFormatter.cs b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.DocCommentFormatter.cs index 50a1ec26ec11129900115e6f2cbb4ad48a9a0eb4..bfc989f90554c1d31eea186b2f340d72cd709f44 100644 --- a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.DocCommentFormatter.cs +++ b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.DocCommentFormatter.cs @@ -12,12 +12,12 @@ internal partial class AbstractMetadataAsSourceService { internal class DocCommentFormatter { - private static readonly int s_indentSize = 2; - private static readonly int s_wrapLength = 80; + private const int s_indentSize = 2; + private const int s_wrapLength = 80; private static readonly string s_summaryHeader = FeaturesResources.Summary_colon; private static readonly string s_paramHeader = FeaturesResources.Parameters_colon; - private static readonly string s_labelFormat = "{0}:"; + private const string s_labelFormat = "{0}:"; private static readonly string s_typeParameterHeader = FeaturesResources.Type_parameters_colon; private static readonly string s_returnsHeader = FeaturesResources.Returns_colon; private static readonly string s_exceptionsHeader = FeaturesResources.Exceptions_colon; diff --git a/src/Features/Core/Portable/Remote/RemoteArguments.cs b/src/Features/Core/Portable/Remote/RemoteArguments.cs index 0172cff8e8c62aa48db4e7c775afe26c81914b74..4dd88b41336d3ecf29fcfe55e19ad403a86ac89c 100644 --- a/src/Features/Core/Portable/Remote/RemoteArguments.cs +++ b/src/Features/Core/Portable/Remote/RemoteArguments.cs @@ -43,7 +43,7 @@ internal INavigateToSearchResult Rehydrate(Solution solution) { return new NavigateToSearchResult( AdditionalInformation, Kind, MatchKind, IsCaseSensitive, - Name, NameMatchSpans.ToImmutableArray(), + Name, NameMatchSpans, SecondarySort, Summary, NavigableItem.Rehydrate(solution)); } @@ -113,7 +113,7 @@ public INavigableItem Rehydrate(Solution solution) ? ImmutableArray.Empty : ChildItems.SelectAsArray(c => c.Rehydrate(solution)); return new NavigableItem( - Glyph, DisplayTaggedParts.ToImmutableArray(), + Glyph, DisplayTaggedParts, DisplayFileLocation, IsImplicitlyDeclared, solution.GetDocument(Document), SourceSpan, diff --git a/src/Features/VisualBasic/Portable/MakeMethodSynchronous/VisualBasicMakeMethodSynchronousCodeFixProvider.vb b/src/Features/VisualBasic/Portable/MakeMethodSynchronous/VisualBasicMakeMethodSynchronousCodeFixProvider.vb index e3ad9a10b79a3054ee195b63df724085fb6f7d4c..93583ac70ff2c2ddc0af228d964253e08fa84da5 100644 --- a/src/Features/VisualBasic/Portable/MakeMethodSynchronous/VisualBasicMakeMethodSynchronousCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/MakeMethodSynchronous/VisualBasicMakeMethodSynchronousCodeFixProvider.vb @@ -7,7 +7,8 @@ Imports Microsoft.CodeAnalysis.MakeMethodSynchronous Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.MakeMethodSynchronous - + + Friend Class VisualBasicMakeMethodSynchronousCodeFixProvider Inherits AbstractMakeMethodSynchronousCodeFixProvider diff --git a/src/Scripting/CoreTestUtilities/ObjectFormatterTests.Fixtures.cs b/src/Scripting/CoreTestUtilities/ObjectFormatterTests.Fixtures.cs index ac205efee22c27776a694021ded4fa6529825fc2..5a0cd13f9f42a4831f2f60b19e7bcf9ca7000213 100644 --- a/src/Scripting/CoreTestUtilities/ObjectFormatterTests.Fixtures.cs +++ b/src/Scripting/CoreTestUtilities/ObjectFormatterTests.Fixtures.cs @@ -16,7 +16,7 @@ public class Nested { public readonly int A = 1; public readonly int B = 2; - public static readonly int S = 3; + public const int S = 3; } } diff --git a/src/Test/Perf/Utilities/VsPerfTest.cs b/src/Test/Perf/Utilities/VsPerfTest.cs index 2470d366a7592f7fa9f4f15173ad0ccc7185f122..c78d8db335a30d131ffe59acb9fad27a198774e6 100644 --- a/src/Test/Perf/Utilities/VsPerfTest.cs +++ b/src/Test/Perf/Utilities/VsPerfTest.cs @@ -7,7 +7,7 @@ namespace Roslyn.Test.Performance.Utilities { public abstract class VsPerfTest : PerfTest { - private static readonly string _rootSuffix = "RoslynPerf"; + private const string _rootSuffix = "RoslynPerf"; private readonly ILogger _logger; private readonly string _testTemplateName; diff --git a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs index 02ebd2753104039900139ad4d9e16877eaa07f9c..0b3cc33e3ef80f20ee3fd3ea24dcce1cac66cdfb 100644 --- a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs +++ b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs @@ -24,10 +24,10 @@ namespace BuildBoss internal sealed class StructuredLoggerCheckerUtil : ICheckerUtil { internal static readonly StringComparer FilePathComparer = StringComparer.OrdinalIgnoreCase; - private static readonly string s_copyingFileFrom = "Copying file from \""; - private static readonly string s_creatingHardLink = "Creating hard link to copy \""; - private static readonly string s_didNotCopy = "Did not copy from file \""; - private static readonly string s_to = "\" to \""; + private const string s_copyingFileFrom = "Copying file from \""; + private const string s_creatingHardLink = "Creating hard link to copy \""; + private const string s_didNotCopy = "Did not copy from file \""; + private const string s_to = "\" to \""; private readonly XDocument _document; private readonly Dictionary> _copyMap = new Dictionary>(FilePathComparer); diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/NewLinesViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/NewLinesViewModel.cs index 6e2b61a8e425c1ac4443fef53ecd4a96a6373309..5c112e270f1d704182bd98ed4f9b853f84e493e1 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/NewLinesViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/NewLinesViewModel.cs @@ -44,7 +44,7 @@ class C { //] }"; - private static readonly string s_tryCatchFinallyPreview = @"using System; + private const string s_tryCatchFinallyPreview = @"using System; class C { void Foo() { //[ @@ -58,7 +58,7 @@ class C { } }"; - private static readonly string s_ifElsePreview = @"class C { + private const string s_ifElsePreview = @"class C { void Foo() { //[ if (false) { @@ -69,7 +69,7 @@ class C { } }"; - private static readonly string s_forBlockPreview = @"class C { + private const string s_forBlockPreview = @"class C { void Foo() { //[ for (int i; i < 10; i++){ @@ -78,7 +78,7 @@ class C { } }"; - private static readonly string s_lambdaPreview = @"using System; + private const string s_lambdaPreview = @"using System; class C { void Foo() { //[ @@ -88,7 +88,7 @@ class C { //] } }"; - private static readonly string s_anonymousMethodPreview = @"using System; + private const string s_anonymousMethodPreview = @"using System; delegate int D(int x); @@ -102,7 +102,7 @@ class C { } }"; - private static readonly string s_anonymousTypePreview = @"using System; + private const string s_anonymousTypePreview = @"using System; class C { void Foo() { //[ @@ -112,7 +112,7 @@ class C { //] } }"; - private static readonly string s_InitializerPreviewTrue = @"using System; + private const string s_InitializerPreviewTrue = @"using System; using System.Collections.Generic; class C { @@ -140,7 +140,7 @@ class B { public int A { get; set; } public int B { get; set; } }"; - private static readonly string s_InitializerPreviewFalse = @"using System; + private const string s_InitializerPreviewFalse = @"using System; using System.Collections.Generic; class C { @@ -165,7 +165,7 @@ class B { public int A { get; set; } public int B { get; set; } }"; - private static readonly string s_objectInitializerPreview = @"using System; + private const string s_objectInitializerPreview = @"using System; class C { void Foo() { //[ @@ -180,7 +180,7 @@ class B { public int A { get; set; } public int B { get; set; } }"; - private static readonly string s_queryExpressionPreview = @"using System; + private const string s_queryExpressionPreview = @"using System; using System.Linq; using System.Collections.Generic; class C { diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/SpacingViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/SpacingViewModel.cs index 18787608f21373b5a6dc1a2c502da41612383109..a64dad3c951ebde0c8abad97d243441d9ce4ce78 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/SpacingViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/SpacingViewModel.cs @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options.Formatting /// internal class SpacingViewModel : AbstractOptionPreviewViewModel { - private static readonly string s_methodPreview = @" + private const string s_methodPreview = @" class C { //[ void Foo(){ @@ -29,14 +29,14 @@ class C { } }"; - private static readonly string s_bracketPreview = @"class C { + private const string s_bracketPreview = @"class C { void Foo(){ //[ int[] x = new int[10]; //] } }"; - private static readonly string s_forDelimiterPreview = @"class C{ + private const string s_forDelimiterPreview = @"class C{ void Foo(int x, object y) { //[ for (int i; i < x; i++) { @@ -45,7 +45,7 @@ class C { } }"; - private static readonly string s_delimiterPreview = @"class C{ + private const string s_delimiterPreview = @"class C{ void Foo(int x, object y) { //[ this.Foo(x, y); @@ -53,7 +53,7 @@ class C { } }"; - private static readonly string s_castPreview = @"class C{ + private const string s_castPreview = @"class C{ void Foo(object x) { //[ int y = (int)x; @@ -61,7 +61,7 @@ class C { } }"; - private static readonly string s_expressionPreview = @"class C{ + private const string s_expressionPreview = @"class C{ void Foo(int x, object y) { //[ var x = 3; @@ -71,7 +71,7 @@ class C { } }"; - private static readonly string s_expressionSpacingPreview = @" + private const string s_expressionSpacingPreview = @" class c { int Foo(int x, int y) { //[ @@ -79,7 +79,7 @@ class c { //] } }"; - private static readonly string s_declarationSpacingPreview = @"class MyClass { + private const string s_declarationSpacingPreview = @"class MyClass { //[ int index = 0; string text = ""Start""; @@ -90,7 +90,7 @@ class c { } //] }"; - private static readonly string s_baseColonPreview = @"//[ + private const string s_baseColonPreview = @"//[ interface I { } diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs index de58425e5615c284a4be65596dd69509ca3ff5e2..eabe2f07c234aa01fa788d99c382c32d8f151abb 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs @@ -21,7 +21,7 @@ internal class StyleViewModel : AbstractOptionPreviewViewModel { #region "Preview Text" - private static readonly string s_fieldDeclarationPreviewTrue = @" + private const string s_fieldDeclarationPreviewTrue = @" class C{ int capacity; void Method() @@ -32,7 +32,7 @@ void Method() } }"; - private static readonly string s_fieldDeclarationPreviewFalse = @" + private const string s_fieldDeclarationPreviewFalse = @" class C{ int capacity; void Method() @@ -43,7 +43,7 @@ void Method() } }"; - private static readonly string s_propertyDeclarationPreviewTrue = @" + private const string s_propertyDeclarationPreviewTrue = @" class C{ public int Id { get; set; } void Method() @@ -54,7 +54,7 @@ void Method() } }"; - private static readonly string s_propertyDeclarationPreviewFalse = @" + private const string s_propertyDeclarationPreviewFalse = @" class C{ public int Id { get; set; } void Method() @@ -65,7 +65,7 @@ void Method() } }"; - private static readonly string s_eventDeclarationPreviewTrue = @" + private const string s_eventDeclarationPreviewTrue = @" using System; class C{ event EventHandler Elapsed; @@ -77,7 +77,7 @@ void Handler(object sender, EventArgs args) } }"; - private static readonly string s_eventDeclarationPreviewFalse = @" + private const string s_eventDeclarationPreviewFalse = @" using System; class C{ event EventHandler Elapsed; @@ -89,7 +89,7 @@ void Handler(object sender, EventArgs args) } }"; - private static readonly string s_methodDeclarationPreviewTrue = @" + private const string s_methodDeclarationPreviewTrue = @" using System; class C{ void Display() @@ -100,7 +100,7 @@ void Display() } }"; - private static readonly string s_methodDeclarationPreviewFalse = @" + private const string s_methodDeclarationPreviewFalse = @" using System; class C{ void Display() @@ -111,7 +111,7 @@ void Display() } }"; - private static readonly string s_intrinsicPreviewDeclarationTrue = @" + private const string s_intrinsicPreviewDeclarationTrue = @" class Program { //[ @@ -123,7 +123,7 @@ static void M(int argument) //] }"; - private static readonly string s_intrinsicPreviewDeclarationFalse = @" + private const string s_intrinsicPreviewDeclarationFalse = @" using System; class Program { @@ -136,7 +136,7 @@ static void M(Int32 argument) //] }"; - private static readonly string s_intrinsicPreviewMemberAccessTrue = @" + private const string s_intrinsicPreviewMemberAccessTrue = @" class Program { //[ @@ -147,7 +147,7 @@ static void M() //] }"; - private static readonly string s_intrinsicPreviewMemberAccessFalse = @" + private const string s_intrinsicPreviewMemberAccessFalse = @" using System; class Program { @@ -489,7 +489,7 @@ public int GetAge() }} "; - private static readonly string s_preferExpressionBodyForMethods = @" + private const string s_preferExpressionBodyForMethods = @" using System; //[ @@ -502,7 +502,7 @@ class Customer //] "; - private static readonly string s_preferBlockBodyForMethods = @" + private const string s_preferBlockBodyForMethods = @" using System; //[ @@ -518,7 +518,7 @@ public int GetAge() //] "; - private static readonly string s_preferExpressionBodyForConstructors = @" + private const string s_preferExpressionBodyForConstructors = @" using System; //[ @@ -531,7 +531,7 @@ class Customer //] "; - private static readonly string s_preferBlockBodyForConstructors = @" + private const string s_preferBlockBodyForConstructors = @" using System; //[ @@ -547,7 +547,7 @@ public Customer(int age) //] "; - private static readonly string s_preferExpressionBodyForOperators = @" + private const string s_preferExpressionBodyForOperators = @" using System; struct ComplexNumber @@ -559,7 +559,7 @@ struct ComplexNumber } "; - private static readonly string s_preferBlockBodyForOperators = @" + private const string s_preferBlockBodyForOperators = @" using System; struct ComplexNumber @@ -573,7 +573,7 @@ struct ComplexNumber } "; - private static readonly string s_preferExpressionBodyForProperties = @" + private const string s_preferExpressionBodyForProperties = @" using System; //[ @@ -585,7 +585,7 @@ class Customer //] "; - private static readonly string s_preferBlockBodyForProperties = @" + private const string s_preferBlockBodyForProperties = @" using System; //[ @@ -597,7 +597,7 @@ class Customer //] "; - private static readonly string s_preferExpressionBodyForAccessors = @" + private const string s_preferExpressionBodyForAccessors = @" using System; //[ @@ -613,7 +613,7 @@ public int Age //] "; - private static readonly string s_preferBlockBodyForAccessors = @" + private const string s_preferBlockBodyForAccessors = @" using System; //[ @@ -629,7 +629,7 @@ public int Age //] "; - private static readonly string s_preferExpressionBodyForIndexers= @" + private const string s_preferExpressionBodyForIndexers = @" using System; //[ @@ -641,7 +641,7 @@ class List //] "; - private static readonly string s_preferBlockBodyForIndexers = @" + private const string s_preferBlockBodyForIndexers = @" using System; //[ diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/WrappingViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/WrappingViewModel.cs index 620c87b752d5d9407213f7e11c4b2bc112b31fbb..9c76e226d31b4de3cc34210da36cd7b47be42088 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/WrappingViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/WrappingViewModel.cs @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options.Formatting /// internal class WrappingViewModel : AbstractOptionPreviewViewModel { - private static readonly string s_blockPreview = @" + private const string s_blockPreview = @" class C { //[ @@ -21,7 +21,7 @@ class C //] }"; - private static readonly string s_declarationPreview = @" + private const string s_declarationPreview = @" class C{ void foo() { diff --git a/src/VisualStudio/CSharp/Repl/CSharpInteractiveCommands.cs b/src/VisualStudio/CSharp/Repl/CSharpInteractiveCommands.cs index 50f87f41fd352767c9579b7c4f3a8832dde6c028..f1f58354a819fecd4535b634754a4f2c42c828aa 100644 --- a/src/VisualStudio/CSharp/Repl/CSharpInteractiveCommands.cs +++ b/src/VisualStudio/CSharp/Repl/CSharpInteractiveCommands.cs @@ -9,7 +9,7 @@ internal static class CSharpInteractiveCommands public const int InteractiveToolWindow = 0x0001; public const int ResetInteractiveFromProject = 0x0002; - public static readonly string InteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6"; + public const string InteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6"; public static readonly Guid InteractiveCommandSetId = new Guid(InteractiveCommandSetIdString); } } diff --git a/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs b/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs index 3148e808a9ce0676363e933eef7e13abd9f7dedd..45e5f50c74eaffdec004433495c883286351a402 100644 --- a/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs +++ b/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs @@ -14,10 +14,10 @@ internal static class InteractiveCommands // TODO: Remove pending https://github.com/dotnet/roslyn/issues/8927 . public const int ExecuteInInteractiveWindow = 0x0010C; - public static readonly string CSharpInteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6"; + public const string CSharpInteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6"; public static readonly Guid CSharpInteractiveCommandSetId = new Guid(CSharpInteractiveCommandSetIdString); - public static readonly string VisualBasicInteractiveCommandSetIdString = "93DF185E-D75B-4FDB-9D47-E90F111971C5"; + public const string VisualBasicInteractiveCommandSetIdString = "93DF185E-D75B-4FDB-9D47-E90F111971C5"; public static readonly Guid VisualBasicInteractiveCommandSetId = new Guid(VisualBasicInteractiveCommandSetIdString); } } diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Helpers.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Helpers.cs index a04c6552d002d811710f4d8ae34bf1b1c8befec2..de721baaffda1258aabac0066c6fc9bc943e8958 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Helpers.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Helpers.cs @@ -62,7 +62,7 @@ public static uint ObjectListKindToListType(ObjectListKind kind) return 0; } - public static readonly _LIB_LISTFLAGS ClassView = _LIB_LISTFLAGS.LLF_TRUENESTING; + public const _LIB_LISTFLAGS ClassView = _LIB_LISTFLAGS.LLF_TRUENESTING; public static bool IsClassView(uint flags) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs index 4248e488bdecbf26fae6dad03a8b906c22aa02bb..99d53a72360c788f295fa31e86d773727ae4d9f6 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs @@ -153,9 +153,13 @@ public void Dispose() } } +#pragma warning disable CA1821 // Remove empty Finalizers +#if DEBUG ~InvisibleEditor() { Debug.Assert(Environment.HasShutdownStarted, GetType().Name + " was leaked without Dispose being called."); } +#endif +#pragma warning restore CA1821 // Remove empty Finalizers } } diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs index 009db4a898c9e0c6e63298d4a7bc16923c65f5e0..28bbe8e9db6d45dea8125ec7422ecd86e352c7ad 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs @@ -117,11 +117,15 @@ public void Dispose() } } +#pragma warning disable CA1821 // Remove empty Finalizers +#if DEBUG ~WorkspaceUndoTransaction() { // make sure we closed it correctly Contract.Requires(!_transactionAlive); } +#endif +#pragma warning restore CA1821 // Remove empty Finalizers } } } diff --git a/src/VisualStudio/VisualBasic/Repl/VisualBasicInteractiveCommands.vb b/src/VisualStudio/VisualBasic/Repl/VisualBasicInteractiveCommands.vb index 73f90c962551decdf66c27368d624309f18c228f..509af9430a9b113c212e544c64e908bfe9fcec3d 100644 --- a/src/VisualStudio/VisualBasic/Repl/VisualBasicInteractiveCommands.vb +++ b/src/VisualStudio/VisualBasic/Repl/VisualBasicInteractiveCommands.vb @@ -7,7 +7,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Interactive Public Const InteractiveToolWindow = &H1 Public Const ResetInteractiveFromProject = &H2 - Public ReadOnly InteractiveCommandSetIdString As String = "93DF185E-D75B-4FDB-9D47-E90F111971C5" + Public Const InteractiveCommandSetIdString As String = "93DF185E-D75B-4FDB-9D47-E90F111971C5" Public ReadOnly InteractiveCommandSetId As Guid = New Guid(InteractiveCommandSetIdString) End Module End Namespace diff --git a/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj b/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj index 7e45c78c2a3733996c200e950c24c3efea4858c2..94bbd2abcf20ebc0d3a4964c5b2d18f76d3bc69f 100644 --- a/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj +++ b/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj @@ -98,6 +98,7 @@ + diff --git a/src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs index 35a67b9d3e1d5b73e048447dc30d7c886f88caeb..4f683b3385df8f7c43e706cb60fd22651c9e694b 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; @@ -119,57 +120,15 @@ private static TextSpan GetUsingsSpan(CompilationUnitSyntax root, NamespaceDecla return root; } - var comparer = placeSystemNamespaceFirst - ? UsingsAndExternAliasesDirectiveComparer.SystemFirstInstance - : UsingsAndExternAliasesDirectiveComparer.NormalInstance; - var usings = AddUsingDirectives(root, usingDirectives); // Keep usings sorted if they were originally sorted. - if (root.Usings.IsSorted(comparer)) - { - usings.Sort(comparer); - } + usings.SortUsingDirectives(root.Usings, placeSystemNamespaceFirst); if (root.Externs.Count == 0) { - if (root.Usings.Count == 0) - { - // We don't have any existing usings. Move any trivia on the first token - // of the file to the first using. - // - // Don't do this for doc comments, as they belong to the first element - // already in the file (like a class) and we don't want it to move to - // the using. - var firstToken = root.GetFirstToken(); - - // Remove the leading directives from the first token. - var newFirstToken = firstToken.WithLeadingTrivia( - firstToken.LeadingTrivia.Where(t => IsDocCommentOrElastic(t))); - - root = root.ReplaceToken(firstToken, newFirstToken); - - // Move the leading trivia from the first token to the first using. - var newFirstUsing = usings[0].WithLeadingTrivia( - firstToken.LeadingTrivia.Where(t => !IsDocCommentOrElastic(t))); - usings[0] = newFirstUsing; - } - else - { - var originalFirstUsing = root.Usings[0]; - if (usings[0] != originalFirstUsing) - { - // We added a new first-using. Take the trivia on the existing first using - // And move it to the new using. - var originalFirstUsingCurrentIndex = usings.IndexOf(originalFirstUsing); - - var newFirstUsing = usings[0].WithLeadingTrivia(originalFirstUsing.GetLeadingTrivia()) - .WithAppendedTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed); - - usings[0] = newFirstUsing; - usings[originalFirstUsingCurrentIndex] = originalFirstUsing.WithoutLeadingTrivia(); - } - } + root = AddImportHelpers.MoveTrivia( + CSharpSyntaxFactsService.Instance, root, root.Usings, usings); } return root.WithUsings( @@ -215,6 +174,7 @@ private static bool IsDocCommentOrElastic(SyntaxTrivia t) { usings.InsertRange(startOfLastDirective, usingDirectives); } + return usings; } } diff --git a/src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs index 48095b846ad312b966a3b8b9d7b14c282e4ce514..65d7f67c77b4330683d2d288ac83d7542329ffa0 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs @@ -2,15 +2,7 @@ using System.Collections.Generic; using System.Linq; -using System.Threading; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.CSharp.Utilities; -using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Text; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Extensions { @@ -27,24 +19,15 @@ internal static class NamespaceDeclarationSyntaxExtensions return namespaceDeclaration; } - var specialCaseSystem = placeSystemNamespaceFirst; - var comparer = specialCaseSystem - ? UsingsAndExternAliasesDirectiveComparer.SystemFirstInstance - : UsingsAndExternAliasesDirectiveComparer.NormalInstance; + var newUsings = new List(); + newUsings.AddRange(namespaceDeclaration.Usings); + newUsings.AddRange(usingDirectives); - var usings = new List(); - usings.AddRange(namespaceDeclaration.Usings); - usings.AddRange(usingDirectives); - - if (namespaceDeclaration.Usings.IsSorted(comparer)) - { - usings.Sort(comparer); - } - - usings = usings.Select(u => u.WithAdditionalAnnotations(annotations)).ToList(); - var newNamespace = namespaceDeclaration.WithUsings(usings.ToSyntaxList()); + newUsings.SortUsingDirectives(namespaceDeclaration.Usings, placeSystemNamespaceFirst); + newUsings = newUsings.Select(u => u.WithAdditionalAnnotations(annotations)).ToList(); + var newNamespace = namespaceDeclaration.WithUsings(newUsings.ToSyntaxList()); return newNamespace; } } -} +} \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/Extensions/UsingDirectiveSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/UsingDirectiveSyntaxExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..9b1b8f3139e570f70269575423742df8f92299ef --- /dev/null +++ b/src/Workspaces/CSharp/Portable/Extensions/UsingDirectiveSyntaxExtensions.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.CSharp.Utilities; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.CSharp.Extensions +{ + internal static class UsingDirectiveSyntaxExtensions + { + public static void SortUsingDirectives( + this List usingDirectives, + SyntaxList existingDirectives, + bool placeSystemNamespaceFirst) + { + var systemFirstInstance = UsingsAndExternAliasesDirectiveComparer.SystemFirstInstance; + var normalInstance = UsingsAndExternAliasesDirectiveComparer.NormalInstance; + + var specialCaseSystem = placeSystemNamespaceFirst; + var comparers = specialCaseSystem + ? (systemFirstInstance, normalInstance) + : (normalInstance, systemFirstInstance); + + // First, see if the usings were sorted according to the user's preference. If so, + // keep the same sorting after we add the using. However, if the usings weren't sorted + // according to their preference, then see if they're sorted in the other way. If so + // preserve that sorting as well. That way if the user is working with a file that + // was written on a machine with a different default, the usings will stay in a + // reasonable order. + if (existingDirectives.IsSorted(comparers.Item1)) + { + usingDirectives.Sort(comparers.Item1); + } + else if (existingDirectives.IsSorted(comparers.Item2)) + { + usingDirectives.Sort(comparers.Item2); + } + } + } +} \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs index 32b81e811f1b3cb9feea441c0aaa544e74810953..805304d438bbef6da9e27f0adeea926c1d11e599 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs +++ b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs @@ -32,6 +32,9 @@ private CSharpSyntaxFactsService() public StringComparer StringComparer { get; } = StringComparer.Ordinal; + public SyntaxTrivia ElasticCarriageReturnLineFeed + => SyntaxFactory.ElasticCarriageReturnLineFeed; + protected override IDocumentationCommentService DocumentationCommentService => CSharpDocumentationCommentService.Instance; @@ -1350,6 +1353,9 @@ public bool IsRegularComment(SyntaxTrivia trivia) public bool IsDocumentationComment(SyntaxTrivia trivia) => trivia.IsDocComment(); + public bool IsElastic(SyntaxTrivia trivia) + => trivia.IsElastic(); + public bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia) => trivia.Kind() == SyntaxKind.DocumentationCommentExteriorTrivia; diff --git a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs index cce210504efdd66a9467a0c6a0023fd437dd4324..b16f5544684c62bc81dda0123f064cc6bf4f63ee 100644 --- a/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs +++ b/src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs @@ -168,7 +168,7 @@ protected override bool CanNodeBeSimplifiedWithoutSpeculation(SyntaxNode node) return false; } - private static readonly string s_CS8019_UnusedUsingDirective = "CS8019"; + private const string s_CS8019_UnusedUsingDirective = "CS8019"; protected override void GetUnusedNamespaceImports(SemanticModel model, HashSet namespaceImports, CancellationToken cancellationToken) { diff --git a/src/Workspaces/Core/Portable/AddImports/AddImportHelpers.cs b/src/Workspaces/Core/Portable/AddImports/AddImportHelpers.cs new file mode 100644 index 0000000000000000000000000000000000000000..d360d9d994993e2147e59a3bedd7ba10c7edea6f --- /dev/null +++ b/src/Workspaces/Core/Portable/AddImports/AddImportHelpers.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.AddImports +{ + internal static class AddImportHelpers + { + public static TRootSyntax MoveTrivia( + ISyntaxFactsService syntaxFacts, + TRootSyntax root, + SyntaxList existingImports, + List newImports) + where TRootSyntax : SyntaxNode + where TImportDirectiveSyntax : SyntaxNode + { + if (existingImports.Count == 0) + { + // We don't have any existing usings. Move any trivia on the first token + // of the file to the first using. + // + // Don't do this for doc comments, as they belong to the first element + // already in the file (like a class) and we don't want it to move to + // the using. + var firstToken = root.GetFirstToken(); + + // Remove the leading directives from the first token. + var newFirstToken = firstToken.WithLeadingTrivia( + firstToken.LeadingTrivia.Where(t => IsDocCommentOrElastic(syntaxFacts, t))); + + root = root.ReplaceToken(firstToken, newFirstToken); + + // Move the leading trivia from the first token to the first using. + var newFirstUsing = newImports[0].WithLeadingTrivia( + firstToken.LeadingTrivia.Where(t => !IsDocCommentOrElastic(syntaxFacts, t))); + newImports[0] = newFirstUsing; + } + else + { + var originalFirstUsing = existingImports[0]; + if (newImports[0] != originalFirstUsing) + { + // We added a new first-using. Take the trivia on the existing first using + // And move it to the new using. + var originalFirstUsingCurrentIndex = newImports.IndexOf(originalFirstUsing); + + newImports[0] = newImports[0].WithLeadingTrivia(originalFirstUsing.GetLeadingTrivia()); + + if (!syntaxFacts.IsEndOfLineTrivia(newImports[0].GetTrailingTrivia().LastOrDefault())) + { + newImports[0] = newImports[0].WithAppendedTrailingTrivia(syntaxFacts.ElasticCarriageReturnLineFeed); + } + + newImports[originalFirstUsingCurrentIndex] = originalFirstUsing.WithoutLeadingTrivia(); + } + } + + return root; + } + + private static bool IsDocCommentOrElastic(ISyntaxFactsService syntaxFacts, SyntaxTrivia t) + => syntaxFacts.IsDocumentationComment(t) || syntaxFacts.IsElastic(t); + } +} \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs b/src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs index 21a16230fbf0d8141627bba8426d81b9c5a4384f..6f54204d791e85bc77e603b2820defb3fd858c41 100644 --- a/src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs +++ b/src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs @@ -648,7 +648,7 @@ private class SpanMarker public SyntaxAnnotation Annotation { get; } - public static readonly string AnnotationId = "SpanMarker"; + public const string AnnotationId = "SpanMarker"; private SpanMarker(SpanMarkerType type, SpanMarkerType oppositeMarkerType, SyntaxAnnotation annotation) { diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllLogger.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllLogger.cs index c1af48119044c80f2c1bc0ade46c3c9dd0a97e37..0647bb204795eef96f5438f6248fec5ebb2c94b9 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllLogger.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllLogger.cs @@ -15,25 +15,25 @@ namespace Microsoft.CodeAnalysis.CodeFixes internal static class FixAllLogger { // Fix all context logging. - private static readonly string s_codeFixProvider = "CodeFixProvider"; - private static readonly string s_codeActionEquivalenceKey = "CodeActionEquivalenceKey"; - private static readonly string s_fixAllScope = "FixAllScope"; - private static readonly string s_languageName = "LanguageName"; - private static readonly string s_documentCount = "DocumentCount"; + private const string s_codeFixProvider = "CodeFixProvider"; + private const string s_codeActionEquivalenceKey = "CodeActionEquivalenceKey"; + private const string s_fixAllScope = "FixAllScope"; + private const string s_languageName = "LanguageName"; + private const string s_documentCount = "DocumentCount"; // Fix all computation result logging. - private static readonly string s_result = "Result"; - private static readonly string s_completed = "Completed"; - private static readonly string s_timedOut = "TimedOut"; - private static readonly string s_cancelled = "Cancelled"; - private static readonly string s_allChangesApplied = "AllChangesApplied"; - private static readonly string s_subsetOfChangesApplied = "SubsetOfChangesApplied"; + private const string s_result = "Result"; + private const string s_completed = "Completed"; + private const string s_timedOut = "TimedOut"; + private const string s_cancelled = "Cancelled"; + private const string s_allChangesApplied = "AllChangesApplied"; + private const string s_subsetOfChangesApplied = "SubsetOfChangesApplied"; // Diagnostics and fixes logging. - private static readonly string s_documentsWithDiagnosticsToFix = "DocumentsWithDiagnosticsToFix"; - private static readonly string s_projectsWithDiagnosticsToFix = "ProjectsWithDiagnosticsToFix"; - private static readonly string s_totalDiagnosticsToFix = "TotalDiagnosticsToFix"; - private static readonly string s_totalFixesToMerge = "TotalFixesToMerge"; + private const string s_documentsWithDiagnosticsToFix = "DocumentsWithDiagnosticsToFix"; + private const string s_projectsWithDiagnosticsToFix = "ProjectsWithDiagnosticsToFix"; + private const string s_totalDiagnosticsToFix = "TotalDiagnosticsToFix"; + private const string s_totalFixesToMerge = "TotalFixesToMerge"; public static void LogState(FixAllState fixAllState, bool isInternalCodeFixProvider) { diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs b/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs index c0a72d63e85d6637ad27541be14ac70aa0b3c597..9abf7b357dc25d83354ea363fd4631ccb37cab45 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs +++ b/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs @@ -14,6 +14,8 @@ internal interface ISyntaxFactsService : ILanguageService bool IsCaseSensitive { get; } StringComparer StringComparer { get; } + SyntaxTrivia ElasticCarriageReturnLineFeed { get; } + bool SupportsIndexingInitializer(ParseOptions options); bool SupportsThrowExpression(ParseOptions options); @@ -48,6 +50,7 @@ internal interface ISyntaxFactsService : ILanguageService bool IsRegularComment(SyntaxTrivia trivia); bool IsDocumentationComment(SyntaxTrivia trivia); + bool IsElastic(SyntaxTrivia trivia); bool IsDocumentationComment(SyntaxNode node); bool IsNumericLiteralExpression(SyntaxNode node); @@ -304,4 +307,4 @@ internal enum DisplayNameOptions IncludeType = 1 << 3, IncludeTypeParameters = 1 << 4 } -} +} \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/NamingStyles/Serialization/NamingStylePreferences.cs b/src/Workspaces/Core/Portable/NamingStyles/Serialization/NamingStylePreferences.cs index 4d3cbd63d6df1631f63e39d5d4c83a8342e882b1..96bed287015cb384707a42dc31bfc535e794e279 100644 --- a/src/Workspaces/Core/Portable/NamingStyles/Serialization/NamingStylePreferences.cs +++ b/src/Workspaces/Core/Portable/NamingStyles/Serialization/NamingStylePreferences.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles /// internal class NamingStylePreferences : IEquatable { - private readonly static int s_serializationVersion = 4; + private const int s_serializationVersion = 4; public readonly ImmutableArray SymbolSpecifications; public readonly ImmutableArray NamingStyles; diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs index dc75366f7288d72aa7dc55a638784eff4fd96bac..d0310eeb1018e9b60195b6063d87263307107e93 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs @@ -31,7 +31,7 @@ internal static partial class ConflictResolver propertyStyle: SymbolDisplayPropertyStyle.NameOnly, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers); - private static readonly string s_metadataNameSeparators = " .,:<`>()\r\n"; + private const string s_metadataNameSeparators = " .,:<`>()\r\n"; /// /// Performs the renaming of the symbol in the solution, identifies renaming conflicts and automatically resolves them where possible. diff --git a/src/Workspaces/Core/Portable/Workspaces.csproj b/src/Workspaces/Core/Portable/Workspaces.csproj index f1eaac3dcf85c2b1dda3f1544742f19da5273707..7a63952a587ac4bcf610ef2c9f0f963dbc5ed24d 100644 --- a/src/Workspaces/Core/Portable/Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Workspaces.csproj @@ -205,6 +205,7 @@ InternalUtilities\SyntaxTreeExtensions.cs + diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb index 52cbc853df4730f38dc63547e73254a9019e522f..27dc4890fbd7601ee88fa2b5dbd73024931c68b1 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb @@ -3,6 +3,7 @@ Imports System.Runtime.CompilerServices Imports System.Threading Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.AddImports Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Utilities @@ -45,44 +46,39 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return root End If - Dim comparer = If(placeSystemNamespaceFirst, - ImportsStatementComparer.SystemFirstInstance, - ImportsStatementComparer.NormalInstance) + Dim systemFirstInstance = ImportsStatementComparer.SystemFirstInstance + Dim normalInstance = ImportsStatementComparer.NormalInstance + + Dim comparers = If(placeSystemNamespaceFirst, + (systemFirstInstance, normalInstance), + (normalInstance, systemFirstInstance)) Dim [imports] = AddImportsStatements(root, importsStatements) - ' If the user likes to have their Imports statements unsorted, allow them to - If root.Imports.IsSorted(comparer) Then - [imports].Sort(comparer) + ' First, see if the imports were sorted according to the user's preference. If so, + ' keep the same sorting after we add the import. However, if the imports weren't sorted + ' according to their preference, then see if they're sorted in the other way. If so + ' preserve that sorting as well. That way if the user is working with a file that + ' was written on a machine with a different default, the imports will stay in a + ' reasonable order. + If root.Imports.IsSorted(comparers.Item1) Then + [imports].Sort(comparers.Item1) + ElseIf root.Imports.IsSorted(comparers.Item2) Then + [imports].Sort(comparers.Item2) End If - ' If any using we added was moved to the first location, then take the trivia from - ' the start of the first token And add it to the using we added. This way things - ' Like #define's and #r's will stay above the using. - If root.Imports.Count = 0 OrElse [imports](0) IsNot root.Imports(0) Then - Dim firstToken = root.GetFirstToken - - ' Move the leading directives from the first directive to the New using. - Dim firstImport = [imports](0).WithLeadingTrivia(firstToken.LeadingTrivia.Where(Function(t) Not t.IsKind(SyntaxKind.DocumentationCommentTrivia) AndAlso Not t.IsElastic)) - - ' Remove the leading directives from the first token. - Dim newFirstToken = firstToken.WithLeadingTrivia(firstToken.LeadingTrivia.Where(Function(t) t.IsKind(SyntaxKind.DocumentationCommentTrivia) OrElse t.IsElastic)) - - ' Remove the leading trivia from the first token from the tree. - root = root.ReplaceToken(firstToken, newFirstToken) + root = AddImportHelpers.MoveTrivia( + VisualBasicSyntaxFactsService.Instance, root, root.Imports, [imports]) - ' Create the New list of imports - Dim finalImports = New List(Of ImportsStatementSyntax) - finalImports.Add(firstImport) - finalImports.AddRange(root.Imports) - finalImports.AddRange(importsStatements.Except({[imports](0)})) - finalImports.Sort(comparer) - [imports] = finalImports - End If + Return root.WithImports( + [imports].Select(Function(u) u.WithAdditionalAnnotations(annotations)).ToSyntaxList()) + End Function - Return root.WithImports([imports].ToSyntaxList).WithAdditionalAnnotations(annotations) + Private Function IsDocCommentOrElastic(t As SyntaxTrivia) As Boolean + Return t.Kind() = SyntaxKind.DocumentationCommentTrivia OrElse t.IsElastic() End Function + Private Function AddImportsStatements(root As CompilationUnitSyntax, importsStatements As IList(Of ImportsStatementSyntax)) As List(Of ImportsStatementSyntax) ' We need to try and not place the using inside of a directive if possible. Dim [imports] = New List(Of ImportsStatementSyntax) diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb index a2f5a0a2e43887e741b256fca35df80e28686163..17442977fe2a071b304ca5a46eea712d1001eb39 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb +++ b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb @@ -5,7 +5,6 @@ Imports System.Composition Imports System.Text Imports System.Threading Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.Host Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices @@ -46,6 +45,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Get End Property + Public ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia Implements ISyntaxFactsService.ElasticCarriageReturnLineFeed + Get + Return SyntaxFactory.ElasticCarriageReturnLineFeed + End Get + End Property + Protected Overrides ReadOnly Property DocumentationCommentService As IDocumentationCommentService Get Return VisualBasicDocumentationCommentService.Instance @@ -1502,6 +1507,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Return trivia.Kind = SyntaxKind.DocumentationCommentTrivia End Function + Public Function IsElastic(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFactsService.IsElastic + Return trivia.IsElastic() + End Function + Public Function IsOnTypeHeader(root As SyntaxNode, position As Integer) As Boolean Implements ISyntaxFactsService.IsOnTypeHeader Dim statement = root.FindToken(position).GetAncestor(Of TypeStatementSyntax) If statement Is Nothing Then diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb index d8c1469412ccf7d7e5aeadfb991c13d721f1d696..443c56b38c14aee7459987ab47ece235b7125aad 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb @@ -165,8 +165,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification TypeOf node.Parent Is FieldDeclarationSyntax End Function - Private Shared ReadOnly s_BC50000_UnusedImportsClause As String = "BC50000" - Private Shared ReadOnly s_BC50001_UnusedImportsStatement As String = "BC50001" + Private Const s_BC50000_UnusedImportsClause As String = "BC50000" + Private Const s_BC50001_UnusedImportsStatement As String = "BC50001" Protected Overrides Sub GetUnusedNamespaceImports(model As SemanticModel, namespaceImports As HashSet(Of SyntaxNode), cancellationToken As CancellationToken) Dim root = model.SyntaxTree.GetRoot()