Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ dotnet_diagnostic.CA1001.severity = silent
dotnet_diagnostic.CA1002.severity = none

# CA1003: Use generic event handler instances
dotnet_diagnostic.CA1003.severity = none
dotnet_diagnostic.CA1003.severity = warning
dotnet_code_quality.ca1003.api_surface = private, internal

# CA1005: Avoid excessive parameters on generic types
dotnet_diagnostic.CA1005.severity = none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,10 @@ public AsyncResultErrorEventArgs(
/// <typeparam name="T">object type</typeparam>
internal class CimResultObserver<T> : IObserver<T>
{
/// <summary>
/// Define delegate that handles new cmdlet action come from
/// the operations related to the current CimSession object.
/// </summary>
/// <param name="cimSession">CimSession object, which raised the event.</param>
/// <param name="actionArgs">Event args.</param>
public delegate void ResultEventHandler(
object observer,
AsyncResultEventArgsBase resultArgs);

/// <summary>
/// Define an Event based on the NewActionHandler.
/// </summary>
public event ResultEventHandler OnNewResult;
public event EventHandler<AsyncResultEventArgsBase> OnNewResult;

/// <summary>
/// Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,41 +296,21 @@ internal static void RemoveCimSessionFromTemporaryCache(CimSession session)

#region Event definitions

/// <summary>
/// Define delegate that handles new cmdlet action come from
/// the operations related to the current CimSession object.
/// </summary>
/// <param name="cimSession">CimSession object, which raised the event.</param>
/// <param name="actionArgs">Event args.</param>
public delegate void NewCmdletActionHandler(
object cimSession,
CmdletActionEventArgs actionArgs);

/// <summary>
/// Define an Event based on the NewActionHandler.
/// </summary>
public event NewCmdletActionHandler OnNewCmdletAction;

/// <summary>
/// Define delegate that handles operation creation and complete
/// issued by the current CimSession object.
/// </summary>
/// <param name="cimSession">CimSession object, which raised the event.</param>
/// <param name="actionArgs">Event args.</param>
public delegate void OperationEventHandler(
object cimSession,
OperationEventArgs actionArgs);
public event EventHandler<CmdletActionEventArgs> OnNewCmdletAction;

/// <summary>
/// Event triggered when a new operation is started.
/// </summary>
public event OperationEventHandler OnOperationCreated;
public event EventHandler<OperationEventArgs> OnOperationCreated;

/// <summary>
/// Event triggered when a new operation is completed,
/// either success or failed.
/// </summary>
public event OperationEventHandler OnOperationDeleted;
public event EventHandler<OperationEventArgs> OnOperationDeleted;

#endregion

Expand Down Expand Up @@ -751,7 +731,7 @@ protected void FireNewActionEvent(CimBaseAction action)
return;
}

NewCmdletActionHandler temp = this.OnNewCmdletAction;
EventHandler<CmdletActionEventArgs> temp = this.OnNewCmdletAction;
if (temp != null)
{
temp(this.session, actionArgs);
Expand Down
6 changes: 3 additions & 3 deletions src/System.Management.Automation/help/HelpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected override void ProcessRecord()
this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(this, "Microsoft.PowerShell.Commands.Internal.HelpWindowHelper");
}
#endif
helpSystem.OnProgress += new HelpSystem.HelpProgressHandler(HelpSystem_OnProgress);
helpSystem.OnProgress += HelpSystem_OnProgress;

bool failed = false;
HelpCategory helpCategory = ToHelpCategory(Category, ref failed);
Expand Down Expand Up @@ -354,7 +354,7 @@ protected override void ProcessRecord()
}
finally
{
helpSystem.OnProgress -= new HelpSystem.HelpProgressHandler(HelpSystem_OnProgress);
helpSystem.OnProgress -= HelpSystem_OnProgress;
HelpSystem_OnComplete();

// finally clear the ScriptBlockAst -> Token[] cache
Expand Down Expand Up @@ -683,7 +683,7 @@ private void LaunchOnlineHelp(Uri uriToLaunch)

#endregion

private void HelpSystem_OnProgress(object sender, HelpProgressInfo arg)
private void HelpSystem_OnProgress(object sender, HelpProgressEventArgs arg)
{
var record = new ProgressRecord(0, this.CommandInfo.Name, arg.Activity)
{
Expand Down
14 changes: 6 additions & 8 deletions src/System.Management.Automation/help/HelpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ internal ExecutionContext ExecutionContext

#region Progress Callback

internal delegate void HelpProgressHandler(object sender, HelpProgressInfo arg);

internal event HelpProgressHandler OnProgress;
internal event EventHandler<HelpProgressEventArgs> OnProgress;

#endregion

Expand Down Expand Up @@ -463,7 +461,7 @@ private IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest)
bool searchInHelpContent = false;
bool shouldBreak = false;

HelpProgressInfo progress = new HelpProgressInfo();
HelpProgressEventArgs progress = new HelpProgressEventArgs();

progress.Activity = StringUtil.Format(HelpDisplayStrings.SearchingForHelpContent, helpRequest.Target);
progress.Completed = false;
Expand Down Expand Up @@ -802,11 +800,11 @@ internal void ClearScriptBlockTokenCache()
/// <summary>
/// Help progress info.
/// </summary>
internal class HelpProgressInfo
internal class HelpProgressEventArgs : EventArgs
{
internal bool Completed;
internal string Activity;
internal int PercentComplete;
internal bool Completed { get; set; }
internal string Activity { get; set; }
internal int PercentComplete { get; set; }
}

/// <summary>
Expand Down