Skip to content

Commit

Permalink
Fix number keyword not resolving (#38)
Browse files Browse the repository at this point in the history
Also add help for `hasdefault` and update manifest
  • Loading branch information
SeeminglyScience authored May 1, 2022
1 parent 2845fdd commit c92d4c9
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
71 changes: 71 additions & 0 deletions docs/en-US/about_Type_Signatures.help.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Type signatures are a custom query language built into PowerShell type expressio
* [`concrete`](#concrete)
* [`index`](#index)
* [`number`](#number)
* [`hasdefault`](#hasdefault)
* [`decoration`, `hasattr`](#decoration-hasattr)
* [`generic`](#generic)
* [Resolution Maps](#resolution-maps)
Expand Down Expand Up @@ -3242,6 +3243,76 @@ public readonly struct DateTime
</tr>
</table>

## `hasdefault`

<sup>([Back to Top](#keywords))</sup>

Matches only parameters with a default value.

<table>
<tr>
<td colspan="2" width="1000">

```powershell
Find-Member -ParameterType { [hasdefault] }
```

</td>
</tr>
<tr>
<th width="1">

</th>
<th>

Signature

</th>
</tr>
<tr>
<td width="1">

:x:

</td>
<td>

```csharp
void Example(string str);
```

</td>
</tr>
<tr>
<td width="1">

:heavy_check_mark:

</td>
<td>

```csharp
void Example(string str = "something");
```

</td>
</tr>
<tr>
<td width="1">

:heavy_check_mark:

</td>
<td>

```csharp
void Example(CancellationToken token = default);
```

</td>
</tr>
</table>

## `decoration`, `hasattr`

<sup>([Back to Top](#keywords))</sup>
Expand Down
7 changes: 6 additions & 1 deletion module/ClassExplorer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'ClassExplorer.psm1'

# Version number of this module.
ModuleVersion = '2.3.0'
ModuleVersion = '2.3.1'

# Supported PSEditions
CompatiblePSEditions = 'Desktop', 'Core'
Expand Down Expand Up @@ -78,6 +78,11 @@ PrivateData = @{

# ReleaseNotes of this module
ReleaseNotes = @'
## 2.3.1
* Fix `number` signature keyword not resolving
* Add help for `hasdefault` keyword
## 2.3.0
* Add `-Extension` parameter to `Find-Member`. This will find only extension methods
Expand Down
1 change: 1 addition & 0 deletions src/ClassExplorer/Signatures/SignatureParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public ITypeSignature ParseDefinition(
Keywords.any => new AnySignature(),
Keywords.generic => Consume(ParseGeneric(args, typeName), out argsConsumed),
Keywords.hasdefault => new HasDefaultSignature(),
Keywords.number => new NumberTypeSignature(),
Keywords.decoration or Keywords.hasattr => Consume(Decoration(args, typeName), out argsConsumed),
Keywords.pointer => Consume(ParsePointer(args, typeName), out argsConsumed),
_ => Default(typeName, args),
Expand Down
12 changes: 12 additions & 0 deletions tools/Signatures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ keywords:
- match: false
sig: public readonly struct DateTime

- header: "`hasdefault`"
description: Matches only parameters with a default value.
examples:
- syntax: Find-Member -ParameterType { [hasdefault] }
signatures:
- match: false
sig: void Example(string str);
- match: true
sig: void Example(string str = "something");
- match: true
sig: void Example(CancellationToken token = default);

- header: "`decoration`, `hasattr`"
description: Matches parameters or types decorated with this attribute.
examples:
Expand Down

0 comments on commit c92d4c9

Please sign in to comment.