Skip to content

Commit

Permalink
Run analyzer on IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Feb 22, 2023
1 parent 7347efa commit 542ddeb
Show file tree
Hide file tree
Showing 38 changed files with 103 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public OperationDeconstructor(
_accessesBase = false;
}

public void Dispose()
public readonly void Dispose()
=> _hashedSymbols.Free();

public (bool accessesBase, ImmutableArray<ISymbol> hashedSymbol) GetResult()
public readonly (bool accessesBase, ImmutableArray<ISymbol> hashedSymbol) GetResult()
=> (_accessesBase, _hashedSymbols.ToImmutable());

/// <summary>
Expand Down Expand Up @@ -194,7 +194,7 @@ private static bool TryGetFieldOrProperty(IOperation operation, [NotNullWhen(tru
return false;
}

private bool TryAddSymbol(ISymbol member)
private readonly bool TryAddSymbol(ISymbol member)
{
// Not a legal GetHashCode to convert if we refer to members multiple times.
if (_hashedSymbols.Contains(member))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public CustomDebugInfoEncoder(BlobBuilder builder)
builder.WriteInt16(0);
}

public int RecordCount => _recordCount;
public readonly int RecordCount => _recordCount;

/// <exception cref="InvalidOperationException">More than <see cref="byte.MaxValue"/> records added.</exception>
public byte[] ToArray()
public readonly byte[] ToArray()
{
if (_recordCount == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal Enumerator(SegmentedHashSet<T> set)
/// <inheritdoc cref="ImmutableHashSet{T}.Enumerator.Current"/>
public T Current => _enumerator.Current;

object? IEnumerator.Current => ((IEnumerator)_enumerator).Current;
readonly object? IEnumerator.Current => ((IEnumerator)_enumerator).Current;

/// <inheritdoc cref="ImmutableHashSet{T}.Enumerator.Dispose()"/>
public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal Enumerator(SegmentedList<T> list)

public T Current => _enumerator.Current;

object? IEnumerator.Current => ((IEnumerator)_enumerator).Current;
readonly object? IEnumerator.Current => ((IEnumerator)_enumerator).Current;

public void Dispose()
=> _enumerator.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ internal ValueBuilder(ImmutableSegmentedList<T> list)

public int Count => ReadOnlyList.Count;

private SegmentedList<T> ReadOnlyList => _mutableList ?? _list._list;
private readonly SegmentedList<T> ReadOnlyList => _mutableList ?? _list._list;

bool ICollection<T>.IsReadOnly => false;
readonly bool ICollection<T>.IsReadOnly => false;

bool IList.IsFixedSize => false;
readonly bool IList.IsFixedSize => false;

bool IList.IsReadOnly => false;
readonly bool IList.IsReadOnly => false;

bool ICollection.IsSynchronized => false;
readonly bool ICollection.IsSynchronized => false;

object ICollection.SyncRoot => throw new NotSupportedException();
readonly object ICollection.SyncRoot => throw new NotSupportedException();

public T this[int index]
{
Expand Down
4 changes: 2 additions & 2 deletions src/Dependencies/Collections/Internal/BitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal BitHelper(Span<int> span, bool clear)
_span = span;
}

internal void MarkBit(int bitPosition)
internal readonly void MarkBit(int bitPosition)
{
var bitArrayIndex = bitPosition / IntSize;
if ((uint)bitArrayIndex < (uint)_span.Length)
Expand All @@ -35,7 +35,7 @@ internal void MarkBit(int bitPosition)
}
}

internal bool IsMarked(int bitPosition)
internal readonly bool IsMarked(int bitPosition)
{
var bitArrayIndex = bitPosition / IntSize;
return
Expand Down
10 changes: 5 additions & 5 deletions src/Dependencies/Collections/SegmentedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public AlignedSegmentEnumerator(T[][] firstSegments, int firstOffset, T[][] seco
_current = (Memory<T>.Empty, Memory<T>.Empty);
}

public (Memory<T> first, Memory<T> second) Current => _current;
public readonly (Memory<T> first, Memory<T> second) Current => _current;

public bool MoveNext()
{
Expand Down Expand Up @@ -570,7 +570,7 @@ public UnalignedSegmentEnumerator(T[][] firstSegments, int firstOffset, T[][] se
_current = (Memory<T>.Empty, Memory<T>.Empty);
}

public (Memory<T> first, Memory<T> second) Current => _current;
public readonly (Memory<T> first, Memory<T> second) Current => _current;

public bool MoveNext()
{
Expand Down Expand Up @@ -618,7 +618,7 @@ public Reverse(T[][] firstSegments, int firstOffset, T[][] secondSegments, int s
_current = (Memory<T>.Empty, Memory<T>.Empty);
}

public (Memory<T> first, Memory<T> second) Current => _current;
public readonly (Memory<T> first, Memory<T> second) Current => _current;

public bool MoveNext()
{
Expand Down Expand Up @@ -710,7 +710,7 @@ public SegmentEnumerator(T[][] segments, int offset, int length)
_current = Memory<T>.Empty;
}

public Memory<T> Current => _current;
public readonly Memory<T> Current => _current;

public bool MoveNext()
{
Expand Down Expand Up @@ -759,7 +759,7 @@ public Reverse(T[][] segments, int offset, int length)
_current = Memory<T>.Empty;
}

public Memory<T> Current => _current;
public readonly Memory<T> Current => _current;

public bool MoveNext()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Dependencies/Collections/SegmentedArray`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ public Enumerator(SegmentedArray<T> array)
_current = default!;
}

public T Current => _current;
public readonly T Current => _current;
object? IEnumerator.Current => Current;

public void Dispose()
public readonly void Dispose()
{
}

Expand Down
24 changes: 12 additions & 12 deletions src/Dependencies/Collections/SegmentedDictionary`2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,13 +1178,13 @@ public bool MoveNext()
return false;
}

public KeyValuePair<TKey, TValue> Current => _current;
public readonly KeyValuePair<TKey, TValue> Current => _current;

public void Dispose()
public readonly void Dispose()
{
}

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down Expand Up @@ -1213,7 +1213,7 @@ void IEnumerator.Reset()
_current = default;
}

DictionaryEntry IDictionaryEnumerator.Entry
readonly DictionaryEntry IDictionaryEnumerator.Entry
{
get
{
Expand All @@ -1226,7 +1226,7 @@ DictionaryEntry IDictionaryEnumerator.Entry
}
}

object IDictionaryEnumerator.Key
readonly object IDictionaryEnumerator.Key
{
get
{
Expand All @@ -1239,7 +1239,7 @@ object IDictionaryEnumerator.Key
}
}

object? IDictionaryEnumerator.Value
readonly object? IDictionaryEnumerator.Value
{
get
{
Expand Down Expand Up @@ -1398,7 +1398,7 @@ internal Enumerator(SegmentedDictionary<TKey, TValue> dictionary)
_currentKey = default;
}

public void Dispose()
public readonly void Dispose()
{
}

Expand All @@ -1425,9 +1425,9 @@ public bool MoveNext()
return false;
}

public TKey Current => _currentKey!;
public readonly TKey Current => _currentKey!;

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down Expand Up @@ -1598,7 +1598,7 @@ internal Enumerator(SegmentedDictionary<TKey, TValue> dictionary)
_currentValue = default;
}

public void Dispose()
public readonly void Dispose()
{
}

Expand All @@ -1624,9 +1624,9 @@ public bool MoveNext()
return false;
}

public TValue Current => _currentValue!;
public readonly TValue Current => _currentValue!;

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down
6 changes: 3 additions & 3 deletions src/Dependencies/Collections/SegmentedHashSet`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,11 +1422,11 @@ public bool MoveNext()
return false;
}

public T Current => _current;
public readonly T Current => _current;

public void Dispose() { }
public readonly void Dispose() { }

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down
4 changes: 2 additions & 2 deletions src/Dependencies/Collections/SegmentedList`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ internal Enumerator(SegmentedList<T> list)
_current = default;
}

public void Dispose()
public readonly void Dispose()
{
}

Expand Down Expand Up @@ -1205,7 +1205,7 @@ private bool MoveNextRare()
return false;
}

public T Current => _current!;
public readonly T Current => _current!;

object? IEnumerator.Current
{
Expand Down
2 changes: 1 addition & 1 deletion src/Dependencies/PooledObjects/ArrayBuilder.Enumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Enumerator(ArrayBuilder<T> builder)
_index = -1;
}

public T Current
public readonly T Current
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct MatchingPair
public string Old;
public string New;

public override string ToString()
public override readonly string ToString()
=> "{ \"" + Old.Replace("\"", "\\\"") + "\", \"" + New.Replace("\"", "\\\"") + "\" }";
}

Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/TestUtilities/Rename/RenamerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected struct DocumentWithInfo
public string Text { get; set; }
public string DocumentName { get; set; }
public string DocumentFilePath { get; set; }
public string[] DocumentFolders => GetDocumentFolders(DocumentFilePath);
public readonly string[] DocumentFolders => GetDocumentFolders(DocumentFilePath);
}

protected async Task TestRenameDocument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TypeEnumerator(Type type)
_stack.Push(type);
}

public Type Current => _stack.Peek();
public readonly Type Current => _stack.Peek();

public bool MoveNext()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DkmEvaluationAsyncResult(DkmEvaluationResult Result)

public int ErrorCode { get { throw new NotImplementedException(); } }

public DkmEvaluationResult Result { get { return _result; } }
public readonly DkmEvaluationResult Result { get { return _result; } }

internal Exception Exception { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public JsonLexer(VirtualCharSequence text) : this()
Text = text;
}

public VirtualChar CurrentChar => Text[Position];
public readonly VirtualChar CurrentChar => Text[Position];

public VirtualCharSequence GetCharsToCurrentPosition(int start)
=> GetSubSequence(start, Position);

public VirtualCharSequence GetSubSequence(int start, int end)
public readonly VirtualCharSequence GetSubSequence(int start, int end)
=> Text.GetSubSequence(TextSpan.FromBounds(start, end));

public JsonToken ScanNextToken()
Expand Down Expand Up @@ -314,13 +314,13 @@ private JsonTrivia ScanMultiLineComment()
new EmbeddedDiagnostic(FeaturesResources.Unterminated_comment, GetTextSpan(start, Position)));
}

private TextSpan GetTextSpan(int startInclusive, int endExclusive)
private readonly TextSpan GetTextSpan(int startInclusive, int endExclusive)
=> TextSpan.FromBounds(Text[startInclusive].Span.Start, Text[endExclusive - 1].Span.End);

private bool IsAt(string val)
=> TextAt(this.Position, val);

private bool TextAt(int position, string val)
private readonly bool TextAt(int position, string val)
{
for (var i = 0; i < val.Length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private JsonSeparatedList ParseCommaSeparatedSequenceWorker()
return new JsonSeparatedList(result.ToImmutable());
}

private bool ShouldConsumeSequenceElement()
private readonly bool ShouldConsumeSequenceElement()
=> _currentToken.Kind switch
{
JsonKind.EndOfFile => false,
Expand Down Expand Up @@ -587,7 +587,7 @@ private JsonToken ConsumeToken(JsonKind kind, string? error)
return result.AddDiagnosticIfNone(new EmbeddedDiagnostic(error, GetTokenStartPositionSpan(_currentToken)));
}

private TextSpan GetTokenStartPositionSpan(JsonToken token)
private readonly TextSpan GetTokenStartPositionSpan(JsonToken token)
=> token.Kind == JsonKind.EndOfFile
? new TextSpan(_lexer.Text.Last().Span.End, 0)
: new TextSpan(token.VirtualChars[0].Span.Start, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ internal struct RegexLexer
public RegexLexer(VirtualCharSequence text) : this()
=> Text = text;

public VirtualChar CurrentChar => Position < Text.Length ? Text[Position] : default;
public readonly VirtualChar CurrentChar => Position < Text.Length ? Text[Position] : default;

public VirtualCharSequence GetSubPatternToCurrentPos(int start)
=> GetSubPattern(start, Position);

public VirtualCharSequence GetSubPattern(int start, int end)
public readonly VirtualCharSequence GetSubPattern(int start, int end)
=> Text.GetSubSequence(TextSpan.FromBounds(start, end));

public RegexToken ScanNextToken(bool allowTrivia, RegexOptions options)
Expand Down Expand Up @@ -175,13 +175,13 @@ private ImmutableArray<RegexTrivia> ScanLeadingTrivia(bool allowTrivia, RegexOpt
return null;
}

public TextSpan GetTextSpan(int startInclusive, int endExclusive)
public readonly TextSpan GetTextSpan(int startInclusive, int endExclusive)
=> TextSpan.FromBounds(Text[startInclusive].Span.Start, Text[endExclusive - 1].Span.End);

public bool IsAt(string val)
=> TextAt(this.Position, val);

private bool TextAt(int position, string val)
private readonly bool TextAt(int position, string val)
{
for (var i = 0; i < val.Length; i++)
{
Expand Down
Loading

0 comments on commit 542ddeb

Please sign in to comment.