@@ -11,8 +11,7 @@ Plan to implement: Yes
11
11
12
12
# \# Requires Additions
13
13
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:
16
15
17
16
* ` -Version <N>[.<n>] ` , where a minimum PowerShell version can be specified
18
17
* ` -PSSnapin <PSSnapin-Name> [-Version <N><n>] ` , where a required PowerShell Snapin can be specified
@@ -44,35 +43,12 @@ This RFC proposes the following changes:
44
43
version can be specified as required. See [ this PowerShell issue] ( https://github.com/PowerShell/PowerShell/issues/2846 ) .
45
44
* ` -MinimumPSVersion ` as an alias of ` -MinimumVersion ` .
46
45
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
-
65
46
## Motivation
66
47
67
48
> As a PowerShell user, I will be warned about
68
49
> ` #requires ` statements that won't behave the
69
50
> way I might expect based on position.
70
51
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
-
76
52
> As a PowerShell user, I can specify that my script
77
53
> ` #requires ` being run on a specific operating system,
78
54
> so that I can effectively, efficiently and declaratively
@@ -122,8 +98,6 @@ PowerShell issue](https://github.com/PowerShell/PowerShell/issues/4549).
122
98
123
99
## Alternate Proposals and Considerations
124
100
125
- * ** Withdrawn** . ~~ An ` -Assembly ` parameter may be unneccessary, given the
126
- possibility of using ` using assembly <Assembly-name> ` .~~
127
101
* Given the suite of proposed changes to ` #requires ` , any
128
102
other proposed parameters for ` #requires ` are worth
129
103
including and discussing in this RFC. Possible
@@ -139,3 +113,23 @@ PowerShell issue](https://github.com/PowerShell/PowerShell/issues/4549).
139
113
currently [ undocumented] ( https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-6 ) and
140
114
there is an [ open issue for it] ( https://github.com/PowerShell/PowerShell/issues/5908 ) . It may
141
115
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