Skip to content

Commit

Permalink
Enable SA1008 Opening parenthesis should be spaced correctly (Power…
Browse files Browse the repository at this point in the history
  • Loading branch information
xtqqczze committed Apr 16, 2021
1 parent 1feed06 commit a562fa6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ dotnet_diagnostic.SA1006.severity = warning
dotnet_diagnostic.SA1007.severity = warning

# SA1008: Opening parenthesis should be spaced correctly
dotnet_diagnostic.SA1008.severity = none
dotnet_diagnostic.SA1008.severity = warning

# SA1009: Closing parenthesis should be spaced correctly
dotnet_diagnostic.SA1009.severity = none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static class AnalysisCache

// This dictionary shouldn't see much use, so low concurrency and capacity
private static readonly ConcurrentDictionary<string, string> s_modulesBeingAnalyzed =
new ConcurrentDictionary<string, string>( /*concurrency*/1, /*capacity*/2, StringComparer.OrdinalIgnoreCase);
new(concurrencyLevel: 1, capacity: 2, StringComparer.OrdinalIgnoreCase);

internal static readonly char[] InvalidCommandNameCharacters = new[]
{
Expand Down Expand Up @@ -384,8 +384,10 @@ private static ConcurrentDictionary<string, CommandTypes> AnalyzeScriptModule(st
}
}

var exportedClasses = new ConcurrentDictionary<string, TypeAttributes>( /*concurrency*/
1, scriptAnalysis.DiscoveredClasses.Count, StringComparer.OrdinalIgnoreCase);
ConcurrentDictionary<string, TypeAttributes> exportedClasses = new(
concurrencyLevel: 1,
capacity: scriptAnalysis.DiscoveredClasses.Count,
StringComparer.OrdinalIgnoreCase);
foreach (var exportedClass in scriptAnalysis.DiscoveredClasses)
{
exportedClasses[exportedClass.Name] = exportedClass.TypeAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace System.Management.Automation.Remoting
/// <param name="extraInfo">PCWSTR.</param>
/// <param name="startupInfo">WSMAN_SHELL_STARTUP_INFO*.</param>
/// <param name="inboundShellInformation">WSMAN_DATA*.</param>
internal delegate void WSMPluginShellDelegate( // TODO: Rename to WSManPluginShellDelegate once I remove the MC++ module.
internal delegate void WSManPluginShellDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -45,7 +45,7 @@ internal delegate void WSMPluginShellDelegate( // TODO: Rename to WSManPluginShe
/// </summary>
/// <param name="pluginContext">PVOID.</param>
/// <param name="shellContext">PVOID.</param>
internal delegate void WSMPluginReleaseShellContextDelegate(
internal delegate void WSManPluginReleaseShellContextDelegate(
IntPtr pluginContext,
IntPtr shellContext);

Expand All @@ -57,7 +57,7 @@ internal delegate void WSMPluginReleaseShellContextDelegate(
/// <param name="shellContext">PVOID.</param>
/// <param name="commandContext">PVOID optional.</param>
/// <param name="inboundConnectInformation">WSMAN_DATA* optional.</param>
internal delegate void WSMPluginConnectDelegate(
internal delegate void WSManPluginConnectDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -73,7 +73,7 @@ internal delegate void WSMPluginConnectDelegate(
/// <param name="shellContext">PVOID.</param>
/// <param name="commandLine">PCWSTR.</param>
/// <param name="arguments">WSMAN_COMMAND_ARG_SET*.</param>
internal delegate void WSMPluginCommandDelegate(
internal delegate void WSManPluginCommandDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -85,15 +85,15 @@ internal delegate void WSMPluginCommandDelegate(
/// Delegate that is passed to native layer for callback on operation shutdown notifications.
/// </summary>
/// <param name="shutdownContext">IntPtr.</param>
internal delegate void WSMPluginOperationShutdownDelegate(
internal delegate void WSManPluginOperationShutdownDelegate(
IntPtr shutdownContext);

/// <summary>
/// </summary>
/// <param name="pluginContext">PVOID.</param>
/// <param name="shellContext">PVOID.</param>
/// <param name="commandContext">PVOID.</param>
internal delegate void WSMPluginReleaseCommandContextDelegate(
internal delegate void WSManPluginReleaseCommandContextDelegate(
IntPtr pluginContext,
IntPtr shellContext,
IntPtr commandContext);
Expand All @@ -107,7 +107,7 @@ internal delegate void WSMPluginReleaseCommandContextDelegate(
/// <param name="commandContext">PVOID.</param>
/// <param name="stream">PCWSTR.</param>
/// <param name="inboundData">WSMAN_DATA*.</param>
internal delegate void WSMPluginSendDelegate(
internal delegate void WSManPluginSendDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -124,7 +124,7 @@ internal delegate void WSMPluginSendDelegate(
/// <param name="shellContext">PVOID.</param>
/// <param name="commandContext">PVOID optional.</param>
/// <param name="streamSet">WSMAN_STREAM_ID_SET* optional.</param>
internal delegate void WSMPluginReceiveDelegate(
internal delegate void WSManPluginReceiveDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -140,7 +140,7 @@ internal delegate void WSMPluginReceiveDelegate(
/// <param name="shellContext">PVOID.</param>
/// <param name="commandContext">PVOID optional.</param>
/// <param name="code">PCWSTR.</param>
internal delegate void WSMPluginSignalDelegate(
internal delegate void WSManPluginSignalDelegate(
IntPtr pluginContext,
IntPtr requestDetails,
int flags,
Expand All @@ -160,7 +160,7 @@ internal delegate void WaitOrTimerCallbackDelegate(
/// <summary>
/// </summary>
/// <param name="pluginContext">PVOID.</param>
internal delegate void WSMShutdownPluginDelegate(
internal delegate void WSManShutdownPluginDelegate(
IntPtr pluginContext);

/// <summary>
Expand Down Expand Up @@ -192,7 +192,7 @@ internal WSManPluginEntryDelegatesInternal UnmanagedStruct
private GCHandle _pluginSignalGCHandle;
private GCHandle _pluginConnectGCHandle;
private GCHandle _shutdownPluginGCHandle;
private GCHandle _WSMPluginOperationShutdownGCHandle;
private GCHandle _WSManPluginOperationShutdownGCHandle;

#endregion

Expand Down Expand Up @@ -255,57 +255,57 @@ private void populateDelegates()
// disposal. Using GCHandle without pinning reduces fragmentation potential
// of the managed heap.
{
WSMPluginShellDelegate pluginShell = new WSMPluginShellDelegate(WSManPluginManagedEntryWrapper.WSManPluginShell);
WSManPluginShellDelegate pluginShell = new WSManPluginShellDelegate(WSManPluginManagedEntryWrapper.WSManPluginShell);
_pluginShellGCHandle = GCHandle.Alloc(pluginShell);
// marshal the delegate to a unmanaged function pointer so that AppDomain reference is stored correctly.
// Populate the outgoing structure so the caller has access to the entry points
_unmanagedStruct.wsManPluginShellCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginShell);
}
{
WSMPluginReleaseShellContextDelegate pluginReleaseShellContext = new WSMPluginReleaseShellContextDelegate(WSManPluginManagedEntryWrapper.WSManPluginReleaseShellContext);
WSManPluginReleaseShellContextDelegate pluginReleaseShellContext = new WSManPluginReleaseShellContextDelegate(WSManPluginManagedEntryWrapper.WSManPluginReleaseShellContext);
_pluginReleaseShellContextGCHandle = GCHandle.Alloc(pluginReleaseShellContext);
_unmanagedStruct.wsManPluginReleaseShellContextCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginReleaseShellContext);
}
{
WSMPluginCommandDelegate pluginCommand = new WSMPluginCommandDelegate(WSManPluginManagedEntryWrapper.WSManPluginCommand);
WSManPluginCommandDelegate pluginCommand = new WSManPluginCommandDelegate(WSManPluginManagedEntryWrapper.WSManPluginCommand);
_pluginCommandGCHandle = GCHandle.Alloc(pluginCommand);
_unmanagedStruct.wsManPluginCommandCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginCommand);
}
{
WSMPluginReleaseCommandContextDelegate pluginReleaseCommandContext = new WSMPluginReleaseCommandContextDelegate(WSManPluginManagedEntryWrapper.WSManPluginReleaseCommandContext);
WSManPluginReleaseCommandContextDelegate pluginReleaseCommandContext = new WSManPluginReleaseCommandContextDelegate(WSManPluginManagedEntryWrapper.WSManPluginReleaseCommandContext);
_pluginReleaseCommandContextGCHandle = GCHandle.Alloc(pluginReleaseCommandContext);
_unmanagedStruct.wsManPluginReleaseCommandContextCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginReleaseCommandContext);
}
{
WSMPluginSendDelegate pluginSend = new WSMPluginSendDelegate(WSManPluginManagedEntryWrapper.WSManPluginSend);
WSManPluginSendDelegate pluginSend = new WSManPluginSendDelegate(WSManPluginManagedEntryWrapper.WSManPluginSend);
_pluginSendGCHandle = GCHandle.Alloc(pluginSend);
_unmanagedStruct.wsManPluginSendCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginSend);
}
{
WSMPluginReceiveDelegate pluginReceive = new WSMPluginReceiveDelegate(WSManPluginManagedEntryWrapper.WSManPluginReceive);
WSManPluginReceiveDelegate pluginReceive = new WSManPluginReceiveDelegate(WSManPluginManagedEntryWrapper.WSManPluginReceive);
_pluginReceiveGCHandle = GCHandle.Alloc(pluginReceive);
_unmanagedStruct.wsManPluginReceiveCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginReceive);
}
{
WSMPluginSignalDelegate pluginSignal = new WSMPluginSignalDelegate(WSManPluginManagedEntryWrapper.WSManPluginSignal);
WSManPluginSignalDelegate pluginSignal = new WSManPluginSignalDelegate(WSManPluginManagedEntryWrapper.WSManPluginSignal);
_pluginSignalGCHandle = GCHandle.Alloc(pluginSignal);
_unmanagedStruct.wsManPluginSignalCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginSignal);
}
{
WSMPluginConnectDelegate pluginConnect = new WSMPluginConnectDelegate(WSManPluginManagedEntryWrapper.WSManPluginConnect);
WSManPluginConnectDelegate pluginConnect = new WSManPluginConnectDelegate(WSManPluginManagedEntryWrapper.WSManPluginConnect);
_pluginConnectGCHandle = GCHandle.Alloc(pluginConnect);
_unmanagedStruct.wsManPluginConnectCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginConnect);
}
{
WSMShutdownPluginDelegate shutdownPlugin = new WSMShutdownPluginDelegate(WSManPluginManagedEntryWrapper.ShutdownPlugin);
WSManShutdownPluginDelegate shutdownPlugin = new WSManShutdownPluginDelegate(WSManPluginManagedEntryWrapper.ShutdownPlugin);
_shutdownPluginGCHandle = GCHandle.Alloc(shutdownPlugin);
_unmanagedStruct.wsManPluginShutdownPluginCallbackNative = Marshal.GetFunctionPointerForDelegate(shutdownPlugin);
}

if (!Platform.IsWindows)
{
WSMPluginOperationShutdownDelegate pluginShutDownDelegate = new WSMPluginOperationShutdownDelegate(WSManPluginManagedEntryWrapper.WSManPSShutdown);
_WSMPluginOperationShutdownGCHandle = GCHandle.Alloc(pluginShutDownDelegate);
WSManPluginOperationShutdownDelegate pluginShutDownDelegate = new WSManPluginOperationShutdownDelegate(WSManPluginManagedEntryWrapper.WSManPSShutdown);
_WSManPluginOperationShutdownGCHandle = GCHandle.Alloc(pluginShutDownDelegate);
_unmanagedStruct.wsManPluginShutdownCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginShutDownDelegate);
}
}
Expand All @@ -328,7 +328,7 @@ private void CleanUpDelegates()
_shutdownPluginGCHandle.Free();
if (!Platform.IsWindows)
{
_WSMPluginOperationShutdownGCHandle.Free();
_WSManPluginOperationShutdownGCHandle.Free();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/tools/WebListener/Controllers/ResponseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string Index()
}

StringValues responsePhrase;
if ( Request.Query.TryGetValue("responsephrase", out responsePhrase))
if (Request.Query.TryGetValue("responsephrase", out responsePhrase))
{
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = responsePhrase.FirstOrDefault();
}
Expand Down
2 changes: 1 addition & 1 deletion test/tools/WebListener/DeflateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace mvc.Controllers
{
internal sealed class DeflateFilter : ResultFilterAttribute
{
public override async Task OnResultExecutionAsync( ResultExecutingContext context, ResultExecutionDelegate next)
public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
var httpContext = context.HttpContext;
using (var memoryStream = new MemoryStream())
Expand Down
2 changes: 1 addition & 1 deletion test/tools/WebListener/GzipFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace mvc.Controllers
{
internal sealed class GzipFilter : ResultFilterAttribute
{
public override async Task OnResultExecutionAsync( ResultExecutingContext context, ResultExecutionDelegate next)
public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
var httpContext = context.HttpContext;
using (var memoryStream = new MemoryStream())
Expand Down

0 comments on commit a562fa6

Please sign in to comment.