Skip to content

Commit 79789f1

Browse files
authored
Merge pull request #262 from Turnerj/source-generator-tweaks
Source generator tweaks
2 parents 5c222d6 + a0a2776 commit 79789f1

15 files changed

+90
-108
lines changed

Tools/Schema.NET.Tool/CustomOverrides/AddQueryInputPropertyToSearchAction.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ public void Override(GeneratorSchemaClass c)
2323
throw new ArgumentNullException(nameof(c));
2424
}
2525

26-
var property = new GeneratorSchemaProperty(c, "query-input", "QueryInput")
27-
{
28-
Description = "Gets or sets the query input search parameter.",
29-
};
26+
var property = new GeneratorSchemaProperty(c, "query-input", "QueryInput", "Gets or sets the query input search parameter.");
3027
property.Types.AddRange(
3128
new List<GeneratorSchemaPropertyType>()
3229
{

Tools/Schema.NET.Tool/CustomOverrides/RenameEventProperty.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public void Override(GeneratorSchemaClass c)
2828
.First(x => string.Equals(x.Name, "Event", StringComparison.OrdinalIgnoreCase));
2929
c.Properties.Remove(eventProperty);
3030

31-
var updatedProperty = new GeneratorSchemaProperty(c, eventProperty.JsonName, "Events")
31+
var updatedProperty = new GeneratorSchemaProperty(c, eventProperty.JsonName, "Events", eventProperty.Description)
3232
{
33-
Description = eventProperty.Description,
3433
Order = eventProperty.Order,
3534
};
3635
updatedProperty.Types.AddRange(eventProperty.Types);

Tools/Schema.NET.Tool/GeneratorModels/GeneratorSchemaClass.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ namespace Schema.NET.Tool.GeneratorModels
77
using Schema.NET.Tool.Constants;
88

99
[DebuggerDisplay("{Name}")]
10-
#pragma warning disable CA1716 // Identifiers should not match keywords
1110
public class GeneratorSchemaClass : GeneratorSchemaObject
12-
#pragma warning restore CA1716 // Identifiers should not match keywords
1311
{
1412
public GeneratorSchemaClass(Uri id)
15-
: base(string.Empty, string.Empty) => this.Id = id;
13+
: this(layer: string.Empty, id, name: string.Empty, description: string.Empty)
14+
{
15+
}
1616

17-
public GeneratorSchemaClass(Uri id, string layer, string name)
18-
: base(layer, name) => this.Id = id;
17+
public GeneratorSchemaClass(string layer, Uri id, string name, string description, bool isCombined = false)
18+
: base(layer, name, description)
19+
{
20+
this.Id = id;
21+
this.IsCombined = isCombined;
22+
}
1923

2024
public IEnumerable<GeneratorSchemaClass> Ancestors => EnumerableExtensions
2125
.Traverse(this, x => x.Parents)
@@ -29,15 +33,13 @@ public GeneratorSchemaClass(Uri id, string layer, string name)
2933
.Traverse(this, x => x.Children)
3034
.Where(x => x != this);
3135

32-
public string? Description { get; set; }
33-
3436
public Uri Id { get; }
3537

3638
public bool IsArchived => EnumerableExtensions
3739
.Traverse(this, x => x.Parents)
3840
.Any(x => string.Equals(x.Layer, LayerName.Archived, StringComparison.Ordinal));
3941

40-
public bool IsCombined { get; set; }
42+
public bool IsCombined { get; }
4143

4244
public IEnumerable<GeneratorSchemaProperty> DeclaredProperties
4345
{

Tools/Schema.NET.Tool/GeneratorModels/GeneratorSchemaEnumeration.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ namespace Schema.NET.Tool.GeneratorModels
44
using System.Diagnostics;
55

66
[DebuggerDisplay("{Name}")]
7-
#pragma warning disable CA1724 // Identifiers should conflict with namespaces
87
public class GeneratorSchemaEnumeration : GeneratorSchemaObject
9-
#pragma warning restore CA1724 // Identifiers should conflict with namespaces
108
{
11-
public GeneratorSchemaEnumeration(string layer, string name)
12-
: base(layer, name)
9+
public GeneratorSchemaEnumeration(string layer, string name, string description)
10+
: base(layer, name, description)
1311
{
1412
}
1513

16-
public string? Description { get; set; }
17-
1814
public List<GeneratorSchemaEnumerationValue> Values { get; } = new List<GeneratorSchemaEnumerationValue>();
1915
}
2016
}

Tools/Schema.NET.Tool/GeneratorModels/GeneratorSchemaEnumerationValue.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ namespace Schema.NET.Tool.GeneratorModels
66
[DebuggerDisplay("{Name}")]
77
public class GeneratorSchemaEnumerationValue
88
{
9-
public GeneratorSchemaEnumerationValue(string name, Uri uri)
9+
public GeneratorSchemaEnumerationValue(string name, Uri uri, string description)
1010
{
1111
this.Name = name;
1212
this.Uri = uri;
13+
this.Description = description;
1314
}
1415

15-
public string? Description { get; set; }
16+
public string Description { get; }
1617

1718
public string Name { get; }
1819

Tools/Schema.NET.Tool/GeneratorModels/GeneratorSchemaObject.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ namespace Schema.NET.Tool.GeneratorModels
22
{
33
public class GeneratorSchemaObject
44
{
5-
public GeneratorSchemaObject(string layer, string name)
5+
public GeneratorSchemaObject(string layer, string name, string description)
66
{
77
this.Layer = layer;
88
this.Name = name;
9+
this.Description = description;
910
}
1011

12+
public string Description { get; }
13+
1114
public string Layer { get; }
1215

1316
public string Name { get; }

Tools/Schema.NET.Tool/GeneratorModels/GeneratorSchemaProperty.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ namespace Schema.NET.Tool.GeneratorModels
66
using System.Linq;
77

88
[DebuggerDisplay("{Name}")]
9-
#pragma warning disable CA1716 // Identifiers should not match keywords
109
public class GeneratorSchemaProperty
11-
#pragma warning restore CA1716 // Identifiers should not match keywords
1210
{
13-
public GeneratorSchemaProperty(GeneratorSchemaClass @class, string jsonName, string name)
11+
public GeneratorSchemaProperty(GeneratorSchemaClass @class, string jsonName, string name, string description)
1412
{
1513
this.Class = @class;
1614
this.JsonName = jsonName;
1715
this.Name = name;
16+
this.Description = description;
1817
}
1918

2019
public GeneratorSchemaClass Class { get; }
2120

22-
public string? Description { get; set; }
21+
public string Description { get; }
2322

2423
public string JsonName { get; }
2524

@@ -66,9 +65,8 @@ public string JsonConverterType
6665

6766
public GeneratorSchemaProperty Clone(GeneratorSchemaClass context)
6867
{
69-
var property = new GeneratorSchemaProperty(context, this.JsonName, this.Name)
68+
var property = new GeneratorSchemaProperty(context, this.JsonName, this.Name, this.Description)
7069
{
71-
Description = this.Description,
7270
Order = this.Order,
7371
};
7472
property.Types.AddRange(this.Types.Select(x => x.Clone()));

Tools/Schema.NET.Tool/Models/SchemaClass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public class SchemaClass : SchemaObject
99
{
1010
private static readonly Uri EnumerationId = new("https://schema.org/Enumeration");
1111

12-
public SchemaClass(Uri id, string label, string layer)
13-
: base(id, label, layer)
12+
public SchemaClass(string layer, Uri id, string label, string comment)
13+
: base(layer, id, label, comment)
1414
{
1515
}
1616

Tools/Schema.NET.Tool/Models/SchemaEnumerationValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ namespace Schema.NET.Tool.Models
44

55
public class SchemaEnumerationValue : SchemaObject
66
{
7-
public SchemaEnumerationValue(Uri id, string label, string layer)
8-
: base(id, label, layer)
7+
public SchemaEnumerationValue(string layer, Uri id, string label, string comment)
8+
: base(layer, id, label, comment)
99
{
1010
}
1111
}

Tools/Schema.NET.Tool/Models/SchemaObject.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@ public abstract class SchemaObject
3030
"PronounceableText",
3131
};
3232

33-
public SchemaObject(Uri id, string label, string layer)
33+
public SchemaObject(string layer, Uri id, string label, string comment)
3434
{
35+
this.Layer = layer;
3536
this.Id = id;
3637
this.Label = label;
37-
this.Layer = layer;
38+
this.Comment = comment;
3839
}
3940

41+
public string Comment { get; }
42+
4043
public Uri Id { get; }
4144

4245
public string Label { get; }
4346

4447
public string Layer { get; }
4548

46-
public string? Comment { get; set; }
47-
4849
public List<string> Types { get; } = new List<string>();
4950

5051
public virtual bool IsArchived => string.Equals(this.Layer, LayerName.Archived, StringComparison.OrdinalIgnoreCase);

0 commit comments

Comments
 (0)