Skip to content

Commit

Permalink
Fix IDE0051 and IDE0052 violations
Browse files Browse the repository at this point in the history
  • Loading branch information
mavasani committed Jul 14, 2020
1 parent 37ddd56 commit 4b156b5
Show file tree
Hide file tree
Showing 166 changed files with 265 additions and 617 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.ObjectBrowser
internal class ObjectBrowserLibraryManager : AbstractObjectBrowserLibraryManager
{
public ObjectBrowserLibraryManager(IServiceProvider serviceProvider, IComponentModel componentModel, VisualStudioWorkspace workspace)
: base(LanguageNames.CSharp, Guids.CSharpLibraryId, __SymbolToolLanguage.SymbolToolLanguage_CSharp, serviceProvider, componentModel, workspace)
: base(LanguageNames.CSharp, Guids.CSharpLibraryId, serviceProvider, componentModel, workspace)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ internal struct HACK_VariantStructure
{
private readonly short _type;

#pragma warning disable IDE0051 // Remove unused private members - padding bytes
private readonly short _padding1;
private readonly short _padding2;
private readonly short _padding3;

private readonly short _booleanValue;
private readonly IntPtr _padding4; // this will be aligned to the IntPtr-sized address
#pragma warning restore IDE0051 // Remove unused private members

public unsafe object ConvertToObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public override int GetExpansionFunction(IXMLDOMNode xmlFunctionNode, string bst
switch (snippetFunctionName)
{
case "SimpleTypeName":
pFunc = new SnippetFunctionSimpleTypeName(this, TextView, SubjectBuffer, bstrFieldName, param);
pFunc = new SnippetFunctionSimpleTypeName(this, SubjectBuffer, bstrFieldName, param);
return VSConstants.S_OK;
case "ClassName":
pFunc = new SnippetFunctionClassName(this, TextView, SubjectBuffer, bstrFieldName);
pFunc = new SnippetFunctionClassName(this, SubjectBuffer, bstrFieldName);
return VSConstants.S_OK;
case "GenerateSwitchCases":
pFunc = new SnippetFunctionGenerateSwitchCases(this, TextView, SubjectBuffer, bstrFieldName, param);
pFunc = new SnippetFunctionGenerateSwitchCases(this, SubjectBuffer, bstrFieldName, param);
return VSConstants.S_OK;
default:
pFunc = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@

using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.VisualStudio.LanguageServices.Implementation.Snippets;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.CSharp.Snippets.SnippetFunctions
{
internal sealed class SnippetFunctionClassName : AbstractSnippetFunctionClassName
{
public SnippetFunctionClassName(SnippetExpansionClient snippetExpansionClient, ITextView textView, ITextBuffer subjectBuffer, string fieldName)
: base(snippetExpansionClient, textView, subjectBuffer, fieldName)
public SnippetFunctionClassName(SnippetExpansionClient snippetExpansionClient, ITextBuffer subjectBuffer, string fieldName)
: base(snippetExpansionClient, subjectBuffer, fieldName)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.Snippets.SnippetFunctions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;
using TextSpan = Microsoft.CodeAnalysis.Text.TextSpan;
using VsTextSpan = Microsoft.VisualStudio.TextManager.Interop.TextSpan;
Expand All @@ -21,8 +20,8 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Snippets.SnippetFunctio
{
internal sealed class SnippetFunctionGenerateSwitchCases : AbstractSnippetFunctionGenerateSwitchCases
{
public SnippetFunctionGenerateSwitchCases(SnippetExpansionClient snippetExpansionClient, ITextView textView, ITextBuffer subjectBuffer, string caseGenerationLocationField, string switchExpressionField)
: base(snippetExpansionClient, textView, subjectBuffer, caseGenerationLocationField, switchExpressionField)
public SnippetFunctionGenerateSwitchCases(SnippetExpansionClient snippetExpansionClient, ITextBuffer subjectBuffer, string caseGenerationLocationField, string switchExpressionField)
: base(snippetExpansionClient, subjectBuffer, caseGenerationLocationField, switchExpressionField)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.Snippets.SnippetFunctions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.CSharp.Snippets.SnippetFunctions
{
internal sealed class SnippetFunctionSimpleTypeName : AbstractSnippetFunctionSimpleTypeName
{
public SnippetFunctionSimpleTypeName(SnippetExpansionClient snippetExpansionClient, ITextView textView, ITextBuffer subjectBuffer, string fieldName, string fullyQualifiedName)
: base(snippetExpansionClient, textView, subjectBuffer, fieldName, fullyQualifiedName)
public SnippetFunctionSimpleTypeName(SnippetExpansionClient snippetExpansionClient, ITextBuffer subjectBuffer, string fieldName, string fullyQualifiedName)
: base(snippetExpansionClient, subjectBuffer, fieldName, fullyQualifiedName)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public async Task TestCodeElementFromPoint()
var tree = await (GetCurrentDocument()).GetSyntaxTreeAsync();
var position = text.ToString().IndexOf("DynamicMethod", StringComparison.Ordinal);
var virtualTreePoint = new VirtualTreePoint(tree, text, position);
var textPoint = new MockTextPoint(virtualTreePoint, 4);
var textPoint = new MockTextPoint(virtualTreePoint);
var scope = vsCMElement.vsCMElementFunction;
var element = (GetCodeModel()).CodeElementFromPoint(textPoint, scope);
Assert.Equal("DynamicMethod", element.Name);
Expand All @@ -553,7 +553,7 @@ public async Task TestCodeElementFromPointBetweenMembers()
var tree = await (GetCurrentDocument()).GetSyntaxTreeAsync();
var position = text.ToString().IndexOf("protected virtual string MethodB", StringComparison.Ordinal) - 1;
var virtualTreePoint = new VirtualTreePoint(tree, text, position);
var textPoint = new MockTextPoint(virtualTreePoint, 4);
var textPoint = new MockTextPoint(virtualTreePoint);

Assert.Throws<COMException>(() =>
(GetCodeModel()).CodeElementFromPoint(textPoint, vsCMElement.vsCMElementFunction));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public class InteractiveCommandHandlerTests
Task.Run(() => { return 1; });";
private const string ExampleCode2Line2 =
@"Task.Run(() => { return 1; });";
private const string ExampleCode3 =
@"Console.WriteLine(
""InteractiveCommandHandlerExample"");";

private const string ExampleMultiline =
@"namespace N {
void goo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ internal partial class ChangeSignatureDialogViewModel : AbstractNotifyPropertyCh
private ImmutableArray<SymbolDisplayPart> _declarationParts;
private bool _previewChanges;

private readonly Dictionary<string, List<ParameterViewModel>> _parameterNameOverlapMap = new Dictionary<string, List<ParameterViewModel>>();

/// <summary>
/// The document where the symbol we are changing signature is defined.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectBrowser.Lists;
Expand All @@ -28,11 +27,8 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi

internal ILibraryService LibraryService => _libraryService.Value;

private readonly IServiceProvider _serviceProvider;
private readonly Lazy<ILibraryService> _libraryService;

private readonly string _languageName;
private readonly __SymbolToolLanguage _preferredLanguage;

private uint _classVersion;
private uint _membersVersion;
Expand All @@ -47,15 +43,12 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi
protected AbstractObjectBrowserLibraryManager(
string languageName,
Guid libraryGuid,
__SymbolToolLanguage preferredLanguage,
IServiceProvider serviceProvider,
IComponentModel componentModel,
VisualStudioWorkspace workspace)
: base(libraryGuid, serviceProvider)
{
_languageName = languageName;
_preferredLanguage = preferredLanguage;
_serviceProvider = serviceProvider;

Workspace = workspace;
Workspace.WorkspaceChanged += OnWorkspaceChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public ObjectList(
private bool IsClassView()
=> Helpers.IsClassView(_flags);

private bool IsFindSymbol()
=> Helpers.IsFindSymbol(_flags);

private ObjectListItem GetListItem(uint index)
{
var listItem = _items[(int)index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ internal sealed class LanguageSettingsPersister : ForegroundThreadAffinitizedObj
private readonly IVsTextManager4 _textManager;
private readonly IGlobalOptionService _optionService;

#pragma warning disable IDE0052 // Remove unread private members - Seems like a bug that we Advise to the event sink, but do not Unadvise. TODO: File a bug.
private readonly ComEventSink _textManagerEvents2Sink;
#pragma warning restore IDE0052 // Remove unread private members

/// <summary>
/// The mapping between language names and Visual Studio language service GUIDs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text.Differencing;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Utilities;
Expand All @@ -25,7 +24,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Preview
{
internal class PreviewEngine : ForegroundThreadAffinitizedObject, IVsPreviewChangesEngine
{
private readonly ITextDifferencingSelectorService _diffSelector;
private readonly IVsEditorAdaptersFactoryService _editorFactory;
private readonly Solution _newSolution;
private readonly Solution _oldSolution;
Expand Down Expand Up @@ -69,7 +67,6 @@ public PreviewEngine(
_description = description ?? throw new ArgumentNullException(nameof(description));
_newSolution = newSolution.WithMergedLinkedFileChangesAsync(oldSolution, cancellationToken: CancellationToken.None).Result;
_oldSolution = oldSolution;
_diffSelector = componentModel.GetService<ITextDifferencingSelectorService>();
_editorFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
_componentModel = componentModel;
this.ShowCheckBoxes = showCheckBoxes;
Expand Down Expand Up @@ -113,7 +110,7 @@ public int GetRootChangesList(out object ppIUnknownPreviewChangesList)
var changes = _newSolution.GetChanges(_oldSolution);
var projectChanges = changes.GetProjectChanges();

_topLevelChange = new TopLevelChange(_topLevelName, _topLevelGlyph, _newSolution, _oldSolution, _componentModel, this);
_topLevelChange = new TopLevelChange(_topLevelName, _topLevelGlyph, _newSolution, this);

var builder = ArrayBuilder<AbstractChange>.GetInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.Preview
{
Expand All @@ -21,11 +16,9 @@ internal partial class PreviewUpdater
internal class PreviewTagger : ITagger<HighlightTag>
{
private readonly ITextBuffer _textBuffer;
private readonly ITextView _textView;

public PreviewTagger(ITextView textView, ITextBuffer textBuffer)
public PreviewTagger(ITextBuffer textBuffer)
{
_textView = textView;
_textBuffer = textBuffer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public PreviewUpdater(IThreadingContext threadingContext, ITextView textView)
: base(threadingContext)
{
PreviewUpdater.TextView = textView;
Tagger = new PreviewTagger(textView, textView.TextBuffer);
Tagger = new PreviewTagger(textView.TextBuffer);
}

public void CloseWorkspace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
Expand All @@ -19,25 +18,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Preview
internal class TopLevelChange : AbstractChange
{
private readonly string _name;
private readonly IComponentModel _componentModel;
private readonly Solution _newSolution;
private readonly Solution _oldSolution;
private readonly Glyph _glyph;

public TopLevelChange(
string name,
Glyph glyph,
Solution newSolution,
Solution oldSolution,
IComponentModel componentModel,
PreviewEngine engine)
: base(engine)
{
_name = name;
_glyph = glyph;
_componentModel = componentModel;
_newSolution = newSolution;
_oldSolution = oldSolution;
}

public override int GetText(out VSTREETEXTOPTIONS tto, out string pbstrText)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
Expand All @@ -27,19 +26,9 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj
{
internal const string ProjectGuidPropertyName = "ProjectGuid";

internal static object RuleSetErrorId = new object();

private string _displayName;
private readonly VisualStudioWorkspace _visualStudioWorkspace;

private readonly DiagnosticDescriptor _errorReadingRulesetRule = new DiagnosticDescriptor(
id: IDEDiagnosticIds.ErrorReadingRulesetId,
title: ServicesVSResources.ErrorReadingRuleset,
messageFormat: ServicesVSResources.Error_reading_ruleset_file_0_1,
category: FeaturesResources.Roslyn_HostError,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

public AbstractProject(
VisualStudioProjectTracker projectTracker,
Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Immutable;
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Interop;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Legacy
{
internal partial class AbstractLegacyProject : IIntellisenseBuildTarget
{
void IIntellisenseBuildTarget.SetIntellisenseBuildResult(bool succeeded, string reason)
{
}

#if false
private static readonly object s_diagnosticKey = new object();

void IIntellisenseBuildTarget.SetIntellisenseBuildResult(bool succeeded, string reason)
Expand Down Expand Up @@ -75,5 +73,6 @@ private string GetDescription(string reason)

return string.Join(Environment.NewLine, logFileDescription, string.Empty, ServicesVSResources.Additional_information_colon, reason);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.Snippets
{
internal abstract partial class AbstractSnippetFunction : IVsExpansionFunction
{
private readonly ITextView _textView;
private readonly ITextBuffer _subjectBuffer;

protected AbstractSnippetExpansionClient snippetExpansionClient;

public AbstractSnippetFunction(AbstractSnippetExpansionClient snippetExpansionClient, ITextView textView, ITextBuffer subjectBuffer)
public AbstractSnippetFunction(AbstractSnippetExpansionClient snippetExpansionClient, ITextBuffer subjectBuffer)
{
this.snippetExpansionClient = snippetExpansionClient;
_textView = textView;
_subjectBuffer = subjectBuffer;
}

Expand Down
Loading

0 comments on commit 4b156b5

Please sign in to comment.