Skip to content

Commit 8345e45

Browse files
Json schema generator (#45)
* add json schema generator * add props & targets, cli tool * fix incorrect type check in attribute factory implement enum hints * update pipeline * undo namespace cleanup * fix formatting * move from InternalsVisibleTo to public types
1 parent 6163f13 commit 8345e45

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<AutoIncrementedAssemblyRevision>1473</AutoIncrementedAssemblyRevision>
3+
<AutoIncrementedAssemblyRevision>1474</AutoIncrementedAssemblyRevision>
44
</PropertyGroup>
55

66
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">

JsonSchemaGenerator.Cli/JsonSchemaGenerator.Cli.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
<Compile Include="..\JsonSchemaGenerator\Attributes\GeneratedJsonSchemaAttribute.cs" Link="GeneratedJsonSchemaAttribute.cs" />
1313
</ItemGroup>
1414

15-
<ItemGroup>
16-
<InternalsVisibleTo Include="RhoMicro.CodeAnalysis.JsonSchemaGenerator.Tests.1.0.0" />
17-
</ItemGroup>
18-
1915
<ItemGroup>
2016
<PackageReference Include="IKVM.Core.MSBuild" Version="0.1.103">
2117
<PrivateAssets>all</PrivateAssets>

JsonSchemaGenerator.Cli/MainService.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,46 @@
1010
using Microsoft.Extensions.Hosting;
1111
using Microsoft.Extensions.Logging;
1212

13-
internal class MainService(Settings settings, ILogger logger, IHostApplicationLifetime lifetime) : BackgroundService
13+
/// <summary>
14+
/// Inspects an assembly for <see cref="GeneratedJsonSchemaAttribute"/>
15+
/// annotations and emits the json schemata provided by them to a directory.
16+
/// </summary>
17+
/// <param name="settings">
18+
/// The object providing settings to the service.
19+
/// </param>
20+
/// <param name="logger">
21+
/// The logger to use when logging progress.
22+
/// </param>
23+
/// <param name="lifetime">
24+
/// The lifetime of the application hosting the service. When done, the service
25+
/// will stop the application via this object.
26+
/// </param>
27+
public sealed class MainService(Settings settings, ILogger logger, IHostApplicationLifetime lifetime) : BackgroundService
1428
{
1529
private static readonly JsonSerializerOptions _schemaSerializationOptions = new(JsonSerializerDefaults.General)
1630
{
1731
WriteIndented = true,
1832
PropertyNamingPolicy = null
1933
};
20-
34+
/// <summary>
35+
/// Creates a new instance of the service.
36+
/// </summary>
37+
/// <param name="settings">
38+
/// The object providing settings to the service.
39+
/// </param>
40+
/// <param name="loggerFactory">
41+
/// The factory to use when creating a logger to use when logging progress.
42+
/// </param>
43+
/// <param name="lifetime">
44+
/// The lifetime of the application hosting the service. When done, the
45+
/// service will stop the application via this object.
46+
/// </param>
47+
/// <returns>
48+
/// A new service instance.
49+
/// </returns>
2150
public static MainService Create(Settings settings, ILoggerFactory loggerFactory, IHostApplicationLifetime lifetime) =>
2251
new(settings, loggerFactory.CreateLogger<MainService>(), lifetime);
23-
52+
/// <inheritdoc/>
2453
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2554
{
2655
stoppingToken.ThrowIfCancellationRequested();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
namespace RhoMicro.CodeAnalysis.JsonSchemaGenerator.Cli;
22
using System;
33

4-
sealed class Settings
4+
/// <summary>
5+
/// Provides settings for the <see cref="MainService"/>.
6+
/// </summary>
7+
public sealed class Settings
58
{
9+
/// <summary>
10+
/// Gets or sets the path of the assembly to emit generated json schemata for.
11+
/// </summary>
612
public required String AssemblyPath { get; set; }
13+
/// <summary>
14+
/// Gets or sets the path to output generated schemata into.
15+
/// </summary>
716
public required String SchemataPath { get; set; }
817
}

0 commit comments

Comments
 (0)