Open Stephanevg opened 4 years ago
Adding the return types (even VOID ones) actually fixes this issue:
We need to implement the same behaviour as for the [VOID] for the NotDefinedreturntypes (which is in the end [VOID]
Si this code exapmle with [VOID]
Class PCCPackage {
[String]$Name
[version]$Version
[system.io.DirectoryInfo]$Path
[String]$OS
[String]$Type
[String]$Platform
PCCPAckage(){
}
PccPAckage([String]$Path){
$P = [System.Io.DirectoryInfo]::New($Path)
If($P.Exists){
if(!($P.Name.ToString().ToUpper().StartsWith("PCC.CHK"))){
Throw "the module folder doesn't start with the required prefexi 'PCC.CHK'!"
}
$this.Path = $P
$this.Name = $p.Name.ToUpper()
$this.SetValues()
}else{
Throw "$($Path) not present"
}
}
PCCPackage([String]$Name,[String]$Path){
$this.Name = $Name
$this.Path = $Path
$This.SetValues()
}
[void]SetValues(){
$this._SetVersion()
$this._SetPlatform()
$this._SetOS()
$this._SetType()
}
Hidden [void]_SetVersion(){
try{
$ver = (Get-Module $this.Path.FullName -ListAvailable -ErrorAction Stop).Version.ToString()
}Catch{
$ver = $null
}
$this.Version = $ver
}
hidden [void] _SetPlatform(){
$p = $this.Name.Split(".")[2]
$This.Platform =$p
}
hidden [void] _SetOS(){
$this.OS = $this.Name.Split(".")[3]
}
Hidden [void] _SetType(){
$t = $this.Name.Split(".")[4]
$This.Type = $t
}
Hidden [String] GetOS(){
return $this.Os
}
[String] GetFullPath(){
REturn $this.Path.FullName
}
[version] GetVersion(){
return $this.version
}
}
Regarding this class below.
The SetVersionType (and for that matter all the void methods) still have a test to test their return type.
When a method has no return type the test to test for the type should not be generated.
See use case below.
See the _SEtVersion() test