You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The MoveUsingStatements feature doesn't work for using namespace #96
Then if we get the error because the using statement isn't the first thing in the new module, we will always(?) also get a TypeNotFound error about the Dictionary, which will prevent the using statement from being removed.
This one wasn't fixed, but I've noticed this and a few other issues.
In short, I think we should always try to move using statements if we find UsingMustBeAtStartOfScript error, because if the module is invalid, it sould be caught just after being built.
There are Parsing errors that PowerShell don't mind, and still happily build the modules.
There are other types of errors that we'll always have during parsing, like some type not found, because the type is not loaded (maybe in module manifest, or in code).
That happens as well with class attributes, like the YamlDotNet [YamlIgnore()] attribute...
All in all, now I suggest to just move the using statements anyway as soon as we find a UsingMustBeAtStartOfScript.
If anything goes wrong after that, it may or may not be our fault, but for sure if the using is not at the right place it will most likely fail.
Honestly, the reason we're checking is that if the module is busted, we don't want to make it worse (or more confusing to troubleshoot) -- but as you say, right now it means some modules won't build at all. I'll have to think about adding a -IgnoreUsingStatements switch so people can disable it if it's causing them problems.
Activity
gaelcolas commentedon Aug 13, 2020
This one wasn't fixed, but I've noticed this and a few other issues.
In short, I think we should always try to move using statements if we find
UsingMustBeAtStartOfScripterror, because if the module is invalid, it sould be caught just after being built.There are Parsing errors that PowerShell don't mind, and still happily build the modules.
There are other types of errors that we'll always have during parsing, like some type not found, because the type is not loaded (maybe in module manifest, or in code).
That happens as well with class attributes, like the YamlDotNet
[YamlIgnore()]attribute...All in all, now I suggest to just move the using statements anyway as soon as we find a
UsingMustBeAtStartOfScript.If anything goes wrong after that, it may or may not be our fault, but for sure if the using is not at the right place it will most likely fail.
What do you think?
Jaykul commentedon Aug 13, 2020
I guess I can live with that.
Honestly, the reason we're checking is that if the module is busted, we don't want to make it worse (or more confusing to troubleshoot) -- but as you say, right now it means some modules won't build at all. I'll have to think about adding a
-IgnoreUsingStatementsswitch so people can disable it if it's causing them problems.fix PoshCode#96 by moving statements even if parsing errors exists
fix PoshCode#96 by moving statements even if parsing errors exists
Fix #96 move using statements even if there are parse errors afteward
Fix #96 move using statements even if there are parse errors afteward