System Details Output
### VSCode version: 1.47.3 91899dcef7b8110878ea59626991a18c8a6a1b3e x64
### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
### PSES version: 2.3.0.0
### PowerShell version:
Name Value
---- -----
PSVersion 7.1.0-preview.5
PSEdition Core
GitCommitId 7.1.0-preview.5
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS Class with using module statement throws type not found. If in the integrated PS console I run using module X and then remove and add back the using statements the error will away.
It looks as though VS code is not running the using statements while editing the script.
Open a class file with types residing in a module and no type not found error is thrown.
Type not found until manually running using statements in integrated console.
Follow the instructions in the troubleshooting docs
about capturing and sending logs.
@ThomasNieto can you provide an example?
using module statements are notoriously finicky when it comes to static analysis.
@SeeminglyScience Here is a way to reproduce:
I have a classtest.dll which is the RootModule in the Test module.
namespace ClassTest.Test
{
public class Animal
{
public string Name { get; set; }
}
}
The animal class will throw a type not found error. To get it to work I have to do the following:
using module TestThis workflow can be reproduced over and over by restarting the integrated console.
using module Test
using namespace ClassTest.Test
class Dog : Animal
{
}
Removing the using namespace doesn't make a difference.
using module Test
class Dog : ClassTest.Test.Animal
{
}
Yeah that's one of the situations where it doesn't work, binary modules. Here's the issue tracking it: PowerShell/PowerShell#6653 (sort of, that needs to come first but even then there's a lot of obstacles to jump from using assembly to using module for static analysis of assemblies)
I get having to run using module in the console to load the assemblies but why does it require redefining the using statements in the script?
You sure it isn't just any edit? PSSA (where those warnings come from kinda sorta) wouldn't be ran again until there's an edit of some sort.
Yeah, any edit seems to do.
There isn't much we can do in the PowerShell extension, something that would be nice to have is re-running diagnostics when a module is loaded, but PowerShell doesnt have an event for that and likely wont in the intermediate future leaving us without many options
Most helpful comment
Yeah, any edit seems to do.