Remove IMeter from Metering source-gen (#4112)

Co-authored-by: Nikita Balabaev <nbalabaev@microsoft.com>
This commit is contained in:
Nikita Balabaev 2023-06-26 10:32:15 +02:00 коммит произвёл GitHub
Родитель 04608fd766
Коммит bb9d90008f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 6 добавлений и 18 удалений

Просмотреть файл

@ -415,14 +415,6 @@ internal sealed class Parser
return (null, false);
}
// check if any of methodSymbol parameters is of IMeter type
if (symbols.IMeterInterface != null &&
methodSymbol.Parameters.Any(p => ParserUtilities.IsBaseOrIdentity(p.Type, symbols.IMeterInterface, _compilation)))
{
// The method uses old IMeter, no need to parse it
return (null, false);
}
if (instrumentKind == InstrumentKind.Gauge)
{
Diag(DiagDescriptors.ErrorGaugeNotSupported, methodSymbol.GetLocation());

Просмотреть файл

@ -13,5 +13,4 @@ internal sealed record class SymbolHolder(
INamedTypeSymbol? HistogramOfTAttribute,
INamedTypeSymbol? GaugeAttribute,
INamedTypeSymbol LongTypeSymbol,
INamedTypeSymbol? DimensionAttribute,
INamedTypeSymbol? IMeterInterface);
INamedTypeSymbol? DimensionAttribute);

Просмотреть файл

@ -14,7 +14,6 @@ internal static class SymbolLoader
internal const string HistogramAttribute = "Microsoft.Extensions.Telemetry.Metering.HistogramAttribute";
internal const string DimensionAttribute = "Microsoft.Extensions.Telemetry.Metering.DimensionAttribute";
internal const string MeterClass = "System.Diagnostics.Metrics.Meter";
private const string MeterInterface = "Microsoft.Extensions.Telemetry.Metering.IMeter";
internal static SymbolHolder? LoadSymbols(Compilation compilation)
{
@ -35,7 +34,6 @@ internal static class SymbolLoader
var gaugeAttribute = compilation.GetTypeByMetadataName(GaugeAttribute);
var dimensionAttribute = compilation.GetTypeByMetadataName(DimensionAttribute);
var longType = compilation.GetSpecialType(SpecialType.System_Int64);
var meterInterface = compilation.GetTypeByMetadataName(MeterInterface);
return new(
meterClassSymbol,
@ -45,7 +43,6 @@ internal static class SymbolLoader
histogramTAttribute,
gaugeAttribute,
longType,
dimensionAttribute,
meterInterface);
dimensionAttribute);
}
}

Просмотреть файл

@ -24,7 +24,7 @@ namespace Microsoft.Extensions.Telemetry.Metering;
/// static partial class Metric
/// {
/// [Gauge]
/// static partial MemoryUsage CreateMemoryUsage(IMeter meter);
/// static partial MemoryUsage CreateMemoryUsage(Meter meter);
/// }
/// </code>
/// </example>
@ -58,7 +58,7 @@ public sealed class GaugeAttribute : Attribute
/// static partial class Metric
/// {
/// [Gauge(Name="SampleMetric")]
/// static partial MemoryUsage CreateMemoryUsage(IMeter meter);
/// static partial MemoryUsage CreateMemoryUsage(Meter meter);
/// }
/// </code>
/// </example>

Просмотреть файл

@ -24,7 +24,7 @@ namespace Microsoft.Extensions.Telemetry.Metering;
/// static partial class Metric
/// {
/// [Histogram("RequestName", "RequestStatusCode")]
/// static partial RequestLatency CreateRequestLatency(IMeter meter);
/// static partial RequestLatency CreateRequestLatency(Meter meter);
/// }
/// </code>
/// </example>
@ -58,7 +58,7 @@ public sealed class HistogramAttribute : Attribute
/// static partial class Metric
/// {
/// [Histogram("RequestName", "RequestStatusCode", Name="SampleMetric")]
/// static partial RequestLatency CreateRequestLatency(IMeter meter);
/// static partial RequestLatency CreateRequestLatency(Meter meter);
/// }
/// </code>
/// </example>