Skip to content

Commit

Permalink
remove System.Text.Json from GitVersion.Core
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Mar 21, 2024
1 parent dacd364 commit e88f431
Show file tree
Hide file tree
Showing 33 changed files with 129 additions and 94 deletions.
32 changes: 21 additions & 11 deletions schemas/6.0/GitVersion.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,8 @@
"pre-release-weight": {
"$ref": "#/$defs/nullableOfInt32"
},
"prevent-increment-of-merged-branch-version": {
"$ref": "#/$defs/nullableOfBoolean2"
},
"prevent-increment-when-current-commit-tagged": {
"$ref": "#/$defs/nullableOfBoolean3"
"prevent-increment": {
"$ref": "#/$defs/preventIncrementConfiguration"
},
"regex": {
"$ref": "#/$defs/string2"
Expand Down Expand Up @@ -186,6 +183,7 @@
"description": "Specifies which version strategies (one or more) will be used to determine the next version. Following values are available: 'ConfiguredNextVersion', 'MergeMessage', 'TaggedCommit', 'TrackReleaseBranches', 'VersionInBranchName' and 'TrunkBased'.",
"enum": [
"None",
"Fallback",
"ConfiguredNextVersion",
"MergeMessage",
"TaggedCommit",
Expand Down Expand Up @@ -231,11 +229,8 @@
"pre-release-weight": {
"$ref": "#/$defs/nullableOfInt32"
},
"prevent-increment-of-merged-branch-version": {
"$ref": "#/$defs/nullableOfBoolean2"
},
"prevent-increment-when-current-commit-tagged": {
"$ref": "#/$defs/nullableOfBoolean3"
"prevent-increment": {
"$ref": "#/$defs/preventIncrementConfiguration"
},
"regex": {
"$ref": "#/$defs/string2"
Expand Down Expand Up @@ -319,8 +314,23 @@
"null"
]
},
"preventIncrementConfiguration": {
"description": "The prevent increment configuration section.",
"type": "object",
"properties": {
"of-merged-branch": {
"$ref": "#/$defs/nullableOfBoolean2"
},
"when-branch-merged": {
"$ref": "#/$defs/nullableOfBoolean2"
},
"when-current-commit-tagged": {
"$ref": "#/$defs/nullableOfBoolean3"
}
}
},
"nullableOfBoolean2": {
"description": "Prevent increment of merged branch version.",
"description": "Prevent increment when branch merged.",
"type": [
"boolean",
"null"
Expand Down
1 change: 0 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json"/>
<PackageReference Include="Roslynator.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using GitVersion.Configuration;

namespace GitVersion.Attributes;
namespace GitVersion.Configuration.Attributes;

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class JsonPropertyDefaultAttribute : JsonAttribute
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#if GITVERSION_CONFIGURATION
namespace GitVersion.Configuration.Attributes;
#elif GITVERSION_OUTPUT
namespace GitVersion.Output.Attributes;
#endif

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class JsonPropertyDescriptionAttribute(string description) : JsonAttribute
{
/// <summary>
/// The description of the property.
/// </summary>
public string Description { get; } = description;
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
namespace GitVersion.Attributes;
namespace GitVersion.Configuration.Attributes;

/// <summary>
/// <para>The <c>format</c> keyword allows for basic semantic identification of certain kinds of string values that are commonly used. For example, because JSON doesn't have a "DateTime" type, dates need to be encoded as strings. <c>format</c> allows the schema author to indicate that the string value should be interpreted as a date. By default, <c>format</c> is just an annotation and does not effect validation.</para>
/// <para>Optionally, validator implementations can [...] enable <c>format</c> to function as an assertion rather than just an annotation.</para>
/// <see href="https://json-schema.org/understanding-json-schema/reference/string#format"/>
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class JsonPropertyFormatAttribute : JsonAttribute
public sealed class JsonPropertyFormatAttribute(Format format) : JsonAttribute
{
/// <summary>
/// Initializes a new instance of <see cref="JsonPropertyFormatAttribute"/> with the specified format for string-encoded property values. JSON validators may use this annotation to constrain properties to certain pre-define, string-encoded types.
/// </summary>
/// <param name="format">The string format.</param>
public JsonPropertyFormatAttribute(Format format) => Format = format;

/// <summary>
/// The format of the string.
/// </summary>
public Format Format { get; }
public Format Format { get; } = format;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Attributes;
using GitVersion.Configuration.Attributes;
using GitVersion.Extensions;
using GitVersion.VersionCalculation;

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Configuration.SupportedWorkflows;
using GitVersion.Configuration.Workflows;
using GitVersion.Extensions;
using Microsoft.Extensions.Options;
using YamlDotNet.Core;
Expand Down
12 changes: 9 additions & 3 deletions src/GitVersion.Configuration/GitVersion.Configuration.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<DefineConstants>GITVERSION_CONFIGURATION</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GitVersion.Core\GitVersion.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json"/>
<PackageReference Include="YamlDotNet" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="SupportedWorkflows\GitFlow\v1.yml" />
<EmbeddedResource Include="SupportedWorkflows\GitHubFlow\v1.yml" />
<EmbeddedResource Include="SupportedWorkflows\TrunkBased\v1.yml" />
<EmbeddedResource Include="Workflows\GitFlow\v1.yml" />
<EmbeddedResource Include="Workflows\GitHubFlow\v1.yml" />
<EmbeddedResource Include="Workflows\TrunkBased\v1.yml" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/GitVersionConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Text.RegularExpressions;
using GitVersion.Attributes;
using GitVersion.Configuration.Attributes;
using GitVersion.Extensions;
using GitVersion.VersionCalculation;
using static GitVersion.Configuration.ConfigurationConstants;
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/IgnoreConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Attributes;
using GitVersion.Configuration.Attributes;

namespace GitVersion.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Attributes;
using GitVersion.Configuration.Attributes;

namespace GitVersion.Configuration;

Expand Down
34 changes: 34 additions & 0 deletions src/GitVersion.Configuration/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
#nullable enable
GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Date = 0 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.DateTime = 1 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Duration = 2 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Email = 3 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Hostname = 4 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.IdnEmail = 5 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.IdnHostname = 6 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Ipv4 = 7 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Ipv6 = 8 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Iri = 9 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.IriReference = 10 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.JsonPointer = 11 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Regex = 12 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.RelativeJsonPointer = 13 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Time = 14 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Uri = 15 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.UriReference = 16 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.UriTemplate = 17 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.Format.Uuid = 18 -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(bool value) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.Configuration.AssemblyFileVersioningScheme value) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.Configuration.AssemblyVersioningScheme value) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.SemanticVersionFormat value) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(object? boxedValue) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(string? value) -> void
GitVersion.Configuration.Attributes.JsonPropertyDefaultAttribute.Value.get -> string!
GitVersion.Configuration.Attributes.JsonPropertyDescriptionAttribute
GitVersion.Configuration.Attributes.JsonPropertyDescriptionAttribute.Description.get -> string!
GitVersion.Configuration.Attributes.JsonPropertyDescriptionAttribute.JsonPropertyDescriptionAttribute(string! description) -> void
GitVersion.Configuration.Attributes.JsonPropertyFormatAttribute
GitVersion.Configuration.Attributes.JsonPropertyFormatAttribute.Format.get -> GitVersion.Configuration.Attributes.Format
GitVersion.Configuration.Attributes.JsonPropertyFormatAttribute.JsonPropertyFormatAttribute(GitVersion.Configuration.Attributes.Format format) -> void
GitVersion.Configuration.ConfigurationException
GitVersion.Configuration.ConfigurationException.ConfigurationException() -> void
GitVersion.Configuration.ConfigurationException.ConfigurationException(string! message, System.Exception! innerException) -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GitVersion.Extensions;

namespace GitVersion.Configuration.SupportedWorkflows;
namespace GitVersion.Configuration.Workflows;

internal static class WorkflowManager
{
Expand Down

This file was deleted.

34 changes: 0 additions & 34 deletions src/GitVersion.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,6 @@ GitVersion.AssemblySettingsInfo.EnsureAssemblyInfo -> bool
GitVersion.AssemblySettingsInfo.Files -> System.Collections.Generic.ISet<string!>!
GitVersion.AssemblySettingsInfo.UpdateAssemblyInfo -> bool
GitVersion.AssemblySettingsInfo.UpdateProjectFiles -> bool
GitVersion.Attributes.Format
GitVersion.Attributes.Format.Date = 0 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.DateTime = 1 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Duration = 2 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Email = 3 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Hostname = 4 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.IdnEmail = 5 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.IdnHostname = 6 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Ipv4 = 7 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Ipv6 = 8 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Iri = 9 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.IriReference = 10 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.JsonPointer = 11 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Regex = 12 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.RelativeJsonPointer = 13 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Time = 14 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Uri = 15 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.UriReference = 16 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.UriTemplate = 17 -> GitVersion.Attributes.Format
GitVersion.Attributes.Format.Uuid = 18 -> GitVersion.Attributes.Format
GitVersion.Attributes.JsonPropertyDefaultAttribute
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.Configuration.AssemblyFileVersioningScheme value) -> void
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.Configuration.AssemblyVersioningScheme value) -> void
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(object? boxedValue) -> void
GitVersion.Attributes.JsonPropertyDefaultAttribute.Value.get -> string!
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(bool value) -> void
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(string? value) -> void
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.SemanticVersionFormat value) -> void
GitVersion.Attributes.JsonPropertyDescriptionAttribute
GitVersion.Attributes.JsonPropertyDescriptionAttribute.Description.get -> string!
GitVersion.Attributes.JsonPropertyDescriptionAttribute.JsonPropertyDescriptionAttribute(string! description) -> void
GitVersion.Attributes.JsonPropertyFormatAttribute
GitVersion.Attributes.JsonPropertyFormatAttribute.Format.get -> GitVersion.Attributes.Format
GitVersion.Attributes.JsonPropertyFormatAttribute.JsonPropertyFormatAttribute(GitVersion.Attributes.Format format) -> void
GitVersion.BugException
GitVersion.BugException.BugException() -> void
GitVersion.BugException.BugException(string! message) -> void
Expand Down
13 changes: 13 additions & 0 deletions src/GitVersion.Output/GitVersion.Output.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<DefineConstants>GITVERSION_OUTPUT</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GitVersion.Core\GitVersion.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json"/>
</ItemGroup>

<ItemGroup>
<Compile Remove="*\AddFormats\**\*.*" />
<Compile Remove="*\Templates\**\*.*" />
<Compile Include="..\GitVersion.Configuration\Attributes\JsonPropertyDescriptionAttribute.cs">
<Link>Attributes\JsonPropertyDescriptionAttribute.cs</Link>
</Compile>
<EmbeddedResource Include="*\AddFormats\**\*.*" />
<EmbeddedResource Include="*\Templates\**\*.*" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/GitVersion.Output/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ GitVersion.IGitVersionOutputTool.GenerateGitVersionInformation(GitVersion.Output
GitVersion.IGitVersionOutputTool.OutputVariables(GitVersion.OutputVariables.GitVersionVariables! variables, bool updateBuildNumber) -> void
GitVersion.IGitVersionOutputTool.UpdateAssemblyInfo(GitVersion.OutputVariables.GitVersionVariables! variables) -> void
GitVersion.IGitVersionOutputTool.UpdateWixVersionFile(GitVersion.OutputVariables.GitVersionVariables! variables) -> void
GitVersion.Output.Attributes.JsonPropertyDescriptionAttribute
GitVersion.Output.Attributes.JsonPropertyDescriptionAttribute.Description.get -> string!
GitVersion.Output.Attributes.JsonPropertyDescriptionAttribute.JsonPropertyDescriptionAttribute(string! description) -> void
GitVersion.Output.GitVersionOutputModule
GitVersion.Output.GitVersionOutputModule.GitVersionOutputModule() -> void
GitVersion.Output.GitVersionOutputModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Attributes;
using GitVersion.Output.Attributes;

namespace GitVersion.OutputVariables;

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Schema/DefaultAttributeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitVersion.Attributes;
using GitVersion.Configuration.Attributes;
using Json.Schema.Generation;
using Json.Schema.Generation.Intents;

Expand Down
19 changes: 16 additions & 3 deletions src/GitVersion.Schema/DescriptionAttributeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
using GitVersion.Attributes;
using Json.Schema.Generation;
using Json.Schema.Generation.Intents;

using ConfigurationDescriptionAttribute = GitVersion.Configuration.Attributes.JsonPropertyDescriptionAttribute;
using OutputDescriptionAttribute = GitVersion.Output.Attributes.JsonPropertyDescriptionAttribute;

namespace GitVersion.Schema;

internal class DescriptionAttributeHandler : IAttributeHandler<JsonPropertyDescriptionAttribute>
internal class DescriptionAttributeHandler1 : IAttributeHandler<ConfigurationDescriptionAttribute>
{
void IAttributeHandler.AddConstraints(SchemaGenerationContextBase context, Attribute attribute)
{
if (attribute is ConfigurationDescriptionAttribute descriptionAttribute)
{
context.Intents.Insert(0, new DescriptionIntent(descriptionAttribute.Description));
}
}
}

internal class DescriptionAttributeHandler2 : IAttributeHandler<OutputDescriptionAttribute>
{
void IAttributeHandler.AddConstraints(SchemaGenerationContextBase context, Attribute attribute)
{
if (attribute is JsonPropertyDescriptionAttribute descriptionAttribute)
if (attribute is OutputDescriptionAttribute descriptionAttribute)
{
context.Intents.Insert(0, new DescriptionIntent(descriptionAttribute.Description));
}
Expand Down
8 changes: 4 additions & 4 deletions src/GitVersion.Schema/FormatAttributeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using GitVersion.Attributes;
using Json.Schema;
using Json.Schema.Generation;
using Json.Schema.Generation.Intents;
using Format = GitVersion.Attributes.Format;
using Format = GitVersion.Configuration.Attributes.Format;
using FormatAttribute = GitVersion.Configuration.Attributes.JsonPropertyFormatAttribute;

namespace GitVersion.Schema;
internal class FormatAttributeHandler : IAttributeHandler<JsonPropertyFormatAttribute>
internal class FormatAttributeHandler : IAttributeHandler<FormatAttribute>
{
void IAttributeHandler.AddConstraints(SchemaGenerationContextBase context, Attribute attribute)
{
if (attribute is JsonPropertyFormatAttribute formatAttribute)
if (attribute is FormatAttribute formatAttribute)
{
Json.Schema.Format? format = formatAttribute.Format switch
{
Expand Down
5 changes: 3 additions & 2 deletions src/GitVersion.Schema/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
};

AttributeHandler.AddHandler<DefaultAttributeHandler>();
AttributeHandler.AddHandler<DescriptionAttributeHandler>();
AttributeHandler.AddHandler<DescriptionAttributeHandler1>();
AttributeHandler.AddHandler<DescriptionAttributeHandler2>();
AttributeHandler.AddHandler<FormatAttributeHandler>();

var builder = new JsonSchemaBuilder();
Expand All @@ -33,7 +34,7 @@

configuration.PropertyNameResolver = PropertyNameResolvers.AsDeclared;

builder = new JsonSchemaBuilder();
builder = new();
builder.Schema("http://json-schema.org/draft-07/schema#");
builder.Id($"https://gitversion.net/schemas/{schemaVersion}/GitVersion.json");
builder.Title("GitVersion version variables output");
Expand Down

0 comments on commit e88f431

Please sign in to comment.