Skip to content

Commit

Permalink
Fix C# xml docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeminglyScience committed Jun 27, 2024
1 parent 051a60f commit f419463
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 11 deletions.
3 changes: 1 addition & 2 deletions SecretManagement.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $HelpOut = Join-Path $ModuleOut en-US
$CSharpArtifacts = @(
"$FullModuleName.dll",
"$FullModuleName.pdb",
"$FullModuleName.xml",
"System.Runtime.InteropServices.RuntimeInformation.dll")

$BaseArtifacts = @(
Expand Down Expand Up @@ -77,8 +78,6 @@ task BuildModule {
$manifestContent = Get-Content -LiteralPath $ManifestPath -Raw
$newManifestContent = $manifestContent -replace '{{ModuleVersion}}', $moduleVersion
Set-Content -LiteralPath "$ModuleOut/$FullModuleName.psd1" -Encoding utf8 -Value $newManifestContent

# New-ExternalHelp -Path docs/Microsoft.PowerShell.ConsoleGuiTools -OutputPath module/en-US -Force
}

task PackageModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<file src="images/PowerShell_64.png" target="images/" />
<file src="$artifacts$/refs/$id$.dll" target="ref/net461" />
<file src="$artifacts$/publish/$id$.dll" target="lib/net461" />
<file src="$artifacts$/publish/$id$.xml" target="lib/net461" />
</files>
</package>
7 changes: 6 additions & 1 deletion src/code/Microsoft.PowerShell.SecretManagement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
<FileVersion>$(ModuleVersion)</FileVersion>
<InformationalVersion>$(ModuleVersion)</InformationalVersion>
<TargetFramework>net461</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-*" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" PrivateAssets="All" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<IntermediateRefAssembly Include="$(ArtifactsPath)/refs/$(TargetName)$(TargetExt)" />
</ItemGroup>
</Project>
71 changes: 67 additions & 4 deletions src/code/SecretManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public sealed class RegisterSecretVaultCommand : PSCmdlet

#region Overrides

/// <summary>
/// Performs initialization of command execution.
/// </summary>
protected override void BeginProcessing()
{
// Disallow 'Verbose' in VaultParameters because it is reserved.
Expand Down Expand Up @@ -224,6 +227,9 @@ protected override void BeginProcessing()
}
}

/// <summary>
/// Performs clean-up after the command execution.
/// </summary>
protected override void EndProcessing()
{
var vaultInfo = new Hashtable();
Expand Down Expand Up @@ -569,6 +575,9 @@ public sealed class UnregisterSecretVaultCommand : PSCmdlet
[ValidateNotNullOrEmpty]
public string[] Name { get; set; }

/// <summary>
/// Gets or sets the secret vault to unregister.
/// </summary>
[Parameter(
ParameterSetName = SecretVaultParameterSet,
Position = 0,
Expand Down Expand Up @@ -717,6 +726,9 @@ public sealed class SetSecretVaultDefaultCommand : PSCmdlet

#region Overrides

/// <summary>
/// Performs clean-up after the command execution.
/// </summary>
protected override void EndProcessing()
{
if (!ShouldProcess(Name, "Set vault as default"))
Expand Down Expand Up @@ -767,6 +779,9 @@ protected override void EndProcessing()

#region SecretCmdlet

/// <summary>
/// Base type for Secret cmdlets.
/// </summary>
public abstract class SecretCmdlet : PSCmdlet
{
/// <summary>
Expand Down Expand Up @@ -860,7 +875,7 @@ public sealed class GetSecretVaultCommand : SecretCmdlet

/// <summary>
/// Gets or sets an optional name of the secret vault to return.
/// <summary>
/// </summary>
[Parameter(Position = 0)]
[ArgumentCompleter(typeof(VaultNameCompleter))]
[SupportsWildcards]
Expand All @@ -870,6 +885,9 @@ public sealed class GetSecretVaultCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs clean-up after the command execution.
/// </summary>
protected override void EndProcessing()
{
Name = Name ?? new string[] { "*" };
Expand Down Expand Up @@ -932,7 +950,7 @@ public sealed class UnlockSecretVaultCommand : SecretCmdlet

/// <summary>
/// Gets or sets the name of the secret vault to unlock.
/// <summary>
/// </summary>
[Parameter(Position = 0, Mandatory = true)]
[ArgumentCompleter(typeof(VaultNameCompleter))]
[ValidateNotNullOrEmpty]
Expand All @@ -948,6 +966,9 @@ public sealed class UnlockSecretVaultCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs clean-up after the command execution.
/// </summary>
protected override void EndProcessing()
{
var extensionModule = GetExtensionVault(Name);
Expand Down Expand Up @@ -994,12 +1015,18 @@ public sealed class GetSecretInfoCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs initialization of command execution.
/// </summary>
protected override void BeginProcessing()
{
base.BeginProcessing();
Utils.CheckForRegisteredVaults(this);
}

/// <summary>
/// Performs clean-up after the command execution.
/// </summary>
protected override void EndProcessing()
{
if (string.IsNullOrEmpty(Name))
Expand Down Expand Up @@ -1125,19 +1152,28 @@ public sealed class SetSecretInfoCommand : SecretCmdlet
[ArgumentCompleter(typeof(VaultNameCompleter))]
public string Vault { get; set; }

/// <summary>
/// Gets or sets the secret to set.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = InfoParameterSet)]
public SecretInformation InputObject { get; set; }

#endregion

#region Overrides

/// <summary>
/// Performs initialization of command execution.
/// </summary>
protected override void BeginProcessing()
{
base.BeginProcessing();
Utils.CheckForRegisteredVaults(this);
}

/// <summary>
/// Performs execution of the command.
/// </summary>
protected override void ProcessRecord()
{
if (!ShouldProcess(Vault, "Write secret metadata to vault and override any existing metadata associated with the secret"))
Expand Down Expand Up @@ -1215,7 +1251,7 @@ public sealed class GetSecretCommand : SecretCmdlet

/// <summary>
/// Gets or sets a name of secret to retrieve.
/// <summary>
/// </summary>
[Parameter(Position = 0,
Mandatory = true,
ValueFromPipeline = true,
Expand Down Expand Up @@ -1260,12 +1296,18 @@ enum InvokeResult

#region Overrides

/// <summary>
/// Performs initialization of command execution.
/// </summary>
protected override void BeginProcessing()
{
base.BeginProcessing();
Utils.CheckForRegisteredVaults(this);
}

/// <summary>
/// Performs execution of the command.
/// </summary>
protected override void ProcessRecord()
{
if (ParameterSetName == InfoParameterSet)
Expand Down Expand Up @@ -1472,6 +1514,9 @@ public sealed class SetSecretCommand : SecretCmdlet
ParameterSetName = SecureStringParameterSet)]
public SecureString SecureStringSecret { get; set; }

/// <summary>
/// Gets or sets the secret to set.
/// </summary>
[Parameter(
Position = 1,
Mandatory = true,
Expand Down Expand Up @@ -1505,12 +1550,18 @@ public sealed class SetSecretCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs initialization of command execution.
/// </summary>
protected override void BeginProcessing()
{
base.BeginProcessing();
Utils.CheckForRegisteredVaults(this);
}

/// <summary>
/// Performs execution of the command.
/// </summary>
protected override void ProcessRecord()
{
if (!ShouldProcess(Vault, "Write secret to vault and override any existing secret of the same name"))
Expand Down Expand Up @@ -1648,7 +1699,7 @@ private bool SecretExistsInVault(

/// <summary>
/// Removes a secret by name from the local default vault.
/// <summary>
/// </summary>
[Cmdlet(VerbsCommon.Remove, "Secret", SupportsShouldProcess = true)]
public sealed class RemoveSecretCommand : SecretCmdlet
{
Expand Down Expand Up @@ -1684,6 +1735,9 @@ public sealed class RemoveSecretCommand : SecretCmdlet
[ValidateNotNullOrEmpty]
public string Vault { get; set; }

/// <summary>
/// Gets or sets the secret to be removed.
/// </summary>
[Parameter(
Position = 0,
Mandatory = true,
Expand All @@ -1695,6 +1749,9 @@ public sealed class RemoveSecretCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs execution of the command.
/// </summary>
protected override void ProcessRecord()
{
if (!ShouldProcess(Vault, "Remove secret by name from vault"))
Expand Down Expand Up @@ -1732,6 +1789,9 @@ public sealed class TestSecretVaultCommand : SecretCmdlet
{
#region Parameters

/// <summary>
/// Gets or sets the secret name.
/// </summary>
[Parameter(
Position = 0,
ValueFromPipeline = true,
Expand All @@ -1744,6 +1804,9 @@ public sealed class TestSecretVaultCommand : SecretCmdlet

#region Overrides

/// <summary>
/// Performs execution of the command.
/// </summary>
protected override void ProcessRecord()
{
Name = Name ?? new string[] { "*" };
Expand Down
41 changes: 37 additions & 4 deletions src/code/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,52 @@ public static void CheckForRegisteredVaults(PSCmdlet cmdlet)
/// </summary>
public enum SecretType
{
/// <summary>
/// Specifies the value is of an unknown type.
/// </summary>
Unknown = 0,

/// <summary>
/// Specifes the value is a <see cref="T:byte[]"/>.
/// </summary>
ByteArray,

/// <summary>
/// Specifes the value is a <see cref="T:string"/>.
/// </summary>
String,

/// <summary>
/// Specifes the value is a <see cref="System.Security.SecureString"/>.
/// </summary>
SecureString,

/// <summary>
/// Specifies the value is a <see cref="System.Management.Automation.PSCredential"/>.
/// </summary>
PSCredential,
Hashtable
};

/// <summary>
/// Specifes the value is a <see cref="System.Collections.Hashtable"/> .
/// </summary>
Hashtable,
}

#endregion

#region Exceptions

/// <summary>
/// Represents errors that occur due to a password not being specified when required.
/// </summary>
public sealed class PasswordRequiredException : InvalidOperationException
{
#region Constructor

/// <summary>
/// Initializes a new instance of the <see cref="PasswordRequiredException" /> class.
/// </summary>
/// <param name="msg">The message that describes the error.</param>
public PasswordRequiredException(string msg)
: base(msg)
{
Expand All @@ -201,6 +231,9 @@ public PasswordRequiredException(string msg)

#region SecretInformation class

/// <summary>
/// Represents a secret from a secret vault.
/// </summary>
public sealed class SecretInformation
{
#region Properties
Expand Down Expand Up @@ -442,7 +475,7 @@ internal class ExtensionVaultModule

/// <summary>
/// Additional vault parameters.
/// <summary>
/// </summary>
public IReadOnlyDictionary<string, object> VaultParameters { get; }

/// <summary>
Expand Down Expand Up @@ -1197,6 +1230,7 @@ public static Hashtable GetAll()
/// <summary>
/// Add item to cache.
/// </summary>
/// <param name="keyName">The key of the vault to add.</param>
/// <param name="vaultInfo">Hashtable of vault information.</param>
/// <param name="defaultVault">When true, this vault is designated as the default vault.</param>
/// <param name="overWriteExisting">When true, this will overwrite an existing vault with the same name.</param>
Expand Down Expand Up @@ -1423,7 +1457,6 @@ private static void DeleteSecretVaultRegistryFile()
/// </summary>
/// <param name="vaultInfo">Hashtable containing registered vault information.</param>
/// <param name="defaultVaultName">The default vault name.</param>
/// </summary>
private static void WriteSecretVaultRegistry(
Hashtable vaultInfo,
string defaultVaultName)
Expand Down

0 comments on commit f419463

Please sign in to comment.