Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
BearOffice committed Jan 13, 2022
1 parent 2b3c786 commit b427b43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion BearMLLib/BearMLLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>3.1.4</Version>
<Version>3.1.5</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>Bear</Authors>
<Company>Bear Office</Company>
Expand Down
2 changes: 1 addition & 1 deletion BearMLLib/Core/Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(new string[0]), true, out _);
Expand Down
10 changes: 5 additions & 5 deletions BearMLLib/Serialization/ObjectSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down
24 changes: 12 additions & 12 deletions BearMLLib/Text/TextProcesser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -192,15 +192,15 @@ internal static string Escape(this string input, EscapeLevel level)

i++;

var lastpos = i;
var lastPos = i;
while (i < input.Length)
{
ch = input[i];
if (IsEscapechar(ch, level)) break;

i++;
}
sb.Append(input, lastpos, i - lastpos);
sb.Append(input, lastPos, i - lastPos);

} while (i < input.Length);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b427b43

Please sign in to comment.