Skip to content

Commit

Permalink
2️⃣ Add netstandard2.0 support (#87)
Browse files Browse the repository at this point in the history
* 2️⃣ Add netstandard2.0 support

* 🧪 Run tests on netcore as well
  • Loading branch information
heytherewill authored Mar 29, 2023
1 parent 56d1ea2 commit b6ebcf2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>10</LangVersion>
</PropertyGroup>
Expand All @@ -28,6 +28,13 @@

<ItemGroup>
<Compile Remove="goldens/*.cs" />
<Compile Remove="ModuleInitializer.cs" />
</ItemGroup>

<!-- Hacks to make netstandard more usable -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<!-- Needed to make module initializers work -->
<Compile Include="ModuleInitializer.cs" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions Bearded.FluentSourceGen.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;

namespace System.Runtime.CompilerServices
{
// HACK: Needed to make ModuleInitializer work
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class ModuleInitializerAttribute : Attribute { }
}
15 changes: 13 additions & 2 deletions Bearded.FluentSourceGen/Bearded.FluentSourceGen.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<LangVersion>10</LangVersion>
</PropertyGroup>

<ItemGroup>
<Compile Remove="IsExternalInit.cs" />
</ItemGroup>

<!-- Hacks to make netstandard more usable -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- Needed to make indexes work -->
<PackageReference Include="IndexRange" Version="1.0.2" />
<!-- Needed to make C#9 features work -->
<Compile Include="IsExternalInit.cs" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions Bearded.FluentSourceGen/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace System.Runtime.CompilerServices
{
// HACK: This is needed in order to use C#9+ features in netstandard
public class IsExternalInit { }
}

0 comments on commit b6ebcf2

Please sign in to comment.