Skip to content

Clu #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 31, 2015
Merged

Clu #286

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
12 changes: 12 additions & 0 deletions src/CLU/Microsoft.CLU/CommandBinder/CmdletBinderAndCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,18 @@ private void BindDynamicParameters()
// If Cmdlet instance support dynamic parameters then rerun the parser to bind dynamic parameters.
_dynamicParameterBindInProgress = true;
this.ParserSeekBeginAndRun();
var psCmdlet = _cmdlet as PSCmdlet;
if (psCmdlet != null)
{
// We need to add all dynamic parameters that were bound
foreach (var boundParam in _cmdletMetadata.Instance.Parameters)
{
if (boundParam.Value.IsBound && boundParam.Value.IsDynamic && !psCmdlet.MyInvocation.BoundParameters.ContainsKey(boundParam.Value.Name))
{
psCmdlet.MyInvocation.BoundParameters[boundParam.Value.Name] = boundParam.Value;
}
}
}
_dynamicParameterBindInProgress = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Microsoft.CLU/Metadata/CmdletMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class CmdletMetadata
/// <summary>
/// The metadata information of the cmdlet instance.
/// </summary>
public InstanceMetadata Instance { get; set; }
public InstanceMetadata Instance { get; private set; }

/// <summary>
/// Creates an instance of CmdletMetadata.
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Microsoft.CLU/Metadata/InstanceMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets
}
}

Dictionary<string, ParameterMetadata> _dynamicParameters;
Dictionary<string, ParameterMetadata> _dynamicParameters = new Dictionary<string, ParameterMetadata>();
/// <summary>
/// Get dynamic parameter metadata dictionary. The key is name of the dynamic
/// parameter and value is the dynamic parameter metadata.
Expand Down
15 changes: 14 additions & 1 deletion src/CLU/Microsoft.CLU/System.Management.Automation/CmdletInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.ObjectModel;
using Microsoft.CLU.Metadata;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;

namespace System.Management.Automation
{
Expand All @@ -25,6 +27,9 @@ internal CmdletInfo(Type cmdlet, PSModuleInfo module, ICommandRuntime runtime, s
cmdlet.GetTypeInfo().GetCustomAttributes(typeof(OutputTypeAttribute), true)
.Select(a => a as OutputTypeAttribute)
.SelectMany(ot => ot.Type).ToList());

_typeMetadata = new TypeMetadata(cmdlet);
_typeMetadata.Load();
}

public string Noun
Expand All @@ -37,6 +42,13 @@ public string Verb
get; private set;
}

public override Dictionary<string, ParameterMetadata> Parameters
{
get
{
return _typeMetadata.Parameters;
}
}
public override ReadOnlyCollection<PSTypeName> OutputType
{
get
Expand Down Expand Up @@ -67,6 +79,7 @@ public override string ToString()
return Name;
}

private TypeMetadata _typeMetadata;
private ReadOnlyCollection<PSTypeName> _outputTypes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public abstract class CommandInfo
public CommandTypes CommandType { get { return CommandTypes.Cmdlet; } }
public string Name { get; protected set; }
public abstract ReadOnlyCollection<PSTypeName> OutputType { get; }
public virtual Dictionary<string, ParameterMetadata> Parameters { get; private set; }
public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets { get; protected set; }
public virtual Dictionary<string, ParameterMetadata> Parameters { get; }
public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets { get; }
public PSModuleInfo Module { get; protected set; }
public string ModuleName { get { return Module.Name; } }

Expand Down