Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

visual studio code - Powershell intellisense when importing modules

At work we're developing a PowerShell solution using VSCode, the PowerShell extension and PSScriptAnalyzer. Our files are defined as .psm1 files containging classes, and use using module to import other .psm1 files using relative paths.

The problem is, that using module doesn't seem to support intellisense, i.e. is not statically analyzable by the PowerShell parser: This can also be due the type not being known at parse time due to types imported by 'using' statements. PSScriptAnalyzer(TypeNotFound)

I'm wondering if there is a way to import other modules using relative paths while still supporting intellisense.

Ideally this would happen in the .psm1 files themselves to reduce setup time for new developers, but I'm ok with additional setup steps, i.e. adding them to $env:PSModulePath.

This is how the files are structured right now:

# ./BaseClass.psm1
class BaseClass {
  # ...
}

# ./SomeClass.psm1
using module .BaseClass.psm1

class SomeClass : BaseClass {
  # ...
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...