Skip to content
Merged
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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Order named arguments even if optional arguments are not specified [RCS1205](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1205.md) ([#941](https://github.com/josefpihrt/roslynator/pull/941).
- Prefix identifier with `@` if necessary ([RCS1220](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1220.md)) ([#943](https://github.com/josefpihrt/roslynator/pull/943).
- Do not suggest to make local variable a const when it is used in ref extension method ([RCS1118](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1118.md)) ([#948](https://github.com/josefpihrt/roslynator/pull/948).
- Fix formatting of argument list ([#952](https://github.com/josefpihrt/roslynator/pull/952).

-----
<!-- Content below does not adhere to 'Keep a Changelog' format -->
Expand Down
6 changes: 3 additions & 3 deletions src/CSharp/CSharp/IndentationAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ private IndentationAnalysis(SyntaxTrivia indentation, int indentSize)

public SyntaxTrivia Indentation => (_indentSize == -1) ? default : _indentation;

public int IndentSize => (_indentSize == -1) ? _indentation.Span.Length : _indentSize;
public int IndentSize => (_indentSize == -1) ? 0 : _indentSize;

public int IndentationLength => (_indentSize == -1) ? 0 : Indentation.Span.Length;

public int IncreasedIndentationLength => (_indentSize == -1) ? _indentation.Span.Length : (Indentation.Span.Length + _indentSize);
public int IncreasedIndentationLength => (_indentSize == -1) ? 0 : (Indentation.Span.Length + _indentSize);

public bool IsDefault => _indentation == default && _indentSize == 0;

Expand All @@ -47,7 +47,7 @@ public static IndentationAnalysis Create(SyntaxNode node, CancellationToken canc
{
return (trivia1.Span.Length > 0)
? new IndentationAnalysis(indentation, trivia1.Span.Length)
: new IndentationAnalysis(indentation, indentation.Span.Length);
: new IndentationAnalysis(indentation, -1);
}
else if (trivia1.Span.Length > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,5 +1272,29 @@ await VerifyNoDiagnosticAsync(@"
.Select(f => f);
", options: Options.WithCompilationOptions(Options.CompilationOptions.WithOutputKind(OutputKind.ConsoleApplication)));
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.FixFormattingOfList)]
public async Task TestNoDiagnostic_ArrayInitializerInGlobalStatement()
{
await VerifyNoDiagnosticAsync(@"
Foo.Method(
foo: new Foo[]
{
new Foo(
"""")
});
", additionalFiles: new[] { @"
public class Foo
{
public Foo(string v1)
{
}

internal static void Method(Foo[] foo)
{
}
}
" }, options: Options.WithCompilationOptions(Options.CompilationOptions.WithOutputKind(OutputKind.ConsoleApplication)));
}
}
}