Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Target Framework netstandard2.0 #2

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Markdig.Renderers.Docx/DocxDocumentRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void ForceCloseParagraph()
}
}

public override DocxDocumentRenderer Render(MarkdownObject markdownObject)
public override object Render(MarkdownObject markdownObject)
Copy link
Contributor Author

@marknn3 marknn3 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the return type to object for compatibility with .NET Framework and .NET Standard 2.0:
Error CS8830 '...runtime doesn't support covariant return types in overrides. Return type must be 'object' to match overridden member 'RendererBase.Render(MarkdownObject)'

{
if (markdownObject is MarkdownDocument)
{
Expand Down
9 changes: 5 additions & 4 deletions src/Markdig.Renderers.Docx/Markdig.Renderers.Docx.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -20,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
<PackageReference Include="Markdig" Version="0.27.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" />
<PackageReference Include="Markdig" Version="0.33.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

Expand Down
34 changes: 34 additions & 0 deletions src/Markdig.Renderers.Docx/Polyfills/NetStandard20Polyfills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Markdig.Renderers.Docx;

internal static class NetStandard20Polyfills
{
public static TValue GetValueOrDefault<TKey, TValue>(
this IReadOnlyDictionary<TKey, TValue> target,
TKey key,
TValue defaultValue = default!)
{
if (target.TryGetValue(key, out var result))
{
return result!;
}

return defaultValue;
}

public static bool TryPeek<T>(this Stack<T> stack, out T result)
{
if (stack.Count == 0)
{
result = default!;
return false;
}

result = stack.Peek();
return true;
}

public static string[] Split(this string str, string separator, StringSplitOptions options = StringSplitOptions.None)
{
return str.Split(separator.ToCharArray(), options);
}
}
Loading