I have those three files:
Glass.ps1
class Glass
{
# Properties
[int32]$Size
[int32]$CurrentAmount
# Constructors
Glass () { }
Glass ($Size, $Amount)
{
$this.Size = $Size
$this.CurrentAmount = $Amount
}
# Methods
[Boolean] Fill ([int32]$volume)
{
Write-Host "Calling PARENT class"
return $true
}
[Boolean] Drink ([int32]$amount)
{
return $true
}
}
AnyGlass.ps1
class AnyGlass : Glass
{
[String]$Name
AnyGlass () {
$this.Size = 6 # parent property
$this.CurrentAmount = 0 # parent property
$this.Name = "My glass" # child property
}
# Methods overload
[void] Fill ([int]$volume, [string]$Warning)
{
Write-Host "Calling CHILD class"
reurn $true
}
}
runIncluded.ps1
. ".\Glass.ps1"
. ".\AnyGlass.ps1"
$glass = New-Object -TypeName Glass
$anyGlass = New-Object -TypeName AnyGlass
$anyGlass.Fill(1)
If I start new PS console and run runIncluded.ps1
then the output is as expected:
PS C:\Users\wakatana\Desktop\ps\> .\runIncluded.ps1
Calling PARENT s class
True
But If I change Write-Host "Calling PARENT class"
e.g. to Write-Host "Calling PARENT class NEW VERSION"
and I run runIncluded.ps1
again (from the same PS console) then I get the same output as previous. If I restart the console then it works just OK and i get Calling PARENT class NEW VERSION
. If I put content of three mentioned file into one, then run it from console, then edit it, then run again, everything is working fine. Is it necessary to somehow reset the environment before running new scripts or what is the problem?
PS: To me this looks like broken PS, I guess this might be related to my other issue
My OS: Windows 10 Home - Latest Updates