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 @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix analyzer [RCS1246](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1246) ([PR](https://github.com/dotnet/roslynator/pull/1460))
- Fix analyzer [RCS1085](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1085) ([PR](https://github.com/dotnet/roslynator/pull/1461))

## [4.12.2] - 2024-04-23

Expand Down
2 changes: 1 addition & 1 deletion src/Analyzers/CSharp/Analysis/UseAutoPropertyAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public override void VisitArgument(ArgumentSyntax node)
{
CancellationToken.ThrowIfCancellationRequested();

if (node.RefOrOutKeyword.IsKind(SyntaxKind.RefKeyword, SyntaxKind.OutKeyword))
if (node.RefOrOutKeyword.IsKind(SyntaxKind.RefKeyword, SyntaxKind.OutKeyword, SyntaxKind.InKeyword))
{
ExpressionSyntax expression = node.Expression?.WalkDownParentheses();

Expand Down
29 changes: 29 additions & 0 deletions src/Tests/Analyzers.Tests/RCS1085UseAutoPropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -952,4 +952,33 @@ class C
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseAutoProperty)]
public async Task TestNoDiagnostic_BackingFieldUsedByReference()
{
await VerifyNoDiagnosticAsync(@"
using System.Buffers;

class Repro(ReadOnlySequence<byte> data)
{
public ReadOnlySequence<byte> Data => _data;
private readonly ReadOnlySequence<byte> _data = data;

public void Method(IBufferWriter<byte> writer)
{
Write1(in _data, writer);
Write2(in _data, writer);
}

private static void Write1(in ReadOnlySequence<byte> data, IBufferWriter<byte> writer)
{
data.CopyTo(writer.GetSpan((int)data.Length));
}

private static void Write2(ref readonly ReadOnlySequence<byte> data, IBufferWriter<byte> writer)
{
data.CopyTo(writer.GetSpan((int)data.Length));
}
}");
}
}