-
Notifications
You must be signed in to change notification settings - Fork 510
Go To Definition/Find All References with Set-Variable #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We'll look into it! |
This is tricky because Plus there are other ways for variable creation e.g.: |
Yep, Keith's right, it's difficult to make this work 100% (or even 50% for that matter). I think the expectation should be that "obvious cases" like |
Don’t forget |
As a workaround for the case of constants, I'm defining normal variables at first and use $CONST_FOO = 42; Set-Variable CONST_FOO -Option ReadOnly
$CONST_FOO = 0
# -> WriteError: Cannot overwrite variable CONST_FOO because it is read-only or constant. Often one defines a bunch of constants in a separate module. Using a common prefix, you only need a single $CONST_FOO = 42
$CONST_BAR = 23
Set-Variable CONST_* -Option ReadOnly
Export-ModuleMember -Variable CONST_* Within a module, the A caveat is that a variable with Edit: $CONST_FOO = 42
$CONST_BAR = 23
Get-Variable CONST_* | ForEach-Object { New-Variable -Name $_.Name -Value $_.Value -Option Constant -Force } I don't see any downside of this pattern (yet). |
Please fill in these details so that we can help you!
System Details
$PSVersionTable
:PSVersion 5.0.10240.17146
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 10.0.10011.16384
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
Issue Description
Not sure how feasible this is with your plugin, but if a variable is defined using the Set-Variable cmdlet (such as how you define constants) if is not possible to use Find All References or Go To Definition command on them because they are not defined using the $ notation.
The text was updated successfully, but these errors were encountered: