Skip to content

ArgumentException when calling Activity.AddException, due to in TagList tags = default parameter #26784

@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

Prerequisites

Steps to reproduce

[System.Diagnostics.Activity]::new("dummy").AddException([Exception]::new())

Expected behavior

A reference to a zero-initialized TagList is passed to Activity.AddException.

Actual behavior

OperationStopped: Type must not be ByRef (Parameter 'type')

Error details

Exception             :
    Type       : System.ArgumentException
    Message    : Type must not be ByRef (Parameter 'type')
    ParamName  : type
    TargetSite :
        Name          : Default
        DeclaringType : [System.Linq.Expressions.Expression]
        MemberType    : Method
        Module        : System.Linq.Expressions.dll
    Data       : System.Collections.ListDictionaryInternal
    Source     : System.Linq.Expressions
    HResult    : -2147024809
    StackTrace :
   at System.Linq.Expressions.Expression.Default(Type type)
   at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeMethod(MethodBase mi, DynamicMetaObject target, DynamicMetaObject[] args, Boolean expandParameters, MethodInvocationType invocationType)
   at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeDotNetMethod(CallInfo callInfo, String name, PSMethodInvocationConstraints psMethodInvocationConstraints, MethodInvocationType methodInvo
cationType, DynamicMetaObject target, DynamicMetaObject[] args, BindingRestrictions restrictions, MethodInformation[] mi, Type errorExceptionType)
   at System.Management.Automation.Language.PSInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
   at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
   at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo          : OperationStopped: (:) [], ArgumentException
FullyQualifiedErrorId : System.ArgumentException
InvocationInfo        :
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 50
    Line             : [System.Diagnostics.Activity]::new("dummy").AddException([Exception]::new())
    Statement        : [System.Diagnostics.Activity]::new("dummy").AddException([Exception]::new())
    PositionMessage  : At line:1 char:1
                       + [System.Diagnostics.Activity]::new("dummy").AddException([Exception]: …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions