Skip to content

Commit 289d7ce

Browse files
committed
Add trimming support and dynamic access attributes.
Also move to file-scoped namespaces everywhere. Closes #49
1 parent 4393f63 commit 289d7ce

File tree

72 files changed

+2713
-2560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2713
-2560
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
22

3-
namespace Tomlet.Attributes
3+
namespace Tomlet.Attributes;
4+
5+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6+
public class TomlNonSerializedAttribute : Attribute
47
{
5-
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6-
public class TomlNonSerializedAttribute : Attribute
7-
{
8-
}
9-
}
8+
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class InvalidTomlDateTimeException : TomlExceptionWithLine
4-
{
5-
private readonly string _inputString;
1+
namespace Tomlet.Exceptions;
62

7-
public InvalidTomlDateTimeException(int lineNumber, string inputString) : base(lineNumber)
8-
{
9-
_inputString = inputString;
10-
}
3+
public class InvalidTomlDateTimeException : TomlExceptionWithLine
4+
{
5+
private readonly string _inputString;
116

12-
public override string Message => $"Found an invalid TOML date/time string '{_inputString}' on line {LineNumber}";
7+
public InvalidTomlDateTimeException(int lineNumber, string inputString) : base(lineNumber)
8+
{
9+
_inputString = inputString;
1310
}
11+
12+
public override string Message => $"Found an invalid TOML date/time string '{_inputString}' on line {LineNumber}";
1413
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class InvalidTomlEscapeException : TomlExceptionWithLine
4-
{
5-
private readonly string _escapeSequence;
1+
namespace Tomlet.Exceptions;
62

7-
public InvalidTomlEscapeException(int lineNumber, string escapeSequence) : base(lineNumber)
8-
{
9-
_escapeSequence = escapeSequence;
10-
}
3+
public class InvalidTomlEscapeException : TomlExceptionWithLine
4+
{
5+
private readonly string _escapeSequence;
116

12-
public override string Message => $"Found an invalid escape sequence '\\{_escapeSequence}' on line {LineNumber}";
7+
public InvalidTomlEscapeException(int lineNumber, string escapeSequence) : base(lineNumber)
8+
{
9+
_escapeSequence = escapeSequence;
1310
}
11+
12+
public override string Message => $"Found an invalid escape sequence '\\{_escapeSequence}' on line {LineNumber}";
1413
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
namespace Tomlet.Exceptions
1+
namespace Tomlet.Exceptions;
2+
3+
public class InvalidTomlInlineTableException : TomlExceptionWithLine
24
{
3-
public class InvalidTomlInlineTableException : TomlExceptionWithLine
5+
public InvalidTomlInlineTableException(int lineNumber, TomlException cause) : base(lineNumber, cause)
46
{
5-
public InvalidTomlInlineTableException(int lineNumber, TomlException cause) : base(lineNumber, cause)
6-
{
7-
}
8-
9-
public override string Message => $"Found an invalid inline TOML table on line {LineNumber}. See further down for cause.";
107
}
8+
9+
public override string Message => $"Found an invalid inline TOML table on line {LineNumber}. See further down for cause.";
1110
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class InvalidTomlKeyException : TomlException
4-
{
5-
private readonly string _key;
1+
namespace Tomlet.Exceptions;
62

7-
public InvalidTomlKeyException(string key)
8-
{
9-
_key = key;
10-
}
3+
public class InvalidTomlKeyException : TomlException
4+
{
5+
private readonly string _key;
116

12-
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.";
7+
public InvalidTomlKeyException(string key)
8+
{
9+
_key = key;
1310
}
11+
12+
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.";
1413
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class InvalidTomlNumberException : TomlExceptionWithLine
4-
{
5-
private readonly string _input;
1+
namespace Tomlet.Exceptions;
62

7-
public InvalidTomlNumberException(int lineNumber, string input) : base(lineNumber)
8-
{
9-
_input = input;
10-
}
3+
public class InvalidTomlNumberException : TomlExceptionWithLine
4+
{
5+
private readonly string _input;
116

12-
public override string Message => $"While reading input line {LineNumber}, found an invalid number literal '{_input}'";
7+
public InvalidTomlNumberException(int lineNumber, string input) : base(lineNumber)
8+
{
9+
_input = input;
1310
}
11+
12+
public override string Message => $"While reading input line {LineNumber}, found an invalid number literal '{_input}'";
1413
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class MissingIntermediateInTomlTableArraySpecException : TomlExceptionWithLine
4-
{
5-
private readonly string _missing;
1+
namespace Tomlet.Exceptions;
62

7-
public MissingIntermediateInTomlTableArraySpecException(int lineNumber, string missing) : base(lineNumber)
8-
{
9-
_missing = missing;
10-
}
3+
public class MissingIntermediateInTomlTableArraySpecException : TomlExceptionWithLine
4+
{
5+
private readonly string _missing;
116

12-
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.";
7+
public MissingIntermediateInTomlTableArraySpecException(int lineNumber, string missing) : base(lineNumber)
8+
{
9+
_missing = missing;
1310
}
11+
12+
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.";
1413
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
namespace Tomlet.Exceptions
1+
namespace Tomlet.Exceptions;
2+
3+
public class NewLineInTomlInlineTableException : TomlExceptionWithLine
24
{
3-
public class NewLineInTomlInlineTableException : TomlExceptionWithLine
5+
public NewLineInTomlInlineTableException(int lineNumber) : base(lineNumber)
46
{
5-
public NewLineInTomlInlineTableException(int lineNumber) : base(lineNumber)
6-
{
7-
}
8-
9-
public override string Message => "Found a new-line character within a TOML inline table. This is not allowed.";
107
}
8+
9+
public override string Message => "Found a new-line character within a TOML inline table. This is not allowed.";
1110
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
namespace Tomlet.Exceptions
1+
namespace Tomlet.Exceptions;
2+
3+
public class NoTomlKeyException : TomlExceptionWithLine
24
{
3-
public class NoTomlKeyException : TomlExceptionWithLine
4-
{
5-
public NoTomlKeyException(int lineNumber) : base(lineNumber) { }
5+
public NoTomlKeyException(int lineNumber) : base(lineNumber) { }
66

7-
public override string Message => $"Expected a TOML key on line {LineNumber}, but found an equals sign ('=').";
8-
}
7+
public override string Message => $"Expected a TOML key on line {LineNumber}, but found an equals sign ('=').";
98
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace Tomlet.Exceptions
2-
{
3-
public class TimeOffsetOnTomlDateOrTimeException : TomlExceptionWithLine
4-
{
5-
private readonly string _tzString;
1+
namespace Tomlet.Exceptions;
62

7-
public TimeOffsetOnTomlDateOrTimeException(int lineNumber, string tzString) : base(lineNumber)
8-
{
9-
_tzString = tzString;
10-
}
3+
public class TimeOffsetOnTomlDateOrTimeException : TomlExceptionWithLine
4+
{
5+
private readonly string _tzString;
116

12-
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.";
7+
public TimeOffsetOnTomlDateOrTimeException(int lineNumber, string tzString) : base(lineNumber)
8+
{
9+
_tzString = tzString;
1310
}
11+
12+
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.";
1413
}

0 commit comments

Comments
 (0)