Skip to content

Commit ea8c839

Browse files
committed
add lesson for generation
1 parent 5aadce3 commit ea8c839

File tree

5 files changed

+271
-29
lines changed

5 files changed

+271
-29
lines changed

LearnJsonEverything.Tests/ProvidedSolutionTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public void Schema(LessonData lesson)
4848
foreach (var result in results)
4949
{
5050
Console.WriteLine(result);
51+
}
52+
53+
foreach (var result in results)
54+
{
5155
Assert.That(result, Does.StartWith(Iconography.SuccessIcon));
5256
}
5357
}

LearnJsonEverything.Tests/ReferenceLoader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System.Reflection;
12
using System.Text.Json.Nodes;
23
using Json.Schema;
4+
using Json.Schema.Generation;
35
using Microsoft.CodeAnalysis;
46
using Yaml2JsonNode;
57

@@ -18,6 +20,7 @@ static ReferenceLoader()
1820
SchemaRegistry.Global.Fetch = null!;
1921
_ = YamlSerializer.Parse(string.Empty);
2022
_ = new NullRunner();
23+
_ = typeof(NullRunner).GetCustomAttributes<MinimumAttribute>();
2124
}
2225

2326
public static MetadataReference[] Load()

LearnJsonEverything/LearnJsonEverything.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
1616
<PackageReference Include="BlazorMonaco" Version="3.2.0" />
1717
<PackageReference Include="JsonSchema.Net" Version="7.0.4" />
18+
<PackageReference Include="JsonSchema.Net.Generation" Version="4.3.0.2" />
1819
<PackageReference Include="Markdig" Version="0.37.0" />
1920
<PackageReference Include="Markdig.SyntaxHighlighting" Version="1.1.7" />
2021
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" />

LearnJsonEverything/Services/CompilationHelpers.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using Microsoft.CodeAnalysis;
1+
using Json.Schema.Generation.XmlComments;
2+
using Microsoft.CodeAnalysis;
23
using Microsoft.CodeAnalysis.CSharp;
34
using System.Reflection;
5+
using Json.Schema.Generation;
46
using static LearnJsonEverything.Services.Iconography;
57

68
namespace LearnJsonEverything.Services;
@@ -15,6 +17,7 @@ public static class CompilationHelpers
1517
"Json.More",
1618
"JsonPointer.Net",
1719
"JsonSchema.Net",
20+
"JsonSchema.Net.Generation",
1821
"LearnJsonEverything.Template",
1922
"Yaml2JsonNode",
2023
];
@@ -105,10 +108,18 @@ public static (ILessonRunner<T>?, string[]) GetRunner<T>(LessonData lesson)
105108
#pragma warning disable IL2026
106109
#pragma warning disable IL2072
107110
#pragma warning disable IL2070
111+
#pragma warning disable CS0618
108112
var assembly = Assembly.Load(dllStream.ToArray());
109113

114+
xmlStream.Position = 0;
115+
using var reader = new StreamReader(xmlStream);
116+
var xmlContent = reader.ReadToEnd();
117+
DocXmlReader.ExplicitlyAddAssemblyXml(assembly, xmlContent);
118+
119+
110120
var type = assembly.DefinedTypes.Single(x => !x.IsInterface && x.ImplementedInterfaces.Contains(typeof(ILessonRunner<T>)));
111121
var runner = (ILessonRunner<T>)Activator.CreateInstance(type)!;
122+
#pragma warning restore CS0618
112123
#pragma warning restore IL2070
113124
#pragma warning restore IL2072
114125
#pragma warning restore IL2026

0 commit comments

Comments
 (0)