Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trim_trailing_whitespace = true

# MSBuild project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj,props,targets}]
indent_size = 2
indent_size = 4

# Xml config files
[*.{ruleset,config,nuspec,resx,vsixmanifest,vsct,runsettings}]
Expand Down Expand Up @@ -84,7 +84,7 @@ dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
# Constants are PascalCase
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style

dotnet_naming_symbols.constants.applicable_kinds = field, local
dotnet_naming_symbols.constants.required_modifiers = const
Expand All @@ -94,7 +94,7 @@ dotnet_naming_style.constant_style.capitalization = pascal_case
# Static fields are camelCase
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
dotnet_naming_rule.static_fields_should_be_camel_case.style = camel_case_style

dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
Expand All @@ -104,7 +104,7 @@ dotnet_naming_style.static_field_style.capitalization = camel_case
# Instance fields are camelCase
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
dotnet_naming_rule.instance_fields_should_be_camel_case.style = camel_case_style

dotnet_naming_symbols.instance_fields.applicable_kinds = field

Expand All @@ -122,7 +122,7 @@ dotnet_naming_style.camel_case_style.capitalization = camel_case
# Local functions are PascalCase
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style

dotnet_naming_symbols.local_functions.applicable_kinds = local_function

Expand All @@ -131,7 +131,7 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case
# By default, name items with PascalCase
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style

dotnet_naming_symbols.all_members.applicable_kinds = *

Expand Down Expand Up @@ -209,6 +209,7 @@ dotnet_diagnostic.SA1130.severity = silent

# IDE1006: Naming Styles - StyleCop handles these for us
dotnet_diagnostic.IDE1006.severity = none
dotnet_diagnostic.IDE0290.severity = silent

dotnet_diagnostic.DOC100.severity = silent
dotnet_diagnostic.DOC104.severity = warning
Expand All @@ -226,7 +227,7 @@ csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_primary_constructors = false:silent
csharp_prefer_system_threading_lock = true:suggestion
csharp_style_expression_bodied_lambdas = when_on_single_line:silent
csharp_style_expression_bodied_local_functions = when_on_single_line:silent
Expand Down
11 changes: 11 additions & 0 deletions .runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<DiffEngine_ToolOrder></DiffEngine_ToolOrder>
<DiffEngine_Disabled>true</DiffEngine_Disabled>
<DiffEngine_TargetOnLeft>false</DiffEngine_TargetOnLeft>
<DiffEngine_MaxInstances>5</DiffEngine_MaxInstances>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
11 changes: 11 additions & 0 deletions nvim-diff.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<DiffEngine_ToolOrder>Neovim</DiffEngine_ToolOrder>
<DiffEngine_Disabled>false</DiffEngine_Disabled>
<DiffEngine_TargetOnLeft>false</DiffEngine_TargetOnLeft>
<DiffEngine_MaxInstances>5</DiffEngine_MaxInstances>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
<ItemGroup>
<Compile Include="..\SharpSchema.Annotations\**\*.cs" Pack="true" PackagePath="content\SharpSchema\;contentFiles\cs\netstandard2.0\SharpSchema\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
namespace SharpSchema.Generator;
using System;

namespace SharpSchema.Annotations;

/// <summary>
/// Specifies the allowed accessibilities.
/// </summary>
[Flags]
public enum Accessibilities
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
enum AccessibilityMode
{
/// <summary>
/// Indicates public accessibility.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using Json.Schema;

namespace SharpSchema.Generator;

namespace SharpSchema.Annotations;

/// <summary>
/// Specifies the mode for dictionary keys.
/// </summary>
public enum DictionaryKeyMode
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
enum DictionaryKeyMode

{
/// <summary>
/// Loose mode allows any type of dictionary key,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
namespace SharpSchema.Generator;
namespace SharpSchema.Annotations;

/// <summary>
/// Specifies how enums are handled in the generated code.
/// </summary>
public enum EnumHandling
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
enum EnumMode
{
/// <summary>
/// Enum values are represented as strings.
Expand Down
42 changes: 42 additions & 0 deletions src/SharpSchema.Annotations/GeneratorOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using SharpSchema.Annotations;

#pragma warning disable IDE0130 // Namespace does not match folder structure
namespace SharpSchema.Generator;
#pragma warning restore IDE0130 // Namespace does not match folder structure

/// <summary>
/// Represents the options for the generator.
/// </summary>
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
record GeneratorOptions(
AccessibilityMode AccessibilityMode = AccessibilityMode.Public,
TraversalMode TraversalMode = TraversalMode.Bases,
DictionaryKeyMode DictionaryKeyMode = DictionaryKeyMode.Loose,
EnumMode EnumMode = EnumMode.String,
NumberMode NumberMode = NumberMode.StrictDefs)
{
/// <summary>
/// Initializes a new instance of the <see cref="GeneratorOptions"/> class by copying the values from another instance.
/// </summary>
/// <param name="options">The <see cref="GeneratorOptions"/> instance to copy values from.</param>
public GeneratorOptions(GeneratorOptions options)
{
if (options is null)
throw new System.ArgumentNullException(nameof(options));

Check warning on line 29 in src/SharpSchema.Annotations/GeneratorOptions.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/GeneratorOptions.cs#L29

Added line #L29 was not covered by tests

AccessibilityMode = options.AccessibilityMode;
TraversalMode = options.TraversalMode;
DictionaryKeyMode = options.DictionaryKeyMode;
EnumMode = options.EnumMode;
NumberMode = options.NumberMode;
}

/// <summary>
/// Gets the default generator options.
/// </summary>
public static GeneratorOptions Default { get; } = new GeneratorOptions();
}
29 changes: 29 additions & 0 deletions src/SharpSchema.Annotations/NumberMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace SharpSchema.Annotations;

/// <summary>
/// Specifies the mode for handling numeric types in the schema generation.
/// </summary>
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
enum NumberMode
{
/// <summary>
/// Uses the best matching type for numbers, adding range validation based on .NET type.
/// Numeric subschema placed in $defs, and referenced inline.
/// </summary>
StrictDefs,

/// <summary>
/// Uses the best matching type for numbers, adding range validation based on .NET type.
/// Numeric subschema are always placed inline.
/// </summary>
StrictInline,

/// <summary>
/// Uses the best matching json type for numbers, without adding range validation.
/// </summary>
JsonNative,
}
22 changes: 22 additions & 0 deletions src/SharpSchema.Annotations/SchemaAccessibilityModeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

#nullable enable

namespace SharpSchema.Annotations;

/// <summary>
/// Overrides the default traversal option for a given type.
/// </summary>
[AttributeUsage(SchemaAttribute.SupportedTypes)]
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
class SchemaAccessibilityModeAttribute(AccessibilityMode value) : SchemaAttribute

Check warning on line 16 in src/SharpSchema.Annotations/SchemaAccessibilityModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaAccessibilityModeAttribute.cs#L16

Added line #L16 was not covered by tests
{
/// <summary>
/// Gets the accessibility option for the type.
/// </summary>
public AccessibilityMode Value { get; } = value;

Check warning on line 21 in src/SharpSchema.Annotations/SchemaAccessibilityModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaAccessibilityModeAttribute.cs#L21

Added line #L21 was not covered by tests
}
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaConstAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
/// </summary>
[AttributeUsage(SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaConstAttribute(object value) : SchemaAttribute
public
#else
internal class SchemaConstAttribute(object value) : SchemaAttribute
internal
#endif
class SchemaConstAttribute(object value) : SchemaAttribute

Check warning on line 16 in src/SharpSchema.Annotations/SchemaConstAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaConstAttribute.cs#L16

Added line #L16 was not covered by tests
{
/// <summary>
/// Gets the constant value.
Expand Down
22 changes: 22 additions & 0 deletions src/SharpSchema.Annotations/SchemaDictionaryKeyModeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

#nullable enable

namespace SharpSchema.Annotations;

/// <summary>
/// Overrides the default dictionary key mode for a given type.
/// </summary>
[AttributeUsage(SchemaAttribute.SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
class SchemaDictionaryKeyModeAttribute(DictionaryKeyMode value) : SchemaAttribute

Check warning on line 16 in src/SharpSchema.Annotations/SchemaDictionaryKeyModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaDictionaryKeyModeAttribute.cs#L16

Added line #L16 was not covered by tests
{
/// <summary>
/// Gets the dictionary key mode.
/// </summary>
public DictionaryKeyMode Value { get; } = value;

Check warning on line 21 in src/SharpSchema.Annotations/SchemaDictionaryKeyModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaDictionaryKeyModeAttribute.cs#L21

Added line #L21 was not covered by tests
}
22 changes: 22 additions & 0 deletions src/SharpSchema.Annotations/SchemaEnumModeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

#nullable enable

namespace SharpSchema.Annotations;

/// <summary>
/// Overrides the default enum mode for a given type.
/// </summary>
[AttributeUsage(AttributeTargets.Enum)]
#if SHARPSCHEMA_ASSEMBLY
public
#else
internal
#endif
class SchemaEnumModeAttribute(EnumMode value) : SchemaAttribute

Check warning on line 16 in src/SharpSchema.Annotations/SchemaEnumModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaEnumModeAttribute.cs#L16

Added line #L16 was not covered by tests
{
/// <summary>
/// Gets the enum mode.
/// </summary>
public EnumMode Value { get; } = value;

Check warning on line 21 in src/SharpSchema.Annotations/SchemaEnumModeAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaEnumModeAttribute.cs#L21

Added line #L21 was not covered by tests
}
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaEnumValueAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaEnumValueAttribute(string value) : SchemaAttribute
public
#else
internal class SchemaEnumValueAttribute(string value) : SchemaAttribute
internal
#endif
class SchemaEnumValueAttribute(string value) : SchemaAttribute

Check warning on line 16 in src/SharpSchema.Annotations/SchemaEnumValueAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaEnumValueAttribute.cs#L16

Added line #L16 was not covered by tests
{
/// <summary>
/// Gets the value of the enum member.
Expand Down
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaFormatAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
/// </remarks>
[AttributeUsage(SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaFormatAttribute(string format) : SchemaAttribute
public
#else
internal class SchemaFormatAttribute(string format) : SchemaAttribute
internal
#endif
class SchemaFormatAttribute(string format) : SchemaAttribute

Check warning on line 19 in src/SharpSchema.Annotations/SchemaFormatAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/SharpSchema.Annotations/SchemaFormatAttribute.cs#L19

Added line #L19 was not covered by tests
{
/// <summary>
/// Gets the format of the schema.
Expand Down
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaIgnoreAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ namespace SharpSchema.Annotations;
/// </summary>
[AttributeUsage(SupportedTypes | SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaIgnoreAttribute : SchemaAttribute
public
#else
internal class SchemaIgnoreAttribute : SchemaAttribute
internal
#endif
class SchemaIgnoreAttribute : SchemaAttribute
{
}
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaItemsRangeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ namespace SharpSchema.Annotations;
/// </remarks>
[AttributeUsage(SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaItemsRangeAttribute : SchemaAttribute
public
#else
internal class SchemaItemsRangeAttribute : SchemaAttribute
internal
#endif
class SchemaItemsRangeAttribute : SchemaAttribute
{
/// <summary>
/// Gets or sets the minimum items allowed for the array.
Expand Down
5 changes: 3 additions & 2 deletions src/SharpSchema.Annotations/SchemaLengthRangeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ namespace SharpSchema.Annotations;
/// </remarks>
[AttributeUsage(SupportedMembers)]
#if SHARPSCHEMA_ASSEMBLY
public class SchemaLengthRangeAttribute : SchemaAttribute
public
#else
internal class SchemaLengthRangeAttribute : SchemaAttribute
internal
#endif
class SchemaLengthRangeAttribute : SchemaAttribute
{
/// <summary>
/// Gets or sets the minimum length allowed for the schema.
Expand Down
Loading