PowerShell / PowerShell/PSScriptAnalyzer

Documentation for implementing rules in a .NET assembly

Open
#765 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Documentation Consider - 2.0 Issue - Enhancement
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

Apologies if I've just missed something, but I can't seem to find much in the way of documentation for implementing rules in a .NET assembly. I took a stab at it anyway by creating a class that implements IScriptRule, but ScriptAnalyzer can't seem to find it. I just get something like:

Invoke-ScriptAnalyzer : Exception of type 'System.Exception' was thrown.
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path C:\local\test.ps1 -Cu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceExists: (Microsoft.Windo....ScriptAnalyzer:ScriptAnalyzer) [Invoke-ScriptAnalyzer], Exception
    + FullyQualifiedErrorId : Cannot find ScriptAnalyzer rules in the specified path,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand

I've tried adding an [Export(typeof(IScriptRule))] attribute to my class, but it didn't help.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with IScriptRule and the ScriptAnalyzer behavior described in the report, then reproduce the shown Invoke-ScriptAnalyzer failure with the referenced .NET assembly. Determine what assembly and class details documentation must explain, and finish with documentation that lets a user implement and discover a rule successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.