ambiguous reference: AddApplicationInsightsTelemetryProcess
Describe the bug
Simple issue, in case we have common shared project used for function and main app (support logger classes and everything is in the base), Microsoft.ApplicationInsights.WorkerService and Microsoft.ApplicationInsights.AspNetCore conflicts on extension method in namespace Microsoft.Extensions.DependencyInjection method public static IServiceCollection AddApplicationInsightsTelemetryProcessor<T>(this IServiceCollection services) where T : ITelemetryProcessor
Because you renamed AddApplicationInsightsTelemetry to AddApplicationInsightsTelemetryWorkerService, it makes sense to rename it also here.
To Reproduce
create a new .net 8 project (with latest versions of the libs) and include both these libraries Microsoft.ApplicationInsights.WorkerService Microsoft.ApplicationInsights.AspNetCore
sinple main
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using SRChatBot.Common;
namespace BotOneFunctions
{
public class Program
{
public static void Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryProcessor<ITelemetryProcessor>();
})
.Build();
host.Run();
}
}
}
line:
services.AddApplicationInsightsTelemetryProcessor<ITelemetryProcessor>();
cannot be reasonable resolved in any way or form due to identical match from two libraries extenting exact same namespace
error
CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.AddApplicationInsightsTelemetryProcessor<T>(Microsoft.Extensions.DependencyInjection.IServiceCollection)' and 'Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.AddApplicationInsightsTelemetryProcessor<T>(Microsoft.Extensions.DependencyInjection.IServiceCollection)'
ugly fix
have dummy projects having just one of these dependencies that has one single extension file wrapping this method with different name.
eg.
using Microsoft.ApplicationInsights.Extensibility;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ApplicationInsightsExtensions
{
public static IServiceCollection AddApplicationInsightsTelemetryWorkerServiceProcessor<T>(this IServiceCollection services) where T : ITelemetryProcessor
{
return services.AddApplicationInsightsTelemetryProcessor<T>();
}
}
}
having both AddApplicationInsightsTelemetryWorkerServiceProcessor and AddApplicationInsightsTelemetryProcessor in Microsoft.ApplicationInsights.WorkerService would allow backward compatibility as well, as the base project just needs to have basic Insights, Worker Insights are usually needed only in the function project.
we can live with the ugly fix, just wanted to report it. If it is not worth changing, I will understand