Skip to content

Commit

Permalink
Merge pull request #63674 from CyrusNajmabadi/useReadOnlyStruct
Browse files Browse the repository at this point in the history
Run 'make struct readonly' on IDE code
  • Loading branch information
CyrusNajmabadi committed Aug 30, 2022
2 parents dd993cd + 31e6e9d commit d73d31c
Show file tree
Hide file tree
Showing 95 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.UseSystemHashCode
/// Helper code to support both "UseSystemHashCodeCodeFixProvider" and
/// <see cref="UseSystemHashCodeDiagnosticAnalyzer"/>.
/// </summary>
internal partial struct Analyzer
internal readonly partial struct Analyzer
{
private readonly Compilation _compilation;
private readonly IMethodSymbol _objectGetHashCodeMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal partial class Controller
{
internal partial class Session
{
internal struct SignatureHelpSelection
internal readonly struct SignatureHelpSelection
{
private readonly SignatureHelpItem _selectedItem;
private readonly bool _userSelected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void UnregisterForVisibilityChanges(ITextBuffer subjectBuffer, Action cal
public TestAccessor GetTestAccessor()
=> new TestAccessor(this);

public struct TestAccessor
public readonly struct TestAccessor
{
private readonly WpfTextBufferVisibilityTracker _visibilityTracker;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Microsoft.CodeAnalysis.Editor
{
internal struct InlineRenameLocation
internal readonly struct InlineRenameLocation
{
public Document Document { get; }
public TextSpan TextSpan { get; }
Expand Down Expand Up @@ -65,7 +65,7 @@ internal enum InlineRenameFileRenameInfo
Allowed
}

internal struct InlineRenameReplacement
internal readonly struct InlineRenameReplacement
{
public InlineRenameReplacementKind Kind { get; }
public TextSpan OriginalSpan { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ private static RenameSpanKind GetRenameSpanKind(InlineRenameReplacementKind kind
}
}

private struct SelectionTracking : IDisposable
private readonly struct SelectionTracking : IDisposable
{
private readonly int? _anchor;
private readonly int? _active;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ internal bool IsInOpenTextBuffer(SnapshotPoint point)
internal TestAccessor GetTestAccessor()
=> new TestAccessor(this);

public struct TestAccessor
public readonly struct TestAccessor
{
private readonly InlineRenameSession _inlineRenameSession;

Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/Core/InlineRename/RenameTrackingSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
{
internal struct RenameTrackingSpan
internal readonly struct RenameTrackingSpan
{
public readonly ITrackingSpan TrackingSpan;
public readonly RenameSpanKind Type;
Expand Down
4 changes: 2 additions & 2 deletions src/EditorFeatures/Core/IntelliSense/ViewTextSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
/// which need to be mapped to ViewTextSpans before comparing to view positions
/// such as the current caret location.
/// </summary>
internal struct ViewTextSpan
internal readonly struct ViewTextSpan
{
public readonly TextSpan TextSpan;

public ViewTextSpan(TextSpan textSpan)
=> this.TextSpan = textSpan;
}

internal struct DisconnectedBufferGraph
internal readonly struct DisconnectedBufferGraph
{
// The subject buffer's snapshot at the point of the initial model's creation
public readonly ITextSnapshot SubjectBufferSnapshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private async Task ProcessItemSelectionAsync(NavigationBarItem item, Cancellatio
StartModelUpdateAndSelectedItemUpdateTasks();
}

public struct TestAccessor
public readonly struct TestAccessor
{
private readonly NavigationBarController _navigationBarController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
{
internal struct VirtualTreePoint : IComparable<VirtualTreePoint>, IEquatable<VirtualTreePoint>
internal readonly struct VirtualTreePoint : IComparable<VirtualTreePoint>, IEquatable<VirtualTreePoint>
{
private readonly SyntaxTree _tree;
private readonly SourceText _text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.CodeAnalysis.EditAndContinue.UnitTests
{
internal struct RudeEditDiagnosticDescription : IEquatable<RudeEditDiagnosticDescription>
internal readonly struct RudeEditDiagnosticDescription : IEquatable<RudeEditDiagnosticDescription>
{
private readonly RudeEditKind _rudeEditKind;
private readonly string _firstLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Roslyn.Test.Utilities
{
public abstract partial class AbstractLanguageServerProtocolTests
{
internal record struct InitializationOptions()
internal readonly record struct InitializationOptions()
{
internal string[] SourceGeneratedMarkups { get; init; } = Array.Empty<string>();
internal LSP.ClientCapabilities ClientCapabilities { get; init; } = new LSP.ClientCapabilities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
{
public struct SignatureHelpTestItem
public readonly struct SignatureHelpTestItem
{
/// <summary>
/// Includes prefix, signature, suffix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.CodeAnalysis.CSharp.ChangeSignature
{
internal struct UnifiedArgumentSyntax : IUnifiedArgumentSyntax
internal readonly struct UnifiedArgumentSyntax : IUnifiedArgumentSyntax
{
private readonly SyntaxNode _argument;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Completion.Providers
{
internal partial class DeclarationNameCompletionProvider
{
internal struct NameDeclarationInfo
internal readonly struct NameDeclarationInfo
{
private static readonly ImmutableArray<SymbolKindOrTypeKind> s_parameterSyntaxKind =
ImmutableArray.Create(new SymbolKindOrTypeKind(SymbolKind.Parameter));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.AddConstructorParametersFromMembers
{
internal partial class AddConstructorParametersFromMembersCodeRefactoringProvider
{
private struct AddConstructorParameterResult
private readonly struct AddConstructorParameterResult
{
internal readonly ImmutableArray<AddConstructorParametersCodeAction> RequiredParameterActions;
internal readonly ImmutableArray<AddConstructorParametersCodeAction> OptionalParameterActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void AddEmbeddedLanguageClassifications(
worker.Recurse(root);
}

private ref struct Worker
private readonly ref struct Worker
{
private readonly AbstractEmbeddedLanguageClassificationService _owner;
private readonly Project _project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.CodeAnalysis.Classification
{
internal struct EmbeddedLanguageClassificationContext
internal readonly struct EmbeddedLanguageClassificationContext
{
private readonly ArrayBuilder<ClassifiedSpan> _result;

Expand Down
2 changes: 1 addition & 1 deletion src/Features/Core/Portable/Intents/IntentResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Features.Intents
/// <summary>
/// Defines the text changes needed to apply an intent.
/// </summary>
internal struct IntentProcessorResult
internal readonly struct IntentProcessorResult
{
/// <summary>
/// The changed solution for this intent result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.QuickInfo
{
internal abstract partial class CommonSemanticQuickInfoProvider
{
public struct TokenInformation
public readonly struct TokenInformation
{
public readonly ImmutableArray<ISymbol> Symbols;

Expand Down
2 changes: 1 addition & 1 deletion src/Features/Core/Portable/Snippets/SnippetData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Snippets
/// Avoids using the Snippet and creating a TextChange/finding cursor
/// position before we know it was the selected CompletionItem.
/// </summary>
internal struct SnippetData
internal readonly struct SnippetData
{
public readonly string Description;
public readonly string SnippetIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void ChangeProgressStatus(ref int referenceCount, ProgressStatus status)
private void OnProgressChanged(ProgressData progressData)
=> ProgressChanged?.Invoke(this, progressData);

private struct ProgressStatusRAII : IDisposable
private readonly struct ProgressStatusRAII : IDisposable
{
private readonly SolutionCrawlerProgressReporter _owner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static ImmutableArray<SpellCheckSpan> GetSpans(Document document, Syntax
return spans.ToImmutable();
}

private ref struct Worker
private readonly ref struct Worker
{
private readonly ISyntaxFactsService _syntaxFacts;
private readonly ISyntaxKinds _syntaxKinds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
/// expected to be. Namely, multiple client can be calling <see cref="IProgress{T}.Report(T)"/> on it at the same
/// time. This is safe, though the order that the items are reported in when called concurrently is not specified.
/// </summary>
internal struct BufferedProgress<T> : IProgress<T[]>, IProgress<T>, IDisposable
internal readonly struct BufferedProgress<T> : IProgress<T[]>, IProgress<T>, IDisposable
{
/// <summary>
/// The progress stream to report results to. May be <see langword="null"/> for clients that do not support streaming.
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Lsif/Generator/Graph/Id.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// </summary>
/// <typeparam name="T">Used to distinguish what type of object this ID applies to. This is dropped in serialization, but simply helps
/// to ensure type safety in the code so we don't cross IDs of different types.</typeparam>
internal struct Id<T> : IEquatable<Id<T>>, ISerializableId where T : Element
internal readonly struct Id<T> : IEquatable<Id<T>>, ISerializableId where T : Element
{
public Id(int id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim
/// it to null instead of true.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct HACK_VariantStructure
internal readonly struct HACK_VariantStructure
{
private readonly short _type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private static bool IsOriginalLocationMovedAboveInFile(int originalLine, int ori
return false;
}

private struct MappedSpan
private readonly struct MappedSpan
{
private readonly int _originalLine;
private readonly int _originalColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Microsoft.VisualStudio.LanguageServices.ExternalAccess.VSTypeScript.Api
{
internal struct VSTypeScriptContainedDocumentWrapper
internal readonly struct VSTypeScriptContainedDocumentWrapper
{
private readonly ContainedDocument _underlyingObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Microsoft.VisualStudio.LanguageServices.ExternalAccess.VSTypeScript.Api
{
internal struct VSTypeScriptContainedLanguageWrapper
internal readonly struct VSTypeScriptContainedLanguageWrapper
{
private readonly ContainedLanguage _underlyingObject;

Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Core/Def/Interop/ComHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Interop
/// </summary>
/// <typeparam name="THandle">The COM interface type to keep a reference to</typeparam>
/// <typeparam name="TObject">The managed object type to keep a reference to</typeparam>
internal struct ComHandle<THandle, TObject>
internal readonly struct ComHandle<THandle, TObject>
where THandle : class
where TObject : class, THandle
{
Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Core/Def/Interop/WeakComHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.VisualStudio.LanguageServices.Implementation.Interop
{
internal struct WeakComHandle<THandle, TObject>
internal readonly struct WeakComHandle<THandle, TObject>
where THandle : class
where TObject : class, THandle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Packaging
{
internal partial class PackageInstallerService
{
private struct ProjectState
private readonly struct ProjectState
{
public static readonly ProjectState Disabled = new(isEnabled: false, ImmutableDictionary<string, string>.Empty);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Microsoft.VisualStudio.LanguageServices.Shared
{
internal struct CompositeImage
internal readonly struct CompositeImage
{
public readonly ImmutableArray<ImageCompositionLayer> Layers;
public readonly IImageHandle ImageHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
{
internal sealed partial class CodeModelProjectCache
{
private struct CacheEntry
private readonly struct CacheEntry
{
// NOTE: The logic here is a little bit tricky. We can't just keep a WeakReference to
// something like a ComHandle, since it's not something that our clients keep alive.
Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Core/Impl/CodeModel/GlobalNodeKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
{
internal struct GlobalNodeKey
internal readonly struct GlobalNodeKey
{
public readonly SyntaxNodeKey NodeKey;
public readonly SyntaxPath Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.Metho
{
internal abstract partial class AbstractMethodXmlBuilder
{
private struct AttributeInfo
private readonly struct AttributeInfo
{
public static readonly AttributeInfo Empty = new AttributeInfo();

Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Core/Impl/CodeModel/ParentHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
{
internal struct ParentHandle<T>
internal readonly struct ParentHandle<T>
{
private readonly ComHandle<object, object> _comHandle;

Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Core/Impl/CodeModel/SyntaxNodeKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
/// ordinal value. The ordinal value is used to distinguish nodes which have the same
/// qualified name -- for example, across partial classes within the same tree.
/// </summary>
internal struct SyntaxNodeKey : IEquatable<SyntaxNodeKey>
internal readonly struct SyntaxNodeKey : IEquatable<SyntaxNodeKey>
{
private readonly string _name;
private readonly int _ordinal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Roslyn.VisualStudio.IntegrationTests.InProcess
{
internal struct InputKey
internal readonly struct InputKey
{
public readonly ImmutableArray<VirtualKeyCode> Modifiers;
public readonly VirtualKeyCode VirtualKeyCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion
/// <summary>
/// Contextual information needed for processing completion requests.
/// </summary>
internal struct XamlCompletionContext
internal readonly struct XamlCompletionContext
{
public XamlCompletionContext(TextDocument document, int offset, char triggerChar = '\0')
{
Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/Xaml/Impl/Features/DocumentSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Microsoft.CodeAnalysis.Editor.Xaml.Features
{
[DebuggerDisplay("{GetDebuggerDisplay(),nq}")]
internal struct DocumentSpan
internal readonly struct DocumentSpan
{
public Document Document { get; }
public TextSpan TextSpan { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Workspaces/CSharp/Portable/Classification/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Classification
/// artifacts T T is normally either ClassificationSpan or a Tuple (for testing purposes)
/// and constructed via provided factory.
/// </summary>
internal ref partial struct Worker
internal readonly ref partial struct Worker
{
private readonly TextSpan _textSpan;
private readonly ArrayBuilder<ClassifiedSpan> _result;
Expand Down
Loading

0 comments on commit d73d31c

Please sign in to comment.