Skip to content

Commit 3771870

Browse files
authored
Merge pull request #1 from markcowl/store-fix
Store fix
2 parents 8f8e05a + fa6ac08 commit 3771870

File tree

6 files changed

+88
-48
lines changed

6 files changed

+88
-48
lines changed

src/Storage/custom/GetCommonParameter.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Storage/custom/Kind.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
namespace Microsoft.Azure.PowerShell.Cmdlets.Storage.Support
4+
{
5+
6+
[System.ComponentModel.TypeConverter(typeof(KindConverter))]
7+
public partial struct Kind
8+
{
9+
/// <summary>FIXME: Field BlobStorage is MISSING DESCRIPTION</summary>
10+
}
11+
12+
public class KindConverter : System.Management.Automation.PSTypeConverter
13+
{
14+
public override bool CanConvertFrom(object sourceValue, Type destinationType)
15+
{
16+
return true;
17+
}
18+
19+
public override bool CanConvertTo(object sourceValue, Type destinationType)
20+
{
21+
return false;
22+
}
23+
24+
public override object ConvertFrom(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase)
25+
{
26+
return Kind.CreateFrom(sourceValue);
27+
}
28+
29+
public override object ConvertTo(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase)
30+
{
31+
return default(object);
32+
}
33+
}
34+
}

src/Storage/custom/SkuName.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace Microsoft.Azure.PowerShell.Cmdlets.Storage.Support
4+
{
5+
[System.ComponentModel.TypeConverter(typeof(SkuNameConverter))]
6+
7+
public partial struct SkuName
8+
{
9+
}
10+
public class SkuNameConverter : System.Management.Automation.PSTypeConverter
11+
{
12+
public override bool CanConvertFrom(object sourceValue, Type destinationType)
13+
{
14+
return true;
15+
}
16+
17+
public override bool CanConvertTo(object sourceValue, Type destinationType)
18+
{
19+
return false;
20+
}
21+
22+
public override object ConvertFrom(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase)
23+
{
24+
return SkuName.CreateFrom(sourceValue);
25+
}
26+
27+
public override object ConvertTo(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase)
28+
{
29+
return default(object);
30+
}
31+
}
32+
33+
}

src/Storage/custom/latest-2019-04-30/New-AzStorageAccount.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ function New-AzStorageAccount {
270270
process {
271271
if ($PSBoundParameters.ContainsKey("AsJob")) {
272272
$null = $PSBoundParameters.Remove("AsJob")
273-
Start-Job -ScriptBlock {param($arg) Az.Storage\New-AzStorageAccount @arg} -InitializationScript {Import-Module "C:\Users\niassis\source\repos\generating\azure-powershell\src\Storage\Az.Storage.psd1"} -ArgumentList $PSBoundParameters
273+
Start-Job -ScriptBlock {
274+
param($arg, $modulePath)
275+
Import-Module $modulePath
276+
Az.Storage\New-AzStorageAccount @arg} -ArgumentList $PSBoundParameters, (Join-Path $PSScriptRoot "..\..\Az.Storage.psd1")
274277
} else {
275278
if ($PSBoundParameters.ContainsKey("StorageEncryption")) {
276279
$null = $PSBoundParameters.Add("EncryptionKeySource", "Microsoft.Storage")

src/Storage/how-to.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To build, run the `build-module.ps1` at the root of the module directory. This w
88
To add cmdlets that were not generated by the REST specification, use the `custom` folder. This folder allows you to add handwritten `.ps1` and `.cs` files. Currently, we support using `.ps1` scripts as new cmdlets or as additional low-level variants (via `ParameterSet`), and `.cs` files as low-level (variants) cmdlets that the exported script cmdlets call. We do not support exporting any `.cs` (dll) cmdlets directly. To read more about custom cmdlets, look at the [readme.md](custom/readme.md) in the `custom` folder.
99

1010
## Generating documentation
11-
To generate documentation, run the `generate-help.ps1` script. This will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [readme.md](examples/readme.md) in the `examples` folder. To read more about documentation, look at the [readme.md](docs/readme.md) in the `docs` folder.
11+
To generate documentation, the process is now integrated into the `build-module.ps1` script. If you don't want to run this process as part of `build-module.ps1`, you can provide the `-NoDocs` switch. If you want to run documentation generation after the build process, you may still run the `generate-help.ps1` script. Overall, the process will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [readme.md](examples/readme.md) in the `examples` folder. To read more about documentation, look at the [readme.md](docs/readme.md) in the `docs` folder.
1212

1313
## Testing `Az.Storage`
1414
To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [readme.md](examples/readme.md) in the `examples` folder.
@@ -19,14 +19,16 @@ To pack `Az.Storage` for distribution, run the `pack-module.ps1` script. This wi
1919
## Module Script Details
2020
There are multiple scripts created for performing different actions for developing `Az.Storage`.
2121
- `build-module.ps1`
22-
- Builds the module DLL (`./bin/Az.Storage.private.dll`), creates the exported cmdlets, generates custom cmdlet test stubs, and updates `./Az.Storage.psd1` with Azure profile information.
22+
- Builds the module DLL (`./bin/Az.Storage.private.dll`), creates the exported cmdlets and documentation, generates custom cmdlet test stubs and exported cmdlet example stubs, and updates `./Az.Storage.psd1` with Azure profile information.
2323
- **Parameters**: [`Switch` parameters]
2424
- `-Run`: After building, creates an isolated PowerShell session and loads `Az.Storage`.
2525
- `-Test`: After building, runs the `Pester` tests defined in the `test` folder.
2626
- `-Docs`: After building, generates the Markdown documents for the modules into the `docs` folder.
2727
- `-Pack`: After building, packages the module into a `.nupkg`.
2828
- `-Code`: After building, opens a VSCode window with the module's directory and runs (see `-Run`) the module.
2929
- `-Release`: Builds the module in `Release` configuration (as opposed to `Debug` configuration).
30+
- `-NoDocs`: Supresses writing the documentation markdown files as part of the cmdlet exporting process.
31+
- `-Debugger`: Used when attaching the debugger in Visual Studio to the PowerShell session, and running the build process without recompiling the DLL. This suppresses running the script as an isolated process.
3032
- `run-module.ps1`
3133
- Creates an isolated PowerShell session and loads `Az.Storage` into the session.
3234
- Same as `-Run` in `build-module.ps1`.
@@ -42,7 +44,15 @@ There are multiple scripts created for performing different actions for developi
4244
- `pack-module.ps1`
4345
- Packages the module into a `.nupkg` for distribution.
4446
- Same as `-Pack` in `build-module.ps1`.
47+
- `generate-help.ps1`
48+
- Generates the Markdown documents for the modules into the `docs` folder.
49+
- Same as `-Docs` in `build-module.ps1`.
50+
- This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`.
51+
- `export-surface.ps1`
52+
- Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module.
53+
- These files are placed into the `resources` folder.
54+
- Used for investigating the surface of your module. These are *not* documentation for distribution.
4555
- `check-dependencies.ps1`
46-
- Used in `run-module.ps1`, `generate-help.ps1`, and `test-module.ps1` to verify dependent modules are available to run those tasks.
56+
- Used in `run-module.ps1` and `test-module.ps1` to verify dependent modules are available to run those tasks.
4757
- It will download local (within the module's directory structure) versions of those modules as needed.
4858
- This script *does not* need to be ran by-hand.

src/Storage/test/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ This directory contains the [Pester](https://www.powershellgallery.com/packages/
77
- Committed: yes
88
- Packaged: no
99

10-
## Details (*WIP*)
11-
We allow three testing modes: `live`, `record`, and `playback`.
10+
## Details
11+
We allow three testing modes: *live*, *record*, and *playback*. These can be selected using the `-Live`, `-Record`, and `-Playback` switches respectively on the `test-module.ps1` script. This script will run through any `.Tests.ps1` scripts in the `test` folder. If you choose the *record* mode, it will create a `.Recording.json` file of the REST calls between the client and server. Then, when you choose *playback* mode, it will use the `.Recording.json` file to mock the communication between server and client. The *live* mode runs the same as the *record* mode; however, it doesn't create the `.Recording.json` file.
1212

1313
## Purpose
1414
Custom cmdlets generally encompass additional functionality not described in the REST specification, or combines functionality generated from the REST spec. To validate this functionality continues to operate as intended, creating tests that can be ran and re-ran against custom cmdlets is part of the framework.
1515

16-
## Usage (*WIP*)
17-
This feature is currently a **work-in-progress**. It is able to create test recordings of the HTTP pipeline. However, folder structure, file names, and processes are being implemented.
16+
## Usage
17+
To execute tests, run the `test-module.ps1`. To write tests, [this example](https://github.com/pester/Pester/blob/8b9cf4248315e44f1ac6673be149f7e0d7f10466/Examples/Planets/Get-Planet.Tests.ps1#L1) from the Pester repository is very useful for getting started.

0 commit comments

Comments
 (0)