mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-22 10:07:37 +00:00
## Summary of the Pull Request - #39572 updated check-spelling but ignored: > 🐣 Breaking Changes [Code Scanning action requires a Code Scanning Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset) If you use SARIF reporting, then instead of the workflow yielding an ❌ when it fails, it will rely on [github-advanced-security 🤖](https://github.com/apps/github-advanced-security) to report the failure. You will need to adjust your checks for PRs. This means that check-spelling hasn't been properly doing its job 😦. I'm sorry, I should have pushed a thing to this repo earlier,... Anyway, as with most refreshes, this comes with a number of fixes, some are fixes for typos that snuck in before the 0.0.25 upgrade, some are for things that snuck in after, some are based on new rules in spell-check-this, and some are hand written patterns based on running through this repository a few times. About the 🐣 **breaking change**: someone needs to create a ruleset for this repository (see [Code Scanning action requires a Code Scanning Ruleset: Sample ruleset ](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)). The alternative to adding a ruleset is to change the condition to not use sarif for this repository. In general, I think the github integration from sarif is prettier/more helpful, so I think that it's the better choice. You can see an example of it working in: - https://github.com/check-spelling-sandbox/PowerToys/pull/23 --------- Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com> Co-authored-by: Mike Griese <migrie@microsoft.com> Co-authored-by: Dustin L. Howett <dustin@howett.net>
6.0 KiB
6.0 KiB
Value Generator Plugin
The Value Generator plugin is used to generate hashes for strings, to calculate base64 encodings, escape and encode URLs/URIs and to generate GUIDs of version 1, 3, 4, 5, and 7.
IComputeRequest
- Interface for a request for computation
- the
bool Compute()
method must populate theIsSuccessful
and one of theResult
andErrorMessage
fields - The result of
string ResultToString()
will be used for the Result's title - The
Description
field will be used for the Result's subtitle
HashRequest
- Implements IComputeRequest
- Supports the hashing algorithms from System.Security.Cryptography:
- MD5
- SHA1
- SHA256
- SHA384
- SHA512
- If other algorithms are added to System.Security.Cryptography, they can be added to the
_algorithms
dictionary.InputParser.ParseInput()
will need to return aHashRequest
for the algorithm in the query
Base64Request
- Implements IComputeRequest
Compute()
will populateResult
with the base64 encoding of the byte array passed in the constructor
Base64DecodeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the decoded byte array of the base64 string passed in the constructor
GUIDRequest
- Implements IComputeRequest
- Uses the
GUIDGenerator
class to generate or compute the requested GUID
GUIDGenerator
- Utility class for generating or calculating GUIDs
- Generating GUID versions 1, 4, and 7 is done using builtin APIs:
UuidCreateSequential
for version 1System.Guid.NewGuid()
for version 4System.Guid.CreateVersion7()
for version 7
- Versions 3 and 5 take two parameters: a namespace and a name
- The namespace must be a valid GUID or one of the predefined ones
- The
PredefinedNamespaces
dictionary contains aliases for the predefined namespaces - The name can be any string
UrlEncodeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the encoded url converted usingHttpUtility.UrlEncode()
.
UrlDecodeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the decoded url converted usingHttpUtility.UrlDecode()
.
DataEscapeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the escaped data string converted usingSystem.Uri.EscapeDataString()
.
DataUnescapeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the unescaped data string converted usingSystem.Uri.UnescapeDataString()
.
HexEscapeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the escaped data string converted usingSystem.Uri.HexEscape()
.- Only single characters are supported as input.
HexUnescapeRequest
- Implements IComputeRequest
Compute()
will populateResult
with the unescaped data string converted usingSystem.Uri.HexUnescape()
.- Only the first hexadecimal character in the string gets unescaped. The rest of the user input is ignored.
InputParser
- It is responsible only for parsing the query from the user
- Based on the user query, the
ParseInput()
method must return an object that implements theIComputeRequest
interface or it must throw one ofFormatException
orArgumentException
- Throwing an
ArgumentException
should signal the fact that the query contains a mistake that the user can fix (e.g. an unsupported hash function, an invalid GUID version, an invalid namespace, etc.)
The error message will be shown to the user and no log message will be created
- Throwing a
FormatException
should signal either:- that the query may become valid, and so it does not make sense to show an error just yet (e.g. the query does not contain a request yet, a hash request without a string to hash)
- that the query is completely invalid
The error message will not be shown to the user but a log message will be created
Adding a new value generator
- To add a new value generator, create a folder under
/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.ValueGenerator/Generators/
and inside it add a class that implementsIComputeRequest
. - Add any utility classes that are specific to the new generator inside the same folder to keep them separated from the other generators.
- Modify the
InputParser.ParseInput()
to handle a request for the new generator and return an instance of the class you created in step 1