Skip to content

TypeNotFound when using classes #1064

Closed
@abelal83

Description

@abelal83

Steps to reproduce

class SecretComparer : System.Collections.IComparer {
    
    [int] $ChangeInDays = 7

    [bool] ShouldChangeSecret() {

        #throw "method not implemented"
        return $true
    }

    # this will compare if the secret is same
    [int] Compare([object] $obja, [object] $objb) {

        throw "method not implemented"
    }

}
using module .\Clarksons.Scripts.PlatformEngineering.DevsKeyVault.SecretComparer.psm1

class KeyVault {
    
    [string] $KeyVaultName

    KeyVault([string] $KeyVaultName, [SecretComparer] $comparer) {
    
        write-host $comparer
    }

}

$t = [SecretComparer]::new()
$x = [KeyVault]::new('gfdgfd', $t)

Expected behavior

This message should not appear as I'm loading classes into the sessions

Actual behavior

image

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14393.693
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.693
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions