Added nullable annotation for all generated files

This commit is contained in:
Darth Affe 2024-07-21 21:51:43 +02:00
parent 1b929ac886
commit fed16da8ce
61 changed files with 201 additions and 55 deletions

View File

@ -15,6 +15,8 @@ public class ColorSortSourceGenerator : IIncrementalGenerator
#region Properties & Fields #region Properties & Fields
private const string SORT_GENERATOR_ATTRIBUTE_SOURCE = """ private const string SORT_GENERATOR_ATTRIBUTE_SOURCE = """
#nullable enable
namespace HPPH; namespace HPPH;
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
@ -79,6 +81,8 @@ public class ColorSortSourceGenerator : IIncrementalGenerator
foreach (KeyValuePair<(string @namespace, string @class, string classModifier), string> data in sourceMapping) foreach (KeyValuePair<(string @namespace, string @class, string classModifier), string> data in sourceMapping)
{ {
context.AddSource($"{data.Key.@class}.g.cs", SourceText.From($$""" context.AddSource($"{data.Key.@class}.g.cs", SourceText.From($$"""
#nullable enable
using System.Buffers; using System.Buffers;
namespace {{data.Key.@namespace}}; namespace {{data.Key.@namespace}};

View File

@ -18,6 +18,8 @@ internal class Average : IGeneratorFeature
private static string GenerateColorFormatAverage(ColorFormatData colorFormat) private static string GenerateColorFormatAverage(ColorFormatData colorFormat)
{ {
return $$""" return $$"""
#nullable enable
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;
@ -36,6 +38,8 @@ internal class Average : IGeneratorFeature
private static string GenerateColorFormatInterfaceAverage() private static string GenerateColorFormatInterfaceAverage()
{ {
return """ return """
#nullable enable
namespace HPPH; namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat

View File

@ -25,6 +25,8 @@ internal class Colors : IGeneratorFeature
=> colorFormat.Bpp switch => colorFormat.Bpp switch
{ {
3 => $$""" 3 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -89,6 +91,8 @@ internal class Colors : IGeneratorFeature
""", """,
4 => $$""" 4 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -159,6 +163,8 @@ internal class Colors : IGeneratorFeature
private static string GenerateColorFormatCode(ColorFormatData colorFormat) private static string GenerateColorFormatCode(ColorFormatData colorFormat)
{ {
return $$""" return $$"""
#nullable enable
namespace HPPH; namespace HPPH;
public sealed partial class ColorFormat{{colorFormat.Format}} : IColorFormat public sealed partial class ColorFormat{{colorFormat.Format}} : IColorFormat
@ -188,6 +194,8 @@ internal class Colors : IGeneratorFeature
{ {
StringBuilder sb = new(); StringBuilder sb = new();
sb.AppendLine(""" sb.AppendLine("""
#nullable enable
namespace HPPH; namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat

View File

@ -20,6 +20,8 @@ internal class MinMax : IGeneratorFeature
=> colorFormat.Bpp switch => colorFormat.Bpp switch
{ {
3 => $$""" 3 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -73,6 +75,8 @@ internal class MinMax : IGeneratorFeature
""", """,
4 => $$""" 4 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -133,6 +137,8 @@ internal class MinMax : IGeneratorFeature
private static string GenerateColorFormatMinMax(ColorFormatData colorFormat) private static string GenerateColorFormatMinMax(ColorFormatData colorFormat)
{ {
return $$""" return $$"""
#nullable enable
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;
@ -151,6 +157,8 @@ internal class MinMax : IGeneratorFeature
private static string GenerateColorFormatInterfaceMinMax() private static string GenerateColorFormatInterfaceMinMax()
{ {
return """ return """
#nullable enable
namespace HPPH; namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat

View File

@ -18,6 +18,8 @@ internal class Quantize : IGeneratorFeature
private static string GenerateColorFormatQuantize(ColorFormatData colorFormat) private static string GenerateColorFormatQuantize(ColorFormatData colorFormat)
{ {
return $$""" return $$"""
#nullable enable
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;
@ -56,6 +58,8 @@ internal class Quantize : IGeneratorFeature
private static string GenerateColorFormatInterfaceQuantize() private static string GenerateColorFormatInterfaceQuantize()
{ {
return """ return """
#nullable enable
namespace HPPH; namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat

View File

@ -20,6 +20,8 @@ internal class Sum : IGeneratorFeature
=> colorFormat.Bpp switch => colorFormat.Bpp switch
{ {
3 => $$""" 3 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -58,6 +60,8 @@ internal class Sum : IGeneratorFeature
""", """,
4 => $$""" 4 => $$"""
#nullable enable
// ReSharper disable ConvertToAutoProperty // ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
@ -100,6 +104,8 @@ internal class Sum : IGeneratorFeature
private static string GenerateColorFormatSum(ColorFormatData colorFormat) private static string GenerateColorFormatSum(ColorFormatData colorFormat)
{ {
return $$""" return $$"""
#nullable enable
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;
@ -118,6 +124,8 @@ internal class Sum : IGeneratorFeature
private static string GenerateColorFormatInterfaceSum() private static string GenerateColorFormatInterfaceSum()
{ {
return """ return """
#nullable enable
namespace HPPH; namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
internal class ColorSortGeneratorAttribute(string dataTypeName, string sortValueName) : Attribute internal class ColorSortGeneratorAttribute(string dataTypeName, string sortValueName) : Attribute

View File

@ -1,4 +1,6 @@
using System.Buffers; #nullable enable
using System.Buffers;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatABGR : IColorFormat public sealed partial class ColorFormatABGR : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatARGB : IColorFormat public sealed partial class ColorFormatARGB : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatBGR : IColorFormat public sealed partial class ColorFormatBGR : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatBGRA : IColorFormat public sealed partial class ColorFormatBGRA : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatRGB : IColorFormat public sealed partial class ColorFormatRGB : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
using System.Runtime.InteropServices; #nullable enable
using System.Runtime.InteropServices;
namespace HPPH; namespace HPPH;

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public sealed partial class ColorFormatRGBA : IColorFormat public sealed partial class ColorFormatRGBA : IColorFormat
{ {

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat
{ {

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat
{ {

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat
{ {

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat
{ {

View File

@ -1,4 +1,6 @@
namespace HPPH; #nullable enable
namespace HPPH;
public partial interface IColorFormat public partial interface IColorFormat
{ {

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter

View File

@ -1,4 +1,6 @@
// ReSharper disable ConvertToAutoProperty #nullable enable
// ReSharper disable ConvertToAutoProperty
// ReSharper disable ConvertToAutoPropertyWhenPossible // ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ReplaceWithPrimaryConstructorParameter // ReSharper disable ReplaceWithPrimaryConstructorParameter