PowerShell / PowerShell/PSScriptAnalyzer

Revise semantics of compatibility rule profile inclusion

Offen
#1,224 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area - Configuration Area - Engine Consider - 2.0 Issue - Enhancement
Vorherrschende Sprache
C#
Sterne
2.2k
Forks
414
Ø Merge
13 Std. 1 Min.
Gemergte PRs (30 T.)
2

Beschreibung

UseCompatibleCommands and UseCompatibleTypes create a "union" profile for comparison of target profiles to a base standard. This allows us to use simple heuristic to determine whether a PowerShell AST represents something that is platform-specific (we see if the command or type is available in any platform, and if not ignore it as user-defined).

The problem here is that to create good warnings we have to have a good baseline union profile. Meaning we need to be judicious about how we make the profile. But since we could get it wrong, I created an informal mechanism for including things into the union profile. We use all the profiles in the "profile directory" and nothing else:

https://github.com/PowerShell/PSScriptAnalyzer/blob/df566b577803375cd6f1faba7d9d5d8715deefab/PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Utility/CompatibilityProfileLoader.cs#L76

This means that:

  • Including only one target, you still get good warnings, because it's compared against all the other profiles we ship by default
  • Using a target not in the profile directory, that won't be included in the union comparison
  • You can configure a different profile directory to get rid of comparisons to PowerShells you don't care about

This works but it's a bit subtle. I think we should move to:

  • All targets are in the union by default
  • Targets in the profile directory are in the union by default
  • Targets can be excluded from the union in a configuration setting, by name or path
  • The profile directory automatic union inclusion can be turned off by default

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit CompatibilityProfileLoader.cs, insbesondere mit der im Issue verknüpften Logik zum Laden des Profilverzeichnisses, und verfolge, wie UseCompatibleCommands und UseCompatibleTypes das Union-Profil aufbauen. Definiere das Konfigurations- und Ausschlussverhalten für benannte oder pfadbasierte Ziele sowie für die Deaktivierung der automatischen Einbeziehung des Profilverzeichnisses. Als erledigt gilt die Aufgabe, wenn standardmäßig alle Ziele einbezogen werden und konfigurierte Ausschlüsse sowie die Opt-out-Einstellung berücksichtigt werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, powershell
Bereich
devtools, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.