Skip to content

Commit

Permalink
Add a polyfill to enable newer compiler features
Browse files Browse the repository at this point in the history
New versions of C# offer many features that improve quality of life:
nullable annotations, record types, init and required properties, etc.
These can be enabled in projects targeting older framework versions by
adding the right attributes and types to the compilation.

PolySharp is a source generator which automatically does this.  For each
project, it will generate all of the types/attributes which are missing.
In the case of an InternalsVisibleTo reference, it is smart enough to
only define types in the second assembly that are not being consumed
from the first assembly (avoiding duplicate type definitions).
  • Loading branch information
jimmylewis committed Jan 6, 2025
1 parent 24387cd commit 3185208
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,7 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit" Version="2.9.0" />
</ItemGroup>
</Project>
<ItemGroup>
<GlobalPackageReference Include="PolySharp" Version="1.15.0" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<clear />
<packageSource key="NuGet.org">
<package pattern="Antlr" />
<package pattern="AngleSharp.*" />
<package pattern="AngleSharp.*" />
<package pattern="AngleSharp" />
<package pattern="Autofac.*" />
<package pattern="Autofac" />
Expand Down Expand Up @@ -52,6 +52,7 @@
<package pattern="Owin" />
<package pattern="Polly.Extensions.Http" />
<package pattern="Polly" />
<package pattern="PolySharp" />
<package pattern="Portable.BouncyCastle" />
<package pattern="RazorEngine" />
<package pattern="RouteMagic" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private async Task<IReadOnlyList<WritableRepositoryInformation>> GetResultsFromG

var request = new SearchRepositoriesRequest
{
Stars = new Range(_minStars, upperStarBound),
Stars = new(_minStars, upperStarBound),
Language = Language.CSharp,
SortField = RepoSearchSort.Stars,
Order = SortDirection.Descending,
Expand Down

0 comments on commit 3185208

Please sign in to comment.