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

Migrate to just netstandard2.0 target framework #141

Merged
merged 3 commits into from
Feb 28, 2024
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
16 changes: 10 additions & 6 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET 2.1.X Core
uses: actions/setup-dotnet@v1
- name: Setup .NET 6.X
uses: actions/setup-dotnet@v2
with:
dotnet-version: 2.1.x
- name: Setup .NET 3.1.X Core
uses: actions/setup-dotnet@v1
dotnet-version: 6.x
- name: Setup .NET 7.X
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.x
dotnet-version: 7.x
- name: Setup .NET 8.X
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.x
- name: where are we?
run: ls
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion Source/Expressive.Tests/Expressive.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net45</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>

<IsPackable>false</IsPackable>

Expand Down
3 changes: 0 additions & 3 deletions Source/Expressive/Exceptions/ExpressiveException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ namespace Expressive.Exceptions
/// <summary>
/// The main exposed <see cref="Exception"/> for users of an Expression. Check the InnerException for more information.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class ExpressiveException : Exception
{
internal ExpressiveException(string message) : base(message)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using System;
using Expressive.Functions;
#if !NETSTANDARD1_4
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace Expressive.Exceptions
{
/// <summary>
/// Represents an error that is thrown when registering an <see cref="IFunction"/> and the name is already used.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class FunctionNameAlreadyRegisteredException : Exception
{
/// <summary>
Expand All @@ -29,20 +22,5 @@ internal FunctionNameAlreadyRegisteredException(string name)
{
this.Name = name;
}

#if !NETSTANDARD1_4
/// <summary>
/// Set the <see cref="SerializationInfo"/> with information about this exception.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);

info.AddValue("Name", Name);
}
#endif
}
}
3 changes: 0 additions & 3 deletions Source/Expressive/Exceptions/MissingParticipantException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ namespace Expressive.Exceptions
/// <summary>
/// Represents an error that is thrown when one side of an operation is missing inside an <see cref="Expression"/>.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class MissingParticipantException : Exception
{
/// <summary>
Expand Down
22 changes: 0 additions & 22 deletions Source/Expressive/Exceptions/MissingTokenException.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
using System;
#if !NETSTANDARD1_4
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace Expressive.Exceptions
{
/// <summary>
/// Represents an error that is thrown when a missing token is detected inside an <see cref="Expression"/>.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class MissingTokenException : Exception
{
/// <summary>
Expand All @@ -29,20 +22,5 @@ internal MissingTokenException(string message, char missingToken)
{
this.MissingToken = missingToken;
}

#if !NETSTANDARD1_4
/// <summary>
/// Set the <see cref="SerializationInfo"/> with information about this exception.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);

info.AddValue("MissingToken", MissingToken);
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
using System;
using Expressive.Operators;

#if !NETSTANDARD1_4
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace Expressive.Exceptions
{
/// <summary>
/// Represents an error that is thrown when registering an <see cref="IOperator"/> and the name is already used.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class OperatorNameAlreadyRegisteredException : Exception
{
/// <summary>
Expand All @@ -30,20 +22,5 @@ internal OperatorNameAlreadyRegisteredException(string tag)
{
this.Tag = tag;
}

#if !NETSTANDARD1_4
/// <summary>
/// Set the <see cref="SerializationInfo"/> with information about this exception.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);

info.AddValue("Tag", Tag);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ namespace Expressive.Exceptions
/// <summary>
/// Represents an error that is thrown when a function has an incorrect number of parameters.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class ParameterCountMismatchException : Exception
{
/// <summary>
Expand Down
23 changes: 0 additions & 23 deletions Source/Expressive/Exceptions/UnrecognisedTokenException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
using System;

#if !NETSTANDARD1_4
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace Expressive.Exceptions
{
/// <summary>
/// Represents an error that is thrown when a token is not recognised inside an <see cref="Expression"/>.
/// </summary>
#if !NETSTANDARD1_4
[Serializable]
#endif
public sealed class UnrecognisedTokenException : Exception
{
/// <summary>
Expand All @@ -29,20 +21,5 @@ internal UnrecognisedTokenException(string token)
{
this.Token = token;
}

#if !NETSTANDARD1_4
/// <summary>
/// Set the <see cref="SerializationInfo"/> with information about this exception.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);

info.AddValue("Token", Token);
}
#endif
}
}
4 changes: 0 additions & 4 deletions Source/Expressive/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ public void EvaluateAsync<T>(Action<string, T> callback, IDictionary<string, obj
throw new ArgumentNullException(nameof(callback));
}

#if NETSTANDARD1_4
Task.Run(() =>
#else
ThreadPool.QueueUserWorkItem((o) =>
#endif
{
var result = default(T);
string message = null;
Expand Down
6 changes: 3 additions & 3 deletions Source/Expressive/Expressive.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.4;netstandard2.0;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ExpressiveStrongName.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
Expand All @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/bijington/expressive</PackageProjectUrl>
<Product>Expressive Parser</Product>
<Description>A multi-platform expression parsing and evaluating framework.</Description>
<Copyright>Copyright(c) 2020 Shaun Lawrence</Copyright>
<Copyright>Copyright(c) 2024 Shaun Lawrence</Copyright>
<PackageTags>Expression Parser Evaluator Cross-Platform NET Standard Xamarin Xamarin.Forms</PackageTags>
<PackageIcon>logo-64.png</PackageIcon>
<PackageIconUrl />
Expand Down Expand Up @@ -50,4 +50,4 @@
</PackageReference>
</ItemGroup>

</Project>
</Project>
63 changes: 1 addition & 62 deletions Source/Expressive/Helpers/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,7 @@ public static class TypeHelper
/// <returns>The code of the underlying type, or <see cref="TypeCode.Empty"/> if type is null.</returns>
public static TypeCode GetTypeCode(object value)
{
var typeCode = TypeCode.Object;

#if NETSTANDARD1_4
// TODO: Explore converting all numbers to decimal and simplifying all of this.

switch (value)
{
case bool _:
typeCode = TypeCode.Boolean;
break;
case byte _:
typeCode = TypeCode.Byte;
break;
case char _:
typeCode = TypeCode.Char;
break;
case DateTime _:
typeCode = TypeCode.DateTime;
break;
case decimal _:
typeCode = TypeCode.Decimal;
break;
case double _:
typeCode = TypeCode.Double;
break;
case long _:
typeCode = TypeCode.Int64;
break;
case int _:
typeCode = TypeCode.Int32;
break;
case short _:
typeCode = TypeCode.Int16;
break;
case sbyte _:
typeCode = TypeCode.SByte;
break;
case float _:
typeCode = TypeCode.Single;
break;
case string _:
typeCode = TypeCode.String;
break;
case ushort _:
typeCode = TypeCode.UInt16;
break;
case uint _:
typeCode = TypeCode.UInt32;
break;
case ulong _:
typeCode = TypeCode.UInt64;
break;
case null:
typeCode = TypeCode.Empty;
break;
}

#else
typeCode = Type.GetTypeCode(value?.GetType());
#endif

return typeCode;
return Type.GetTypeCode(value?.GetType());
}
}
}
Loading