PowerShell / PowerShell/PSScriptAnalyzer
New Rule Suggestion: Validate ps1xml Schema
Open
Nobody has claimed this yet.
Up-for-Grabs
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
*.Format.ps1xml and *.Types.ps1xml have a XSD now. This can be used to create a rule to validate types and format XML schema.
In my build scripts I have the following code to validate ps1xml files.
$ps1xmlFiles = Get-ChildItem -Path $modulePath -Filter *.ps1xml
foreach ($ps1xml in $ps1xmlFiles) {
[xml]$xml = Get-Content -Path $ps1xml.FullName
$null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd')
$null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd')
$xml.Validate( { throw "File '$($ps1xml.Name)' schema error: $($_.Message)" })
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed PowerShell validation snippet and the referenced Format.xsd and Types.xsd schemas. Review how PSScriptAnalyzer rules discover and report issues, then confirm the rule handles both *.Format.ps1xml and *.Types.ps1xml files and reports schema errors; add or run relevant rule tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, xml
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100