Skip to content

Commit

Permalink
switch
Browse files Browse the repository at this point in the history
  • Loading branch information
omsmith committed Nov 21, 2023
1 parent 6bf3514 commit 3396d62
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ internal sealed class FeatureDefinitionAnalyzer : DiagnosticAnalyzer {

public const string FeatureDefinitionFullName = "D2L.LP.LaunchDarkly.FeatureDefinition`1";

private static readonly ImmutableHashSet<SpecialType> ValidTypes = ImmutableHashSet.Create(
SpecialType.System_Int32,
SpecialType.System_Boolean,
SpecialType.System_String,
SpecialType.System_Single
);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(
Diagnostics.InvalidLaunchDarklyFeatureDefinition
);
Expand Down Expand Up @@ -67,7 +60,7 @@ INamedTypeSymbol featureDefinitionType
return;
}

if( ValidTypes.Contains( namedValueType.SpecialType ) ) {
if( IsValidType( namedValueType ) ) {
return;
}

Expand All @@ -79,5 +72,13 @@ INamedTypeSymbol featureDefinitionType
messageArgs: new[] { namedValueType.ToDisplayString() }
);
}

private static bool IsValidType( INamedTypeSymbol valueType ) => valueType.SpecialType switch {
SpecialType.System_Int32 => true,
SpecialType.System_Boolean => true,
SpecialType.System_String => true,
SpecialType.System_Single => true,
_ => false
};
}
}

0 comments on commit 3396d62

Please sign in to comment.