Those are from Application Insights Version=2.6.4.0
Here is an interface :
public interface ISupportSampling
{
double? SamplingPercentage { get; set; }
}
And here is what I can see from VS a class that is supposed to implement the interface.
#region Assembly Microsoft.ApplicationInsights, Version=2.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// nsame namespace as the above interface
public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics
{
public EventTelemetry();
public EventTelemetry(string name);
public DateTimeOffset Timestamp { get; set; }
public string Sequence { get; set; }
public TelemetryContext Context { get; }
public string Name { get; set; }
public IDictionary<string, double> Metrics { get; }
public IDictionary<string, string> Properties { get; }
public ITelemetry DeepClone();
}
You can see that the only property from the interface is not in the list of public properties.
So, it means that, when coding, 2 things happen that are not desirable :
1)
This code
EventTelemetry eventTelemetry;
// ...
eventTelemetry.SamplingPercentage = 100;
Causes the following compilation error :
'EventTelemetry' does not contain a definition for 'SamplingPercentage' and no accessible extension method 'SamplingPercentage' accepting a first argument of type 'EventTelemetry' could be found (are you missing a using directive or an assembly reference?`
2)
Also, the SamplingPercentage
property will not show up in autocomplete.
Why ? Am I being lied to by VS on what I see from the class ? (that SamplingPercentage is indeed present and public, but for some reasons not shown to me ?)
My current workaround (and also given in the last snippet in this doc from Microsoft here ) is to cast as this :
((ISupportSampling) eventTelemetry).SamplingPercentage = 100;
Is there a more "developper friendly" way, without using explicit cast ? (using Visual Studio 2017)