PowerShell / EditorSyntax

PowerShell syntax highlighting for editors (VS Code, Atom, SublimeText, TextMate, etc.) and GitHub!
MIT License
133 stars 45 forks source link

Using Namespace will be shown as error #115

Closed dotChris90 closed 6 years ago

dotChris90 commented 6 years ago

Environment

Issue Description

Screenshots

image

Expected Behavior

do not Show error

omniomi commented 6 years ago

Hi there @dotChris90,

That's actually https://github.com/PowerShell/PSScriptAnalyzer that's doing the underlining not the syntax. The issue is that the using statements in PowerShell cannot have anything other than comments between them and the beginning of the file.

The using statement needs to be the first statement in the script. - About_Using

You need to move the Add-Type line below the using statements. As it stands they're invalid and being ignored.

dotChris90 commented 6 years ago

@omniomi

thanks for that. it works. I did not know Powershell was truely able to using a Namespace before the DLL was loaded into the scope of it. ;)

Thanks you a lot. Wish you a nice Weekend.

vors commented 6 years ago

I think you need just replace add-type by using assembly to bring it into the session.

dotChris90 commented 6 years ago

thanks for advice but the Add-Type works fine. Just the red lines was weird to me because I though powershell just can using namespaces of imported DLLs but .... nope. You can put the add-type at the end and all is fine. ^^