Skip to content

Logic bug within Initialize(..,..) in TelemetryContext : null-conditional operator comparison is always null #692

@DanSmith

Description

@DanSmith

Hi,

I have set several default properties on a TelemetryClient's Context and they seem to not be copied over to custom events and exceptions.

I think the issue started when the Initialize method in TelemetryContext was updated here in this commit:

e0208cd#diff-3d363b608e70a044e45f704453bce8de

If the private context fields of the new TelemetryContext are null, the ? operator will always fail to call the copy from the source.

This logic was previously reversed prior to the mentioned commit where the call would copy the source if the source wasn't null, which use to work as expected.

Repro Steps

  1. Set client.Context.Component.Version = "some version"
  2. Create a new EventTelemetry and call TrackEvent on the client

Actual Behavior

Component.Version, ai.application.ver, isn't set, serialized, or reported to the endpoint.

Expected Behavior

ai.application.ver is included in the tags in the json serialization

Version Info

SDK Version : dotnet:2.5.0-55494
.NET Version : 4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions