How to find candidates for implicit usings in C#

Implicit using is a feature which comes with C# 10. The question is how to find candidates for implicit usings in some C# project. For this task following PowerShell snippet can be used:

Get-ChildItem *.cs -Exclude *assembly* -Recurse `
 | Get-Content `
 | Select-String using `
 | Group-Object `
 | Sort-Object -Property Count -Descending

After running this command in folder with some C# files you can discover repeating usings, for example that in unit tests are repeating using of FluentAssertions and Xunit which can be added into .csproj file as implicit usings:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <Using Include="FluentAssertions" />
    <Using Include="Xunit" />
  </ItemGroup>  
</Project>

What is new in C# 6

My first Udemy course https://www.udemy.com/what-is-new-in-csharp-6 covers new features of C# 6. Taking this course you learn:

  • Auto-property initializers
  • Getter-only auto-properties
  • Expression-bodied members
  • Using static
  • Null-conditional operators
  • String interpolation
  • nameof expressions
  • Index initializers
  • Exception filters
  • Await in catch and finally blocks