Skip to content
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

PS Class type not found error with using module #2887

Open
ThomasNieto opened this issue Aug 12, 2020 · 10 comments
Open

PS Class type not found error with using module #2887

ThomasNieto opened this issue Aug 12, 2020 · 10 comments
Labels
Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.

Comments

@ThomasNieto
Copy link

System Details

System Details Output

### VSCode version: 1.47.3 91899dcef7b8110878ea59626991a18c8a6a1b3e x64

### VSCode extensions:
Damien.autoit@1.0.5
DavidAnson.vscode-markdownlint@0.36.2
eamodio.gitlens@10.2.2
fernandoescolar.vscode-solution-explorer@0.3.10
GrapeCity.gc-excelviewer@3.0.39
jmrog.vscode-nuget-package-manager@1.1.6
mechatroner.rainbow-csv@1.7.1
mhutchie.git-graph@1.25.0
ms-dotnettools.csharp@1.22.1
ms-mssql.mssql@1.9.0
ms-python.python@2020.7.96456
ms-vscode-remote.remote-wsl@0.44.4
ms-vscode.cpptools@0.29.0
ms-vscode.powershell@2020.6.0
ms-vscode.powershell-preview@2020.7.0
redhat.vscode-xml@0.13.0
streetsidesoftware.code-spell-checker@1.9.0
zhuangtongfa.material-theme@3.8.5


### 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

Issue Description

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.

Expected Behaviour

Open a class file with types residing in a module and no type not found error is thrown.

Actual Behaviour

Type not found until manually running using statements in integrated console.

Attached Logs

Follow the instructions in the troubleshooting docs
about capturing and sending logs.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 12, 2020
@SeeminglyScience
Copy link
Collaborator

@ThomasNieto can you provide an example?

using module statements are notoriously finicky when it comes to static analysis.

@ThomasNieto
Copy link
Author

ThomasNieto commented Aug 12, 2020

@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:

  1. In integrated console run: using module Test
  2. Cut and paste either using statement.
  3. Animal type no longer has the error

This 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
{

}

@SeeminglyScience
Copy link
Collaborator

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)

@ThomasNieto
Copy link
Author

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?

@SeeminglyScience
Copy link
Collaborator

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.

@ThomasNieto
Copy link
Author

Yeah, any edit seems to do.

@SydneyhSmith SydneyhSmith added Bug: PowerShell Core Bugs when using PowerShell Core. Resolution-External Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Aug 13, 2020
@SydneyhSmith
Copy link
Collaborator

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

@ghost ghost closed this as completed Aug 13, 2020
@JustinGrote
Copy link
Collaborator

@andschwa @SeeminglyScience there currently is a situation where we get both the "unable to find type" and the PSScriptAnalyzer "Ignoring TypeNotFound" info. Maybe if we detect both of these we can silently suppress the error Problem and only present the information warning?

image

If so it may be worth reopening this issue to address.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 30, 2021
@ghost
Copy link

ghost commented Nov 30, 2021

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@andyleejordan
Copy link
Member

Just FYI @JustinGrote I'm adding you to the bot's ignore list for it's auto responder lol. Setting it to exclude "collaborators" and up now.

To the issue at hand, I'm not sure! But I can reopen for us to look at again.

@andyleejordan andyleejordan reopened this Dec 9, 2021
@andyleejordan andyleejordan added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! and removed Needs: Maintainer Attention Maintainer attention needed! Resolution-External Will close automatically. Bug: PowerShell Core Bugs when using PowerShell Core. labels Dec 9, 2021
@StevenBucher98 StevenBucher98 added Up for Grabs Will shepherd PRs. and removed Needs: Triage Maintainer attention needed! labels Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

6 participants