Skip to content

Commit ca3e1f2

Browse files
committed
Code cleanup and updating stylecop settings
1 parent fa7d33c commit ca3e1f2

38 files changed

+169
-145
lines changed

src/WebJobs.Script.Grpc/Abstractions/ArgumentsDescription.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
55

@@ -8,22 +8,22 @@ namespace Microsoft.Azure.WebJobs.Script.Abstractions
88
public class ArgumentsDescription
99
{
1010
/// <summary>
11-
/// The path to the executable (java, node, etc).
11+
/// Gets or sets the path to the executable (java, node, etc).
1212
/// </summary>
1313
public string ExecutablePath { get; set; }
1414

1515
/// <summary>
16-
/// Arguments to be passed to the executable. Optional.
16+
/// Gets or sets arguments to be passed to the executable. Optional.
1717
/// </summary>
1818
public List<string> ExecutableArguments { get; set; } = new List<string>();
1919

2020
/// <summary>
21-
/// The path to the worker file, i.e. nodejsWorker.js.
21+
/// Gets or sets the path to the worker file, i.e. nodejsWorker.js.
2222
/// </summary>
2323
public string WorkerPath { get; set; }
2424

2525
/// <summary>
26-
/// Arguments to be passed to the worker. Optional.
26+
/// Gets or sets arguments to be passed to the worker. Optional.
2727
/// </summary>
2828
public List<string> WorkerArguments { get; set; } = new List<string>();
2929
}

src/WebJobs.Script.Grpc/Abstractions/DefaultWorkerOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
namespace Microsoft.Azure.WebJobs.Script.Abstractions
55
{
66
public class DefaultWorkerOptions
77
{
88
/// <summary>
9-
/// The path to the worker
9+
/// Gets or sets the path to the worker
1010
/// </summary>
1111
public string Path { get; set; } = string.Empty;
1212

1313
/// <summary>
14-
/// The debugging port
14+
/// Gets or sets the debugging port
1515
/// </summary>
1616
public string Debug { get; set; } = string.Empty;
1717

src/WebJobs.Script.Grpc/Abstractions/IRpcServer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
55
using System.Collections.Generic;
@@ -10,6 +10,11 @@ namespace Microsoft.Azure.WebJobs.Script.Abstractions
1010
{
1111
public interface IRpcServer
1212
{
13+
/// <summary>
14+
/// Gets the address that the rpc server is listening on
15+
/// </summary>
16+
Uri Uri { get; }
17+
1318
/// <summary>
1419
/// Starts a server which will listen for rpc connections
1520
/// </summary>
@@ -21,10 +26,5 @@ public interface IRpcServer
2126
/// </summary>
2227
/// <returns>A task that completes when the server has shutdown</returns>
2328
Task ShutdownAsync();
24-
25-
/// <summary>
26-
/// The address that the rpc server is listening on
27-
/// </summary>
28-
Uri Uri { get; }
2929
}
3030
}

src/WebJobs.Script.Grpc/Abstractions/IWorkerProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.Logging;

src/WebJobs.Script.Grpc/Abstractions/WorkerDescription.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
namespace Microsoft.Azure.WebJobs.Script.Abstractions
55
{
66
public class WorkerDescription
77
{
88
/// <summary>
9-
/// The name of the supported language. This is the same name as the IConfiguration section for the worker.
9+
/// Gets or sets the name of the supported language. This is the same name as the IConfiguration section for the worker.
1010
/// </summary>
1111
public string Language { get; set; }
1212

1313
/// <summary>
14-
/// The supported file extension type. Functions are registered with workers based on extension.
14+
/// Gets or sets the supported file extension type. Functions are registered with workers based on extension.
1515
/// </summary>
1616
public string Extension { get; set; }
1717

1818
/// <summary>
19-
/// The default executable path.
19+
/// Gets or sets the default executable path.
2020
/// </summary>
2121
public string DefaultExecutablePath { get; set; }
2222

2323
/// <summary>
24-
/// The default path to the worker (relative to the bin/workers/{language} directory)
24+
/// Gets or sets the default path to the worker (relative to the bin/workers/{language} directory)
2525
/// </summary>
2626
public string DefaultWorkerPath { get; set; }
2727
}

src/WebJobs.Script.Grpc/Server/GrpcServer.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
1010

1111
namespace Microsoft.Azure.WebJobs.Script.Grpc
12-
{
12+
{
1313
public class GrpcServer : IRpcServer, IDisposable
1414
{
1515
private Server _server;
16+
private bool _disposed = false;
1617

1718
public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl)
1819
{
@@ -23,34 +24,31 @@ public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl)
2324
};
2425
}
2526

26-
public Task StartAsync() {
27+
public Uri Uri => new Uri($"http://127.0.0.1:{_server.Ports.First().BoundPort}");
28+
29+
public Task StartAsync()
30+
{
2731
_server.Start();
2832
return Task.CompletedTask;
2933
}
3034

3135
public Task ShutdownAsync() => _server.ShutdownAsync();
3236

33-
public Uri Uri => new Uri($"http://127.0.0.1:{_server.Ports.First().BoundPort}");
34-
35-
#region IDisposable Support
36-
private bool disposedValue = false; // To detect redundant calls
37-
3837
protected virtual void Dispose(bool disposing)
3938
{
40-
if (!disposedValue)
39+
if (!_disposed)
4140
{
4241
if (disposing)
4342
{
4443
_server.ShutdownAsync();
4544
}
46-
disposedValue = true;
45+
_disposed = true;
4746
}
4847
}
4948

5049
public void Dispose()
5150
{
5251
Dispose(true);
5352
}
54-
#endregion
5553
}
5654
}

src/WebJobs.Script.Grpc/WebJobs.Script.Grpc.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
</PackageReference>
1818
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
1919
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
20+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
2023
</ItemGroup>
2124

2225
<Target Name="GenerateProtoFiles" BeforeTargets="BeforeBuild" Inputs="Proto/FunctionRpc.proto" Outputs="Messages/DotNet/FunctionRpc.cs;Messages/DotNet/FunctionRpcGrpc.cs">

src/WebJobs.Script.WebHost/Middleware/ScriptHostCheckMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Threading.Tasks;

src/WebJobs.Script.WebHost/Routing/ScriptRouteHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private async Task<IActionResult> GetResultAsync(HttpContext context, string fun
6565
// Add rounte data to request info
6666
// TODO: Keeping this here for now as other code depend on this property, but this can be done in the HTTP binding.
6767
var routingFeature = context.Features.Get<IRoutingFeature>();
68-
context.Items.Add(HttpExtensionConstants.AzureWebJobsHttpRouteDataKey, new Dictionary<string,object>(routingFeature.RouteData.Values));
68+
context.Items.Add(HttpExtensionConstants.AzureWebJobsHttpRouteDataKey, new Dictionary<string, object>(routingFeature.RouteData.Values));
6969
context.Features.Set<IFunctionExecutionFeature>(new FunctionExecutionFeature { Descriptor = descriptor });
7070

7171
bool authorized = await AuthenticateAndAuthorizeAsync(context, descriptor);

src/WebJobs.Script.WebHost/Security/Authentication/AuthLevelExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
55
using Microsoft.AspNetCore.Authentication;

0 commit comments

Comments
 (0)