Skip to content

Commit

Permalink
made the project compatible with netstandard2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmozibur committed Nov 4, 2024
1 parent 3be9c45 commit d02da37
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ACadSharp/ACadSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0;net7.0;net48;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net5.0;net6.0;net7.0;net48;netstandard2.0</TargetFrameworks>
<Authors>DomCr</Authors>
<PackageId>ACadSharp</PackageId>
<PackageTags>C# Dwg Dxf</PackageTags>
Expand Down Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ACadSharp/IO/DWG/DwgStreamWriters/DwgHandleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DwgHandleWriter(ACadVersion version, MemoryStream stream, Dictionary<ulon
this._handleMap.Add(item.Key, item.Value);
}
#else
this._handleMap = new Dictionary<ulong, long>(map.OrderBy(o => o.Key));
this._handleMap = new Dictionary<ulong, long>(map);
#endif
}

Expand Down
9 changes: 8 additions & 1 deletion src/ACadSharp/Objects/CadDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,14 @@ public bool ContainsKey(string key)
/// <returns>true if the element is successfully removed; otherwise, false.</returns>
public bool Remove(string key, out NonGraphicalObject item)
{
if (this._entries.Remove(key, out item))
item = default;

if (!this._entries.ContainsKey(key))
return false;

item = this._entries[key];

if (this._entries.Remove(key))
{
item.Owner = null;
OnRemove?.Invoke(this, new CollectionChangedEventArgs(item));
Expand Down
7 changes: 6 additions & 1 deletion src/ACadSharp/Tables/Collections/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public T Remove(string key)
if (this.defaultEntries.Contains(key))
return null;

if (this.entries.Remove(key, out T item))
if(!this.entries.ContainsKey(key))
return null;

var item = this.entries[key];

if (this.entries.Remove(key))
{
item.Owner = null;
OnRemove?.Invoke(this, new CollectionChangedEventArgs(item));
Expand Down

0 comments on commit d02da37

Please sign in to comment.