Skip to content

Commit

Permalink
Fix RCS1261 (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Jan 23, 2024
1 parent 72d8f0c commit 301a51a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix analyzer [RCS1055](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1055) ([PR](https://github.com/dotnet/roslynator/pull/1361))
- Fix analyzer [RCS1261](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1261) ([PR](https://github.com/dotnet/roslynator/pull/1374))

## [4.9.0] - 2024-01-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ private static void Analyze(SyntaxNodeAnalysisContext context, StatementSyntax s
Analyze(context, anonymousMethod.Modifiers, usingKeyword, anonymousMethod);
break;
}
else if (node is LockStatementSyntax)
{
return;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,30 @@ internal class Disposable : IDisposable, IAsyncDisposable
public void Dispose() => throw new NotImplementedException();
public ValueTask DisposeAsync() => throw new NotImplementedException();
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.DisposeResourceAsynchronously)]
public async Task TestNoDiagnostic_LockStatement()
{
await VerifyNoDiagnosticAsync(@"
using System.IO;
using System.Threading.Tasks;
abstract class C
{
object _lock = new();
async Task Foo()
{
lock (_lock)
{
using FileStream fs = new(""test.txt"", FileMode.OpenOrCreate);
}
await Task.Yield();
}
}
");
}
}

0 comments on commit 301a51a

Please sign in to comment.