Azure / Azure/azure-functions-openapi-extension

Unexpected build warning CS0436

Open
#552 6 comments 12 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

**Describe the issue**
Unexpected build warning (CS0436) when using Microsoft.Azure.Functions.Worker.Sdk and project reference in combination with InternalsVisibleToAttribute.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a new console app project (ConsoleApp1)
2. Create a new unit test project (TestProject1)
3. Add a project reference from TestProject1 to ConsoleApp1
4. Add [assembly: InternalsVisibleTo("TestProject1")] to Program.cs
5. Add NuGet package Microsoft.Azure.Functions.Worker.Sdk 1.7.0 to ConsoleApp1
6. Add NuGet package Microsoft.Azure.Functions.Worker.Extensions.OpenApi 1.5.1 to ConsoleApp1
7. Rebuild -> Build warning CS0436

**Expected behavior**
No warning on build.

**Environment**
- TargetFramework: net6.0

**Additional context**
The problem is that two identical classes (one per project) are generated by Microsoft.Azure.Functions.Worker.Sdk.Generator, WorkerExtensionStartupCodeExecutor.g.cs.

```c#
//
using System;
using Microsoft.Azure.Functions.Worker.Core;
[assembly: WorkerExtensionStartupCodeExecutorInfo(typeof(Microsoft.Azure.Functions.Worker.WorkerExtensionStartupCodeExecutor))]
namespace Microsoft.Azure.Functions.Worker
{
internal class WorkerExtensionStartupCodeExecutor : WorkerExtensionStartup
{
public override void Configure(IFunctionsWorkerApplicationBuilder applicationBuilder)
{
try
{
new Microsoft.Azure.Functions.Worker.Extensions.OpenApi.OpenApiWorkerStartup().Configure(applicationBuilder);
}
catch (Exception ex)
{
Console.Error.WriteLine("Error calling Configure on Microsoft.Azure.Functions.Worker.Extensions.OpenApi.OpenApiWorkerStartup instance."+ex.ToString());
}
}
}
}
```

Warning message: _Warning CS0436 The type 'WorkerExtensionStartupCodeExecutor' in 'Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.ExtensionStartupRunnerGenerator\WorkerExtensionStartupCodeExecutor.g.cs' conflicts with the imported type 'WorkerExtensionStartupCodeExecutor' in 'ConsoleApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.ExtensionStartupRunnerGenerator\WorkerExtensionStartupCodeExecutor.g.cs'. TestProject1 \FunctionApp1\TestProject1\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.ExtensionStartupRunnerGenerator\WorkerExtensionStartupCodeExecutor.g.cs_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.