@@ -11,8 +11,7 @@ Plan to implement: Yes
1111
1212# \# Requires Additions
1313
14- Currently, PowerShell's ` #requires ` statement (or perhaps
15- pragma?) supports the following parameters:
14+ Currently, PowerShell's ` #requires ` statement (or pragma) supports the following parameters:
1615
1716* ` -Version <N>[.<n>] ` , where a minimum PowerShell version can be specified
1817* ` -PSSnapin <PSSnapin-Name> [-Version <N><n>] ` , where a required PowerShell Snapin can be specified
@@ -44,35 +43,12 @@ This RFC proposes the following changes:
4443 version can be specified as required. See [ this PowerShell issue] ( https://github.com/PowerShell/PowerShell/issues/2846 ) .
4544 * ` -MinimumPSVersion ` as an alias of ` -MinimumVersion ` .
4645
47- * ** Withdrawn** , in favor of ` using ` statements.
48- ~~ ` -Assembly <Assembly-name> ` , where a .NET assembly can
49- be specified as required. See [ this PowerShell issue] ( https://github.com/PowerShell/PowerShell/issues/5022 ) .~~
50- * ** Withdrawn** on the basis that this could break many existing scripts.
51- ~~ Only allow ` #requires ` at the top level of a script,
52- before any lines that are not comments (i.e. with the
53- intention that a hashbang can still work, just before
54- any executable PowerShell code). Placing ` #requires ` anywhere
55- after will cause a parse-time error. This would be a ** breaking
56- change** , albeit one that the documentation already claims to be
57- in force.~~
58- * ** Withdrawn** since this is difficult to implement with little gain
59- and it breaks the layering of the parser.
60- ~~ Using ` #requires ` in the interactive console will cause
61- a parse-time error. This could be a ** minor breaking
62- change** , since currently PowerShell throws a [ pipeline
63- creation error] ( https://github.com/PowerShell/PowerShell/issues/3803 ) .~~
64-
6546## Motivation
6647
6748> As a PowerShell user, I will be warned about
6849> ` #requires ` statements that won't behave the
6950> way I might expect based on position.
7051
71- > As a PowerShell user, I get feedback that ` #requires `
72- > statements cannot be used in the interactive console,
73- > so that it's clear that they have no effect on an
74- > interactive session.
75-
7652> As a PowerShell user, I can specify that my script
7753> ` #requires ` being run on a specific operating system,
7854> so that I can effectively, efficiently and declaratively
@@ -122,8 +98,6 @@ PowerShell issue](https://github.com/PowerShell/PowerShell/issues/4549).
12298
12399## Alternate Proposals and Considerations
124100
125- * ** Withdrawn** . ~~ An ` -Assembly ` parameter may be unneccessary, given the
126- possibility of using ` using assembly <Assembly-name> ` .~~
127101* Given the suite of proposed changes to ` #requires ` , any
128102 other proposed parameters for ` #requires ` are worth
129103 including and discussing in this RFC. Possible
@@ -139,3 +113,23 @@ PowerShell issue](https://github.com/PowerShell/PowerShell/issues/4549).
139113 currently [ undocumented] ( https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-6 ) and
140114 there is an [ open issue for it] ( https://github.com/PowerShell/PowerShell/issues/5908 ) . It may
141115 be worth discussing in this RFC.
116+
117+ ### Withdrawn proposals
118+
119+ * ` -Assembly <Assembly-name> ` , where a .NET assembly can
120+ be specified as required. See [ this PowerShell #5022 ] ( https://github.com/PowerShell/PowerShell/issues/5022 ) .
121+ ** Withdrawn in favor of ` using ` statements.**
122+ * Only allow ` #requires ` at the top level of a script,
123+ before any lines that are not comments (i.e. with the
124+ intention that a hashbang can still work, just before
125+ any executable PowerShell code). Placing ` #requires ` anywhere
126+ after will cause a parse-time error. This would be a ** breaking
127+ change** , albeit one that the documentation already claims to be
128+ in force.
129+ ** Withdrawn on the basis that this could break many existing scripts.**
130+ Instead, a warning is proposed.
131+ * Using ` #requires ` in the interactive console will cause
132+ a parse-time error. This could be a ** minor breaking
133+ change** , since currently PowerShell throws a [ pipeline
134+ creation error] ( https://github.com/PowerShell/PowerShell/issues/3803 ) .
135+ ** Withdrawn since this is difficult to implement with little gain and breaks the layering of the parser.**
0 commit comments