@@ -29,6 +29,7 @@ public static IEnumerable<object[]> TestStatements
2929 yield return new [ ] { "while (i == 0)" } ;
3030 yield return new [ ] { "for (var j = 0; j < i; j++)" } ;
3131 yield return new [ ] { "foreach (var j in new[] { 1, 2, 3 })" } ;
32+ yield return new [ ] { "lock (new object())" } ;
3233 yield return new [ ] { "using (default(System.IDisposable))" } ;
3334 }
3435 }
@@ -363,6 +364,84 @@ public void Bar(int i)
363364 await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
364365 }
365366
367+ [ Fact ]
368+ public async Task TestSingleLineFixedStatementWithoutBracesAsync ( )
369+ {
370+ var testCode = @"public class C {
371+ unsafe private static void TestMethod()
372+ {
373+ var a = new int[] { 1, 2, 3 };
374+ fixed (int* n = &a[0])
375+ *n = a[1] + a[2];
376+ }
377+ }" ;
378+
379+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
380+ }
381+
382+ [ Fact ]
383+ public async Task TestMultiLineFixedStatementWithoutBracesAsync ( )
384+ {
385+ var testCode = @"public class C {
386+ unsafe private static void TestMethod()
387+ {
388+ var a = new int[] { 1, 2, 3 };
389+ fixed (int* n = &a[0])
390+ *n = a[1]
391+ + a[2];
392+ }
393+ }" ;
394+ var fixedCode = @"public class C {
395+ unsafe private static void TestMethod()
396+ {
397+ var a = new int[] { 1, 2, 3 };
398+ fixed (int* n = &a[0])
399+ {
400+ *n = a[1]
401+ + a[2];
402+ }
403+ }
404+ }" ;
405+
406+ var expected = Diagnostic ( ) . WithLocation ( 6 , 13 ) ;
407+ await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
408+ }
409+
410+ [ Fact ]
411+ public async Task TestSingleLineFixedStatementWithBracesAsync ( )
412+ {
413+ var testCode = @"public class C {
414+ unsafe private static void TestMethod()
415+ {
416+ var a = new int[] { 1, 2, 3 };
417+ fixed (int* n = &a[0])
418+ {
419+ *n = a[1] + a[2];
420+ }
421+ }
422+ }" ;
423+
424+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
425+ }
426+
427+ [ Fact ]
428+ public async Task TestMultiLineFixedStatementWithBracesAsync ( )
429+ {
430+ var testCode = @"public class C {
431+ unsafe private static void TestMethod()
432+ {
433+ var a = new int[] { 1, 2, 3 };
434+ fixed (int* n = &a[0])
435+ {
436+ *n = a[1]
437+ + a[2];
438+ }
439+ }
440+ }" ;
441+
442+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
443+ }
444+
366445 /// <summary>
367446 /// Verifies that the code fix provider will work properly for a statement.
368447 /// </summary>
0 commit comments