You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add-Type-TypeDefinition @'public interface IMethod{ static abstract int GetId();}public class CSharpMethod : IMethod{ public static int GetId() => 1;}'@classPwshMethod : IMethod {
static [int] GetId() { return1 }
}
Expected behavior
Class is created and you can do `[PwshMethod]::GetId()` to return `1`.
Actual behavior
ParserError:Line | 1 | class PwshMethod : IMethod { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Error during creation of type "PwshMethod". Error message: Virtual static method 'GetId' is not implemented on type 'PwshMethod' from assembly 'PowerShell Class Assembly, | Version=1.0.0.1, Culture=neutral, PublicKeyToken=null'.
Error details
Type : System.Management.Automation.ParseExceptionErrors : Extent : class PwshMethod : IMethod { static [int] GetId() { return 1 } } ErrorId : TypeCreationError Message : Error during creation of type "PwshMethod". Error message: Virtual static method 'GetId' is not implemented on type 'PwshMethod' from assembly 'PowerShell Class Assembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null'.Message : At line:1 char:1 + class PwshMethod : IMethod { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error during creation of type "PwshMethod". Error message: Virtual static method 'GetId' is not implemented on type 'PwshMethod' from assembly 'PowerShell Class Assembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null'.ErrorRecord : Exception : Type : System.Management.Automation.ParentContainsErrorRecordException Message : At line:1 char:1 + class PwshMethod : IMethod { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error during creation of type "PwshMethod". Error message: Virtual static method 'GetId' is not implemented on type 'PwshMethod' from assembly 'PowerShell Class Assembly, Version=1.0.0.1, Culture=neutral,PublicKeyToken=null'. HResult : -2146233087 CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : TypeCreationError InvocationInfo : ScriptLineNumber : 1 OffsetInLine : 1 HistoryId : -1 Line : class PwshMethod : IMethod { Statement : class PwshMethod : IMethod { static [int] GetId() { return 1 } } PositionMessage : At line:1 char:1 + class PwshMethod : IMethod { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CommandOrigin : InternalTargetSite : Name : Invoke DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.4.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 MemberType : Method Module : System.Management.Automation.dllSource : System.Management.AutomationHResult : -2146233087StackTrace : at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)
Environment data
Name Value
---------
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Arch Linux
Platform Unix
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
Expected behavior
Class is created and you can do `[PwshMethod]::GetId()` to return `1`.Actual behavior
Error details
Environment data
Visuals
No response