Skip to content

Commit

Permalink
Remove unneeded preprocessor directives.
Browse files Browse the repository at this point in the history
  • Loading branch information
metoule committed Aug 18, 2024
1 parent f966f84 commit c3b1390
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
#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
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +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 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
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#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 +17,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
}
}
11 changes: 2 additions & 9 deletions src/DynamicExpresso.Core/Exceptions/ParseException.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
#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 @@ -26,22 +22,19 @@ public ParseException(string message, int position, Exception innerException)

public int Position { get; private set; }

#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,27 @@
#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
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
#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
}
}

0 comments on commit c3b1390

Please sign in to comment.