Skip to content

Commit

Permalink
Fix CA1822 - iteration 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Jan 18, 2021
1 parent 96b0f6d commit 3c4382c
Show file tree
Hide file tree
Showing 48 changed files with 78 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void RaiseAnalyzerChangedWarning(ProjectId projectId, string analyzerPat
}
}

private DateTime? GetLastUpdateTimeUtc(string fullPath)
private static DateTime? GetLastUpdateTimeUtc(string fullPath)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CallHierarchyDetail(Location location, Workspace workspace)
_text = ComputeText(location);
}

private string ComputeText(Location location)
private static string ComputeText(Location location)
{
var lineSpan = location.GetLineSpan();
var start = location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].Start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<ICallHierarchyMemberItem> CreateItemAsync(ISymbol symbol,
return null;
}

private ISymbol GetTargetSymbol(ISymbol symbol)
private static ISymbol GetTargetSymbol(ISymbol symbol)
{
if (symbol is IMethodSymbol methodSymbol)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private async Task SearchAsync(Workspace workspace, CallHierarchySearchScope sco
await SearchWorkerAsync(symbol, project, callback, documents, cancellationToken).ConfigureAwait(false);
}

private IImmutableSet<Document> IncludeDocuments(CallHierarchySearchScope scope, Project project)
private static IImmutableSet<Document> IncludeDocuments(CallHierarchySearchScope scope, Project project)
{
if (scope == CallHierarchySearchScope.CurrentDocument || scope == CallHierarchySearchScope.CurrentProject)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ParameterViewModel(ChangeSignatureDialogViewModel changeSignatureDialogVi
ChangeSignatureDialogViewModel = changeSignatureDialogViewModel;
}

private string ValueOrNone(string value)
private static string ValueOrNone(string value)
{
return !string.IsNullOrEmpty(value)
? value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal partial class ColorSchemeApplier
private class RegistryItem
{
public string SectionName { get; }
public string ValueName => "Data";
public static string ValueName => "Data";
public byte[] ValueData { get; }

public RegistryItem(string sectionName, byte[] valueData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private ColorScheme GetColorScheme(SchemeName schemeName)
return ColorSchemeReader.ReadColorScheme(colorSchemeStream);
}

private Stream GetColorSchemeXmlStream(SchemeName schemeName)
private static Stream GetColorSchemeXmlStream(SchemeName schemeName)
{
var assembly = Assembly.GetExecutingAssembly();
return assembly.GetManifestResourceStream($"Microsoft.VisualStudio.LanguageServices.ColorSchemes.{schemeName}.xml");
Expand All @@ -60,7 +60,7 @@ public void ApplyColorScheme(SchemeName schemeName, ImmutableArray<RegistryItem>
foreach (var item in registryItems)
{
using var itemKey = registryRoot.CreateSubKey(item.SectionName);
itemKey.SetValue(item.ValueName, item.ValueData);
itemKey.SetValue(RegistryItem.ValueName, item.ValueData);
// Flush RegistryKeys out of paranoia
itemKey.Flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void UpdateMembersBasedOnDestinationKind(TypeKind destinationType)
}
}

private void SelectMembers(ImmutableArray<PullMemberUpSymbolViewModel> members, bool isChecked = true)
private static void SelectMembers(ImmutableArray<PullMemberUpSymbolViewModel> members, bool isChecked = true)
{
foreach (var member in members.Where(viewModel => viewModel.IsCheckable))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable<Docum
return true;
}

private ContainedLanguageRenameType GetRenameType(ISymbol symbol)
private static ContainedLanguageRenameType GetRenameType(ISymbol symbol)
{
if (symbol is INamespaceSymbol)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void SetupImmediateWindowProjectionBuffer()
}
}

private int GetQuestionIndex(string text)
private static int GetQuestionIndex(string text)
{
for (var i = 0; i < text.Length; i++)
{
Expand All @@ -269,7 +269,7 @@ private int GetQuestionIndex(string text)
return -1;
}

private bool IsImmediateWindow(IVsUIShell shellService, IVsTextView textView)
private static bool IsImmediateWindow(IVsUIShell shellService, IVsTextView textView)
{
Marshal.ThrowExceptionForHR(shellService.GetToolWindowEnum(out var windowEnum));
Marshal.ThrowExceptionForHR(textView.GetBuffer(out _));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private async Task NotifyProjectSystemAsync(
await Task.WhenAll(tasks).ConfigureAwait(false);
}

private void AddFilteredInfos(ImmutableArray<DesignerAttributeData> data, ArrayBuilder<DesignerAttributeData> filteredData)
private static void AddFilteredInfos(ImmutableArray<DesignerAttributeData> data, ArrayBuilder<DesignerAttributeData> filteredData)
{
using var _ = PooledHashSet<DocumentId>.GetInstance(out var seenDocumentIds);

Expand Down Expand Up @@ -279,7 +279,7 @@ private async Task NotifyCpsProjectSystemAsync(
await Task.WhenAll(tasks).ConfigureAwait(false);
}

private async Task NotifyCpsProjectSystemAsync(
private static async Task NotifyCpsProjectSystemAsync(
IProjectItemDesignerTypeUpdateService updateService,
DesignerAttributeData data,
CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public IReadOnlyDictionary<string, IEnumerable<DiagnosticDescriptor>> GetAllDiag
}
}

private IReadOnlyDictionary<string, IEnumerable<DiagnosticDescriptor>> Transform(
private static IReadOnlyDictionary<string, IEnumerable<DiagnosticDescriptor>> Transform(
ImmutableDictionary<string, ImmutableArray<DiagnosticDescriptor>> map)
{
// unfortunately, we had to do this since ruleset editor and us are set to use this signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private DiagnosticMode ComputeDiagnosticMode(Option2<DiagnosticMode> option)
return _workspace.Options.GetOption(option);
}

private bool IsInCodeSpacesServer()
private static bool IsInCodeSpacesServer()
{
// hack until there is an officially supported free-threaded synchronous platform API to ask this question.
return Environment.GetEnvironmentVariable("VisualStudioServerMode") == "1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private bool TryAdjustSpanIfNeededForVenus(
return startChanged || endChanged;
}

private LinePositionSpan GetLinePositionSpan(LinePosition position1, LinePosition position2)
private static LinePositionSpan GetLinePositionSpan(LinePosition position1, LinePosition position2)
{
if (position1 <= position2)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private DisposableToolTip CreateDisposableToolTip(Document document, TextSpan so
return controlService.CreateDisposableToolTip(document, textBuffer, contentSpan, EnvironmentColors.ToolWindowBackgroundBrushKey);
}

private void SetStaticClassifications(ITextBuffer textBuffer, ImmutableArray<ClassifiedSpan> classifiedSpans)
private static void SetStaticClassifications(ITextBuffer textBuffer, ImmutableArray<ClassifiedSpan> classifiedSpans)
{
var key = PredefinedPreviewTaggerKeys.StaticClassificationSpansKey;
textBuffer.Properties.RemoveProperty(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ internal void UpdateFileNameExtension()
this.FileName = currentFileName;
}

private string UpdateExtension(string currentFileName, string desiredFileExtension, string undesiredFileExtension)
private static string UpdateExtension(string currentFileName, string desiredFileExtension, string undesiredFileExtension)
{
if (currentFileName.EndsWith(desiredFileExtension, StringComparison.OrdinalIgnoreCase))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private IOleUndoManager GetUndoManager(ITextBuffer subjectBuffer)
return null;
}

private IEnumerable<IOleUndoUnit> GetUndoUnits(IOleUndoManager undoManager)
private static IEnumerable<IOleUndoUnit> GetUndoUnits(IOleUndoManager undoManager)
{
IEnumOleUndoUnits undoUnitEnumerator;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private bool ContainsRegionTag(ITextSnapshot textSnapshot)
return false;
}

private bool StartsWithRegionTag(ITextSnapshotLine line)
private static bool StartsWithRegionTag(ITextSnapshotLine line)
{
var start = line.GetFirstNonWhitespacePosition();
if (start != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private void BuildXmlDocumentation(ISymbol symbol, Compilation compilation)
}
}

private bool ShowReturnsDocumentation(ISymbol symbol)
private static bool ShowReturnsDocumentation(ISymbol symbol)
{
return (symbol.Kind == SymbolKind.NamedType && ((INamedTypeSymbol)symbol).TypeKind == TypeKind.Delegate)
|| symbol.Kind == SymbolKind.Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private static bool IncludeMemberSymbol(ISymbol symbol, IAssemblySymbol assembly
return false;
}

private ImmutableArray<ObjectListItem> CreateListItemsFromSymbols<TSymbol>(
private static ImmutableArray<ObjectListItem> CreateListItemsFromSymbols<TSymbol>(
ImmutableArray<TSymbol> symbols,
Compilation compilation,
ProjectId projectId,
Expand Down Expand Up @@ -313,7 +313,7 @@ private ImmutableArray<ObjectListItem> GetMemberListItems(
return builder.ToImmutable();
}

private ImmutableArray<ISymbol> GetMemberSymbols(INamedTypeSymbol namedTypeSymbol, Compilation compilation)
private static ImmutableArray<ISymbol> GetMemberSymbols(INamedTypeSymbol namedTypeSymbol, Compilation compilation)
{
var members = namedTypeSymbol.GetMembers();
var symbolBuilder = ImmutableArray.CreateBuilder<ISymbol>(members.Length);
Expand Down Expand Up @@ -373,7 +373,7 @@ private ImmutableArray<ISymbol> GetInheritedMemberSymbols(INamedTypeSymbol named
return symbolBuilder.ToImmutable();
}

private void AddOverriddenMembers(INamedTypeSymbol namedTypeSymbol, ref HashSet<ISymbol> overriddenMembers)
private static void AddOverriddenMembers(INamedTypeSymbol namedTypeSymbol, ref HashSet<ISymbol> overriddenMembers)
{
foreach (var member in namedTypeSymbol.GetMembers())
{
Expand Down Expand Up @@ -539,7 +539,7 @@ public ImmutableHashSet<Tuple<ProjectId, IAssemblySymbol>> GetAssemblySet(Projec
return set.ToImmutable();
}

private bool ContainsAccessibleTypeMember(INamespaceOrTypeSymbol namespaceOrTypeSymbol, IAssemblySymbol assemblySymbol)
private static bool ContainsAccessibleTypeMember(INamespaceOrTypeSymbol namespaceOrTypeSymbol, IAssemblySymbol assemblySymbol)
{
foreach (var typeMember in namespaceOrTypeSymbol.GetTypeMembers())
{
Expand Down Expand Up @@ -568,7 +568,7 @@ private ImmutableArray<INamedTypeSymbol> GetAccessibleTypeMembers(INamespaceOrTy
return builder.ToImmutable();
}

private bool IncludeTypeMember(INamedTypeSymbol typeMember, IAssemblySymbol assemblySymbol)
private static bool IncludeTypeMember(INamedTypeSymbol typeMember, IAssemblySymbol assemblySymbol)
{
if (!IncludeSymbol(typeMember))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
return false;
}

private async Task FindReferencesAsync(
private static async Task FindReferencesAsync(
IStreamingFindUsagesPresenter presenter, SymbolListItem symbolListItem, Project project)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void LogException(object source, Exception exception)
}
}

private bool ShouldReportCrashDumps(object source) => HasRoslynPublicKey(source);
private static bool ShouldReportCrashDumps(object source) => HasRoslynPublicKey(source);

private static string ToLogFormat(Exception exception)
=> exception.Message + Environment.NewLine + exception.StackTrace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public bool TryFetch(OptionKey optionKey, out object value)
return true;
}

private bool DeserializeCodeStyleOption(ref object value, Type type)
private static bool DeserializeCodeStyleOption(ref object value, Type type)
{
if (value is string serializedValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private ChangeList GetEntireDocumentAsSpanChange(TextDocument document)
return new ChangeList(new[] { entireSpanChild });
}

private string GetDisplayText(string excerpt)
private static string GetDisplayText(string excerpt)
{
if (excerpt.Contains("\r\n"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Solution GetUpdatedSolution(bool applyingChanges)
return solution;
}

private Solution ApplyFileChanges(Solution solution, IEnumerable<FileChange> fileChanges, bool applyingChanges)
private static Solution ApplyFileChanges(Solution solution, IEnumerable<FileChange> fileChanges, bool applyingChanges)
{
foreach (var fileChange in fileChanges)
{
Expand Down Expand Up @@ -179,7 +179,7 @@ void ApplyFileChangesCore(
}
}

private Solution ApplyReferenceChanges(Solution solution, IEnumerable<ReferenceChange> referenceChanges)
private static Solution ApplyReferenceChanges(Solution solution, IEnumerable<ReferenceChange> referenceChanges)
{
foreach (var referenceChange in referenceChanges)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ object IPreviewPaneService.GetPreviewPane(DiagnosticData data, IReadOnlyList<obj
optionPageGuid: optionPageGuid);
}

private Guid GetOptionPageGuidForOptionName(string optionName, string optionLanguage)
private static Guid GetOptionPageGuidForOptionName(string optionName, string optionLanguage)
{
if (optionName == nameof(NamingStyleOptions.NamingPreferences))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public string Label(GraphObject graphObject, string graphCommandDefinitionIdenti
RoslynGraphProperties.FormattedLabelWithContainingSymbol);
}

private string GetStringPropertyForGraphObject(GraphObject graphObject, string graphCommandDefinitionIdentifier, GraphProperty propertyWithoutContainingSymbol, GraphProperty propertyWithContainingSymbol)
private static string GetStringPropertyForGraphObject(GraphObject graphObject, string graphCommandDefinitionIdentifier, GraphProperty propertyWithoutContainingSymbol, GraphProperty propertyWithContainingSymbol)
{

if (graphObject is GraphNode graphNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,25 +307,25 @@ private bool IsOverridable(GraphNode node)
!modifiers.IsSealed;
}

private DeclarationModifiers GetModifiers(GraphNode node)
private static DeclarationModifiers GetModifiers(GraphNode node)
=> (DeclarationModifiers)node[RoslynGraphProperties.SymbolModifiers];

private bool CheckAccessibility(GraphNode node, Accessibility accessibility)
private static bool CheckAccessibility(GraphNode node, Accessibility accessibility)
=> node[RoslynGraphProperties.DeclaredAccessibility].Equals(accessibility);

private bool HasExplicitInterfaces(GraphNode node)
private static bool HasExplicitInterfaces(GraphNode node)
=> ((IList<SymbolKey>)node[RoslynGraphProperties.ExplicitInterfaceImplementations]).Count > 0;

private bool IsRoslynNode(GraphNode node)
private static bool IsRoslynNode(GraphNode node)
{
return node[RoslynGraphProperties.SymbolKind] != null
&& node[RoslynGraphProperties.TypeKind] != null;
}

private bool IsAnySymbolKind(GraphNode node, params SymbolKind[] symbolKinds)
private static bool IsAnySymbolKind(GraphNode node, params SymbolKind[] symbolKinds)
=> symbolKinds.Any(k => k.Equals(node[RoslynGraphProperties.SymbolKind]));

private bool IsAnyTypeKind(GraphNode node, params TypeKind[] typeKinds)
private static bool IsAnyTypeKind(GraphNode node, params TypeKind[] typeKinds)
=> typeKinds.Any(k => node[RoslynGraphProperties.TypeKind].Equals(k));

private static readonly GraphCommandDefinition s_overridesCommandDefinition =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void StopWatchingFile(IFileWatchingToken token)
_fileChangeWatcher.EnqueueWork(service => UnsubscribeFileChangeEventsAsync(service, typedToken));
}

private Task UnsubscribeFileChangeEventsAsync(IVsAsyncFileChangeEx service, FileWatchingToken typedToken)
private static Task UnsubscribeFileChangeEventsAsync(IVsAsyncFileChangeEx service, FileWatchingToken typedToken)
=> service.UnadviseFileChangeAsync(typedToken.Cookie!.Value);

public event EventHandler<string>? FileChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Service(IThreadingContext threadingContext, VisualStudioWorkspace? worksp
// full URI format (i.e. file://c:/...). This will allow us to get the
// actual local in the normal path format.
if (Uri.TryCreate(assembly.CodeBase, UriKind.RelativeOrAbsolute, out var uri) &&
this.CanResolveType(assembly, fullyQualifiedTypeName))
CanResolveType(assembly, fullyQualifiedTypeName))
{
return uri.LocalPath;
}
Expand All @@ -69,7 +69,7 @@ public Service(IThreadingContext threadingContext, VisualStudioWorkspace? worksp
return null;
}

private bool CanResolveType(Assembly assembly, string? fullyQualifiedTypeName)
private static bool CanResolveType(Assembly assembly, string? fullyQualifiedTypeName)
{
if (fullyQualifiedTypeName == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void GetStorageInfoFromTemporaryStorage(FileKey moduleFileKey, out ITemp
pImage = directAccess.GetPointer();
}

private void StreamCopy(Stream source, Stream destination, int start, int length)
private static void StreamCopy(Stream source, Stream destination, int start, int length)
{
source.Position = start;

Expand Down Expand Up @@ -311,7 +311,7 @@ private bool TryGetFileMappingFromMetadataImporter(FileKey fileKey, [NotNullWhen

/// <exception cref="IOException"/>
/// <exception cref="BadImageFormatException" />
private AssemblyMetadata CreateAssemblyMetadata(
private static AssemblyMetadata CreateAssemblyMetadata(
FileKey fileKey, ModuleMetadata manifestModule, List<ITemporaryStreamStorage>? storages,
Func<FileKey, List<ITemporaryStreamStorage>?, ModuleMetadata> moduleMetadataFactory)
{
Expand Down
Loading

0 comments on commit 3c4382c

Please sign in to comment.