Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public PooledObject(ObjectPool<T> pool, Func<ObjectPool<T>, T> allocator, Action
this.releaser = releaser;
}

public T Object
public readonly T Object
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ private static int BinarySearch(SyntaxTriviaList leadingTrivia, SyntaxTrivia tri
/// <summary>
/// Helper class that merges two SyntaxTriviaLists with (hopefully) the lowest possible performance penalty.
/// </summary>
internal struct DualTriviaListHelper : IReadOnlyList<SyntaxTrivia>
internal readonly struct DualTriviaListHelper : IReadOnlyList<SyntaxTrivia>
{
private readonly SyntaxTriviaList part1;
private readonly int part1Count;
Expand Down
42 changes: 21 additions & 21 deletions StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private JsonValue(JsonValueType type, double value, object reference)
/// Gets the type of this JsonValue.
/// </summary>
/// <value>The type of this JsonValue.</value>
public JsonValueType Type
public readonly JsonValueType Type
{
get
{
Expand All @@ -163,7 +163,7 @@ public JsonValueType Type
/// Gets a value indicating whether this JsonValue is Null.
/// </summary>
/// <value>A value indicating whether this JsonValue is Null.</value>
public bool IsNull
public readonly bool IsNull
{
get
{
Expand All @@ -175,7 +175,7 @@ public bool IsNull
/// Gets a value indicating whether this JsonValue is a Boolean.
/// </summary>
/// <value>A value indicating whether this JsonValue is a Boolean.</value>
public bool IsBoolean
public readonly bool IsBoolean
{
get
{
Expand All @@ -187,7 +187,7 @@ public bool IsBoolean
/// Gets a value indicating whether this JsonValue is an Integer.
/// </summary>
/// <value>A value indicating whether this JsonValue is an Integer.</value>
public bool IsInteger
public readonly bool IsInteger
{
get
{
Expand All @@ -205,7 +205,7 @@ public bool IsInteger
/// Gets a value indicating whether this JsonValue is a Number.
/// </summary>
/// <value>A value indicating whether this JsonValue is a Number.</value>
public bool IsNumber
public readonly bool IsNumber
{
get
{
Expand All @@ -217,7 +217,7 @@ public bool IsNumber
/// Gets a value indicating whether this JsonValue is a String.
/// </summary>
/// <value>A value indicating whether this JsonValue is a String.</value>
public bool IsString
public readonly bool IsString
{
get
{
Expand All @@ -229,7 +229,7 @@ public bool IsString
/// Gets a value indicating whether this JsonValue is a JsonObject.
/// </summary>
/// <value>A value indicating whether this JsonValue is a JsonObject.</value>
public bool IsJsonObject
public readonly bool IsJsonObject
{
get
{
Expand All @@ -241,7 +241,7 @@ public bool IsJsonObject
/// Gets a value indicating whether this JsonValue is a JsonArray.
/// </summary>
/// <value>A value indicating whether this JsonValue is a JsonArray.</value>
public bool IsJsonArray
public readonly bool IsJsonArray
{
get
{
Expand All @@ -253,7 +253,7 @@ public bool IsJsonArray
/// Gets a value indicating whether this JsonValue represents a DateTime.
/// </summary>
/// <value>A value indicating whether this JsonValue represents a DateTime.</value>
public bool IsDateTime
public readonly bool IsDateTime
{
get
{
Expand All @@ -265,7 +265,7 @@ public bool IsDateTime
/// Gets a value indicating whether this value is true or false.
/// </summary>
/// <value>This value as a Boolean type.</value>
public bool AsBoolean
public readonly bool AsBoolean
{
get
{
Expand Down Expand Up @@ -294,7 +294,7 @@ public bool AsBoolean
/// Gets this value as an Integer type.
/// </summary>
/// <value>This value as an Integer type.</value>
public int AsInteger
public readonly int AsInteger
{
get
{
Expand All @@ -319,7 +319,7 @@ public int AsInteger
/// Gets this value as a Number type.
/// </summary>
/// <value>This value as a Number type.</value>
public double AsNumber
public readonly double AsNumber
{
get
{
Expand Down Expand Up @@ -354,7 +354,7 @@ public double AsNumber
/// Gets this value as a String type.
/// </summary>
/// <value>This value as a String type.</value>
public string AsString
public readonly string AsString
{
get
{
Expand All @@ -381,7 +381,7 @@ public string AsString
/// Gets this value as an JsonObject.
/// </summary>
/// <value>This value as an JsonObject.</value>
public JsonObject AsJsonObject
public readonly JsonObject AsJsonObject
{
get
{
Expand All @@ -395,7 +395,7 @@ public JsonObject AsJsonObject
/// Gets this value as an JsonArray.
/// </summary>
/// <value>This value as an JsonArray.</value>
public JsonArray AsJsonArray
public readonly JsonArray AsJsonArray
{
get
{
Expand All @@ -409,7 +409,7 @@ public JsonArray AsJsonArray
/// Gets this value as a system.DateTime.
/// </summary>
/// <value>This value as a system.DateTime.</value>
public DateTime? AsDateTime
public readonly DateTime? AsDateTime
{
get
{
Expand All @@ -430,7 +430,7 @@ public DateTime? AsDateTime
/// Gets this (inner) value as a System.object.
/// </summary>
/// <value>This (inner) value as a System.object.</value>
public object AsObject
public readonly object AsObject
{
get
{
Expand Down Expand Up @@ -458,7 +458,7 @@ public object AsObject
/// <exception cref="System.InvalidOperationException">
/// Thrown when this JsonValue is not a JsonObject.
/// </exception>
public JsonValue this[string key]
public readonly JsonValue this[string key]
{
get
{
Expand Down Expand Up @@ -492,7 +492,7 @@ public JsonValue this[string key]
/// <exception cref="InvalidOperationException">
/// Thrown when this <see cref="JsonValue"/> is not a <see cref="JsonArray"/>.
/// </exception>
public JsonValue this[int index]
public readonly JsonValue this[int index]
{
get
{
Expand Down Expand Up @@ -813,7 +813,7 @@ public static JsonValue Parse(string text)
}

/// <inheritdoc/>
public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj == null)
{
Expand All @@ -832,7 +832,7 @@ public override bool Equals(object obj)
}

/// <inheritdoc/>
public override int GetHashCode()
public override readonly int GetHashCode()
{
if (this.IsNull)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ public Enumerator(SeparatedSyntaxListWrapper<TNode> wrapper)
this.current = default;
}

public TNode Current => this.current;
public readonly TNode Current => this.current;

object IEnumerator.Current => this.Current;
readonly object IEnumerator.Current => this.Current;

public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
Enumerator? otherOpt = obj as Enumerator?;
if (!otherOpt.HasValue)
Expand All @@ -189,7 +189,7 @@ public override bool Equals(object obj)
&& other.index == this.index;
}

public override int GetHashCode()
public override readonly int GetHashCode()
{
if (this.wrapper == null)
{
Expand All @@ -199,7 +199,7 @@ public override int GetHashCode()
return this.wrapper.GetHashCode() ^ this.index;
}

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

Expand Down
2 changes: 1 addition & 1 deletion StyleCop.Analyzers/StyleCopTester/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ private static void PrintHelp()
Console.WriteLine("/edititer:<iterations> Specifies the number of iterations to use for testing documents with /editperf. When this is not specified, the default value is 10.");
}

private struct DocumentAnalyzerPerformance
private readonly struct DocumentAnalyzerPerformance
{
public DocumentAnalyzerPerformance(double editsPerSecond)
{
Expand Down
2 changes: 1 addition & 1 deletion StyleCop.Analyzers/StyleCopTester/Statistic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace StyleCopTester
{
internal struct Statistic
internal readonly struct Statistic
{
public Statistic(int numberOfNodes, int numberOfTokens, int numberOfTrivia)
{
Expand Down
Loading