Skip to content

Commit

Permalink
Remove unneeded NETSTANDARD1_6 compiler directives and unneeded usings (
Browse files Browse the repository at this point in the history
#317)

* Remove unneeded preprocessor directives.

* Remove unnecessary usings
  • Loading branch information
metoule authored Aug 19, 2024
1 parent e4589fb commit 53d14df
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 83 deletions.
28 changes: 12 additions & 16 deletions src/DynamicExpresso.Core/DefaultNumberType.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DynamicExpresso
{
/// <summary>
/// Setting the default number types when no suffix is specified
/// </summary>
public enum DefaultNumberType
{
Default = 0, //(Int by default or Double if real number)
Int = 1,
Long = 2,
Single = 3,
Double = 4,
Decimal = 5
}
/// <summary>
/// Setting the default number types when no suffix is specified
/// </summary>
public enum DefaultNumberType
{
Default = 0, //(Int by default or Double if real number)
Int = 1,
Long = 2,
Single = 3,
Double = 4,
Decimal = 5
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
#if !NETSTANDARD1_6
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class AssignmentOperatorDisabledException : ParseException
{
public AssignmentOperatorDisabledException(string operatorString, int position)
: base(string.Format("Assignment operator '{0}' not allowed", operatorString), position)
: base(string.Format("Assignment operator '{0}' not allowed", operatorString), position)
{
OperatorString = operatorString;
}

public string OperatorString { get; private set; }

#if !NETSTANDARD1_6
protected AssignmentOperatorDisabledException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
OperatorString = info.GetString("OperatorString");
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("OperatorString", OperatorString);

base.GetObjectData(info, context);
}
#endif
}
}
12 changes: 2 additions & 10 deletions src/DynamicExpresso.Core/Exceptions/DuplicateParameterException.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
#if !NETSTANDARD1_6
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class DuplicateParameterException : DynamicExpressoException
{
public DuplicateParameterException(string identifier)
: base(string.Format("The parameter '{0}' was defined more than once", identifier))
: base(string.Format("The parameter '{0}' was defined more than once", identifier))
{
Identifier = identifier;
}
public string Identifier { get; private set; }

#if !NETSTANDARD1_6
protected DuplicateParameterException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
Identifier = info.GetString("Identifier");
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Identifier", Identifier);

base.GetObjectData(info, context);
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using System;
using System;

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class DynamicExpressoException : Exception
{
public DynamicExpressoException() { }
public DynamicExpressoException(string message) : base(message) { }
public DynamicExpressoException(string message, Exception inner) : base(message, inner) { }

#if !NETSTANDARD1_6
protected DynamicExpressoException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
#endif
}
}
12 changes: 2 additions & 10 deletions src/DynamicExpresso.Core/Exceptions/NoApplicableMethodException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#if !NETSTANDARD1_6
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class NoApplicableMethodException : ParseException
{
public NoApplicableMethodException(string methodName, string methodTypeName, int position)
: base(string.Format("No applicable method '{0}' exists in type '{1}'", methodName, methodTypeName), position)
: base(string.Format("No applicable method '{0}' exists in type '{1}'", methodName, methodTypeName), position)
{
MethodTypeName = methodTypeName;
MethodName = methodName;
Expand All @@ -21,24 +16,21 @@ public NoApplicableMethodException(string methodName, string methodTypeName, int
public string MethodTypeName { get; private set; }
public string MethodName { get; private set; }

#if !NETSTANDARD1_6
protected NoApplicableMethodException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
MethodTypeName = info.GetString("MethodTypeName");
MethodName = info.GetString("MethodName");
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("MethodName", MethodName);
info.AddValue("MethodTypeName", MethodTypeName);

base.GetObjectData(info, context);
}
#endif
}
}
12 changes: 2 additions & 10 deletions src/DynamicExpresso.Core/Exceptions/ParseException.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#if !NETSTANDARD1_6
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif
using DynamicExpresso.Resources;

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class ParseException : DynamicExpressoException
{
public ParseException(string message, int position)
: base(string.Format(ErrorMessages.Format, message, position))
: base(string.Format(ErrorMessages.Format, message, position))
{
Position = position;
}
Expand All @@ -31,22 +26,19 @@ public static ParseException Create(int pos, string format, params object[] args
return new ParseException(string.Format(format, args), pos);
}

#if !NETSTANDARD1_6
protected ParseException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
Position = info.GetInt32("Position");
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Position", Position);

base.GetObjectData(info, context);
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
#if !NETSTANDARD1_6
using System;
using System.Security.Permissions;
using System.Runtime.Serialization;
#endif

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class ReflectionNotAllowedException : ParseException
{
public ReflectionNotAllowedException()
: base("Reflection expression not allowed. To enable reflection use Interpreter.EnableReflection().", 0)
: base("Reflection expression not allowed. To enable reflection use Interpreter.EnableReflection().", 0)
{
}

#if !NETSTANDARD1_6
protected ReflectionNotAllowedException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
#endif
}
}
12 changes: 2 additions & 10 deletions src/DynamicExpresso.Core/Exceptions/UnknownIdentifierException.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
#if !NETSTANDARD1_6
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace DynamicExpresso.Exceptions
{
#if !NETSTANDARD1_6
[Serializable]
#endif
public class UnknownIdentifierException : ParseException
{
public UnknownIdentifierException(string identifier, int position)
: base(string.Format("Unknown identifier '{0}'", identifier), position)
: base(string.Format("Unknown identifier '{0}'", identifier), position)
{
Identifier = identifier;
}

public string Identifier { get; private set; }

#if !NETSTANDARD1_6
protected UnknownIdentifierException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
: base(info, context)
{
Identifier = info.GetString("Identifier");
}

[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Identifier", Identifier);

base.GetObjectData(info, context);
}
#endif
}
}
1 change: 0 additions & 1 deletion src/DynamicExpresso.Core/Interpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Linq.Expressions;
using DynamicExpresso.Exceptions;
using System.Dynamic;

namespace DynamicExpresso
{
Expand Down
1 change: 0 additions & 1 deletion test/DynamicExpresso.UnitTest/LambdaExpressionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace DynamicExpresso.UnitTest
{
Expand Down

0 comments on commit 53d14df

Please sign in to comment.