From d2888cdf941bd331891d9f39cd9889a675b69368 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Tue, 21 Nov 2023 20:08:09 +0300 Subject: [PATCH] Ignore type warning in IotHubEventSerializer --- .../IotHub/IotHubEventSerializer.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Tingle.EventBus.Transports.Azure.EventHubs/IotHub/IotHubEventSerializer.cs b/src/Tingle.EventBus.Transports.Azure.EventHubs/IotHub/IotHubEventSerializer.cs index 0dcd8058..ea72b65d 100644 --- a/src/Tingle.EventBus.Transports.Azure.EventHubs/IotHub/IotHubEventSerializer.cs +++ b/src/Tingle.EventBus.Transports.Azure.EventHubs/IotHub/IotHubEventSerializer.cs @@ -40,9 +40,6 @@ public IotHubEventSerializer(IOptionsMonitor optio if (source == IotHubEventMessageSource.Telemetry) { telemetry = await JsonNode.ParseAsync(utf8Json: stream, cancellationToken: cancellationToken).ConfigureAwait(false); - - //var @event = new IotHubEvent { Source = source, Telemetry = telemetry, }; - //return new EventEnvelope { Event = @event, }; } else if (source is IotHubEventMessageSource.TwinChangeEvents or IotHubEventMessageSource.DeviceLifecycleEvents @@ -67,11 +64,11 @@ or IotHubEventMessageSource.DeviceLifecycleEvents OperationTimestamp = operationTimestamp, Payload = payload, }; - - //var @event = new IotHubEvent { Source = source, Event = opevent, }; } +#pragma warning disable IL2087 var @event = (T?)Activator.CreateInstance(targetType); +#pragma warning restore IL2087 var ihe = @event as IotHubEvent ?? throw new InvalidOperationException($"The event of type '{targetType.FullName}' could not be cast to '{BaseType.FullName}'."); ihe.Source = source; ihe.Telemetry = telemetry;