diff --git a/BearMLLib/BearMLLib.csproj b/BearMLLib/BearMLLib.csproj index 408d551..e9ab135 100644 --- a/BearMLLib/BearMLLib.csproj +++ b/BearMLLib/BearMLLib.csproj @@ -2,7 +2,7 @@ netstandard2.1 - 3.1.4 + 3.1.5 true Bear Bear Office diff --git a/BearMLLib/Core/Reader.cs b/BearMLLib/Core/Reader.cs index 6cc3f71..4700ce9 100644 --- a/BearMLLib/Core/Reader.cs +++ b/BearMLLib/Core/Reader.cs @@ -39,7 +39,7 @@ internal ConfigsContainer GenerateConfigs() var container = new ConfigsContainer(); var startPos = 0; - if (LineAnalyzer.IsGroupLine(_raw[startPos])) + if (_raw.Count == 0 || LineAnalyzer.IsGroupLine(_raw[startPos])) { // create empty default group at start. var defaultGroup = GroupParser.ParseFromRaw(new ReferList(new string[0]), true, out _); diff --git a/BearMLLib/Serialization/ObjectSerializer.cs b/BearMLLib/Serialization/ObjectSerializer.cs index 6421e1b..2fb91f9 100644 --- a/BearMLLib/Serialization/ObjectSerializer.cs +++ b/BearMLLib/Serialization/ObjectSerializer.cs @@ -31,7 +31,7 @@ internal static object Deserialize(KeyContentPair[] pairs, Type targetType, ICon foreach (var prop in targetType.GetProperties()) { - if (HasIgnoreAttribute(prop)) continue; + if (HasIgnoreAttribute(prop) || prop.GetIndexParameters().Length != 0) continue; var name = prop.Name; var type = prop.PropertyType; @@ -79,12 +79,12 @@ internal static KeyContentPair[] Serialize(object source, Type sourceType, IConv pairs.Add(new KeyContentPair(new Key(key, null, null), content)); } - foreach (var property in sourceType.GetProperties()) + foreach (var prop in sourceType.GetProperties()) { - if (HasIgnoreAttribute(property)) continue; + if (HasIgnoreAttribute(prop) || prop.GetIndexParameters().Length != 0) continue; - var key = property.Name; - var content = ContentTypeSelector.GetContent(property.GetValue(source), providers); + var key = prop.Name; + var content = ContentTypeSelector.GetContent(prop.GetValue(source), providers); pairs.Add(new KeyContentPair(new Key(key, null, null), content)); } diff --git a/BearMLLib/Text/TextProcesser.cs b/BearMLLib/Text/TextProcesser.cs index 02f7854..372c1bc 100644 --- a/BearMLLib/Text/TextProcesser.cs +++ b/BearMLLib/Text/TextProcesser.cs @@ -84,33 +84,33 @@ internal static string TrimStartAndEnd(this string input) return input.TrimStart().TrimEnd(); } - internal static bool StartsWith(this string input, char value, bool ignorewhitespace) + internal static bool StartsWith(this string input, char value, bool ignoreWhiteSpace) { - if (ignorewhitespace) + if (ignoreWhiteSpace) return input.TrimStart().StartsWith(value); else return input.StartsWith(value); } - internal static bool StartsWith(this string input, string value, bool ignorewhitespace) + internal static bool StartsWith(this string input, string value, bool ignoreWhiteSpace) { - if (ignorewhitespace) + if (ignoreWhiteSpace) return input.TrimStart().StartsWith(value); else return input.StartsWith(value); } - internal static bool EndsWith(this string input, char value, bool ignorewhitespace) + internal static bool EndsWith(this string input, char value, bool ignoreWhiteSpace) { - if (ignorewhitespace) + if (ignoreWhiteSpace) return input.TrimEnd().EndsWith(value); else return input.EndsWith(value); } - internal static bool EndsWith(this string input, string value, bool ignorewhitespace) + internal static bool EndsWith(this string input, string value, bool ignoreWhiteSpace) { - if (ignorewhitespace) + if (ignoreWhiteSpace) return input.TrimEnd().EndsWith(value); else return input.EndsWith(value); @@ -192,7 +192,7 @@ internal static string Escape(this string input, EscapeLevel level) i++; - var lastpos = i; + var lastPos = i; while (i < input.Length) { ch = input[i]; @@ -200,7 +200,7 @@ internal static string Escape(this string input, EscapeLevel level) i++; } - sb.Append(input, lastpos, i - lastpos); + sb.Append(input, lastPos, i - lastPos); } while (i < input.Length); @@ -240,12 +240,12 @@ internal static string Unescape(this string input) i++; } - var lastpos = i; + var lastPos = i; while (i < input.Length && input[i] != '\\') { i++; } - sb.Append(input, lastpos, i - lastpos); + sb.Append(input, lastPos, i - lastPos); } while (i < input.Length);