Skip to content

Commit 24b5962

Browse files
Merge pull request #1759 from PowerShell/andschwa/fix-ide0005
Enable IDE0005 (unneccessary using statements) as error
2 parents 2e30add + bf8a482 commit 24b5962

26 files changed

+54
-55
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ dotnet_diagnostic.CS0414.severity = error
3636
dotnet_diagnostic.CS0618.severity = suggestion
3737
# CS0649: Uninitialized private or internal field declaration that is never assigned a value
3838
dotnet_diagnostic.CS0649.severity = error
39+
# CS1570: Parameter has no matching param tag in the XML comment
40+
dotnet_diagnostic.CS1570.severity = silent
41+
# CS1574: XML comment has cref attribute that could not be resolved.
42+
dotnet_diagnostic.CS1574.severity = suggestion
43+
# CS1591: Missing XML comment for publicly visible type or member
44+
dotnet_diagnostic.CS1591.severity = silent
3945
# CS1998: This async method lacks 'await' operators and will run synchronously
4046
dotnet_diagnostic.CS1998.severity = suggestion
4147
# CS4014: Consider applying the await operator to the result of the call

PowerShellEditorServices.Common.props

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<!-- See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview -->
1515
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1616
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
17+
<!-- Required to enable IDE0005 as error -->
18+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1719
<!-- TODO: Enable <AnalysisMode>All</AnalysisMode> -->
1820
<!-- See: https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/implicit-namespaces -->
1921
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>

src/PowerShellEditorServices.Hosting/Configuration/HostLogger.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
1515
/// User-facing log level for editor services configuration.
1616
/// </summary>
1717
/// <remarks>
18-
/// The underlying values of this enum attempt to align to both <see
19-
/// cref="Microsoft.Logging.Extensions.LogLevel"</see> and <see
20-
/// cref="Serilog.Events.LogEventLevel"</see>.
18+
/// The underlying values of this enum attempt to align to both
19+
/// <see cref="Microsoft.Extensions.Logging.LogLevel" /> and
20+
/// <see cref="Serilog.Events.LogEventLevel" />.
2121
/// </remarks>
2222
public enum PsesLogLevel
2323
{

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Diagnostics;
65
using System.IO;
76
using System.Reflection;
87
using System.Threading.Tasks;
@@ -13,6 +12,10 @@
1312
using System.Management.Automation;
1413
using System.Management.Automation.Runspaces;
1514

15+
#if DEBUG
16+
using System.Diagnostics;
17+
#endif
18+
1619
#if CoreCLR
1720
using System.Runtime.Loader;
1821
#else
@@ -58,6 +61,7 @@ public static EditorServicesLoader Create(
5861
/// <param name="logger">The host logger to use.</param>
5962
/// <param name="hostConfig">The host configuration to start editor services with.</param>
6063
/// <param name="sessionFileWriter">The session file writer to write the session file with.</param>
64+
/// <param name="loggersToUnsubscribe">The loggers to unsubscribe form writing to the terminal.</param>
6165
/// <returns></returns>
6266
public static EditorServicesLoader Create(
6367
HostLogger logger,

src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ internal EditorExtensionServiceProvider(IServiceProvider serviceProvider)
5454
/// </summary>
5555
public ILanguageServerService LanguageServer { get; }
5656

57-
/// <summary>
58-
/// Service providing document symbol provider registration.
59-
/// </summary>
60-
// public IDocumentSymbolService DocumentSymbols { get; }
61-
6257
/// <summary>
6358
/// Service providing extension command registration and functionality.
6459
/// </summary>
@@ -93,7 +88,7 @@ internal EditorExtensionServiceProvider(IServiceProvider serviceProvider)
9388
/// <summary>
9489
/// Get an underlying service object from PSES by type name.
9590
/// </summary>
96-
/// <param name="psesServiceFullTypeName">The full type name of the service to get.</param>
91+
/// <param name="fullTypeName">The full type name of the service to get.</param>
9792
/// <param name="assemblyName">The assembly name from which the service comes.</param>
9893
/// <returns>The service object requested, or null if no service of that type name exists.</returns>
9994
/// <remarks>

src/PowerShellEditorServices/Extensions/EditorObject.cs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class EditorObject
7373
/// <summary>
7474
/// Creates a new instance of the EditorObject class.
7575
/// </summary>
76+
/// <param name="serviceProvider">The service provider?</param>
7677
/// <param name="extensionService">An ExtensionService which handles command registration.</param>
7778
/// <param name="editorOperations">An IEditorOperations implementation which handles operations in the host editor.</param>
7879
internal EditorObject(

src/PowerShellEditorServices/Extensions/FileContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public string GetText(FileRange bufferRange)
122122
/// <summary>
123123
/// Gets the file content in the specified range as an array of strings.
124124
/// </summary>
125-
/// <param name="bufferRange">The buffer range for which content will be extracted.</param>
125+
/// <param name="fileRange">The buffer range for which content will be extracted.</param>
126126
/// <returns>An array of strings, each representing a line in the file within the specified range.</returns>
127127
public string[] GetTextLines(FileRange fileRange) => scriptFile.GetLinesInRange(fileRange.ToBufferRange());
128128

src/PowerShellEditorServices/Hosting/EditorServicesServerFactory.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Diagnostics;
65
using System.IO;
76
using Microsoft.Extensions.DependencyInjection;
87
using Microsoft.Extensions.Logging;
@@ -14,6 +13,7 @@
1413
using Microsoft.PowerShell.EditorServices.Services.Extension;
1514

1615
#if DEBUG
16+
using System.Diagnostics;
1717
using Serilog.Debugging;
1818
#endif
1919

@@ -36,7 +36,7 @@ internal sealed class EditorServicesServerFactory : IDisposable
3636
/// <remarks>
3737
/// <para>
3838
/// This can only be called once because it sets global state (the logger) and that call is
39-
/// in <see cref="EditorServicesRunner"/>.
39+
/// in <see cref="Hosting.EditorServicesRunner" />.
4040
/// </para>
4141
/// <para>
4242
/// TODO: Why is this a static function wrapping a constructor instead of just a
@@ -45,7 +45,7 @@ internal sealed class EditorServicesServerFactory : IDisposable
4545
/// </remarks>
4646
/// <param name="logPath">The path of the log file to use.</param>
4747
/// <param name="minimumLogLevel">The minimum log level to use.</param>
48-
/// <returns></returns>
48+
/// <param name="hostLogger">The host logger?</param>
4949
public static EditorServicesServerFactory Create(string logPath, int minimumLogLevel, IObservable<(int logLevel, string message)> hostLogger)
5050
{
5151
Log.Logger = new LoggerConfiguration()
@@ -78,7 +78,7 @@ public static EditorServicesServerFactory Create(string logPath, int minimumLogL
7878
/// Create the LSP server.
7979
/// </summary>
8080
/// <remarks>
81-
/// This is only called once and that's in <see cref="EditorServicesRunner"/>.
81+
/// This is only called once and that's in <see cref="Hosting.EditorServicesRunner"/>.
8282
/// </remarks>
8383
/// <param name="inputStream">The protocol transport input stream.</param>
8484
/// <param name="outputStream">The protocol transport output stream.</param>
@@ -94,7 +94,7 @@ public PsesLanguageServer CreateLanguageServer(
9494
/// Create the debug server given a language server instance.
9595
/// </summary>
9696
/// <remarks>
97-
/// This is only called once and that's in <see cref="EditorServicesRunner"/>.
97+
/// This is only called once and that's in <see cref="Hosting.EditorServicesRunner"/>.
9898
/// </remarks>
9999
/// <param name="inputStream">The protocol transport input stream.</param>
100100
/// <param name="outputStream">The protocol transport output stream.</param>
@@ -116,7 +116,7 @@ public PsesDebugServer CreateDebugServerWithLanguageServer(
116116
/// Create a new debug server based on an old one in an ended session.
117117
/// </summary>
118118
/// <remarks>
119-
/// This is only called once and that's in <see cref="EditorServicesRunner"/>.
119+
/// This is only called once and that's in <see cref="Hosting.EditorServicesRunner"/>.
120120
/// </remarks>
121121
/// <param name="inputStream">The protocol transport input stream.</param>
122122
/// <param name="outputStream">The protocol transport output stream.</param>

src/PowerShellEditorServices/Hosting/HostStartupInfo.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public sealed class HostStartupInfo
101101
/// The minimum log level of log events to be logged.
102102
/// </summary>
103103
/// <remarks>
104-
/// This is cast to all of <see cref="PsesLogLevel"/>, <see
104+
/// This is cast to all of <see cref="Hosting.PsesLogLevel"/>, <see
105105
/// cref="Microsoft.Extensions.Logging.LogLevel"/>, and <see
106106
/// cref="Serilog.Events.LogEventLevel"/>, hence it is an <c>int</c>.
107107
/// </remarks>
@@ -131,8 +131,7 @@ public sealed class HostStartupInfo
131131
/// </param>
132132
/// <param name="version">The host application's version.</param>
133133
/// <param name="psHost">The PowerShell host to use.</param>
134-
/// <param name="allUsersProfilePath">The path to the shared profile.</param>
135-
/// <param name="currentUsersProfilePath">The path to the user specific profile.</param>
134+
/// <param name="profilePaths">The set of profile paths.</param>
136135
/// <param name="featureFlags">Flags of features to enable.</param>
137136
/// <param name="additionalModules">Names or paths of additional modules to import.</param>
138137
/// <param name="initialSessionState">The language mode inherited from the orginal PowerShell process. This will be used when creating runspaces so that we honor the same initialSessionState including allowed modules, cmdlets and language mode.</param>

src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ public AnalysisService(
131131
/// Sets up a script analysis run, eventually returning the result.
132132
/// </summary>
133133
/// <param name="filesToAnalyze">The files to run script analysis on.</param>
134-
/// <param name="cancellationToken">A cancellation token to cancel this call with.</param>
135134
/// <returns>A task that finishes when script diagnostics have been published.</returns>
136-
public void StartScriptDiagnostics(
137-
ScriptFile[] filesToAnalyze)
135+
public void StartScriptDiagnostics(ScriptFile[] filesToAnalyze)
138136
{
139137
if (!_configurationService.CurrentSettings.ScriptAnalysis.Enable)
140138
{
@@ -219,7 +217,7 @@ public async Task<string> GetCommentHelpText(string functionText, string helpLoc
219217
/// <summary>
220218
/// Get the most recent corrections computed for a given script file.
221219
/// </summary>
222-
/// <param name="documentUri">The URI string of the file to get code actions for.</param>
220+
/// <param name="uri">The URI string of the file to get code actions for.</param>
223221
/// <returns>A threadsafe readonly dictionary of the code actions of the particular file.</returns>
224222
public async Task<IReadOnlyDictionary<string, IEnumerable<MarkerCorrection>>> GetMostRecentCodeActionsForFileAsync(DocumentUri uri)
225223
{
@@ -245,7 +243,7 @@ public async Task<IReadOnlyDictionary<string, IEnumerable<MarkerCorrection>>> Ge
245243
/// <summary>
246244
/// Event subscription method to be run when PSES configuration has been updated.
247245
/// </summary>
248-
/// <param name="sender">The sender of the configuration update event.</param>
246+
/// <param name="_">The sender of the configuration update event.</param>
249247
/// <param name="settings">The new language server settings.</param>
250248
public void OnConfigurationUpdated(object _, LanguageServerSettings settings)
251249
{

src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public static Breakpoint SetBreakpoint(Debugger debugger, BreakpointDetailsBase
167167
/// <param name="condition">The expression that needs to be true for the breakpoint to be triggered.</param>
168168
/// <param name="hitCondition">The amount of times this line should be hit til the breakpoint is triggered.</param>
169169
/// <param name="logMessage">The log message to write instead of calling 'break'. In VS Code, this is called a 'logPoint'.</param>
170+
/// <param name="errorMessage">The error message we might return.</param>
170171
/// <returns>ScriptBlock</returns>
171172
public static ScriptBlock GetBreakpointActionScriptBlock(string condition, string hitCondition, string logMessage, out string errorMessage)
172173
{

src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointDetails.cs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private BreakpointDetails()
4949
/// <param name="column"></param>
5050
/// <param name="condition"></param>
5151
/// <param name="hitCondition"></param>
52+
/// <param name="logMessage"></param>
5253
/// <returns></returns>
5354
internal static BreakpointDetails Create(
5455
string source,

src/PowerShellEditorServices/Services/DebugAdapter/Debugging/DebuggerStoppedEventArgs.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal class DebuggerStoppedEventArgs
5959
/// Creates a new instance of the DebuggerStoppedEventArgs class.
6060
/// </summary>
6161
/// <param name="originalEvent">The original DebuggerStopEventArgs instance from which this instance is based.</param>
62-
/// <param name="runspaceDetails">The RunspaceDetails of the runspace which raised this event.</param>
62+
/// <param name="runspaceInfo">The RunspaceDetails of the runspace which raised this event.</param>
6363
public DebuggerStoppedEventArgs(
6464
DebuggerStopEventArgs originalEvent,
6565
IRunspaceInfo runspaceInfo)
@@ -71,7 +71,7 @@ public DebuggerStoppedEventArgs(
7171
/// Creates a new instance of the DebuggerStoppedEventArgs class.
7272
/// </summary>
7373
/// <param name="originalEvent">The original DebuggerStopEventArgs instance from which this instance is based.</param>
74-
/// <param name="runspaceDetails">The RunspaceDetails of the runspace which raised this event.</param>
74+
/// <param name="runspaceInfo">The RunspaceDetails of the runspace which raised this event.</param>
7575
/// <param name="localScriptPath">The local path of the remote script being debugged.</param>
7676
public DebuggerStoppedEventArgs(
7777
DebuggerStopEventArgs originalEvent,

src/PowerShellEditorServices/Services/DebugAdapter/Debugging/StackFrameDetails.cs

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ internal class StackFrameDetails
8383
/// <param name="autoVariables">
8484
/// A variable container with all the filtered, auto variables for this stack frame.
8585
/// </param>
86+
/// <param name="commandVariables">
87+
/// A variable container with all the command variables for this stack frame.
88+
/// </param>
8689
/// <returns>A new instance of the StackFrameDetails class.</returns>
8790
internal static StackFrameDetails Create(
8891
PSObject callStackFrameObject,

src/PowerShellEditorServices/Services/Extension/ExtensionService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ internal Task InitializeAsync()
117117
/// </summary>
118118
/// <param name="commandName">The unique name of the command to be invoked.</param>
119119
/// <param name="editorContext">The context in which the command is being invoked.</param>
120+
/// <param name="cancellationToken">The token used to cancel this.</param>
120121
/// <returns>A Task that can be awaited for completion.</returns>
121122
/// <exception cref="KeyNotFoundException">The command being invoked was not registered.</exception>
122123
public Task InvokeCommandAsync(string commandName, EditorContext editorContext, CancellationToken cancellationToken)

src/PowerShellEditorServices/Services/PowerShell/Context/PowerShellContextFrame.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33

44
using System;
55
using System.Diagnostics;
6-
using System.Text;
76
using Microsoft.Extensions.Logging;
87
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Runspace;
98
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility;
109
using SMA = System.Management.Automation;
1110

11+
#if DEBUG
12+
using System.Text;
13+
#endif
14+
1215
namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Context
1316
{
1417
[DebuggerDisplay("{ToDebuggerDisplayString()}")]

src/PowerShellEditorServices/Services/PowerShell/Context/PowerShellVersionDetails.cs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public PowerShellVersionDetails(
9191
/// Gets the PowerShell version details for the given runspace.
9292
/// </summary>
9393
/// <param name="logger">An ILogger implementation used for writing log messages.</param>
94+
/// <param name="pwsh">The PowerShell instance for which to to get the version.</param>
9495
/// <returns>A new PowerShellVersionDetails instance.</returns>
9596
public static PowerShellVersionDetails GetVersionDetails(ILogger logger, PowerShell pwsh)
9697
{

src/PowerShellEditorServices/Services/PowerShell/Runspace/SessionDetails.cs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public static SessionDetails GetFromPowerShell(PowerShell pwsh)
4343
/// contained in the PSObject which was obtained using the
4444
/// PSCommand returned by GetDetailsCommand.
4545
/// </summary>
46-
/// <param name="detailsObject"></param>
4746
public SessionDetails(
4847
int processId,
4948
string computerName,

src/PowerShellEditorServices/Services/PowerShell/Utility/CommandHelpers.cs

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ internal static class CommandHelpers
5959
/// <param name="commandName">The name of the command.</param>
6060
/// <param name="currentRunspace">The current runspace.</param>
6161
/// <param name="executionService">The execution service.</param>
62+
/// <param name="cancellationToken">The token used to cancel this.</param>
6263
/// <returns>A CommandInfo object with details about the specified command.</returns>
6364
public static async Task<CommandInfo> GetCommandInfoAsync(
6465
string commandName,
@@ -117,6 +118,7 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
117118
/// </summary>
118119
/// <param name="commandInfo">The CommandInfo instance for the command.</param>
119120
/// <param name="executionService">The execution service to use for getting command documentation.</param>
121+
/// <param name="cancellationToken">The token used to cancel this.</param>
120122
/// <returns>The synopsis.</returns>
121123
public static async Task<string> GetCommandSynopsisAsync(
122124
CommandInfo commandInfo,

src/PowerShellEditorServices/Services/Symbols/ScriptDocumentSymbolProvider.cs

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ IEnumerable<ISymbolReference> IDocumentSymbolProvider.ProvideDocumentSymbols(
3030
/// Finds all symbols in a script
3131
/// </summary>
3232
/// <param name="scriptAst">The abstract syntax tree of the given script</param>
33-
/// <param name="powerShellVersion">The PowerShell version the Ast was generated from</param>
3433
/// <returns>A collection of SymbolReference objects</returns>
3534
public static IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst)
3635
{

src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static AstOperations()
5555
/// <param name="fileOffset">
5656
/// The 1-based file offset at which a symbol will be located.
5757
/// </param>
58-
/// <param name="powerShellContext">
58+
/// <param name="executionService">
5959
/// The PowerShellContext to use for gathering completions.
6060
/// </param>
6161
/// <param name="logger">An ILogger implementation used for writing log messages.</param>
@@ -195,7 +195,6 @@ public static SymbolReference FindDefinitionOfSymbol(
195195
/// Finds all symbols in a script
196196
/// </summary>
197197
/// <param name="scriptAst">The abstract syntax tree of the given script</param>
198-
/// <param name="powerShellVersion">The PowerShell version the Ast was generated from</param>
199198
/// <returns>A collection of SymbolReference objects</returns>
200199
public static IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst)
201200
{

src/PowerShellEditorServices/Services/Template/TemplateService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class TemplateService
3434
/// <summary>
3535
/// Creates a new instance of the TemplateService class.
3636
/// </summary>
37-
/// <param name="powerShellContext">The PowerShellContext to use for this service.</param>
37+
/// <param name="executionService">The PowerShellContext to use for this service.</param>
3838
/// <param name="factory">An ILoggerFactory implementation used for writing log messages.</param>
3939
public TemplateService(IInternalPowerShellExecutionService executionService, ILoggerFactory factory)
4040
{

src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public override async Task<CompletionItem> Handle(CompletionItem request, Cancel
109109
/// <param name="columnNumber">
110110
/// The 1-based column number at which completions will be gathered.
111111
/// </param>
112+
/// <param name="cancellationToken">The token used to cancel this.</param>
112113
/// <returns>
113114
/// A CommandCompletion instance completions for the identified statement.
114115
/// </returns>

0 commit comments

Comments
 (0)