With C# 12, it's possible to alias any type. A project that has ImplicitUsings, it works using GlobalUsings.cs. Switching from GlobalUsings.cs to Directory.Build.props breaks compilation.
I've run into a situation where a named tuple alias with a nullable doesn't work, but a collection with elements of an identical named tuple does.
Steps to Reproduce
// GlobalUsings.cs
global using NamedTuple = (bool isUsed, string value);
global using NamedTupleList = System.Collections.Generic.List<(bool isUsed, string value)>;
// Anywhere in the project
NamedTuple nt; // compiles
NamedTupleList ntl; // compiles
When attempting to use these aliases in all projects under solution using .csproj's Using element, NamedTuple doesn't work while NamedTupleList works.
The repro (link) is attempting to achieve this by defining the aliases in the Directory.Build.props file instead of GlobalUsing.cs in the following way.
Issue Description
With C# 12, it's possible to alias any type. A project that has
ImplicitUsings
, it works usingGlobalUsings.cs
. Switching fromGlobalUsings.cs
toDirectory.Build.props
breaks compilation.I've run into a situation where a named tuple alias with a nullable doesn't work, but a collection with elements of an identical named tuple does.
Steps to Reproduce
When attempting to use these aliases in all projects under solution using
.csproj
'sUsing
element,NamedTuple
doesn't work whileNamedTupleList
works.The repro (link) is attempting to achieve this by defining the aliases in the
Directory.Build.props
file instead ofGlobalUsing.cs
in the following way.With this change, the code fails.
Expected Behavior
NamedTuple
andNamedTupleList
types should be available and compilable.Actual Behavior
NamedTupleList
isn't available/compilable.Analysis
No response
Versions & Configurations
MSBuild version 17.10.4+10fbfbf2e .NET 8.0.300 OS Windows 10 Pro 22H2