Skip to content

Commit f3885b4

Browse files
committed
Enable Roslyn analyzers for OmniSharp in VScode
1 parent 82dbc33 commit f3885b4

File tree

10 files changed

+197
-143
lines changed

10 files changed

+197
-143
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"omnisharp.enableRoslynAnalyzers": true,
23
"dotnet-test-explorer.autoExpandTree": true,
34
"dotnet-test-explorer.autoWatch": true,
45
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj",

FollowingFileStream.ConsoleTestTool/FollowingFileStream.ConsoleTestTool.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PropertyGroup>
88
<OutputType>Exe</OutputType>
99
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
10-
<LangVersion>7.1</LangVersion>
10+
<LangVersion>8.0</LangVersion>
1111
<IsPackable>false</IsPackable>
1212
<noWarn>SA0001</noWarn>
1313
</PropertyGroup>

FollowingFileStream.ConsoleTestTool/Program.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ namespace Manandre.IO
1111
using System.IO;
1212
using System.Threading.Tasks;
1313

14+
/// <summary>
15+
/// Console test tool.
16+
/// </summary>
1417
internal static class Program
1518
{
1619
private const string InputPath = "source.txt";
1720
private const string OutputPath = "destination.txt";
1821

22+
/// <summary>
23+
/// Main routine.
24+
/// </summary>
25+
/// <returns>A task representing the main operation.</returns>
1926
public static async Task Main()
2027
{
2128
var input = WriteInput().ConfigureAwait(false);
@@ -25,20 +32,16 @@ public static async Task Main()
2532

2633
private static async Task WriteInput()
2734
{
28-
using (var sw = new StreamWriter(new FileStream(InputPath, FileMode.Create, FileAccess.Write, FileShare.Read)))
29-
using (var sr = new StreamReader(Console.OpenStandardInput()))
30-
{
31-
await sr.CopyToAsync(sw, stopOn: "quit").ConfigureAwait(false);
32-
}
35+
using var sw = new StreamWriter(new FileStream(InputPath, FileMode.Create, FileAccess.Write, FileShare.Read));
36+
using var sr = new StreamReader(Console.OpenStandardInput());
37+
await sr.CopyToAsync(sw, stopOn: "quit").ConfigureAwait(false);
3338
}
3439

3540
private static async Task CopyToOutput()
3641
{
37-
using (var source = new FollowingFileStream(InputPath))
38-
using (var destination = new FileStream(OutputPath, FileMode.Create, FileAccess.Write, FileShare.Read))
39-
{
40-
await source.CopyToAsync(destination).ConfigureAwait(false);
41-
}
42+
using var source = new FollowingFileStream(InputPath);
43+
using var destination = new FileStream(OutputPath, FileMode.Create, FileAccess.Write, FileShare.Read);
44+
await source.CopyToAsync(destination).ConfigureAwait(false);
4245
}
4346
}
4447
}

FollowingFileStream.ConsoleTestTool/TextReaderExtensions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ namespace Manandre.IO
1010
using System.IO;
1111
using System.Threading.Tasks;
1212

13+
/// <summary>
14+
/// Extension methods for the <see cref="TextReader"/> class.
15+
/// </summary>
1316
internal static class TextReaderExtensions
1417
{
18+
/// <summary>
19+
/// Copy lines from reader to writer until a specific string is reached.
20+
/// </summary>
21+
/// <param name="reader">A text reader to read from.</param>
22+
/// <param name="writer">A text writer to write to.</param>
23+
/// <param name="stopOn">A string on which to stop copying.</param>
24+
/// <returns>A task representing the copy operation.</returns>
1525
public static async Task CopyToAsync(this TextReader reader, TextWriter writer, string stopOn)
1626
{
17-
string line = string.Empty;
27+
string line;
1828
while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != stopOn)
1929
{
2030
await writer.WriteLineAsync(line).ConfigureAwait(false);

FollowingFileStream.Tests/AsyncStreamTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ namespace Manandre.IO
1414
using Microsoft.VisualStudio.TestTools.UnitTesting;
1515
using Moq;
1616

17+
/// <summary>
18+
/// Test class for AsyncStream.
19+
/// </summary>
1720
[TestClass]
1821
public class AsyncStreamTest
1922
{
23+
/// <summary>
24+
/// Test AsyncStream read operations.
25+
/// </summary>
2026
[TestMethod]
2127
public void ASRead()
2228
{
@@ -31,6 +37,9 @@ public void ASRead()
3137
Assert.AreEqual(expected, read);
3238
}
3339

40+
/// <summary>
41+
/// Test AsyncStream write operations.
42+
/// </summary>
3443
[TestMethod]
3544
public void ASWrite()
3645
{
@@ -44,6 +53,9 @@ public void ASWrite()
4453
sut.Verify(x => x.WriteAsync(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<CancellationToken>()), Times.Exactly(2));
4554
}
4655

56+
/// <summary>
57+
/// Test AsyncStream flush operations.
58+
/// </summary>
4759
[TestMethod]
4860
public void ASFlush()
4961
{
@@ -53,6 +65,9 @@ public void ASFlush()
5365
sut.Verify(x => x.FlushAsync(It.IsAny<CancellationToken>()), Times.Once);
5466
}
5567

68+
/// <summary>
69+
/// Test AsyncStream dispose operations.
70+
/// </summary>
5671
[TestMethod]
5772
public void ASDispose()
5873
{
@@ -61,6 +76,9 @@ public void ASDispose()
6176
sut.Object.Dispose();
6277
}
6378

79+
/// <summary>
80+
/// Test AsyncStream synchronized operations.
81+
/// </summary>
6482
[TestMethod]
6583
public void ASSynchronized()
6684
{

FollowingFileStream.Tests/FollowingFileStream.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
4+
<LangVersion>8.0</LangVersion>
45
<IsPackable>false</IsPackable>
56
<noWarn>SA0001</noWarn>
67
</PropertyGroup>

0 commit comments

Comments
 (0)