Skip to content

Commit

Permalink
Corrected ReSharper warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmind committed Sep 18, 2016
1 parent 22989c1 commit 627dfec
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 61 deletions.
15 changes: 4 additions & 11 deletions MirrorSharp.AspNetCore.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
using Microsoft.AspNetCore.Hosting;

namespace MirrorSharp.Demo
{
public class Program
{
public static void Main(string[] args)
{
namespace MirrorSharp.Demo {
public class Program {
public static void Main(string[] args) {
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
Expand Down
1 change: 0 additions & 1 deletion MirrorSharp.AspNetCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
15 changes: 7 additions & 8 deletions MirrorSharp.Common/Advanced/MiddlewareBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Net.WebSockets;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using MirrorSharp.Internal;
Expand Down Expand Up @@ -28,13 +27,13 @@ protected async Task WebSocketLoopAsync(WebSocket socket, CancellationToken canc
}
}
}
catch when (connection == null && session != null) {
await session.DisposeAsync().ConfigureAwait(false);
throw;
}
finally {
if (connection != null)
await connection.DisposeAsync().ConfigureAwait(false);
if (connection != null) {
connection.Dispose();
}
else {
session?.Dispose();
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion MirrorSharp.Common/Internal/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using JetBrains.Annotations;

// ReSharper disable CheckNamespace
// ReSharper disable UnusedMember.Global
// ReSharper disable ArrangeStaticMemberQualifier

/// <summary>
/// Provides methods for verification of argument preconditions.
/// </summary>
Expand Down Expand Up @@ -39,7 +42,7 @@ public static T NotNull<T>(
/// <param name="value">Argument value.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="value"/> is <c>null</c>.</exception>
/// <returns><paramref name="value"/> if it is not <c>null</c>.</returns>
[NotNull, AssertionMethod]
[AssertionMethod]
[ContractAnnotation("value:null => halt")]
public static T NotNull<T>(
[NotNull, InvokerParameterName] string name,
Expand Down
4 changes: 2 additions & 2 deletions MirrorSharp.Common/Internal/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Newtonsoft.Json;

namespace MirrorSharp.Internal {
public class Connection : IAsyncDisposable {
public class Connection : IDisposable {
private static readonly Task Done = Task.FromResult((object)null);

private static class Commands {
Expand Down Expand Up @@ -256,6 +256,6 @@ private Task SendJsonMessageAsync(CancellationToken cancellationToken) {
);
}

public Task DisposeAsync() => _session.DisposeAsync();
public void Dispose() => _session.Dispose();
}
}
5 changes: 3 additions & 2 deletions MirrorSharp.Common/Internal/IWorkSession.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Threading;
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Text;
using MirrorSharp.Internal.Results;

namespace MirrorSharp.Internal {
public interface IWorkSession : IAsyncDisposable {
public interface IWorkSession : IDisposable {
SourceText SourceText { get; }
int CursorPosition { get; }

Expand Down
4 changes: 1 addition & 3 deletions MirrorSharp.Common/Internal/Results/SlowUpdateResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;

namespace MirrorSharp.Internal.Results {
Expand Down
6 changes: 1 addition & 5 deletions MirrorSharp.Common/Internal/Results/TypeCharResult.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis.Completion;

namespace MirrorSharp.Internal.Results {
Expand Down
10 changes: 2 additions & 8 deletions MirrorSharp.Common/Internal/WorkSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class WorkSession : IWorkSession {
private CompletionList _completionList;

private readonly CompletionService _completionService;
private readonly CancellationTokenSource _disposing;

private static readonly ImmutableList<MetadataReference> DefaultAssemblyReferences = ImmutableList.Create<MetadataReference>(
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location)
Expand All @@ -43,8 +42,6 @@ public class WorkSession : IWorkSession {
private readonly ImmutableArray<DiagnosticAnalyzer> _analyzers;

public WorkSession() {
_disposing = new CancellationTokenSource();

_workspace = new AdhocWorkspace(HostServices);
var projectId = ProjectId.CreateNewId();
var project = _workspace.AddProject(ProjectInfo.Create(
Expand Down Expand Up @@ -109,11 +106,8 @@ private async Task<TypeCharResult> CreateResultFromCompletionsAsync(Cancellation
public SourceText SourceText => _sourceText;
public int CursorPosition => _cursorPosition;

public async Task DisposeAsync() {
using (_disposing) {
_disposing.Cancel();
_workspace.Dispose();
}
public void Dispose() {
_workspace.Dispose();
}

private class PreloadedAnalyzerAssemblyLoader : IAnalyzerAssemblyLoader {
Expand Down
6 changes: 1 addition & 5 deletions MirrorSharp.Common/MirrorSharpOptions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MirrorSharp.Internal;
using MirrorSharp.Internal;

namespace MirrorSharp {
public sealed class MirrorSharpOptions : IConnectionOptions {
Expand Down
1 change: 0 additions & 1 deletion MirrorSharp.Owin.Demo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
2 changes: 0 additions & 2 deletions MirrorSharp.Owin.Demo/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Owin;
using Microsoft.Owin.StaticFiles;
using MirrorSharp.Owin;
using MirrorSharp.Owin.Demo;
using Owin;

Expand Down
5 changes: 1 addition & 4 deletions MirrorSharp.Owin/Internal/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace MirrorSharp.Owin.Internal {
internal static class DictionaryExtensions {
Expand Down
1 change: 0 additions & 1 deletion MirrorSharp.Owin/Internal/Middleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using JetBrains.Annotations;
using MirrorSharp.Advanced;
using MirrorSharp.Internal;

namespace MirrorSharp.Owin.Internal {
using AppFunc = Func<IDictionary<string, object>, Task>;
Expand Down
1 change: 0 additions & 1 deletion MirrorSharp.Owin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
1 change: 0 additions & 1 deletion MirrorSharp.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
6 changes: 2 additions & 4 deletions MirrorSharp.Tests/SessionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
Expand Down Expand Up @@ -46,7 +44,7 @@ class B { void M(A a) { a| } }

Assert.Equal(
new[] { "x" }.Concat(ObjectMemberNames).OrderBy(n => n),
result.Completions.Items.Select(i => i.DisplayText).OrderBy(n => n)
result.Completions?.Items.Select(i => i.DisplayText).OrderBy(n => n)
);
}

Expand Down
2 changes: 1 addition & 1 deletion MirrorSharp.WebAssets/wwwroot/js/mirrorsharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
socket = openSocket();
openPromise = new Promise(function (resolve) {
socket.addEventListener('open', function () {
reopenPeriodReset = setTimeout(function () { reopenPeriod = 0; }, reopenPeriod);
reopenPeriodResetTimer = setTimeout(function () { reopenPeriod = 0; }, reopenPeriod);
resolve();
});
});
Expand Down
2 changes: 2 additions & 0 deletions MirrorSharp.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=70BCCC0E_002D6EEF_002D40D0_002D932A_002D87F9C42BD67B_002Fd_003Awwwroot_002Fd_003Abower_005Fcomponents/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=D2EB1CDD_002D12B5_002D4FDC_002DA56C_002D8A327200E759_002Fd_003Abower_005Fcomponents/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=Html_002EEventNotResolved/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MissingHasOwnPropertyInForeach/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ThisInGlobalContext/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/JsInspections/LanguageLevel/@EntryValue">ECMAScript 2016</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_OWNER_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
Expand Down

0 comments on commit 627dfec

Please sign in to comment.