PowerShell / PowerShell/PSScriptAnalyzer

Revise semantics of compatibility rule profile inclusion

Aperta
#1,224 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Configuration Area - Engine Consider - 2.0 Issue - Enhancement
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da CompatibilityProfileLoader.cs, in particolare dalla logica di caricamento della directory dei profili collegata nell’issue, e traccia come UseCompatibleCommands e UseCompatibleTypes costruiscono il profilo unione. Definisci il comportamento di configurazione ed esclusione per le destinazioni denominate o basate su percorsi e per la disabilitazione dell’inclusione automatica della directory dei profili. Il lavoro è completato quando tutte le destinazioni sono incluse per impostazione predefinita e vengono rispettate le esclusioni configurate e l’impostazione di opt-out.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, powershell
Ambito
devtools, tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.