diff --git a/.editorconfig b/.editorconfig
index b476f6c880c..1e9ff004ebb 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -35,9 +35,6 @@ indent_size = 2
[*.json]
indent_size = 2
-[*.groovy]
-indent_size = 2
-
# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
@@ -234,6 +231,7 @@ dotnet_diagnostic.CA1821.severity = none # Remove empty Finalizers
dotnet_diagnostic.CA1823.severity = warning # Avoid unused private fields
dotnet_diagnostic.CA1824.severity = none # Mark assemblies with NeutralResourcesLanguageAttribute
dotnet_diagnostic.CA1851.severity = warning # Detect multiple enumeration
+dotnet_diagnostic.CA1852.severity = warning # Seal internal types
dotnet_diagnostic.CA2200.severity = none # Rethrow to preserve stack details
# Microsoft.NetCore.Analyzers
@@ -386,6 +384,8 @@ dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessa
dotnet_diagnostic.IDE0030.severity = warning # Use coalesce expression (nullable) int? y = x.HasValue ? x.Value : 0 int? y = x ?? 0;
dotnet_diagnostic.IDE0030WithoutSuggestion.severity = error
dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (nullable)
+dotnet_diagnostic.IDE0051.severity = warning # Private member unused
+dotnet_diagnostic.IDE0052.severity = warning # Remove unread private members
dotnet_diagnostic.IDE0079.severity = warning # Unused suppresion
dotnet_diagnostic.IDE0083.severity = warning # Use pattern matching
dotnet_diagnostic.IDE0084.severity = warning # Use IsNot
diff --git a/spelling.dic b/spelling.dic
index 601a67eb2c3..f041bf7edf3 100644
--- a/spelling.dic
+++ b/spelling.dic
@@ -3,6 +3,7 @@ async
awaiter
blazor
boolean
+bstr
cmdid
combobox
commandbar
@@ -10,17 +11,18 @@ csproj
debuggable
debugsettings
devdiv
-Dirs
+dirs
docdata
enum
enums
fsscript
func
+fxcop
github
globbing
guid
hwnd
-Impl
+impl
intelli
intellisense
itemid
@@ -57,8 +59,10 @@ shproj
typeof
uint
unadvise
+unescape
+unescapes
ushort
-Usings
+usings
vswhidbey
xaml
xmlns
diff --git a/src/Common/ManagedCodeMarkers.vb b/src/Common/ManagedCodeMarkers.vb
index 8b14925ee88..b2a69e4223a 100644
--- a/src/Common/ManagedCodeMarkers.vb
+++ b/src/Common/ManagedCodeMarkers.vb
@@ -11,7 +11,7 @@ Namespace Microsoft.Internal.Performance
' Singleton access
Public Shared ReadOnly Instance As CodeMarkers = New CodeMarkers()
- Private Class NativeMethods
+ Private NotInheritable Class NativeMethods
' Add a private constructor to prevent compiler from generating a default constructor (FxCop warning CA1812)
Private Sub New()
diff --git a/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabButton.vb b/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabButton.vb
index ee4f47abb40..5a589b27360 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabButton.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabButton.vb
@@ -232,7 +232,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'''
''' custom build accessible object class
'''
- Private Class DesignerTabButtonAccessibleObject
+ Private NotInheritable Class DesignerTabButtonAccessibleObject
Inherits ButtonBaseAccessibleObject
' button which this accessible object belongs to
diff --git a/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabControl.vb b/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabControl.vb
index e825d16f69b..7a7836b179e 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabControl.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabControl.vb
@@ -581,7 +581,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
''' b) has flatstyle
''' c) shows a border only when the mouse hovers over it
'''
- Private Class ImageButton
+ Private NotInheritable Class ImageButton
Inherits Button
Public Sub New()
@@ -633,7 +633,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'''
''' custom build accessible object class
'''
- Private Class DesignerTabControlAccessibleObject
+ Private NotInheritable Class DesignerTabControlAccessibleObject
Inherits ControlAccessibleObject
' button which this accessible object belongs to
diff --git a/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb b/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb
index f23a3704b9a..66e09d27a39 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb
@@ -31,7 +31,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
'Property page GUIDs. These are used only for sorting the tabs in the project designer, and for providing a
' unique ID for SQM. Both cases are optional (we handle getting property pages with GUIDs we don't recognize).
'PERF: NOTE: Initializing GUIDs from numeric values as below is a lot faster than initializing from strings.
- Public Class KnownPropertyPageGuids
+ Public NotInheritable Class KnownPropertyPageGuids
Public Shared ReadOnly GuidApplicationPage_VB As Guid = New Guid(&H8998E48EUI, &HB89AUS, &H4034US, &HB6, &H6E, &H35, &H3D, &H8C, &H1F, &HDC, &H2E)
Public Shared ReadOnly GuidApplicationPage_VB_WPF As Guid = New Guid(&HAA1F44UI, &H2BA3US, &H4EAAUS, &HB5, &H4A, &HCE, &H18, &H0, &HE, &H6C, &H5D)
Public Shared ReadOnly GuidApplicationPage_CS As Guid = New Guid(&H5E9A8AC2UI, &H4F34US, &H4521US, CByte(&H85), CByte(&H8F), CByte(&H4C), CByte(&H24), CByte(&H8B), CByte(&HA3), CByte(&H15), CByte(&H32))
@@ -592,7 +592,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
End Function
#Region "Telemetry"
- Public Class TelemetryLogger
+ Public NotInheritable Class TelemetryLogger
'A list of known editor guids
' Each property page will be reported back to telemetry with the 1-based index in which it is present
@@ -692,7 +692,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
End Class
#End Region
- Public Class ObjectSerializer
+ Public NotInheritable Class ObjectSerializer
' KnownType information is used by DataContractSerializer for serialization of types that it may not know of currently.
' Size is used in Bitmap and has issues being recognized in DataContractSerializer for the unit tests of this class.
diff --git a/src/Microsoft.VisualStudio.AppDesigner/Common/WaitCursor.vb b/src/Microsoft.VisualStudio.AppDesigner/Common/WaitCursor.vb
index 2bbbb96b233..69b1d68a48d 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/Common/WaitCursor.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/Common/WaitCursor.vb
@@ -1,4 +1,4 @@
-' Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.
+' Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.
Option Strict On
Option Explicit On
@@ -20,7 +20,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
' End Using
' End Sub
'**************************************************************************
- Friend Class WaitCursor
+ Friend NotInheritable Class WaitCursor
Implements IDisposable
Private _previousCursor As Cursor
diff --git a/src/Microsoft.VisualStudio.AppDesigner/Common/switches.vb b/src/Microsoft.VisualStudio.AppDesigner/Common/switches.vb
index dfd2d498e7f..153918e19b5 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/Common/switches.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/Common/switches.vb
@@ -143,7 +143,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
'''
''' Contains predefined switches for enabling/disabling trace output or code instrumentation.
'''
- Friend Class Switches
+ Friend NotInheritable Class Switches
'------------- Resource Editor -------------
@@ -395,7 +395,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
'''
''' A Switch which has a simple enum value (either as integer or string representation)
'''
- Public Class EnumSwitch(Of T)
+ Public NotInheritable Class EnumSwitch(Of T)
Inherits Switch
Public Sub New(DisplayName As String, Description As String)
diff --git a/src/Microsoft.VisualStudio.AppDesigner/Common/wmuserconstants.vb b/src/Microsoft.VisualStudio.AppDesigner/Common/wmuserconstants.vb
index 412f75599bf..8e3cec70730 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/Common/wmuserconstants.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/Common/wmuserconstants.vb
@@ -4,7 +4,7 @@ Imports Microsoft.VisualStudio.Editors.AppDesInterop
Namespace Microsoft.VisualStudio.Editors.AppDesCommon
- Friend Class WmUserConstants
+ Friend NotInheritable Class WmUserConstants
Public Const WM_REFPAGE_REFERENCES_REFRESH As Integer = Win32Constant.WM_USER + 21
Public Const WM_REFPAGE_IMPORTCHANGED As Integer = Win32Constant.WM_USER + 22
Public Const WM_REFPAGE_IMPORTS_REFRESH As Integer = Win32Constant.WM_USER + 24
diff --git a/src/Microsoft.VisualStudio.AppDesigner/DesignerFramework/DesignerWindowPaneProviderBase.vb b/src/Microsoft.VisualStudio.AppDesigner/DesignerFramework/DesignerWindowPaneProviderBase.vb
index 5b0992b865e..bffe2b12c64 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/DesignerFramework/DesignerWindowPaneProviderBase.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/DesignerFramework/DesignerWindowPaneProviderBase.vb
@@ -436,7 +436,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesDesignerFramework
''' A toplevel control is needed to handle SystemEvents. When the control is hosted in a native window, there will be no parent WinForm control.
''' Form could handle this correctly. However, for some reason, we couldn't use it here. We have to create a customized class to make a non-form topLevel control.
'''
- Private Class TopLevelControl
+ Private NotInheritable Class TopLevelControl
Inherits Control
'''
diff --git a/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropPageUserControlBase.vb b/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropPageUserControlBase.vb
index 2d3257fc9c3..20be958d672 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropPageUserControlBase.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropPageUserControlBase.vb
@@ -154,7 +154,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
End Enum
'Used for caching property change notification until after Apply is done
- Private Class PropertyChange
+ Private NotInheritable Class PropertyChange
Public ReadOnly DispId As Integer
Public ReadOnly Source As PropertyChangeSource
diff --git a/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropertyControlData.vb b/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropertyControlData.vb
index e88b4656ef0..966ccc17870 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropertyControlData.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/PropPages/PropertyControlData.vb
@@ -1565,7 +1565,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
''' Helper class for PropertyDescriptorSetValue - detects if a PropertyDescriptor.SetValue
''' fails due to a canceled checkout...
'''
- Private Class PropertyDescriptorSetValueHelper
+ Private NotInheritable Class PropertyDescriptorSetValueHelper
Private _valueChangedWasFired As Boolean
'''
diff --git a/src/Microsoft.VisualStudio.AppDesigner/PropPages/ValidationException.vb b/src/Microsoft.VisualStudio.AppDesigner/PropPages/ValidationException.vb
index 2f3f2a93cae..a44b2195cc6 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/PropPages/ValidationException.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/PropPages/ValidationException.vb
@@ -7,7 +7,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
'''
''' The exception will be thrown when validation failed...
'''
- Friend Class ValidationException
+ Friend NotInheritable Class ValidationException
Inherits ApplicationException
Private ReadOnly _validationResult As ValidationResult
diff --git a/src/Microsoft.VisualStudio.AppDesigner/interop/NativeMethods.vb b/src/Microsoft.VisualStudio.AppDesigner/interop/NativeMethods.vb
index 5d86b5c5439..49a73a1a439 100644
--- a/src/Microsoft.VisualStudio.AppDesigner/interop/NativeMethods.vb
+++ b/src/Microsoft.VisualStudio.AppDesigner/interop/NativeMethods.vb
@@ -82,7 +82,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesInterop
Public Const UISF_HIDEFOCUS As Integer = &H1
Public Const UISF_HIDEACCEL As Integer = &H2
- Public Class ConnectionPointCookie
+ Public NotInheritable Class ConnectionPointCookie
Private _connectionPoint As IConnectionPoint
Private _connectionPoint2 As ComTypes.IConnectionPoint
Private _cookie As UInteger
diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/Handlers/ProjectFilePathAndDisplayNameEvaluationHandler.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/Handlers/ProjectFilePathAndDisplayNameEvaluationHandler.cs
index 943efd3e71d..91addd57011 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/Handlers/ProjectFilePathAndDisplayNameEvaluationHandler.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/Handlers/ProjectFilePathAndDisplayNameEvaluationHandler.cs
@@ -13,13 +13,11 @@ namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices.Handlers
[Export(typeof(IWorkspaceUpdateHandler))]
internal class ProjectFilePathAndDisplayNameEvaluationHandler : IWorkspaceUpdateHandler, IProjectEvaluationHandler
{
- private readonly UnconfiguredProject _project;
private readonly IImplicitlyActiveDimensionProvider _implicitlyActiveDimensionProvider;
[ImportingConstructor]
- public ProjectFilePathAndDisplayNameEvaluationHandler(UnconfiguredProject project, IImplicitlyActiveDimensionProvider implicitlyActiveDimensionProvider)
+ public ProjectFilePathAndDisplayNameEvaluationHandler(UnconfiguredProject _, IImplicitlyActiveDimensionProvider implicitlyActiveDimensionProvider)
{
- _project = project;
_implicitlyActiveDimensionProvider = implicitlyActiveDimensionProvider;
}
diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/WPF/AppDotXamlDocument.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/WPF/AppDotXamlDocument.cs
index 3f6348b9956..7ed9f134d65 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/WPF/AppDotXamlDocument.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/WPF/AppDotXamlDocument.cs
@@ -75,14 +75,6 @@ private string GetText(Location startLocation, Location endLocation)
return GetText(startLocation.LineIndex, startLocation.CharIndex, endLocation.LineIndex, endLocation.CharIndex);
}
- ///
- /// Retrieves the text starting at the given point and with the given length
- ///
- private string GetText(Location startLocation, int count)
- {
- return GetText(startLocation.LineIndex, startLocation.CharIndex, count);
- }
-
///
/// Retrieves all of the text in the buffer
///
@@ -294,12 +286,7 @@ private static int FindClosingAngleBracketHelper(string line)
{
MoveToApplicationRootElement(reader);
XamlProperty? prop = FindPropertyAsAttributeInCurrentElement(reader, ApplicationElementName, propertyName);
- if (prop is null)
- {
- prop = FindPropertyAsChildElementInCurrentElement(reader, ApplicationElementName, propertyName);
- }
-
- return prop;
+ return prop ?? FindPropertyAsChildElementInCurrentElement(reader, ApplicationElementName, propertyName);
}
private XamlPropertyInAttributeSyntax? FindPropertyAsAttributeInCurrentElement(XmlTextReader reader, string optionalPropertyQualifier, string propertyName)
@@ -411,7 +398,6 @@ private static int FindClosingAngleBracketHelper(string line)
// Found
Location tagStart = new(reader);
- Location tagEnd = new(reader);
Location? startTagEndingBracketLocation = FindClosingAngleBracket(tagStart);
if (startTagEndingBracketLocation is null)
@@ -469,7 +455,6 @@ private static int FindClosingAngleBracketHelper(string line)
}
// Reader is at location 'x' of . So we want -2 from this location.
- Location currentPosition2 = new(reader);
Location valueEndPlusOne = new Location(reader).Shift(-2);
// Get the inner text and unescape it.
@@ -499,10 +484,7 @@ private static int FindClosingAngleBracketHelper(string line)
private void SetApplicationPropertyValue(string propertyName, string? value)
{
- if (value is null)
- {
- value = string.Empty;
- }
+ value ??= string.Empty;
using BufferLock bufferLock = new(_vsTextLines, this);
@@ -549,14 +531,6 @@ private void SetApplicationPropertyValue(string propertyName, string? value)
}
}
- ///
- /// Replace the text at the given location in the buffer with new text.
- ///
- private void ReplaceText(Location sourceStart, int sourceLength, string newText)
- {
- ((IReplaceText)this).ReplaceText(sourceStart, new Location(sourceStart.LineIndex, sourceStart.CharIndex + sourceLength), newText);
- }
-
///
/// Replace the text at the given location in the buffer with new text.
///
@@ -576,48 +550,6 @@ void IReplaceText.ReplaceText(Location sourceStart, Location sourceEnd, string n
}
}
- ///
- /// Given the location of the start of an element tag, makes sure that it has an end tag.
- /// If the element tag is closed by "/>" instead of an end element, it is expanded
- /// into a start and end tag.
- ///
- ///
- /// The name of the element at the given location
- private void MakeSureElementHasStartAndEndTag(Location tagStartLocation, string elementName)
- {
- if (!"<".Equals(GetText(tagStartLocation, 1), StringComparison.Ordinal))
- {
- DiagnosticsDebug.Fail("MakeSureElementHasStartAndEndTags: The start location doesn't point to the start of an element tag");
- ThrowUnexpectedFormatException(tagStartLocation);
- }
-
- Location? startTagEndingBracketLocation = FindClosingAngleBracket(tagStartLocation);
- if (startTagEndingBracketLocation is null)
- {
- ThrowUnexpectedFormatException(tagStartLocation);
- }
-
- if (">".Equals(GetText(startTagEndingBracketLocation, 1), StringComparison.Ordinal))
- {
- // The element tag is of the form. We assume that there is an ending tag, and
- // we don't need to do anything.
- }
- else
- {
- // It must be an empty tag of the form.
- string slashAndEndBracket = "/>";
- if (!slashAndEndBracket.Equals(GetText(startTagEndingBracketLocation, slashAndEndBracket.Length), StringComparison.Ordinal))
- {
- DiagnosticsDebug.Fail("FindClosingAngleBracket returned the wrong location?");
- ThrowUnexpectedFormatException(startTagEndingBracketLocation);
- }
-
- // We need to change into
- string newText = ">" + elementName + ">";
- ReplaceText(startTagEndingBracketLocation, slashAndEndBracket.Length, newText);
- }
- }
-
///
/// Finds the value of the StartupUri property inside the xaml file. If
/// the property is not set in the xaml, an empty string is returned.
@@ -655,29 +587,6 @@ private static void ThrowUnexpectedFormatException(Location location)
throw new XamlReadWriteException(string.Format(VSResources.WPFApp_Xaml_UnexpectedFormat_2, location.LineIndex + 1, location.CharIndex + 1));
}
- ///
- /// Verify the validity of the Application.xaml file, and throw an exception if
- /// problems are found.
- ///
- private void VerifyAppXamlIsValidAndThrowIfNot()
- {
- using BufferLock bufferLock = new(_vsTextLines, this);
-
- XmlTextReader reader = CreateXmlTextReader();
- MoveToApplicationRootElement(reader);
-
- // Read through the Application element, including any child elements, to
- // ensure everything is properly closed.
- // The name of the element to find is irrelevant, as there shouldn't be
- // any elements following Application.
- reader.ReadToFollowing("Dummy Element");
-
- // If we made it to here, the .xaml file should be well-formed enough for us to read
- // it properly. As a final check, though, try getting some common properties.
- GetStartupUri();
- GetShutdownMode();
- }
-
void IDebugLockCheck.OnBufferLock()
{
_debugBufferLockCount++;
diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImplicitUsingsValueProvider.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImplicitUsingsValueProvider.cs
index dafa701ec40..b19e0614754 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImplicitUsingsValueProvider.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImplicitUsingsValueProvider.cs
@@ -10,16 +10,14 @@ internal class ImplicitUsingsValueProvider : InterceptingPropertyValueProviderBa
{
private readonly IProjectAccessor _projectAccessor;
private readonly ConfiguredProject _configuredProject;
- private readonly IProjectThreadingService _threadingService;
private const string UsingItemType = "Using";
[ImportingConstructor]
- public ImplicitUsingsValueProvider(IProjectAccessor projectAccessor, ConfiguredProject configuredProject, IProjectThreadingService threadingService)
+ public ImplicitUsingsValueProvider(IProjectAccessor projectAccessor, ConfiguredProject configuredProject)
{
_projectAccessor = projectAccessor;
_configuredProject = configuredProject;
- _threadingService = threadingService;
}
private async Task> GetImplicitUsingsAsync()
@@ -51,7 +49,7 @@ private async Task GetImplicitUsingsStringAsync()
List usings = await GetImplicitUsingsAsync();
return JsonConvert.SerializeObject(usings);
}
-
+
public override Task OnGetEvaluatedPropertyValueAsync(string propertyName, string evaluatedPropertyValue, IProjectProperties defaultProperties)
{
return GetImplicitUsingsStringAsync();
@@ -105,7 +103,7 @@ await _projectAccessor.OpenProjectForWriteAsync(_configuredProject, project =>
usingsToSet.Remove(existingUsing);
}
}
-
+
// Verify we have at least one valid import to add before acquiring a write lock.
if (usingsToSet.Any(importToAdd => importToAdd.Include.Length > 0))
{
@@ -124,7 +122,7 @@ await _projectAccessor.OpenProjectForWriteAsync(_configuredProject, project =>
.Where(i => string.Equals(usingToSet.Include, i.EvaluatedInclude, StringComparisons.ItemNames) && !i.IsImported)
);
}
-
+
if (usingToSet.Include.Length > 0 && (usingToSet.Alias is null || usingToSet.Alias.Length > 0))
{
var usingMetadata = new List>();
@@ -137,7 +135,7 @@ await _projectAccessor.OpenProjectForWriteAsync(_configuredProject, project =>
{
usingMetadata.Add(new KeyValuePair("Static", usingToSet.IsStatic.ToString()));
}
-
+
project.AddItem(UsingItemType, usingToSet.Include, usingMetadata);
}
}
diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImportedNamespacesValueProvider.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImportedNamespacesValueProvider.cs
index 49379a80822..24e41ff6415 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImportedNamespacesValueProvider.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Properties/InterceptedProjectProperties/ReferencesPage/ImportedNamespacesValueProvider.cs
@@ -10,15 +10,13 @@ namespace Microsoft.VisualStudio.ProjectSystem.Properties;
internal sealed class ImportedNamespacesValueProvider : InterceptingPropertyValueProviderBase
{
private readonly ConfiguredProject _configuredProject;
- private readonly IProjectThreadingService _threadingService;
private readonly IProjectAccessor _projectAccessor;
private readonly ConcurrentHashSet _specialImports;
-
+
[ImportingConstructor]
- public ImportedNamespacesValueProvider(ConfiguredProject configuredProject, IProjectThreadingService threadingService, IProjectAccessor projectAccessor)
+ public ImportedNamespacesValueProvider(ConfiguredProject configuredProject, IProjectAccessor projectAccessor)
{
_configuredProject = configuredProject;
- _threadingService = threadingService;
_projectAccessor = projectAccessor;
_specialImports = new ConcurrentHashSet();
}
@@ -41,7 +39,7 @@ private async Task GetSelectedImportStringAsync()
{
return KeyValuePairListEncoding.Format(await GetSelectedImportListAsync());
}
-
+
private async Task> GetSelectedImportListAsync()
{
string projectName = Path.GetFileNameWithoutExtension(_configuredProject.UnconfiguredProject.FullPath);
@@ -61,7 +59,7 @@ private async Task GetSelectedImportStringAsync()
return selectedImports;
}
-
+
public override async Task OnGetUnevaluatedPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties)
{
await ((ConfiguredProject2)_configuredProject).EnsureProjectEvaluatedAsync();
@@ -96,10 +94,9 @@ await _projectAccessor.OpenProjectForWriteAsync(_configuredProject, project =>
{
_specialImports.Add(value);
}
-
+
project.RemoveItem(importProjectItem);
});
-
}
catch (Exception ex)
{
@@ -110,7 +107,7 @@ await _projectAccessor.OpenProjectForWriteAsync(_configuredProject, project =>
}
}
}
-
+
importsToAdd.Remove(value);
}
diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/SolutionBuildContext.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/SolutionBuildContext.cs
index f4af5ccb854..26b67360e8b 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/SolutionBuildContext.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/SolutionBuildContext.cs
@@ -10,7 +10,6 @@ namespace Microsoft.VisualStudio.ProjectSystem.UpToDate;
///
internal sealed class SolutionBuildContext
{
-
///
/// A cache of timestamps for the absolute paths of both source and target of copy items
/// across all projects.
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemHostConfiguration.cs b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemHostConfiguration.cs
index 0ee02b731d2..9a9f674c780 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemHostConfiguration.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemHostConfiguration.cs
@@ -6,7 +6,7 @@
namespace Microsoft.VisualStudio
{
- internal class ProjectSystemHostConfiguration : VisualStudioHostConfiguration
+ internal sealed class ProjectSystemHostConfiguration : VisualStudioHostConfiguration
{
// This combined with TestBase.IncludeReferencedAssembliesInHostComposition set to false, deliberately limit
// the number of assemblies added to the composition to reduce MEF composition errors in the build log.
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemOperationsConfiguration.cs b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemOperationsConfiguration.cs
index e9e021c0b25..2fddd238b34 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemOperationsConfiguration.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/Environment/ProjectSystemOperationsConfiguration.cs
@@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio
{
// Heavily based on MsTestOperationsConfiguration, which is only needed so that we can control the CompositionAssemblies
// to avoid MEF composition errors being output into the test output and making it harder to understand the build log.
- internal class ProjectSystemOperationsConfiguration : OperationsConfiguration
+ internal sealed class ProjectSystemOperationsConfiguration : OperationsConfiguration
{
internal ProjectSystemOperationsConfiguration(TestContext testContext)
{
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/LifetimeActions/ShutdownVisualStudioAfterLastTestLifetimeAction.cs b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/LifetimeActions/ShutdownVisualStudioAfterLastTestLifetimeAction.cs
index 2caf26e4e9a..6bf1cf4913e 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/LifetimeActions/ShutdownVisualStudioAfterLastTestLifetimeAction.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.IntegrationTests/LifetimeActions/ShutdownVisualStudioAfterLastTestLifetimeAction.cs
@@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.LifetimeActions
///
[ProvidesOperationsExtension]
[Export(typeof(ITestLifetimeAction))]
- internal class ShutdownVisualStudioAfterLastTestLifetimeAction : ITestLifetimeAction
+ internal sealed class ShutdownVisualStudioAfterLastTestLifetimeAction : ITestLifetimeAction
{
private static IntegrationTestBase? _lastTest;
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IFileSystemMock.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IFileSystemMock.cs
index 0a616e84af1..7d507596640 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IFileSystemMock.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IFileSystemMock.cs
@@ -209,16 +209,5 @@ private FileData GetFileData(string path)
return fileData;
}
-
- private FileData GetOrAddFileData(string path)
- {
- if (!Files.TryGetValue(path, out FileData fileData))
- {
- fileData = new();
- Files.Add(path, fileData);
- }
-
- return fileData;
- }
}
}
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/References/ReferenceCleanupServiceTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/References/ReferenceCleanupServiceTests.cs
index 62bda9830ea..9f41a4fbab9 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/References/ReferenceCleanupServiceTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/References/ReferenceCleanupServiceTests.cs
@@ -20,23 +20,13 @@ public class ReferenceCleanupServiceTests
private static Mock? s_item;
- private static Mock? _packageServicesMock1;
- private static Mock? _assemblyServicesMock1;
-
- private static Mock? _packageServicesMock2;
- private static Mock? _assemblyServicesMock2;
-
- private static Mock? _packageServicesMock3;
- private static Mock? _assemblyServicesMock3;
-
[Fact]
public async Task GetProjectReferencesAsync_NoValidProjectFound_ThrowsException()
{
var referenceCleanupService = Setup();
await Assert.ThrowsAsync(() =>
- referenceCleanupService.GetProjectReferencesAsync("UnknownProject", CancellationToken.None)
- );
+ referenceCleanupService.GetProjectReferencesAsync("UnknownProject", CancellationToken.None));
}
[Fact]
@@ -70,8 +60,7 @@ public async Task UpdateReferenceAsync_TryUpdateReferenceAsync_ShouldThrowExcept
new ProjectSystemReferenceUpdate(ProjectSystemUpdateAction.Remove, new ProjectSystemReferenceInfo(ProjectSystemReferenceType.Package, _package3, true));
await Assert.ThrowsAsync(() =>
- referenceCleanupService.TryUpdateReferenceAsync(_projectPath1, referenceUpdate1, CancellationToken.None)
- );
+ referenceCleanupService.TryUpdateReferenceAsync(_projectPath1, referenceUpdate1, CancellationToken.None));
}
[Fact]
@@ -120,24 +109,26 @@ private void AddLoadedProject(string projectPath, Func
- {
- (_projectPath2, PropertySerializer.SimpleTypes.ToString(false)),
- (_projectPath3, PropertySerializer.SimpleTypes.ToString(false))
- }, new List<(string, string)>
- {
- (_package3 , PropertySerializer.SimpleTypes.ToString(false))
- }, new List<(string, string)>
- {
- (_assembly1, PropertySerializer.SimpleTypes.ToString(false)),
- (_assembly2, PropertySerializer.SimpleTypes.ToString(false))
- },
- out _packageServicesMock1, out _assemblyServicesMock1);
+ return CreateConfiguredProjectServicesForProject(
+ new List<(string, string)>
+ {
+ (_projectPath2, PropertySerializer.SimpleTypes.ToString(false)),
+ (_projectPath3, PropertySerializer.SimpleTypes.ToString(false))
+ },
+ new List<(string, string)>
+ {
+ (_package3 , PropertySerializer.SimpleTypes.ToString(false))
+ },
+ new List<(string, string)>
+ {
+ (_assembly1, PropertySerializer.SimpleTypes.ToString(false)),
+ (_assembly2, PropertySerializer.SimpleTypes.ToString(false))
+ });
}
private static ConfiguredProjectServices CreateConfiguredProjectServicesForProject2()
{
- return createConfiguredProjectServicesForProject(
+ return CreateConfiguredProjectServicesForProject(
new List<(string, string)>
{
(_projectPath3, PropertySerializer.SimpleTypes.ToString(true))
@@ -148,23 +139,19 @@ private static ConfiguredProjectServices CreateConfiguredProjectServicesForProje
(_assembly1, PropertySerializer.SimpleTypes.ToString(true)),
(_assembly2, PropertySerializer.SimpleTypes.ToString(true)),
(_assembly3, PropertySerializer.SimpleTypes.ToString(true))
- },
- out _packageServicesMock2, out _assemblyServicesMock2);
+ });
}
private static ConfiguredProjectServices CreateConfiguredProjectServicesForProject3()
{
- return createConfiguredProjectServicesForProject(
- new List<(string, string)> { },
+ return CreateConfiguredProjectServicesForProject(
new List<(string, string)> { },
new List<(string, string)> { },
- out _packageServicesMock3, out _assemblyServicesMock3);
+ new List<(string, string)> { });
}
- private static ConfiguredProjectServices createConfiguredProjectServicesForProject(
- List<(string, string)> projects, List<(string, string)> packages, List<(string, string)> assemblies,
- out Mock packageServicesMock,
- out Mock assemblyServiceMock)
+ private static ConfiguredProjectServices CreateConfiguredProjectServicesForProject(
+ List<(string, string)> projects, List<(string, string)> packages, List<(string, string)> assemblies)
{
var projectReferencesService = new Mock();
IImmutableSet unresolvedProjectReferences =
@@ -174,13 +161,11 @@ private static ConfiguredProjectServices createConfiguredProjectServicesForProje
var packageReferencesService = new Mock();
IImmutableSet unresolvedPackageReferences = CreateReferences(packages);
packageReferencesService.Setup(c => c.GetUnresolvedReferencesAsync()).ReturnsAsync(unresolvedPackageReferences);
- packageServicesMock = packageReferencesService;
var assemblyReferencesService = new Mock();
IImmutableSet unresolvedAssemblyReferences =
CreateReferences(assemblies);
assemblyReferencesService.Setup(c => c.GetUnresolvedReferencesAsync()).ReturnsAsync(unresolvedAssemblyReferences);
- assemblyServiceMock = assemblyReferencesService;
var configuredProjectServices = ConfiguredProjectServicesFactory.Create(
projectReferences: projectReferencesService.Object, packageReferences: packageReferencesService.Object,