Azure/azure-functions-dotnet-worker

ExtensionStartupRunnerGenerator generating code which conflicts with customer code (namespace)

kshyju opened this issue · 0 comments

Description

The ExtensionStartupRunnerGenerator source generator is generating code which conflicts with customer code.

Steps to reproduce

  1. Create a function app with a service bus trigger.
  2. Create a new class in the project with below code.
namespace TheProjectNameFromStep1.Exception
{
    internal class Foo 
    {
    }
}

Replace TheProjectNameFromStep1 with your project name.

This will cause CS0118 'Exception' is a namespace but is used like a type error because our source generator created the below code where Exception type is used in the catch block.

public override void Configure(IFunctionsWorkerApplicationBuilder applicationBuilder)
{
    try
    {
        new global::Microsoft.Azure.Functions.Worker.ServiceBusExtensionStartup().Configure(applicationBuilder);
    }
    catch (Exception ex)
    {
        // removed 
    }
}

Additionally, double-check other function source generators to see if they have the same issue.