Skip to content

Commit 8ee566e

Browse files
authored
Merge pull request #9140 from drewnoakes/editorconfig-updates
Update editorconfig and fix warnings
2 parents bf4f33e + 8d6e41f commit 8ee566e

File tree

24 files changed

+67
-188
lines changed

24 files changed

+67
-188
lines changed

.editorconfig

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ indent_size = 2
3535
[*.json]
3636
indent_size = 2
3737

38-
[*.groovy]
39-
indent_size = 2
40-
4138
# Dotnet code style settings:
4239
[*.{cs,vb}]
4340
# Sort using and Import directives with System.* appearing first
@@ -234,6 +231,7 @@ dotnet_diagnostic.CA1821.severity = none # Remove empty Finalizers
234231
dotnet_diagnostic.CA1823.severity = warning # Avoid unused private fields
235232
dotnet_diagnostic.CA1824.severity = none # Mark assemblies with NeutralResourcesLanguageAttribute
236233
dotnet_diagnostic.CA1851.severity = warning # Detect multiple enumeration
234+
dotnet_diagnostic.CA1852.severity = warning # Seal internal types
237235
dotnet_diagnostic.CA2200.severity = none # Rethrow to preserve stack details
238236

239237
# Microsoft.NetCore.Analyzers
@@ -386,6 +384,8 @@ dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessa
386384
dotnet_diagnostic.IDE0030.severity = warning # Use coalesce expression (nullable) int? y = x.HasValue ? x.Value : 0 int? y = x ?? 0;
387385
dotnet_diagnostic.IDE0030WithoutSuggestion.severity = error
388386
dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (nullable)
387+
dotnet_diagnostic.IDE0051.severity = warning # Private member unused
388+
dotnet_diagnostic.IDE0052.severity = warning # Remove unread private members
389389
dotnet_diagnostic.IDE0079.severity = warning # Unused suppresion
390390
dotnet_diagnostic.IDE0083.severity = warning # Use pattern matching
391391
dotnet_diagnostic.IDE0084.severity = warning # Use IsNot

spelling.dic

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@ async
33
awaiter
44
blazor
55
boolean
6+
bstr
67
cmdid
78
combobox
89
commandbar
910
csproj
1011
debuggable
1112
debugsettings
1213
devdiv
13-
Dirs
14+
dirs
1415
docdata
1516
enum
1617
enums
1718
fsscript
1819
func
20+
fxcop
1921
github
2022
globbing
2123
guid
2224
hwnd
23-
Impl
25+
impl
2426
intelli
2527
intellisense
2628
itemid
@@ -57,8 +59,10 @@ shproj
5759
typeof
5860
uint
5961
unadvise
62+
unescape
63+
unescapes
6064
ushort
61-
Usings
65+
usings
6266
vswhidbey
6367
xaml
6468
xmlns

src/Common/ManagedCodeMarkers.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Namespace Microsoft.Internal.Performance
1111
' Singleton access
1212
Public Shared ReadOnly Instance As CodeMarkers = New CodeMarkers()
1313

14-
Private Class NativeMethods
14+
Private NotInheritable Class NativeMethods
1515

1616
' Add a private constructor to prevent compiler from generating a default constructor (FxCop warning CA1812)
1717
Private Sub New()

src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabButton.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
232232
'''<summary>
233233
''' custom build accessible object class
234234
'''</summary>
235-
Private Class DesignerTabButtonAccessibleObject
235+
Private NotInheritable Class DesignerTabButtonAccessibleObject
236236
Inherits ButtonBaseAccessibleObject
237237

238238
' button which this accessible object belongs to

src/Microsoft.VisualStudio.AppDesigner/ApplicationDesigner/ProjectDesignerTabControl.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
581581
''' b) has flatstyle
582582
''' c) shows a border only when the mouse hovers over it
583583
''' </summary>
584-
Private Class ImageButton
584+
Private NotInheritable Class ImageButton
585585
Inherits Button
586586

587587
Public Sub New()
@@ -633,7 +633,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
633633
'''<summary>
634634
''' custom build accessible object class
635635
'''</summary>
636-
Private Class DesignerTabControlAccessibleObject
636+
Private NotInheritable Class DesignerTabControlAccessibleObject
637637
Inherits ControlAccessibleObject
638638

639639
' button which this accessible object belongs to

src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
3131
'Property page GUIDs. These are used only for sorting the tabs in the project designer, and for providing a
3232
' unique ID for SQM. Both cases are optional (we handle getting property pages with GUIDs we don't recognize).
3333
'PERF: NOTE: Initializing GUIDs from numeric values as below is a lot faster than initializing from strings.
34-
Public Class KnownPropertyPageGuids
34+
Public NotInheritable Class KnownPropertyPageGuids
3535
Public Shared ReadOnly GuidApplicationPage_VB As Guid = New Guid(&H8998E48EUI, &HB89AUS, &H4034US, &HB6, &H6E, &H35, &H3D, &H8C, &H1F, &HDC, &H2E)
3636
Public Shared ReadOnly GuidApplicationPage_VB_WPF As Guid = New Guid(&HAA1F44UI, &H2BA3US, &H4EAAUS, &HB5, &H4A, &HCE, &H18, &H0, &HE, &H6C, &H5D)
3737
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
592592
End Function
593593

594594
#Region "Telemetry"
595-
Public Class TelemetryLogger
595+
Public NotInheritable Class TelemetryLogger
596596

597597
'A list of known editor guids
598598
' 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
692692
End Class
693693
#End Region
694694

695-
Public Class ObjectSerializer
695+
Public NotInheritable Class ObjectSerializer
696696

697697
' KnownType information is used by DataContractSerializer for serialization of types that it may not know of currently.
698698
' Size is used in Bitmap and has issues being recognized in DataContractSerializer for the unit tests of this class.

src/Microsoft.VisualStudio.AppDesigner/Common/WaitCursor.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' 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.
1+
' 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.
22

33
Option Strict On
44
Option Explicit On
@@ -20,7 +20,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
2020
' End Using
2121
' End Sub
2222
'**************************************************************************
23-
Friend Class WaitCursor
23+
Friend NotInheritable Class WaitCursor
2424
Implements IDisposable
2525

2626
Private _previousCursor As Cursor

src/Microsoft.VisualStudio.AppDesigner/Common/switches.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
143143
''' <summary>
144144
''' Contains predefined switches for enabling/disabling trace output or code instrumentation.
145145
''' </summary>
146-
Friend Class Switches
146+
Friend NotInheritable Class Switches
147147

148148
'------------- Resource Editor -------------
149149

@@ -395,7 +395,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon
395395
''' <summary>
396396
''' A Switch which has a simple enum value (either as integer or string representation)
397397
''' </summary>
398-
Public Class EnumSwitch(Of T)
398+
Public NotInheritable Class EnumSwitch(Of T)
399399
Inherits Switch
400400

401401
Public Sub New(DisplayName As String, Description As String)

src/Microsoft.VisualStudio.AppDesigner/Common/wmuserconstants.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Imports Microsoft.VisualStudio.Editors.AppDesInterop
44

55
Namespace Microsoft.VisualStudio.Editors.AppDesCommon
66

7-
Friend Class WmUserConstants
7+
Friend NotInheritable Class WmUserConstants
88
Public Const WM_REFPAGE_REFERENCES_REFRESH As Integer = Win32Constant.WM_USER + 21
99
Public Const WM_REFPAGE_IMPORTCHANGED As Integer = Win32Constant.WM_USER + 22
1010
Public Const WM_REFPAGE_IMPORTS_REFRESH As Integer = Win32Constant.WM_USER + 24

src/Microsoft.VisualStudio.AppDesigner/DesignerFramework/DesignerWindowPaneProviderBase.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesDesignerFramework
436436
''' A toplevel control is needed to handle SystemEvents. When the control is hosted in a native window, there will be no parent WinForm control.
437437
''' 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.
438438
''' </summary>
439-
Private Class TopLevelControl
439+
Private NotInheritable Class TopLevelControl
440440
Inherits Control
441441

442442
''' <summary>

src/Microsoft.VisualStudio.AppDesigner/PropPages/PropPageUserControlBase.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
154154
End Enum
155155

156156
'Used for caching property change notification until after Apply is done
157-
Private Class PropertyChange
157+
Private NotInheritable Class PropertyChange
158158
Public ReadOnly DispId As Integer
159159
Public ReadOnly Source As PropertyChangeSource
160160

src/Microsoft.VisualStudio.AppDesigner/PropPages/PropertyControlData.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
15651565
''' Helper class for PropertyDescriptorSetValue - detects if a PropertyDescriptor.SetValue
15661566
''' fails due to a canceled checkout...
15671567
''' </summary>
1568-
Private Class PropertyDescriptorSetValueHelper
1568+
Private NotInheritable Class PropertyDescriptorSetValueHelper
15691569
Private _valueChangedWasFired As Boolean
15701570

15711571
''' <summary>

src/Microsoft.VisualStudio.AppDesigner/PropPages/ValidationException.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
77
''' <summary>
88
''' The exception will be thrown when validation failed...
99
''' </summary>
10-
Friend Class ValidationException
10+
Friend NotInheritable Class ValidationException
1111
Inherits ApplicationException
1212

1313
Private ReadOnly _validationResult As ValidationResult

src/Microsoft.VisualStudio.AppDesigner/interop/NativeMethods.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Namespace Microsoft.VisualStudio.Editors.AppDesInterop
8282
Public Const UISF_HIDEFOCUS As Integer = &H1
8383
Public Const UISF_HIDEACCEL As Integer = &H2
8484

85-
Public Class ConnectionPointCookie
85+
Public NotInheritable Class ConnectionPointCookie
8686
Private _connectionPoint As IConnectionPoint
8787
Private _connectionPoint2 As ComTypes.IConnectionPoint
8888
Private _cookie As UInteger

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/Handlers/ProjectFilePathAndDisplayNameEvaluationHandler.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices.Handlers
1313
[Export(typeof(IWorkspaceUpdateHandler))]
1414
internal class ProjectFilePathAndDisplayNameEvaluationHandler : IWorkspaceUpdateHandler, IProjectEvaluationHandler
1515
{
16-
private readonly UnconfiguredProject _project;
1716
private readonly IImplicitlyActiveDimensionProvider _implicitlyActiveDimensionProvider;
1817

1918
[ImportingConstructor]
20-
public ProjectFilePathAndDisplayNameEvaluationHandler(UnconfiguredProject project, IImplicitlyActiveDimensionProvider implicitlyActiveDimensionProvider)
19+
public ProjectFilePathAndDisplayNameEvaluationHandler(UnconfiguredProject _, IImplicitlyActiveDimensionProvider implicitlyActiveDimensionProvider)
2120
{
22-
_project = project;
2321
_implicitlyActiveDimensionProvider = implicitlyActiveDimensionProvider;
2422
}
2523

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/WPF/AppDotXamlDocument.cs

+2-93
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ private string GetText(Location startLocation, Location endLocation)
7575
return GetText(startLocation.LineIndex, startLocation.CharIndex, endLocation.LineIndex, endLocation.CharIndex);
7676
}
7777

78-
/// <summary>
79-
/// Retrieves the text starting at the given point and with the given length
80-
/// </summary>
81-
private string GetText(Location startLocation, int count)
82-
{
83-
return GetText(startLocation.LineIndex, startLocation.CharIndex, count);
84-
}
85-
8678
/// <summary>
8779
/// Retrieves all of the text in the buffer
8880
/// </summary>
@@ -294,12 +286,7 @@ private static int FindClosingAngleBracketHelper(string line)
294286
{
295287
MoveToApplicationRootElement(reader);
296288
XamlProperty? prop = FindPropertyAsAttributeInCurrentElement(reader, ApplicationElementName, propertyName);
297-
if (prop is null)
298-
{
299-
prop = FindPropertyAsChildElementInCurrentElement(reader, ApplicationElementName, propertyName);
300-
}
301-
302-
return prop;
289+
return prop ?? FindPropertyAsChildElementInCurrentElement(reader, ApplicationElementName, propertyName);
303290
}
304291

305292
private XamlPropertyInAttributeSyntax? FindPropertyAsAttributeInCurrentElement(XmlTextReader reader, string optionalPropertyQualifier, string propertyName)
@@ -411,7 +398,6 @@ private static int FindClosingAngleBracketHelper(string line)
411398
// Found
412399

413400
Location tagStart = new(reader);
414-
Location tagEnd = new(reader);
415401

416402
Location? startTagEndingBracketLocation = FindClosingAngleBracket(tagStart);
417403
if (startTagEndingBracketLocation is null)
@@ -469,7 +455,6 @@ private static int FindClosingAngleBracketHelper(string line)
469455
}
470456

471457
// Reader is at location 'x' of </xyz>. So we want -2 from this location.
472-
Location currentPosition2 = new(reader);
473458
Location valueEndPlusOne = new Location(reader).Shift(-2);
474459

475460
// Get the inner text and unescape it.
@@ -499,10 +484,7 @@ private static int FindClosingAngleBracketHelper(string line)
499484

500485
private void SetApplicationPropertyValue(string propertyName, string? value)
501486
{
502-
if (value is null)
503-
{
504-
value = string.Empty;
505-
}
487+
value ??= string.Empty;
506488

507489
using BufferLock bufferLock = new(_vsTextLines, this);
508490

@@ -549,14 +531,6 @@ private void SetApplicationPropertyValue(string propertyName, string? value)
549531
}
550532
}
551533

552-
/// <summary>
553-
/// Replace the text at the given location in the buffer with new text.
554-
/// </summary>
555-
private void ReplaceText(Location sourceStart, int sourceLength, string newText)
556-
{
557-
((IReplaceText)this).ReplaceText(sourceStart, new Location(sourceStart.LineIndex, sourceStart.CharIndex + sourceLength), newText);
558-
}
559-
560534
/// <summary>
561535
/// Replace the text at the given location in the buffer with new text.
562536
/// </summary>
@@ -576,48 +550,6 @@ void IReplaceText.ReplaceText(Location sourceStart, Location sourceEnd, string n
576550
}
577551
}
578552

579-
/// <summary>
580-
/// Given the location of the start of an element tag, makes sure that it has an end tag.
581-
/// If the element tag is closed by "/>" instead of an end element, it is expanded
582-
/// into a start and end tag.
583-
/// </summary>
584-
/// <param name="tagStartLocation"></param>
585-
/// <param name="elementName">The name of the element at the given location</param>
586-
private void MakeSureElementHasStartAndEndTag(Location tagStartLocation, string elementName)
587-
{
588-
if (!"<".Equals(GetText(tagStartLocation, 1), StringComparison.Ordinal))
589-
{
590-
DiagnosticsDebug.Fail("MakeSureElementHasStartAndEndTags: The start location doesn't point to the start of an element tag");
591-
ThrowUnexpectedFormatException(tagStartLocation);
592-
}
593-
594-
Location? startTagEndingBracketLocation = FindClosingAngleBracket(tagStartLocation);
595-
if (startTagEndingBracketLocation is null)
596-
{
597-
ThrowUnexpectedFormatException(tagStartLocation);
598-
}
599-
600-
if (">".Equals(GetText(startTagEndingBracketLocation, 1), StringComparison.Ordinal))
601-
{
602-
// The element tag is of the <xxx> form. We assume that there is an ending </xxx> tag, and
603-
// we don't need to do anything.
604-
}
605-
else
606-
{
607-
// It must be an empty tag of the <xxx/> form.
608-
string slashAndEndBracket = "/>";
609-
if (!slashAndEndBracket.Equals(GetText(startTagEndingBracketLocation, slashAndEndBracket.Length), StringComparison.Ordinal))
610-
{
611-
DiagnosticsDebug.Fail("FindClosingAngleBracket returned the wrong location?");
612-
ThrowUnexpectedFormatException(startTagEndingBracketLocation);
613-
}
614-
615-
// We need to change <xxx attributes/> into <xxx attributes></xxx>
616-
string newText = "></" + elementName + ">";
617-
ReplaceText(startTagEndingBracketLocation, slashAndEndBracket.Length, newText);
618-
}
619-
}
620-
621553
/// <summary>
622554
/// Finds the value of the StartupUri property inside the xaml file. If
623555
/// the property is not set in the xaml, an empty string is returned.
@@ -655,29 +587,6 @@ private static void ThrowUnexpectedFormatException(Location location)
655587
throw new XamlReadWriteException(string.Format(VSResources.WPFApp_Xaml_UnexpectedFormat_2, location.LineIndex + 1, location.CharIndex + 1));
656588
}
657589

658-
/// <summary>
659-
/// Verify the validity of the Application.xaml file, and throw an exception if
660-
/// problems are found.
661-
/// </summary>
662-
private void VerifyAppXamlIsValidAndThrowIfNot()
663-
{
664-
using BufferLock bufferLock = new(_vsTextLines, this);
665-
666-
XmlTextReader reader = CreateXmlTextReader();
667-
MoveToApplicationRootElement(reader);
668-
669-
// Read through the Application element, including any child elements, to
670-
// ensure everything is properly closed.
671-
// The name of the element to find is irrelevant, as there shouldn't be
672-
// any elements following Application.
673-
reader.ReadToFollowing("Dummy Element");
674-
675-
// If we made it to here, the .xaml file should be well-formed enough for us to read
676-
// it properly. As a final check, though, try getting some common properties.
677-
GetStartupUri();
678-
GetShutdownMode();
679-
}
680-
681590
void IDebugLockCheck.OnBufferLock()
682591
{
683592
_debugBufferLockCount++;

0 commit comments

Comments
 (0)