Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Mar 13, 2023
1 parent 2b1acbc commit 88a7a28
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
12 changes: 9 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,29 @@ A traditional nuget that ships a single assembly `Polyfill.dll`.
```cs
static bool InitCalled;

[Fact]
[Test]
public void ModuleInitTest() =>
Assert.True(InitCalled);

[ModuleInitializer]
public static void ModuleInit() =>
InitCalled = true;
```
<sup><a href='/src/Polyfill.Source.Tests/Samples.cs#L3-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-moduleinitializerattribute' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Polyfill.Source.Tests/Samples.cs#L4-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-moduleinitializerattribute' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


### IsExternalInit

`IsExternalInit` is required to use records in older runtimes

snippet: IsExternalInit
<!-- snippet: IsExternalInit -->
<a id='snippet-isexternalinit'></a>
```cs
record MyRecord(string property);
```
<sup><a href='/src/Polyfill.Source.Tests/MyRecord.cs#L1-L5' title='Snippet source file'>snippet source</a> | <a href='#snippet-isexternalinit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


## Icon
Expand Down
9 changes: 4 additions & 5 deletions src/Polyfill.Source.Tests/Polyfill.Source.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649;CS8618;CS0105</NoWarn>
<RootNamespace>Polyfill.Source.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Polyfill.Source\*.cs" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Verify.Xunit" Version="19.11.1" />
<PackageReference Include="Xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
<PackageReference Include="Verify.NUnit" Version="19.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MarkdownSnippets.MsBuild" Version="24.5.1" />
<PackageReference Include="ProjectDefaults" Version="1.0.89" PrivateAssets="all" />
Expand Down
5 changes: 3 additions & 2 deletions src/Polyfill.Source.Tests/Samples.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
public class Samples
[TestFixture]
public class Samples
{
#region ModuleInitializerAttribute

static bool InitCalled;

[Fact]
[Test]
public void ModuleInitTest() =>
Assert.True(InitCalled);

Expand Down
7 changes: 4 additions & 3 deletions src/Polyfill.Source.Usage/Polyfill.Source.Usage.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netcoreapp3.1;netcoreapp3.0;netcoreapp2.2;netcoreapp2.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649;CS8618;CS0105</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Polyfill.Source\*.cs">
</Compile>
<Using Remove="System.Net.Http" />
<Compile Include="..\Polyfill.Source\*.cs" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions src/Polyfill.Tests/Polyfill.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649;CS8618;CS0105</NoWarn>
</PropertyGroup>
<ItemGroup>
<Using Remove="System.Net.Http" />
<Compile Include="..\Polyfill.Source.Tests\*.cs" />
<PackageReference Include="Verify.Xunit" Version="19.11.1" />
<PackageReference Include="Xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
<PackageReference Include="Verify.NUnit" Version="19.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="ProjectDefaults" Version="1.0.89" PrivateAssets="all" />
<ProjectReference Include="..\Polyfill\Polyfill.csproj" />
Expand Down
4 changes: 3 additions & 1 deletion src/Polyfill/Polyfill.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netcoreapp3.1;netcoreapp3.0;netcoreapp2.2;netcoreapp2.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649;CS8618;CS0105</NoWarn>
<DefineConstants>$(DefineConstants);PublicPolyfill</DefineConstants>
<Description>Exposes newer .net and C# features to older runtimes.</Description>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Using Remove="System.Net.Http" />
<Compile Include="..\Polyfill.Source\*.cs" />
<PackageReference Include="ProjectDefaults" Version="1.0.89" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.201",
"version": "8.0.100-preview.1.23115.2",
"allowPrerelease": true,
"rollForward": "latestFeature"
}
Expand Down

0 comments on commit 88a7a28

Please sign in to comment.