-Added IJsonLineInfo. Implemented by JsonTextReader, JsonTokenReader, JsonValidatingReader, JToken

-Added line details to JsonTextReader exception messages and JsonValidatingReader errors
-Change JsonSchemaGenerator to disable additional properties on sealed classes
-Fixed JsonSchemaGenerator to not output enum values and options for flag enums
This commit is contained in:
JamesNK
2009-01-04 05:26:26 +00:00
parent 0319263756
commit 399033059b
26 changed files with 520 additions and 193 deletions
@@ -32,6 +32,9 @@ namespace Newtonsoft.Json.Schema
/// </summary>
public class JsonSchemaException : Exception
{
public int LineNumber { get; private set; }
public int LinePosition { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="JsonSchemaException"/> class.
/// </summary>
@@ -59,5 +62,12 @@ namespace Newtonsoft.Json.Schema
: base(message, innerException)
{
}
internal JsonSchemaException(string message, Exception innerException, int lineNumber, int linePosition)
: base(message, innerException)
{
LineNumber = lineNumber;
LinePosition = linePosition;
}
}
}
@@ -253,8 +253,11 @@ namespace Newtonsoft.Json.Schema
CurrentSchema.Properties.Add(mapping.MappingName, propertySchema);
}
}
if (type.IsSealed)
CurrentSchema.AllowAdditionalProperties = false;
}
else if (CurrentSchema.Type == JsonSchemaType.Integer && type.IsEnum)
else if (CurrentSchema.Type == JsonSchemaType.Integer && type.IsEnum && !type.IsDefined(typeof(FlagsAttribute), true))
{
CurrentSchema.Enum = new List<JToken>();
CurrentSchema.Options = new Dictionary<JToken, string>();