Skip to content

Commit

Permalink
Invert check for langversion as Preview is set to int32.maxvalue -1
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDunn committed May 29, 2024
1 parent 717d910 commit a7ac542
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Vogen/ValueObjectGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void Execute(

internalDiags.RecordResolvedGlobalConfig(mergedConfig);

WriteStaticAbstracts.WriteIfNeeded(mergedConfig, context, compilation);
WriteStaticAbstracts.WriteInterfacesAndMethodsIfNeeded(mergedConfig, context, compilation);

WriteSystemTextJsonConverterFactories.WriteIfNeeded(mergedConfig, workItems, context, compilation);

Expand Down
13 changes: 7 additions & 6 deletions src/Vogen/WriteStaticAbstracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace Vogen;

internal class WriteStaticAbstracts
{
public static void WriteIfNeeded(VogenConfiguration? globalConfig,
public static void WriteInterfacesAndMethodsIfNeeded(VogenConfiguration? globalConfig,
SourceProductionContext context,
Compilation compilation)
{
if (compilation is CSharpCompilation { LanguageVersion: < LanguageVersion.CSharp11 })
if (compilation is not CSharpCompilation { LanguageVersion: >= LanguageVersion.CSharp11 })
{
return;
}
Expand All @@ -30,7 +30,7 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
{GenerateSource()}
""";

context.AddSource("VogenInterfaces_g.cs", source);

string GenerateSource()
Expand Down Expand Up @@ -75,6 +75,7 @@ string GenerateFactoryMethodsIfNeeded()
}
}


string GenerateCastingOperatorsIfNeeded()
{
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -131,11 +132,11 @@ public static string WriteHeaderIfNeeded(string precedingText, VoWorkItem item,
return string.Empty;
}

if (item.LanguageVersion <= LanguageVersion.CSharp11)
if (item.LanguageVersion >= LanguageVersion.CSharp11)
{
return string.Empty;
return precedingText + $" IVogen<{tds.Identifier}, {item.UnderlyingTypeFullName}>";
}

return precedingText + $" IVogen<{tds.Identifier}, {item.UnderlyingTypeFullName}>";
return string.Empty;
}
}

0 comments on commit a7ac542

Please sign in to comment.