Skip to content

Commit fe291a2

Browse files
brettsamjviau
andauthored
bumping stylecop and addressing all errors (#8975)
Co-authored-by: Jacob Viau <javia@microsoft.com>
1 parent eace58f commit fe291a2

File tree

45 files changed

+118
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+118
-131
lines changed

src/WebJobs.Script.Abstractions/WebJobs.Script.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.21.0" />
3939
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
4040
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
41-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
41+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
4242
<PrivateAssets>all</PrivateAssets>
4343
</PackageReference>
4444
</ItemGroup>

src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal class GrpcWorkerChannel : IRpcWorkerChannel, IDisposable
5050
private readonly IOptions<WorkerConcurrencyOptions> _workerConcurrencyOptions;
5151
private readonly WaitCallback _processInbound;
5252
private readonly object _syncLock = new object();
53-
private readonly Dictionary<MsgType, Queue<PendingItem>> _pendingActions = new ();
53+
private readonly Dictionary<MsgType, Queue<PendingItem>> _pendingActions = new();
5454
private readonly ChannelWriter<OutboundGrpcEvent> _outbound;
5555
private readonly ChannelReader<InboundGrpcEvent> _inbound;
5656
private readonly IOptions<FunctionsHostingConfigOptions> _hostingConfigOptions;

src/WebJobs.Script.Grpc/Extensions/ScriptInvocationContextExtensions.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Collections.Generic;
6-
using System.Diagnostics;
76
using System.IO;
87
using System.Linq;
98
using System.Text;
@@ -53,12 +52,12 @@ public static async Task<InvocationRequest> ToRpcInvocationRequest(this ScriptIn
5352
if (isSharedMemoryDataTransferEnabled)
5453
{
5554
// Try to transfer this data over shared memory instead of RPC
56-
if (input.val == null || !sharedMemValueCache.TryGetValue(input.val, out sharedMemValue))
55+
if (input.Val == null || !sharedMemValueCache.TryGetValue(input.Val, out sharedMemValue))
5756
{
58-
sharedMemValue = await input.val.ToRpcSharedMemoryAsync(input.type, logger, invocationRequest.InvocationId, sharedMemoryManager);
59-
if (input.val != null)
57+
sharedMemValue = await input.Val.ToRpcSharedMemoryAsync(input.Type, logger, invocationRequest.InvocationId, sharedMemoryManager);
58+
if (input.Val != null)
6059
{
61-
sharedMemValueCache.Add(input.val, sharedMemValue);
60+
sharedMemValueCache.Add(input.Val, sharedMemValue);
6261
}
6362
}
6463
}
@@ -68,35 +67,35 @@ public static async Task<InvocationRequest> ToRpcInvocationRequest(this ScriptIn
6867
// Data was successfully transferred over shared memory; create a ParameterBinding accordingly
6968
parameterBinding = new ParameterBinding
7069
{
71-
Name = input.name,
70+
Name = input.Name,
7271
RpcSharedMemory = sharedMemValue
7372
};
7473

7574
usedSharedMemory = true;
76-
logBuilder.AppendFormat("{0}:{1},", input.name, sharedMemValue.Count);
75+
logBuilder.AppendFormat("{0}:{1},", input.Name, sharedMemValue.Count);
7776
}
7877
else
7978
{
80-
if (!TryConvertObjectIfNeeded(input.val, logger, out object val))
79+
if (!TryConvertObjectIfNeeded(input.Val, logger, out object val))
8180
{
8281
// Conversion did not take place, keep the existing value as it is
83-
val = input.val;
82+
val = input.Val;
8483
}
8584

8685
// Data was not transferred over shared memory (either disabled, type not supported or some error); resort to RPC
8786
TypedData rpcValue = null;
8887
if (val == null || !rpcValueCache.TryGetValue(val, out rpcValue))
8988
{
9089
rpcValue = await val.ToRpc(logger, capabilities);
91-
if (input.val != null)
90+
if (input.Val != null)
9291
{
9392
rpcValueCache.Add(val, rpcValue);
9493
}
9594
}
9695

9796
parameterBinding = new ParameterBinding
9897
{
99-
Name = input.name,
98+
Name = input.Name,
10099
Data = rpcValue
101100
};
102101
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.21.0" />
2828
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.21.0" />
2929
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
30-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
30+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
3131
<PrivateAssets>all</PrivateAssets>
3232
</PackageReference>
3333
<PackageReference Include="System.Threading.Channels" Version="6.0.0" />

src/WebJobs.Script.WebHost/Extensions/ExceptionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System
77
{
88
internal static class ExceptionExtensions
99
{
10-
public static (string exceptionType, string exceptionMessage, string exceptionDetails) GetExceptionDetails(this Exception exception)
10+
public static (string ExceptionType, string ExceptionMessage, string ExceptionDetails) GetExceptionDetails(this Exception exception)
1111
{
1212
if (exception == null)
1313
{

src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ internal HttpRequestMessage BuildSetTriggersRequest()
687687

688688
// This function will call POST https://{app}.azurewebsites.net/operation/settriggers with the content
689689
// of triggers. It'll verify app ownership using a SWT token valid for 5 minutes. It should be plenty.
690-
private async Task<(bool, string)> SetTriggersAsync(string content)
690+
private async Task<(bool Success, string ErrorMessage)> SetTriggersAsync(string content)
691691
{
692692
var token = SimpleWebTokenHelper.CreateToken(DateTime.UtcNow.AddMinutes(5));
693693

src/WebJobs.Script.WebHost/Management/IWebFunctionsManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public interface IWebFunctionsManager
1212
{
1313
Task<IEnumerable<FunctionMetadataResponse>> GetFunctionsMetadata(bool includeProxies);
1414

15-
Task<(bool, FunctionMetadataResponse)> TryGetFunction(string name, HttpRequest request);
15+
Task<(bool Success, FunctionMetadataResponse Response)> TryGetFunction(string name, HttpRequest request);
1616

17-
Task<(bool, bool, FunctionMetadataResponse)> CreateOrUpdate(string name, FunctionMetadataResponse functionMetadata, HttpRequest request);
17+
Task<(bool Success, bool ConfigChanged, FunctionMetadataResponse Response)> CreateOrUpdate(string name, FunctionMetadataResponse functionMetadata, HttpRequest request);
1818

19-
Task<(bool, string)> TryDeleteFunction(FunctionMetadataResponse function);
19+
Task<(bool Success, string ErrorMessage)> TryDeleteFunction(FunctionMetadataResponse function);
2020
}
2121
}

src/WebJobs.Script.WebHost/Management/InstanceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public async Task<string> ValidateContext(HostAssignmentContext assignmentContex
214214
}
215215
}
216216

217-
private async Task<(string, long?)> ValidateBlobPackageContext(RunFromPackageContext context)
217+
private async Task<(string Error, long? ContentLength)> ValidateBlobPackageContext(RunFromPackageContext context)
218218
{
219219
string blobUri = context.Url;
220220
string eventName = context.IsWarmUpRequest

src/WebJobs.Script.WebHost/Management/LinuxSpecialization/BashCommandHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Diagnostics;
6-
using Microsoft.Azure.WebJobs.Logging;
76
using Microsoft.Azure.WebJobs.Script.Diagnostics;
87
using Microsoft.Extensions.Logging;
98

@@ -22,7 +21,7 @@ public BashCommandHandler(IMetricsLogger metricsLogger, ILogger<BashCommandHandl
2221
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2322
}
2423

25-
public (string, string, int) RunBashCommand(string command, string metricName)
24+
public (string Output, string Error, int ExitCode) RunBashCommand(string command, string metricName)
2625
{
2726
try
2827
{

src/WebJobs.Script.WebHost/Management/LinuxSpecialization/IBashCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Management.LinuxSpecialization
55
{
66
public interface IBashCommandHandler
77
{
8-
(string, string, int) RunBashCommand(string command, string metricName);
8+
(string Output, string Error, int ExitCode) RunBashCommand(string command, string metricName);
99
}
1010
}

src/WebJobs.Script.WebHost/Management/WebFunctionsManager.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Threading.Tasks;
1010
using Microsoft.AspNetCore.Http;
1111
using Microsoft.Azure.WebJobs.Script.Description;
12-
using Microsoft.Azure.WebJobs.Script.Extensions;
1312
using Microsoft.Azure.WebJobs.Script.Management.Models;
1413
using Microsoft.Azure.WebJobs.Script.WebHost.Extensions;
1514
using Microsoft.Extensions.Logging;
@@ -80,11 +79,11 @@ internal IEnumerable<FunctionMetadata> GetFunctionsMetadata(bool includeProxies,
8079
/// It attempts to clean left over artifacts from a possible previous function with the same name
8180
/// if config is changed, then `configChanged` is set to true so the caller can call SyncTriggers if needed.
8281
/// </summary>
83-
/// <param name="name">name of the function to be created</param>
84-
/// <param name="functionMetadata">in case of update for function.json</param>
82+
/// <param name="name">name of the function to be created.</param>
83+
/// <param name="functionMetadata">in case of update for function.json.</param>
8584
/// <param name="request">Current HttpRequest.</param>
86-
/// <returns>(success, configChanged, functionMetadataResult)</returns>
87-
public async Task<(bool, bool, FunctionMetadataResponse)> CreateOrUpdate(string name, FunctionMetadataResponse functionMetadata, HttpRequest request)
85+
/// <returns>(success, configChanged, functionMetadataResult).</returns>
86+
public async Task<(bool Success, bool ConfigChanged, FunctionMetadataResponse Response)> CreateOrUpdate(string name, FunctionMetadataResponse functionMetadata, HttpRequest request)
8887
{
8988
var hostOptions = _applicationHostOptions.CurrentValue.ToHostOptions();
9089
var configChanged = false;
@@ -154,12 +153,12 @@ await functionMetadata
154153
}
155154

156155
/// <summary>
157-
/// maps a functionName to its FunctionMetadataResponse
156+
/// maps a functionName to its FunctionMetadataResponse.
158157
/// </summary>
159-
/// <param name="name">Function name to retrieve</param>
160-
/// <param name="request">Current HttpRequest</param>
161-
/// <returns>(success, FunctionMetadataResponse)</returns>
162-
public async Task<(bool, FunctionMetadataResponse)> TryGetFunction(string name, HttpRequest request)
158+
/// <param name="name">Function name to retrieve.</param>
159+
/// <param name="request">Current HttpRequest.</param>
160+
/// <returns>(success, FunctionMetadataResponse).</returns>
161+
public async Task<(bool Success, FunctionMetadataResponse Response)> TryGetFunction(string name, HttpRequest request)
163162
{
164163
var hostOptions = _applicationHostOptions.CurrentValue.ToHostOptions();
165164
var functionMetadata = GetFunctionsMetadata(includeProxies: false, forceRefresh: true)
@@ -180,9 +179,9 @@ await functionMetadata
180179
/// <summary>
181180
/// Delete a function and all it's artifacts.
182181
/// </summary>
183-
/// <param name="function">Function to be deleted</param>
184-
/// <returns>(success, errorMessage)</returns>
185-
public async Task<(bool, string)> TryDeleteFunction(FunctionMetadataResponse function)
182+
/// <param name="function">Function to be deleted.</param>
183+
/// <returns>(success, errorMessage).</returns>
184+
public async Task<(bool Success, string ErrorMessage)> TryDeleteFunction(FunctionMetadataResponse function)
186185
{
187186
try
188187
{

src/WebJobs.Script.WebHost/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System.Runtime.CompilerServices;
5+
56
[assembly: InternalsVisibleTo("Microsoft.Azure.WebJobs.Script.Benchmarks")]
67
[assembly: InternalsVisibleTo("Microsoft.Azure.WebJobs.Script.Tests")]
78
[assembly: InternalsVisibleTo("Microsoft.Azure.WebJobs.Script.Tests.Integration")]

src/WebJobs.Script.WebHost/Security/Authentication/Keys/AuthenticationLevelHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
8181
}
8282
}
8383

84-
internal static Task<(string, AuthorizationLevel)> GetAuthorizationKeyInfoAsync(HttpRequest request, ISecretManagerProvider secretManagerProvider)
84+
internal static Task<(string KeyName, AuthorizationLevel Level)> GetAuthorizationKeyInfoAsync(HttpRequest request, ISecretManagerProvider secretManagerProvider)
8585
{
8686
if (secretManagerProvider.SecretsEnabled)
8787
{

src/WebJobs.Script.WebHost/Security/KeyManagement/ISecretManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface ISecretManager
1616
/// <param name="key">The key to check.</param>
1717
/// <param name="functionName">Optional function name, if we're authorizing a specific function.</param>
1818
/// <returns>A key name, auth level pair.</returns>
19-
Task<(string, AuthorizationLevel)> GetAuthorizationLevelOrNullAsync(string key, string functionName = null);
19+
Task<(string KeyName, AuthorizationLevel Level)> GetAuthorizationLevelOrNullAsync(string key, string functionName = null);
2020

2121
/// <summary>
2222
/// Deletes a function secret.

src/WebJobs.Script.WebHost/Security/KeyManagement/SecretManager.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
using System.Globalization;
88
using System.IO;
99
using System.Linq;
10-
using System.Net;
1110
using System.Security.Cryptography;
1211
using System.Text;
1312
using System.Threading;
1413
using System.Threading.Tasks;
15-
using Azure;
1614
using Microsoft.Azure.WebJobs.Extensions.Http;
1715
using Microsoft.Azure.WebJobs.Script.Diagnostics;
1816
using Microsoft.Azure.WebJobs.Script.WebHost.Properties;
@@ -388,7 +386,7 @@ private async Task<ScriptSecrets> LoadSecretsAsync(ScriptSecretsType type, strin
388386
return await _repository.ReadAsync(type, keyScope);
389387
}
390388

391-
public async Task<(string, AuthorizationLevel)> GetAuthorizationLevelOrNullAsync(string keyValue, string functionName = null)
389+
public async Task<(string KeyName, AuthorizationLevel Level)> GetAuthorizationLevelOrNullAsync(string keyValue, string functionName = null)
392390
{
393391
if (keyValue != null)
394392
{
@@ -404,7 +402,7 @@ private async Task<ScriptSecrets> LoadSecretsAsync(ScriptSecretsType type, strin
404402
bool secretsCached = _hostSecrets != null || _functionSecrets.Any();
405403

406404
var result = await GetAuthorizationLevelAsync(this, keyValue, functionName);
407-
if (result.Item2 != AuthorizationLevel.Anonymous)
405+
if (result.Level != AuthorizationLevel.Anonymous)
408406
{
409407
// key match
410408
_authorizationCache[cacheKey] = result;
@@ -430,7 +428,7 @@ private async Task<ScriptSecrets> LoadSecretsAsync(ScriptSecretsType type, strin
430428
return (null, AuthorizationLevel.Anonymous);
431429
}
432430

433-
internal static async Task<(string, AuthorizationLevel)> GetAuthorizationLevelAsync(ISecretManager secretManager, string keyValue, string functionName = null)
431+
internal static async Task<(string KeyName, AuthorizationLevel Level)> GetAuthorizationLevelAsync(ISecretManager secretManager, string keyValue, string functionName = null)
434432
{
435433
// see if the key specified is the master key
436434
HostSecretsInfo hostSecrets = await secretManager.GetHostSecretsAsync();

src/WebJobs.Script.WebHost/Security/KeyManagement/SimpleKubernetesClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private async Task CreateIfDoesntExist(string url, bool isSecret)
201201
}
202202
}
203203

204-
private async Task<(string, bool)> GetObjectUrl(string objectName, bool watchUrl = false)
204+
private async Task<(string Url, bool IsSecret)> GetObjectUrl(string objectName, bool watchUrl = false)
205205
{
206206
var isSecret = true;
207207
if (!objectName.StartsWith("secrets/") && !objectName.StartsWith("configmaps/"))

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="$(IdentityDependencyVersion)" />
8484
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="$(IdentityDependencyVersion)" />
8585
<PackageReference Include="Microsoft.Security.Utilities" Version="1.3.0" />
86-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
86+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
8787
<PrivateAssets>all</PrivateAssets>
8888
</PackageReference>
8989
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />

src/WebJobs.Script/Config/TransmissionStatusHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Azure.WebJobs.Script.Config
1717
/// </summary>
1818
internal class TransmissionStatusHandler : IDisposable
1919
{
20-
private static readonly DiagnosticListener _source = new (ScriptConstants.HostDiagnosticSourcePrefix + "ApplicationInsights");
20+
private static readonly DiagnosticListener _source = new(ScriptConstants.HostDiagnosticSourcePrefix + "ApplicationInsights");
2121

2222
internal static void Handler(object sender, TransmissionStatusEventArgs args)
2323
{

src/WebJobs.Script/Description/DotNet/DotNetFunctionDescriptorProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void Dispose(bool disposing)
5151
}
5252
}
5353

54-
public override async Task<(bool, FunctionDescriptor)> TryCreate(FunctionMetadata functionMetadata)
54+
public override async Task<(bool Success, FunctionDescriptor Descriptor)> TryCreate(FunctionMetadata functionMetadata)
5555
{
5656
if (functionMetadata == null)
5757
{

src/WebJobs.Script/Description/DotNet/FunctionAssemblyLoadContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public partial class FunctionAssemblyLoadContext : AssemblyLoadContext
2828
private static readonly ConcurrentDictionary<string, int> _sharedContextAssembliesInFallbackLoad = new ConcurrentDictionary<string, int>();
2929
private static readonly RuntimeAssembliesInfo _runtimeAssembliesInfo = new RuntimeAssembliesInfo();
3030

31-
private static Lazy<FunctionAssemblyLoadContext> _defaultContext = new (() => CreateSharedContext(ResolveFunctionBaseProbingPath()), true);
31+
private static Lazy<FunctionAssemblyLoadContext> _defaultContext = new(() => CreateSharedContext(ResolveFunctionBaseProbingPath()), true);
3232

3333
private readonly List<string> _probingPaths = new List<string>();
3434
private readonly IDictionary<string, RuntimeAsset[]> _depsAssemblies;
@@ -61,7 +61,7 @@ internal static void ResetSharedContext(string baseProbingPath = null)
6161
_runtimeAssembliesInfo.ResetIfStale();
6262
}
6363

64-
internal static (IDictionary<string, RuntimeAsset[]> depsAssemblies, IDictionary<string, RuntimeAsset[]> nativeLibraries) InitializeDeps(string basePath, List<string> ridFallbacks)
64+
internal static (IDictionary<string, RuntimeAsset[]> DepsAssemblies, IDictionary<string, RuntimeAsset[]> NativeLibraries) InitializeDeps(string basePath, List<string> ridFallbacks)
6565
{
6666
string depsFilePath = Path.Combine(basePath, DotNetConstants.FunctionsDepsFileName);
6767

@@ -421,7 +421,7 @@ public Assembly LoadFromAssemblyPath(string assemblyPath, bool addProbingPath)
421421
return LoadFromAssemblyPath(assemblyPath);
422422
}
423423

424-
internal (bool succeeded, Assembly assembly, bool isRuntimeAssembly) TryLoadAssembly(AssemblyName assemblyName)
424+
internal (bool Succeeded, Assembly Assembly, bool IsRuntimeAssembly) TryLoadAssembly(AssemblyName assemblyName)
425425
{
426426
bool isRuntimeAssembly = IsRuntimeAssembly(assemblyName);
427427

0 commit comments

Comments
 (0)