-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trimming support and dynamic access attributes.
Also move to file-scoped namespaces everywhere. Closes #49
- Loading branch information
1 parent
4393f63
commit 289d7ce
Showing
72 changed files
with
2,713 additions
and
2,560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
using System; | ||
|
||
namespace Tomlet.Attributes | ||
namespace Tomlet.Attributes; | ||
|
||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] | ||
public class TomlNonSerializedAttribute : Attribute | ||
{ | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] | ||
public class TomlNonSerializedAttribute : Attribute | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class InvalidTomlDateTimeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _inputString; | ||
namespace Tomlet.Exceptions; | ||
|
||
public InvalidTomlDateTimeException(int lineNumber, string inputString) : base(lineNumber) | ||
{ | ||
_inputString = inputString; | ||
} | ||
public class InvalidTomlDateTimeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _inputString; | ||
|
||
public override string Message => $"Found an invalid TOML date/time string '{_inputString}' on line {LineNumber}"; | ||
public InvalidTomlDateTimeException(int lineNumber, string inputString) : base(lineNumber) | ||
{ | ||
_inputString = inputString; | ||
} | ||
|
||
public override string Message => $"Found an invalid TOML date/time string '{_inputString}' on line {LineNumber}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class InvalidTomlEscapeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _escapeSequence; | ||
namespace Tomlet.Exceptions; | ||
|
||
public InvalidTomlEscapeException(int lineNumber, string escapeSequence) : base(lineNumber) | ||
{ | ||
_escapeSequence = escapeSequence; | ||
} | ||
public class InvalidTomlEscapeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _escapeSequence; | ||
|
||
public override string Message => $"Found an invalid escape sequence '\\{_escapeSequence}' on line {LineNumber}"; | ||
public InvalidTomlEscapeException(int lineNumber, string escapeSequence) : base(lineNumber) | ||
{ | ||
_escapeSequence = escapeSequence; | ||
} | ||
|
||
public override string Message => $"Found an invalid escape sequence '\\{_escapeSequence}' on line {LineNumber}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class InvalidTomlInlineTableException : TomlExceptionWithLine | ||
{ | ||
public class InvalidTomlInlineTableException : TomlExceptionWithLine | ||
public InvalidTomlInlineTableException(int lineNumber, TomlException cause) : base(lineNumber, cause) | ||
{ | ||
public InvalidTomlInlineTableException(int lineNumber, TomlException cause) : base(lineNumber, cause) | ||
{ | ||
} | ||
|
||
public override string Message => $"Found an invalid inline TOML table on line {LineNumber}. See further down for cause."; | ||
} | ||
|
||
public override string Message => $"Found an invalid inline TOML table on line {LineNumber}. See further down for cause."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class InvalidTomlKeyException : TomlException | ||
{ | ||
private readonly string _key; | ||
namespace Tomlet.Exceptions; | ||
|
||
public InvalidTomlKeyException(string key) | ||
{ | ||
_key = key; | ||
} | ||
public class InvalidTomlKeyException : TomlException | ||
{ | ||
private readonly string _key; | ||
|
||
public override string Message => $"The string |{_key}| (between the two bars) contains at least one of both a double quote and a single quote, so it cannot be used for a TOML key."; | ||
public InvalidTomlKeyException(string key) | ||
{ | ||
_key = key; | ||
} | ||
|
||
public override string Message => $"The string |{_key}| (between the two bars) contains at least one of both a double quote and a single quote, so it cannot be used for a TOML key."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class InvalidTomlNumberException : TomlExceptionWithLine | ||
{ | ||
private readonly string _input; | ||
namespace Tomlet.Exceptions; | ||
|
||
public InvalidTomlNumberException(int lineNumber, string input) : base(lineNumber) | ||
{ | ||
_input = input; | ||
} | ||
public class InvalidTomlNumberException : TomlExceptionWithLine | ||
{ | ||
private readonly string _input; | ||
|
||
public override string Message => $"While reading input line {LineNumber}, found an invalid number literal '{_input}'"; | ||
public InvalidTomlNumberException(int lineNumber, string input) : base(lineNumber) | ||
{ | ||
_input = input; | ||
} | ||
|
||
public override string Message => $"While reading input line {LineNumber}, found an invalid number literal '{_input}'"; | ||
} |
19 changes: 9 additions & 10 deletions
19
Tomlet/Exceptions/MissingIntermediateInTomlTableArraySpecException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class MissingIntermediateInTomlTableArraySpecException : TomlExceptionWithLine | ||
{ | ||
private readonly string _missing; | ||
namespace Tomlet.Exceptions; | ||
|
||
public MissingIntermediateInTomlTableArraySpecException(int lineNumber, string missing) : base(lineNumber) | ||
{ | ||
_missing = missing; | ||
} | ||
public class MissingIntermediateInTomlTableArraySpecException : TomlExceptionWithLine | ||
{ | ||
private readonly string _missing; | ||
|
||
public override string Message => $"Missing intermediate definition for {_missing} in table-array specification on line {LineNumber}. This is undefined behavior, and I chose to define it as an error."; | ||
public MissingIntermediateInTomlTableArraySpecException(int lineNumber, string missing) : base(lineNumber) | ||
{ | ||
_missing = missing; | ||
} | ||
|
||
public override string Message => $"Missing intermediate definition for {_missing} in table-array specification on line {LineNumber}. This is undefined behavior, and I chose to define it as an error."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class NewLineInTomlInlineTableException : TomlExceptionWithLine | ||
{ | ||
public class NewLineInTomlInlineTableException : TomlExceptionWithLine | ||
public NewLineInTomlInlineTableException(int lineNumber) : base(lineNumber) | ||
{ | ||
public NewLineInTomlInlineTableException(int lineNumber) : base(lineNumber) | ||
{ | ||
} | ||
|
||
public override string Message => "Found a new-line character within a TOML inline table. This is not allowed."; | ||
} | ||
|
||
public override string Message => "Found a new-line character within a TOML inline table. This is not allowed."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class NoTomlKeyException : TomlExceptionWithLine | ||
{ | ||
public class NoTomlKeyException : TomlExceptionWithLine | ||
{ | ||
public NoTomlKeyException(int lineNumber) : base(lineNumber) { } | ||
public NoTomlKeyException(int lineNumber) : base(lineNumber) { } | ||
|
||
public override string Message => $"Expected a TOML key on line {LineNumber}, but found an equals sign ('=')."; | ||
} | ||
public override string Message => $"Expected a TOML key on line {LineNumber}, but found an equals sign ('=')."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class TimeOffsetOnTomlDateOrTimeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _tzString; | ||
namespace Tomlet.Exceptions; | ||
|
||
public TimeOffsetOnTomlDateOrTimeException(int lineNumber, string tzString) : base(lineNumber) | ||
{ | ||
_tzString = tzString; | ||
} | ||
public class TimeOffsetOnTomlDateOrTimeException : TomlExceptionWithLine | ||
{ | ||
private readonly string _tzString; | ||
|
||
public override string Message => $"Found a time offset string {_tzString} in a partial datetime on line {LineNumber}. This is not allowed - either specify both the date and the time, or remove the offset specifier."; | ||
public TimeOffsetOnTomlDateOrTimeException(int lineNumber, string tzString) : base(lineNumber) | ||
{ | ||
_tzString = tzString; | ||
} | ||
|
||
public override string Message => $"Found a time offset string {_tzString} in a partial datetime on line {LineNumber}. This is not allowed - either specify both the date and the time, or remove the offset specifier."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class TomlArraySyntaxException : TomlExceptionWithLine | ||
{ | ||
private readonly char _charFound; | ||
namespace Tomlet.Exceptions; | ||
|
||
public TomlArraySyntaxException(int lineNumber, char charFound) : base(lineNumber) | ||
{ | ||
_charFound = charFound; | ||
} | ||
public class TomlArraySyntaxException : TomlExceptionWithLine | ||
{ | ||
private readonly char _charFound; | ||
|
||
public override string Message => $"Expecting ',' or ']' after value in array on line {LineNumber}, found '{_charFound}'"; | ||
public TomlArraySyntaxException(int lineNumber, char charFound) : base(lineNumber) | ||
{ | ||
_charFound = charFound; | ||
} | ||
|
||
public override string Message => $"Expecting ',' or ']' after value in array on line {LineNumber}, found '{_charFound}'"; | ||
} |
19 changes: 9 additions & 10 deletions
19
Tomlet/Exceptions/TomlContainsDottedKeyNonTableException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class TomlContainsDottedKeyNonTableException : TomlException | ||
{ | ||
internal readonly string Key; | ||
namespace Tomlet.Exceptions; | ||
|
||
public TomlContainsDottedKeyNonTableException(string key) | ||
{ | ||
Key = key; | ||
} | ||
public class TomlContainsDottedKeyNonTableException : TomlException | ||
{ | ||
internal readonly string Key; | ||
|
||
public override string Message => $"A call was made on a TOML table which attempted to access a sub-key of {Key}, but the value it refers to is not a table"; | ||
public TomlContainsDottedKeyNonTableException(string key) | ||
{ | ||
Key = key; | ||
} | ||
|
||
public override string Message => $"A call was made on a TOML table which attempted to access a sub-key of {Key}, but the value it refers to is not a table"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class TomlDateTimeMissingSeparatorException : TomlExceptionWithLine | ||
{ | ||
public class TomlDateTimeMissingSeparatorException : TomlExceptionWithLine | ||
public TomlDateTimeMissingSeparatorException(int lineNumber) : base(lineNumber) | ||
{ | ||
public TomlDateTimeMissingSeparatorException(int lineNumber) : base(lineNumber) | ||
{ | ||
} | ||
|
||
public override string Message => $"Found a date-time on line {LineNumber} which is missing a separator (T, t, or a space) between the date and time."; | ||
} | ||
|
||
public override string Message => $"Found a date-time on line {LineNumber} which is missing a separator (T, t, or a space) between the date and time."; | ||
} |
13 changes: 6 additions & 7 deletions
13
Tomlet/Exceptions/TomlDateTimeUnnecessarySeparatorException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class TomlDateTimeUnnecessarySeparatorException : TomlExceptionWithLine | ||
{ | ||
public class TomlDateTimeUnnecessarySeparatorException : TomlExceptionWithLine | ||
public TomlDateTimeUnnecessarySeparatorException(int lineNumber) : base(lineNumber) | ||
{ | ||
public TomlDateTimeUnnecessarySeparatorException(int lineNumber) : base(lineNumber) | ||
{ | ||
} | ||
|
||
public override string Message => $"Found an unnecessary date-time separator (T, t, or a space) in a date or time on line {LineNumber}"; | ||
} | ||
|
||
public override string Message => $"Found an unnecessary date-time separator (T, t, or a space) in a date or time on line {LineNumber}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class TomlDottedKeyException : TomlException | ||
{ | ||
private readonly string _key; | ||
namespace Tomlet.Exceptions; | ||
|
||
public TomlDottedKeyException(string key) | ||
{ | ||
_key = key; | ||
} | ||
public class TomlDottedKeyException : TomlException | ||
{ | ||
private readonly string _key; | ||
|
||
public override string Message => $"Tried to redefine key {_key} as a table (by way of a dotted key) when it's already defined as not being a table."; | ||
public TomlDottedKeyException(string key) | ||
{ | ||
_key = key; | ||
} | ||
|
||
public override string Message => $"Tried to redefine key {_key} as a table (by way of a dotted key) when it's already defined as not being a table."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace Tomlet.Exceptions | ||
{ | ||
public class TomlDottedKeyParserException : TomlExceptionWithLine | ||
{ | ||
private readonly string _key; | ||
namespace Tomlet.Exceptions; | ||
|
||
public TomlDottedKeyParserException(int lineNumber, string key) : base(lineNumber) | ||
{ | ||
_key = key; | ||
} | ||
public class TomlDottedKeyParserException : TomlExceptionWithLine | ||
{ | ||
private readonly string _key; | ||
|
||
public override string Message => $"Tried to redefine key {_key} as a table (by way of a dotted key on line {LineNumber}) when it's already defined as not being a table."; | ||
public TomlDottedKeyParserException(int lineNumber, string key) : base(lineNumber) | ||
{ | ||
_key = key; | ||
} | ||
|
||
public override string Message => $"Tried to redefine key {_key} as a table (by way of a dotted key on line {LineNumber}) when it's already defined as not being a table."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Tomlet.Exceptions | ||
namespace Tomlet.Exceptions; | ||
|
||
public class TomlEndOfFileException : TomlExceptionWithLine | ||
{ | ||
public class TomlEndOfFileException : TomlExceptionWithLine | ||
public TomlEndOfFileException(int lineNumber) : base(lineNumber) | ||
{ | ||
public TomlEndOfFileException(int lineNumber) : base(lineNumber) | ||
{ | ||
} | ||
|
||
public override string Message => $"Found unexpected EOF on line {LineNumber} when parsing TOML file"; | ||
} | ||
|
||
public override string Message => $"Found unexpected EOF on line {LineNumber} when parsing TOML file"; | ||
} |
Oops, something went wrong.