-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-TriagedThe issue has been triaged by the designated WG.The issue has been triaged by the designated WG.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Run the following
Add-Type -TypeDefinition @'
public interface IProperty
{
static abstract int Id { get; }
}
public class CSharpProperty : IProperty
{
public static int Id { get=> 1; }
}
'@
class PwshProperty : IProperty {
static [int] $Id = 1
}Expected behavior
You can create the class then do `[PwshProperty]::Id` to return `1`.Actual behavior
ParentContainsErrorRecordException: An error occurred while creating the pipeline.Error details
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : An error occurred while creating the pipeline.
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : RuntimeException
TargetSite :
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.dll
Message : An error occurred while creating the pipeline.
InnerException :
Type : System.ArgumentException
Message : Method cannot be both static and virtual.
TargetSite : Void .ctor(System.String, System.Reflection.MethodAttributes, System.Reflection.CallingConventions, System.Type, System.Type[], System.Type[], System.Type[],
System.Type[][], System.Type[][], System.Reflection.Emit.RuntimeModuleBuilder, System.Reflection.Emit.RuntimeTypeBuilder)
Source : System.Private.CoreLib
HResult : -2147024809
StackTrace :
at System.Reflection.Emit.RuntimeMethodBuilder..ctor(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]
returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][]
parameterTypeOptionalCustomModifiers, RuntimeModuleBuilder mod, RuntimeTypeBuilder type)
at System.Reflection.Emit.RuntimeTypeBuilder.DefineMethodCore(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]
returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][]
parameterTypeOptionalCustomModifiers)
at System.Reflection.Emit.TypeBuilder.DefineMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.EmitPropertyIl(PropertyMemberAst propertyMemberAst, Type type)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineProperty(PropertyMemberAst propertyMemberAst)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineMembers()
at System.Management.Automation.Language.TypeDefiner.DefineTypes(Parser parser, Ast rootAst, TypeDefinitionAst[] typeDefinitions)
at System.Management.Automation.Language.Compiler.DefinePowerShellTypes(Ast rootForDefiningTypes, TypeDefinitionAst[] typeAsts)
at System.Management.Automation.Language.Compiler.GenerateTypesAndUsings(ScriptBlockAst rootForDefiningTypesAndUsings, List`1 exprs)
at System.Management.Automation.Language.Compiler.CompileSingleLambda(ReadOnlyCollection`1 statements, ReadOnlyCollection`1 traps, String funcName, IScriptExtent entryExtent,
IScriptExtent exitExtent, ScriptBlockAst rootForDefiningTypesAndUsings)
at System.Management.Automation.Language.Compiler.CompileNamedBlock(NamedBlockAst namedBlockAst, String funcName, ScriptBlockAst rootForDefiningTypes)
at System.Management.Automation.Language.Compiler.VisitScriptBlock(ScriptBlockAst scriptBlockAst)
at System.Management.Automation.Language.Compiler.Compile(CompiledScriptBlockData scriptBlock, Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.ReallyCompile(Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.CompileUnoptimized()
at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized)
at System.Management.Automation.DlrScriptCommandProcessor.Init()
at System.Management.Automation.DlrScriptCommandProcessor..ctor(ScriptBlock scriptBlock, ExecutionContext context, Boolean useNewScope, CommandOrigin origin,
SessionStateInternal sessionState, Object dollarUnderbar)
at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, Boolean addToHistory, CommandOrigin origin)
at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
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.0Visuals
No response
mklement0 and mattcargile
Metadata
Metadata
Assignees
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-TriagedThe issue has been triaged by the designated WG.The issue has been triaged by the designated WG.