Skip to content

Commit df90a92

Browse files
Small cleanup
1 parent daca4d4 commit df90a92

5 files changed

Lines changed: 55 additions & 46 deletions

File tree

ReQuesty.Builder/CodeDOM/CodeProperty.cs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
11
namespace ReQuesty.Builder.CodeDOM;
2+
23
public enum CodePropertyKind
34
{
45
Custom,
56
RequestBuilder,
67
AdditionalData,
78
BackingStore,
89
UrlTemplate,
10+
911
/// <summary>
10-
/// The set of parameters to be carried over to the next request builder.
12+
/// The set of parameters to be carried over to the next request builder.
1113
/// </summary>
1214
PathParameters,
15+
1316
RequestAdapter,
17+
1418
/// <summary>
15-
/// The request body. Used when request parameters are wrapped in a class.
19+
/// The request body. Used when request parameters are wrapped in a class.
1620
/// </summary>
1721
RequestBody,
22+
1823
/// <summary>
19-
/// A request query parameter. Property of the query parameters class.
24+
/// A request query parameter. Property of the query parameters class.
2025
/// </summary>
2126
QueryParameter,
27+
2228
/// <summary>
23-
/// The request query parameters. Used when request parameters are wrapped in a class.
29+
/// The request query parameters. Used when request parameters are wrapped in a class.
2430
/// </summary>
2531
QueryParameters,
32+
2633
/// <summary>
27-
/// The request headers. Used when request parameters are wrapped in a class.
34+
/// The request headers. Used when request parameters are wrapped in a class.
2835
/// </summary>
2936
Headers,
37+
3038
/// <summary>
31-
/// The request middleware options. Used when request parameters are wrapped in a class.
39+
/// The request middleware options. Used when request parameters are wrapped in a class.
3240
/// </summary>
3341
Options,
42+
3443
/// <summary>
35-
/// The override for the error message for the error/exception type.
44+
/// The override for the error message for the error/exception type.
3645
/// </summary>
3746
ErrorMessageOverride
3847
}
3948

4049
public class CodeProperty : CodeTerminalWithKind<CodePropertyKind>, IDocumentedElement, IAlternativeName, ICloneable, IDeprecableElement, IAccessibleElement
4150
{
42-
public bool ReadOnly
43-
{
44-
get; set;
45-
}
51+
public bool ReadOnly { get; set; }
52+
4653
public AccessModifier Access { get; set; } = AccessModifier.Public;
54+
4755
public bool ExistsInBaseType => OriginalPropertyFromBaseType != null;
48-
public bool ExistsInExternalBaseType
49-
{
50-
get; set;
51-
}
52-
public CodeMethod? Getter
53-
{
54-
get; set;
55-
}
56-
public CodeMethod? Setter
57-
{
58-
get; set;
59-
}
56+
57+
public bool ExistsInExternalBaseType { get; set; }
58+
59+
public CodeMethod? Getter { get; set; }
60+
61+
public CodeMethod? Setter { get; set; }
62+
6063
public CodeMethod? GetterFromCurrentOrBaseType
6164
{
6265
get
@@ -74,6 +77,7 @@ public CodeMethod? GetterFromCurrentOrBaseType
7477
return default;
7578
}
7679
}
80+
7781
public CodeMethod? SetterFromCurrentOrBaseType
7882
{
7983
get
@@ -91,7 +95,8 @@ public CodeMethod? SetterFromCurrentOrBaseType
9195
return default;
9296
}
9397
}
94-
#nullable disable // the backing property is required
98+
99+
#nullable disable // the property is required
95100
private CodeTypeBase type;
96101
#nullable enable
97102
public required CodeTypeBase Type
@@ -103,28 +108,31 @@ public required CodeTypeBase Type
103108
type = value;
104109
}
105110
}
111+
106112
public string DefaultValue { get; set; } = string.Empty;
113+
107114
public CodeDocumentation Documentation { get; set; } = new();
115+
108116
/// <inheritdoc/>
109117
public string SerializationName { get; set; } = string.Empty;
118+
110119
public string NamePrefix { get; set; } = string.Empty;
120+
111121
/// <inheritdoc/>
112122
public bool IsNameEscaped
113123
{
114124
get => !string.IsNullOrEmpty(SerializationName);
115125
}
126+
116127
/// <inheritdoc/>
117128
public string WireName => IsNameEscaped ? SerializationName : Name;
118-
public CodeProperty? OriginalPropertyFromBaseType
119-
{
120-
get; set;
121-
}
122-
public DeprecationInformation? Deprecation
123-
{
124-
get; set;
125-
}
129+
130+
public CodeProperty? OriginalPropertyFromBaseType { get; set; }
131+
132+
public DeprecationInformation? Deprecation { get; set; }
133+
126134
/// <summary>
127-
/// Indicates if the property is the primary error message for the error/exception type.
135+
/// Indicates if the property is the primary error message for the error/exception type.
128136
/// </summary>
129137
public bool IsPrimaryErrorMessage
130138
{
@@ -150,8 +158,9 @@ public object Clone()
150158
NamePrefix = NamePrefix,
151159
OriginalPropertyFromBaseType = OriginalPropertyFromBaseType?.Clone() as CodeProperty,
152160
Deprecation = Deprecation,
153-
IsPrimaryErrorMessage = IsPrimaryErrorMessage,
161+
IsPrimaryErrorMessage = IsPrimaryErrorMessage
154162
};
163+
155164
return property;
156165
}
157166
}

ReQuesty.Builder/CodeDOM/CodeType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public override object Clone()
3838
// e.g. var y = x.Clone(); var z = y.Clone(); y.GenericTypeParameterValues.Add(value);
3939
// shouldn't modify x.GenericTypeParameterValues or z.GenericTypeParameterValues
4040
genericTypeParameterValues = [.. genericTypeParameterValues],
41+
IsNullable = IsNullable
4142
}.BaseClone<CodeType>(this, TypeDefinition is null || IsExternal);
4243
}
4344
public IEnumerable<CodeType> GenericTypeParameterValues

ReQuesty.Builder/CodeDOM/CodeTypeBase.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace ReQuesty.Builder.CodeDOM;
2+
23
public abstract class CodeTypeBase : CodeTerminal, ICloneable
34
{
45
public enum CodeTypeCollectionKind
@@ -9,30 +10,32 @@ public enum CodeTypeCollectionKind
910
}
1011

1112
/// <summary>
12-
/// Indicates that the type is a callback
13-
/// Example: ActionOf:true parameterA: (y: typeA) => void
14-
/// Example: ActionOf:false parameterA: typeA
13+
/// Indicates that the type is a callback
14+
/// Example: ActionOf:true parameterA: (y: typeA) => void
15+
/// Example: ActionOf:false parameterA: typeA
1516
/// </summary>
16-
public bool ActionOf
17-
{
18-
get; set;
19-
}
17+
public bool ActionOf { get; set; }
18+
2019
public bool IsNullable { get; set; }
20+
2121
public CodeTypeCollectionKind CollectionKind { get; set; } = CodeTypeCollectionKind.None;
22+
2223
public bool IsCollection
2324
{
2425
get
2526
{
2627
return CollectionKind != CodeTypeCollectionKind.None;
2728
}
2829
}
30+
2931
public bool IsArray
3032
{
3133
get
3234
{
3335
return CollectionKind == CodeTypeCollectionKind.Array;
3436
}
3537
}
38+
3639
protected virtual TChildType BaseClone<TChildType>(CodeTypeBase source, bool cloneName = true) where TChildType : CodeTypeBase
3740
{
3841
ArgumentNullException.ThrowIfNull(source);

ReQuesty.Builder/Writers/CSharp/CodePropertyWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public override void WriteCodeElement(CodeProperty codeElement, LanguageWriter w
1414
}
1515

1616
string propertyType = conventions.GetTypeString(codeElement.Type, codeElement);
17-
bool isNullable = codeElement.Type.IsNullable;
1817

18+
bool isNullable = codeElement.Type.IsNullable;
1919
if (isNullable && !propertyType.EndsWith('?'))
2020
{
2121
propertyType += "?";

next.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)