|
1 | 1 | using System.Collections.Immutable;
|
2 | 2 | using Microsoft.CodeAnalysis;
|
3 | 3 | using Scriban;
|
4 |
| - |
| 4 | +// ReSharper disable InconsistentNaming |
5 | 5 | namespace GitVersion;
|
6 | 6 |
|
7 | 7 | [Generator(LanguageNames.CSharp)]
|
@@ -83,11 +83,14 @@ private static void GenerateSourceCode(SourceProductionContext context, Immutabl
|
83 | 83 | var commandAttribute = classSymbol.GetAttributeData(CommandAttributeFullName) ?? classSymbol.GetAttributeData(CommandAttributeGenericFullName);
|
84 | 84 | if (commandAttribute is null) return null;
|
85 | 85 |
|
86 |
| - var ctorArguments = commandAttribute.ConstructorArguments.ToImmutableArray(); |
| 86 | + var ctorArguments = commandAttribute.ConstructorArguments; |
87 | 87 |
|
88 | 88 | var name = Convert.ToString(ctorArguments[0].Value);
|
89 | 89 | var description = Convert.ToString(ctorArguments[1].Value);
|
90 | 90 |
|
| 91 | + ArgumentNullException.ThrowIfNull(name); |
| 92 | + ArgumentNullException.ThrowIfNull(description); |
| 93 | + |
91 | 94 | ITypeSymbol? parentCommandType = null;
|
92 | 95 | if (commandAttribute.AttributeClass != null && commandAttribute.AttributeClass.TypeArguments.Any())
|
93 | 96 | {
|
@@ -122,14 +125,16 @@ where optionAttribute is not null
|
122 | 125 | }
|
123 | 126 | private static SettingsPropertyInfo MapToPropertyInfo(IPropertySymbol propertySymbol, AttributeData attribute)
|
124 | 127 | {
|
125 |
| - var ctorArguments = attribute.ConstructorArguments.ToImmutableArray(); |
| 128 | + var ctorArguments = attribute.ConstructorArguments; |
126 | 129 |
|
127 | 130 | var aliases = (ctorArguments[0].Kind == TypedConstantKind.Array
|
128 | 131 | ? ctorArguments[0].Values.Select(x => Convert.ToString(x.Value)).ToArray()
|
129 |
| - : new[] { Convert.ToString(ctorArguments[0].Value) }).Select(x => $@"""{x.Trim()}"""); |
| 132 | + : new[] { Convert.ToString(ctorArguments[0].Value) }).Select(x => $@"""{x?.Trim()}"""); |
130 | 133 |
|
131 | 134 | var alias = string.Join(", ", aliases);
|
132 | 135 | var description = Convert.ToString(ctorArguments[1].Value);
|
| 136 | + ArgumentNullException.ThrowIfNull(description); |
| 137 | + |
133 | 138 | var isRequired = propertySymbol.Type.NullableAnnotation == NullableAnnotation.NotAnnotated;
|
134 | 139 | return new SettingsPropertyInfo
|
135 | 140 | {
|
|
0 commit comments