Where are the using statements/directives in .NET 6

C# 10.0 introduces a new feature called global using directive (global using <fully-qualified-namespace>;) which allows to specify namespaces to be implicitly imported in all files in the compilation. .NET 6 RC1 has this feature enabled by default in new project templates (see <ImplicitUsings>enable</ImplicitUsings> property in your .csproj). For Microsoft.NET.Sdk.Web next namespaces should be implicitly imported … Read more

How do I target attributes for a record class?

To target the various parts of the expanded class, use the appropriate attribute target. For instance: // Target the property, use `property` record Person(string FirstName, string LastName, [property: JsonIgnore] int Age); // Target the backing field of the property, use `field` record Person(string FirstName, string LastName, [field: JsonIgnore] int Age); // Target the constructor parameter, … Read more