Skip to content

Commit

Permalink
Merge pull request #54975 from CyrusNajmabadi/underscoreField
Browse files Browse the repository at this point in the history
Don't combine 'this.' with underscore named fields
  • Loading branch information
CyrusNajmabadi authored Jul 20, 2021
2 parents 87f1664 + 3e65de7 commit cd7b4c7
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal void EventHookupFoundInSession(EventHookupSession analyzedSession)
analyzedSession.TrackingSpan.GetSpan(CurrentSession.TextView.TextSnapshot).Contains(caretPoint.Value))
{
// Create a tooltip presenter that stays alive, even when the user types, without tracking the mouse.
_toolTipPresenter = this._toolTipService.CreatePresenter(analyzedSession.TextView,
_toolTipPresenter = _toolTipService.CreatePresenter(analyzedSession.TextView,
new ToolTipParameters(trackMouse: false, ignoreBufferChange: true));

// tooltips text is: Program_MyEvents; (Press TAB to insert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal abstract class AbstractExtractInterfaceCommandHandler : ICommandHandler
private readonly IThreadingContext _threadingContext;

protected AbstractExtractInterfaceCommandHandler(IThreadingContext threadingContext)
=> this._threadingContext = threadingContext;
=> _threadingContext = threadingContext;

public string DisplayName => EditorFeaturesResources.Extract_Interface;

Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/Core/Tagging/TaggerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void ClearTags()
/// tags from before and after the sub-span and merge them with the newly produced tags.
/// </summary>
public void SetSpansTagged(IEnumerable<DocumentSnapshotSpan> spansTagged)
=> this._spansTagged = spansTagged ?? throw new ArgumentNullException(nameof(spansTagged));
=> _spansTagged = spansTagged ?? throw new ArgumentNullException(nameof(spansTagged));

public IEnumerable<ITagSpan<TTag>> GetExistingContainingTags(SnapshotPoint point)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class CoreFormatterTestsBase
private readonly ITestOutputHelper _output;

protected CoreFormatterTestsBase(ITestOutputHelper output)
=> this._output = output;
=> _output = output;

protected abstract string GetLanguageName();
protected abstract SyntaxNode ParseCompilationUnit(string expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void Clear()
this.CancelSearch();

// Clear the title of the window. It will go back to the default editor title.
this._findReferencesWindow.Title = null;
_findReferencesWindow.Title = null;

lock (Gate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override bool TryGetValue(int index, string keyName, out object? content)
public override bool TryCreateColumnContent(
int index, string columnName, bool singleColumnView, [NotNullWhen(true)] out FrameworkElement? content)
{
return this._entries[index].TryCreateColumnContent(columnName, out content);
return _entries[index].TryCreateColumnContent(columnName, out content);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private async Task LoadAsync()
{
try
{
using var token = this._asynchronousOperationListener.BeginAsyncOperation(nameof(LoadAsync));
using var token = _asynchronousOperationListener.BeginAsyncOperation(nameof(LoadAsync));

// Explicitly switch to the bg so that if this causes any expensive work (like mef loads) it
// doesn't block the UI thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LocalUserRegistryOptionPersister(IThreadingContext threadingContext, ISer
// https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.interop.slocalregistry
threadingContext.ThrowIfNotOnUIThread();

this._registryKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true);
_registryKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true);
}

private static bool TryGetKeyPathAndName(IOption option, out string path, out string key)
Expand Down Expand Up @@ -70,7 +70,7 @@ bool IOptionPersister.TryFetch(OptionKey optionKey, out object value)

lock (_gate)
{
using var subKey = this._registryKey.OpenSubKey(path);
using var subKey = _registryKey.OpenSubKey(path);
if (subKey == null)
{
value = null;
Expand Down Expand Up @@ -135,7 +135,7 @@ bool IOptionPersister.TryFetch(OptionKey optionKey, out object value)

bool IOptionPersister.TryPersist(OptionKey optionKey, object value)
{
if (this._registryKey == null)
if (_registryKey == null)
{
throw new InvalidOperationException();
}
Expand All @@ -147,7 +147,7 @@ bool IOptionPersister.TryPersist(OptionKey optionKey, object value)

lock (_gate)
{
using var subKey = this._registryKey.CreateSubKey(path);
using var subKey = _registryKey.CreateSubKey(path);
// Options that are of type bool have to be serialized as integers
if (optionKey.Option.Type == typeof(bool))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void UpdateProjectOptions_NoLock()

// We've computed what the base values should be; we now give an opportunity for any host-specific settings to be computed
// before we apply them
compilationOptions = ComputeCompilationOptionsWithHostValues(compilationOptions, this._ruleSetFile?.Target.Value);
compilationOptions = ComputeCompilationOptionsWithHostValues(compilationOptions, _ruleSetFile?.Target.Value);
parseOptions = ComputeParseOptionsWithHostValues(parseOptions);

// For managed projects, AssemblyName has to be non-null, but the command line we get might be a partial command line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ internal bool IsPrimaryProject(ProjectId projectId)
{
lock (_gate)
{
foreach (var (_, projects) in this._projectSystemNameToProjectsMap)
foreach (var (_, projects) in _projectSystemNameToProjectsMap)
{
foreach (var project in projects)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public AbstractSnippetExpansionClient(
this.LanguageServiceGuid = languageServiceGuid;
this.TextView = textView;
this.SubjectBuffer = subjectBuffer;
this._signatureHelpControllerProvider = signatureHelpControllerProvider;
this._editorCommandHandlerServiceFactory = editorCommandHandlerServiceFactory;
_signatureHelpControllerProvider = signatureHelpControllerProvider;
_editorCommandHandlerServiceFactory = editorCommandHandlerServiceFactory;
this.EditorAdaptersFactoryService = editorAdaptersFactoryService;
this._allArgumentProviders = argumentProviders;
_allArgumentProviders = argumentProviders;
}

/// <inheritdoc cref="State._expansionSession"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public ImmutableArray<Project> GetProjectsWithInstalledPackage(Solution solution

using var _ = ArrayBuilder<Project>.GetInstance(out var result);

foreach (var (projectId, state) in this._projectToInstalledPackageAndVersion)
foreach (var (projectId, state) in _projectToInstalledPackageAndVersion)
{
if (state.TryGetInstalledVersion(packageName, out var installedVersion) &&
installedVersion == version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public sealed override void Dispose()

public sealed override ValueTask DisposeAsync()
{
if (this._cacheService is IAsyncDisposable asyncDisposable)
if (_cacheService is IAsyncDisposable asyncDisposable)
{
return asyncDisposable.DisposeAsync();
}
else if (this._cacheService is IDisposable disposable)
else if (_cacheService is IDisposable disposable)
{
disposable.Dispose();
return ValueTaskFactory.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ internal void Connect(string languageName)
return;
}

this._registeredLanguageNames.Add(languageName);
if (this._registeredLanguageNames.Count == 1)
_registeredLanguageNames.Add(languageName);
if (_registeredLanguageNames.Count == 1)
{
// Register to hear about option changing.
var optionsService = Workspace.Services.GetService<IOptionService>();
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/Core/Def/Utilities/ProjectPropertyStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private sealed class BuildPropertyStorage : ProjectPropertyStorage
private readonly IVsBuildPropertyStorage _propertyStorage;

public BuildPropertyStorage(IVsBuildPropertyStorage propertyStorage)
=> this._propertyStorage = propertyStorage;
=> _propertyStorage = propertyStorage;

public override void SetProperty(string buildPropertyName, string configurationPropertyName, string value)
=> _propertyStorage.SetPropertyValue(buildPropertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE, value);
Expand All @@ -59,7 +59,7 @@ private sealed class PerConfigurationPropertyStorage : ProjectPropertyStorage
private readonly ConfigurationManager _configurationManager;

public PerConfigurationPropertyStorage(ConfigurationManager configurationManager)
=> this._configurationManager = configurationManager;
=> _configurationManager = configurationManager;

public override void SetProperty(string buildPropertyName, string configurationPropertyName, string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private class BrowseObject : LocalizableProperties

public BrowseObject(SourceGeneratedFileItem sourceGeneratedFileItem)
{
this._sourceGeneratedFileItem = sourceGeneratedFileItem;
_sourceGeneratedFileItem = sourceGeneratedFileItem;
}

[BrowseObjectDisplayName(nameof(SolutionExplorerShim.Name))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task<ImmutableArray<ProjectInfo>> GetRemoteProjectInfosAsync(Cancel
// This is also the case for files for which TypeScript adds the generated TypeScript buffer to a different project.
var filesTasks = project.SourceFiles
.Where(f => f.Scheme != SystemUriSchemeExternal)
.Where(f => !this._secondaryBufferFileExtensions.Any(ext => f.LocalPath.EndsWith(ext)))
.Where(f => !_secondaryBufferFileExtensions.Any(ext => f.LocalPath.EndsWith(ext)))
.Select(f => lspClient.ProtocolConverter.FromProtocolUriAsync(f, false, cancellationToken));
var files = await Task.WhenAll(filesTasks).ConfigureAwait(false);
var projectInfo = CreateProjectInfo(project.Name, project.Language, files.Select(f => f.LocalPath).ToImmutableArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ private bool IsTypeOfUnboundGenericType(SemanticModel semanticModel, TypeOfExpre

public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax originalNode)
{
if (this._semanticModel.GetSymbolInfo(originalNode).Symbol.IsLocalFunction())
if (_semanticModel.GetSymbolInfo(originalNode).Symbol.IsLocalFunction())
{
return originalNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CodeGenerationPropertySymbol(
: base(containingType?.ContainingAssembly, containingType, attributes, declaredAccessibility, modifiers, name)
{
this.Type = type;
this._refKind = refKind;
_refKind = refKind;
this.IsIndexer = isIndexer;
this.Parameters = parametersOpt.NullToEmpty();
this.ExplicitInterfaceImplementations = explicitInterfaceImplementations.NullToEmpty();
Expand Down Expand Up @@ -75,11 +75,11 @@ public override TResult Accept<TResult>(SymbolVisitor<TResult> visitor)

public new IPropertySymbol OriginalDefinition => this;

public RefKind RefKind => this._refKind;
public RefKind RefKind => _refKind;

public bool ReturnsByRef => this._refKind == RefKind.Ref;
public bool ReturnsByRef => _refKind == RefKind.Ref;

public bool ReturnsByRefReadonly => this._refKind == RefKind.RefReadOnly;
public bool ReturnsByRefReadonly => _refKind == RefKind.RefReadOnly;

public IPropertySymbol OverriddenProperty => null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ internal void AssertEquivalentTo(SymbolTreeInfo other)
}

Debug.Assert(_inheritanceMap.Keys.Count == other._inheritanceMap.Keys.Count);
var orderedKeys1 = this._inheritanceMap.Keys.Order().ToList();
var orderedKeys1 = _inheritanceMap.Keys.Order().ToList();

for (var i = 0; i < orderedKeys1.Count; i++)
{
var values1 = this._inheritanceMap[i];
var values1 = _inheritanceMap[i];
var values2 = other._inheritanceMap[i];

Debug.Assert(values1.Length == values2.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ public ConflictResolution ToConflictResolution()
if (ErrorMessage != null)
return new ConflictResolution(ErrorMessage);

var documentIds = this._renamedSpansTracker.DocumentIds.Concat(
var documentIds = _renamedSpansTracker.DocumentIds.Concat(
this.RelatedLocations.Select(l => l.DocumentId)).Distinct().ToImmutableArray();

var relatedLocations = this.RelatedLocations.ToImmutableArray();

var documentToModifiedSpansMap = this._renamedSpansTracker.GetDocumentToModifiedSpansMap();
var documentToComplexifiedSpansMap = this._renamedSpansTracker.GetDocumentToComplexifiedSpansMap();
var documentToModifiedSpansMap = _renamedSpansTracker.GetDocumentToModifiedSpansMap();
var documentToComplexifiedSpansMap = _renamedSpansTracker.GetDocumentToComplexifiedSpansMap();
var documentToRelatedLocationsMap = this.RelatedLocations.GroupBy(loc => loc.DocumentId).ToImmutableDictionary(
g => g.Key, g => g.ToImmutableArray());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public override Task<Compilation> TransformCompilationAsync(Compilation oldCompi
public override CompilationAndGeneratorDriverTranslationAction? TryMergeWithPrior(CompilationAndGeneratorDriverTranslationAction priorAction)
{
if (priorAction is TouchDocumentAction priorTouchAction &&
priorTouchAction._newState == this._oldState)
priorTouchAction._newState == _oldState)
{
return new TouchDocumentAction(priorTouchAction._oldState, this._newState);
return new TouchDocumentAction(priorTouchAction._oldState, _newState);
}

return null;
Expand All @@ -70,9 +70,9 @@ public TouchAdditionalDocumentAction(AdditionalDocumentState oldState, Additiona
public override CompilationAndGeneratorDriverTranslationAction? TryMergeWithPrior(CompilationAndGeneratorDriverTranslationAction priorAction)
{
if (priorAction is TouchAdditionalDocumentAction priorTouchAction &&
priorTouchAction._newState == this._oldState)
priorTouchAction._newState == _oldState)
{
return new TouchAdditionalDocumentAction(priorTouchAction._oldState, this._newState);
return new TouchAdditionalDocumentAction(priorTouchAction._oldState, _newState);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class SingleLineRewriter : CSharpSyntaxRewriter
private bool _lastTokenEndedInWhitespace;

public SingleLineRewriter(bool useElasticTrivia)
=> this._useElasticTrivia = useElasticTrivia;
=> _useElasticTrivia = useElasticTrivia;

public override SyntaxToken VisitToken(SyntaxToken token)
{
Expand Down

0 comments on commit cd7b4c7

Please sign in to comment.