Explorar o código

Misc clean up - remove redundant #ifdefs, rename JsonLineOffset to LineOffset

Brad Robinson %!s(int64=5) %!d(string=hai) anos
pai
achega
baad433df6

+ 2 - 1
PetaJson/CancelReaderException.cs

@@ -21,5 +21,6 @@ using System;
 namespace PetaJson
 {
     class CancelReaderException : Exception
-    { }
+    {
+    }
 }

+ 0 - 7
PetaJson/IJsonLoadField.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonLoaded.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonLoading.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonReader.cs

@@ -18,13 +18,6 @@
 
 using System;
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonWriter.cs

@@ -18,13 +18,6 @@
 
 using System;
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonWriting.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/IJsonWritten.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 8
PetaJson/JsonAttribute.cs

@@ -17,14 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {

+ 0 - 8
PetaJson/JsonExcludeAttribute.cs

@@ -17,14 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {

+ 0 - 9
PetaJson/JsonMemberInfo.cs

@@ -18,13 +18,6 @@
 
 using System;
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson
@@ -41,8 +34,6 @@ namespace PetaJson
         // True if deprecated
         public bool Deprecated;
 
-            
-
         // Reflected member info
         MemberInfo _mi;
         public MemberInfo Member

+ 0 - 8
PetaJson/JsonOptions.cs

@@ -17,14 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {

+ 2 - 10
PetaJson/JsonParseException.cs

@@ -17,27 +17,19 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {
     // Exception thrown for any parse error
     public class JsonParseException : Exception
     {
-        public JsonParseException(Exception inner, string context, JsonLineOffset position) : 
+        public JsonParseException(Exception inner, string context, LineOffset position) : 
             base(string.Format("JSON parse error at {0}{1} - {2}", position, string.IsNullOrEmpty(context) ? "" : string.Format(", context {0}", context), inner.Message), inner)
         {
             Position = position;
             Context = context;
         }
-        public JsonLineOffset Position;
+        public LineOffset Position;
         public string Context;
     }
 }

+ 1 - 6
PetaJson/JsonReader.cs

@@ -25,11 +25,6 @@ using System.Collections;
 #if !PETAJSON_NO_DYNAMIC
 using System.Dynamic;
 #endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson
@@ -167,7 +162,7 @@ namespace PetaJson
             };
         }
 
-        public JsonLineOffset CurrentTokenPosition
+        public LineOffset CurrentTokenPosition
         {
             get { return _tokenizer.CurrentTokenPosition; }
         }

+ 0 - 7
PetaJson/JsonUnknownAttribute.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 0 - 7
PetaJson/JsonWriter.cs

@@ -21,13 +21,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.IO;
 using System.Globalization;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 1 - 9
PetaJson/JsonLineOffset.cs → PetaJson/LineOffset.cs

@@ -16,19 +16,11 @@
 // Define PETAJSON_NO_EMIT to disable Reflection.Emit
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {
     // Represents a line and character offset position in the source Json
-    public struct JsonLineOffset
+    public struct LineOffset
     {
         public int Line;
         public int Offset;

+ 0 - 8
PetaJson/LiteralKind.cs

@@ -16,14 +16,6 @@
 // Define PETAJSON_NO_EMIT to disable Reflection.Emit
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
-
 
 namespace PetaJson
 {

+ 2 - 2
PetaJson/PetaJson.cs

@@ -191,7 +191,7 @@ namespace PetaJson
             }
             catch (Exception x)
             {
-				var loc = reader == null ? new JsonLineOffset() : reader.CurrentTokenPosition;
+				var loc = reader == null ? new LineOffset() : reader.CurrentTokenPosition;
 				Console.WriteLine("Exception thrown while parsing JSON at {0}, context:{1}\n{2}", loc, reader?.Context, x.ToString()); 
 				throw new JsonParseException(x, reader?.Context, loc);
             }
@@ -220,7 +220,7 @@ namespace PetaJson
             }
             catch (Exception x)
             {
-				var loc = reader == null ? new JsonLineOffset() : reader.CurrentTokenPosition;
+				var loc = reader == null ? new LineOffset() : reader.CurrentTokenPosition;
 				Console.WriteLine("Exception thrown while parsing JSON at {0}, context:{1}\n{2}", loc, reader.Context, x.ToString()); 
 				throw new JsonParseException(x,reader.Context,loc);
             }

+ 0 - 7
PetaJson/Token.cs

@@ -17,13 +17,6 @@
 // Define PETAJSON_NO_DATACONTRACT to disable support for [DataContract]/[DataMember]
 
 using System.Reflection;
-#if !PETAJSON_NO_DYNAMIC
-#endif
-#if !PETAJSON_NO_EMIT
-#endif
-#if !PETAJSON_NO_DATACONTRACT
-#endif
-
 
 
 namespace PetaJson

+ 4 - 4
PetaJson/Tokenizer.cs

@@ -43,11 +43,11 @@ namespace PetaJson
         private int _bufUsed;
         private StringBuilder _rewindBuffer;
         private int _rewindBufferPos;
-        private JsonLineOffset _currentCharPos;
+        private LineOffset _currentCharPos;
         private char _currentChar;
         private Stack<ReaderState> _bookmarks = new Stack<ReaderState>();
 
-        public JsonLineOffset CurrentTokenPosition;
+        public LineOffset CurrentTokenPosition;
         public Token CurrentToken;
         public LiteralKind LiteralKind;
         public string String;
@@ -122,8 +122,8 @@ namespace PetaJson
                 tokenizer.LiteralKind = _literalKind;
             }
 
-            private JsonLineOffset _currentCharPos;
-            private JsonLineOffset _currentTokenPos;
+            private LineOffset _currentCharPos;
+            private LineOffset _currentTokenPos;
             private char _currentChar;
             private Token _currentToken;
             private LiteralKind _literalKind;