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 backwards compatibility to net framework 4.8 #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/Algorithm/Algorithm.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Provide algorithms.</Description>
<PackageTags>$(PackageTags);algo;algorithm</PackageTags>
<Version>2.0.0</Version>
<Version>2.1.0-beta2</Version>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
Copy link
Owner

Choose a reason for hiding this comment

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

prefer netstandard2.0 over net48

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/DependencyInjection.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Provides some dependency injection extensions</Description>
<PackageTags>$(PackageTags);ioc;di;injection</PackageTags>
<Version>2.0.0</Version>
<Version>2.1.0-beta2</Version>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 7 additions & 2 deletions src/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ public static Dictionary<TKey, TValue> Apply<TKey, TValue>(
this Dictionary<TKey, TValue> source,
Dictionary<TKey, TValue> other)
{
foreach (var (key, value) in other)
source[key] = value;
#if (NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER)
foreach (var (key, value) in other)
source[key] = value;
#else
foreach (var data in other)
source[data.Key] = data.Value;
#endif

return source;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Provides some extensions</Description>
<PackageTags>$(PackageTags);extensions</PackageTags>
<Version>2.0.0</Version>
<Version>2.1.0-beta2</Version>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ public static void RunStaticConstructor(this Type type)
public static string AsFirstName(this Type type)
{
var name = type.Name;
if (type.IsGenericType)
name = name[..name.IndexOf('`')];
if (type.IsGenericType)
{
#if (NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER)
name = name[..name.IndexOf('`')];
#else
name = name.Substring(0, name.IndexOf('`'));
#endif
}

return name;
}
Expand Down
Loading