I encountered this confusing names-resolution problem while trying to convert legacy solution with .NET 4.6.1 projects to the new SDK-style project formats. I was able to create a minimal repro solution LegacyVsSdkStyleProjectNameResolution
, which is on GitHub here:
https://github.com/PaloMraz/LegacyVsSdkStyleProjectNameResolution.git
The solution contains:
- 3 legacy projects targeting .NET Framework 4.6.1 residing in the „Legacy“ solution folder; the project names start with „Legacy.“).
- 3 SDK-style projects targeting .NET residing in the „Sdk“ solution folder; the project names start with „Sdk.“.
(Please forgive me the non-intuitive assembly / namespace / class names – I could not use the original names and was not able to devise something more feasible).
The dependencies are shown in this image:
The problem is, the Legacy.Common.Configuration
project successfuly compiles with this Bundle
class declaration:
using Legacy.Common.Data;
namespace Legacy.Common.Configuration
{
public class Bundle
{
public Person Person { get; set; }
}
}
But the Sdk.Common.Configuration
produces compilation error CS0118
('Person' is a namespace but is used like a type):
using Sdk.Common.Data;
namespace Sdk.Common.Configuration
{
public class Bundle
{
public Person Person { get; set; }
}
}
Can anybody please explain, why the C# compiler in the Sdk.Common.Configuration
project resolves the Person
type symbol incorrectly to namespace Sdk.Common.Person
, but in the Legacy.Common.Configuration
it resolves it correctly to Legacy.Common.Data.Person
class?