From f5df472a5ce416e171e313dc030cec7da41e58e4 Mon Sep 17 00:00:00 2001 From: Stefan Ossendorf Date: Thu, 22 Feb 2024 23:10:52 +0100 Subject: [PATCH] Nullable context incorporation + config (#13) Add nullable annotation context directive Add config options for nullable context Some refactoring Add config options for nullable context Some refactoring --- README.md | 14 +- .../ConfigConstants.cs | 8 ++ .../DataPortalExtensionGenerator.cs | 38 ++++- .../Diagnostics/DiagnosticHelper.cs | 1 + .../Diagnostics/DiagnosticId.cs | 15 ++ .../Diagnostics/DiagnosticInfo.cs | 2 +- .../Diagnostics/NotPartialDiagnostic.cs | 3 +- .../NullableContextValueDiagnostic.cs | 12 ++ ...rivateClassCanNotBeAParameterDiagnostic.cs | 3 +- .../SuppressWarningCS8669ValueDiagnostic.cs | 12 ++ .../Emitter.cs | 12 +- .../GeneratorHelper.cs | 90 +----------- .../GeneratorOptions.cs | 10 +- ...rf.Csla.DataPortalExtensionGenerator.props | 2 + .../Parser.cs | 89 ++++-------- .../PortalOperationToGenerate.cs | 4 +- .../StringBuilderExtensions.cs | 131 ++++++++++++++++++ .../DiagnosticTests.cs | 66 ++++++++- .../GeneratorSnapshotTests.cs | 68 ++++++++- ...orTests.DataPortalExtensions.g.verified.cs | 3 +- ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 3 +- ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 3 +- ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 12 ++ ...orTests.DataPortalExtensions.g.verified.cs | 1 + ...Tests2.DataPortalExtensions2.g.verified.cs | 1 + .../TestAnalyzerConfigOptions.cs | 21 +++ .../TestAnalyzerConfigOptionsProvider.cs | 28 ++++ .../TestHelper.cs | 52 +++++-- 93 files changed, 713 insertions(+), 210 deletions(-) create mode 100644 src/Csla.DataPortalExtensionGenerator/ConfigConstants.cs create mode 100644 src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticId.cs create mode 100644 src/Csla.DataPortalExtensionGenerator/Diagnostics/NullableContextValueDiagnostic.cs create mode 100644 src/Csla.DataPortalExtensionGenerator/Diagnostics/SuppressWarningCS8669ValueDiagnostic.cs create mode 100644 src/Csla.DataPortalExtensionGenerator/StringBuilderExtensions.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.PrefixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.SuffixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptions.cs create mode 100644 tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptionsProvider.cs diff --git a/README.md b/README.md index a601068..f0195f7 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,10 @@ static partial class DataPortalExtensions { ## How to configure the generator You can configure the following for the generator to respect -* method prefix -* method suffix +* method prefix (default = "") +* method suffix (default = "") +* Enable/Disable nullable annotation context (default = Enable) +* SuppressWarningCS8669 (default = false) The fetch named method example from above can be resolved with a prefix/suffix to generate a method with the name `YourFetch` which in turn can be used and provides reliable compiler support. @@ -75,6 +77,8 @@ You can add the following properties to your csproj-file to configure the genera Prefix Suffix + Enable/Disable + true/false ``` @@ -87,12 +91,6 @@ With this added the consuming project the generator picks the values up and adds - Special case commands to an extension like `commandPortal.ExecuteCommand()` which combines `Create`+`Execute`. - Support for generic business objects - Add attribute to exclude methods explicitly -- Add proper NullableAnnotationContext settings -- Add diagnostics - - Wrong usage/configuration - - Like extension class is not partial - - Wrong config setting (if possible) - - Detailed error when a private nested class is used for any csla method A lot of implementation details are derived/taken from the great series [Andrew Lock: Creating a source generator](https://andrewlock.net/series/creating-a-source-generator/). If you want to create your own source generator I can recommend that series wholeheartedly. diff --git a/src/Csla.DataPortalExtensionGenerator/ConfigConstants.cs b/src/Csla.DataPortalExtensionGenerator/ConfigConstants.cs new file mode 100644 index 0000000..eb65929 --- /dev/null +++ b/src/Csla.DataPortalExtensionGenerator/ConfigConstants.cs @@ -0,0 +1,8 @@ +namespace Ossendorf.Csla.DataPortalExtensionGenerator; + +internal static class ConfigConstants { + public const string MethodPrefix = "DataPortalExtensionGen_MethodPrefix"; + public const string MethodSuffix = "DataPortalExtensionGen_MethodSuffix"; + public const string NullableContext = "DataPortalExtensionGen_NullableContext"; + public const string SuppressWarningCS8669 = "DataPortalExtensionGen_SuppressWarningCS8669"; +} \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/DataPortalExtensionGenerator.cs b/src/Csla.DataPortalExtensionGenerator/DataPortalExtensionGenerator.cs index 698df37..1020761 100644 --- a/src/Csla.DataPortalExtensionGenerator/DataPortalExtensionGenerator.cs +++ b/src/Csla.DataPortalExtensionGenerator/DataPortalExtensionGenerator.cs @@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; using Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Text; namespace Ossendorf.Csla.DataPortalExtensionGenerator; @@ -22,7 +23,10 @@ private static void AddMarkerAttribute(IncrementalGeneratorInitializationContext => context.RegisterPostInitializationOutput(ctx => ctx.AddSource("DataPortalExtensionsAttribute.g.cs", SourceText.From(GeneratorHelper.MarkerAttribute, Encoding.UTF8))); private static void AddCodeGenerator(IncrementalGeneratorInitializationContext context) { - var options = GetGeneratorOptions(context); + var optionsAndDiagnostics = GetGeneratorOptions(context); + + var options = optionsAndDiagnostics + .Select((o, _) => o.Value); var extensionClassesAndDiagnostics = context.SyntaxProvider .ForAttributeWithMetadataName( @@ -55,6 +59,10 @@ private static void AddCodeGenerator(IncrementalGeneratorInitializationContext c methodDeclarationsAndDiagnostics.SelectMany((m, _) => m.Errors), static (ctx, info) => ctx.ReportDiagnostic(info) ); + context.RegisterSourceOutput( + optionsAndDiagnostics.SelectMany((o, _) => o.Errors), + static (ctx, info) => ctx.ReportDiagnostic(info) + ); context.RegisterSourceOutput( source: classesToGenerateInto, @@ -62,18 +70,38 @@ private static void AddCodeGenerator(IncrementalGeneratorInitializationContext c ); } - private static IncrementalValueProvider GetGeneratorOptions(IncrementalGeneratorInitializationContext context) { + private static IncrementalValueProvider> GetGeneratorOptions(IncrementalGeneratorInitializationContext context) { return context.AnalyzerConfigOptionsProvider.Select((options, _) => { - if (!options.GlobalOptions.TryGetValue("build_property.DataPortalExtensionGen_MethodPrefix", out var methodPrefix) || methodPrefix is null) { + if (!TryGetGlobalOption(ConfigConstants.MethodPrefix, out var methodPrefix) || methodPrefix is null) { methodPrefix = ""; } - if (!options.GlobalOptions.TryGetValue("build_property.DataPortalExtensionGen_MethodSuffix", out var methodSuffix) || methodSuffix is null) { + if (!TryGetGlobalOption(ConfigConstants.MethodSuffix, out var methodSuffix) || methodSuffix is null) { methodSuffix = ""; } - return new GeneratorOptions(methodPrefix, methodSuffix); + var errors = new List(); + var nullableContextOptions = NullableContextOptions.Enable; + if (TryGetGlobalOption(ConfigConstants.NullableContext, out var nullabilityContext)) { + if (nullabilityContext.Equals("Disable", StringComparison.OrdinalIgnoreCase)) { + nullableContextOptions = NullableContextOptions.Disable; + } else if (!nullabilityContext.Equals("Enable", StringComparison.OrdinalIgnoreCase)) { + errors.Add(NullableContextValueDiagnostic.Create(nullabilityContext)); + } + } + + var suppressWarningCS8669 = false; + if (TryGetGlobalOption(ConfigConstants.SuppressWarningCS8669, out var suppressWarningString)) { + if (!bool.TryParse(suppressWarningString, out suppressWarningCS8669)) { + suppressWarningCS8669 = false; + errors.Add(SuppressWarningCS8669ValueDiagnostic.Create(suppressWarningString)); + } + } + + return new Result(new GeneratorOptions(methodPrefix, methodSuffix, nullableContextOptions, suppressWarningCS8669), new EquatableArray([.. errors])); + + bool TryGetGlobalOption(string key, [NotNullWhen(true)] out string? value) => options.GlobalOptions.TryGetValue($"build_property.{key}", out value); }); } } \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticHelper.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticHelper.cs index 1244487..08f8088 100644 --- a/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticHelper.cs +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticHelper.cs @@ -5,6 +5,7 @@ namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; internal static class DiagnosticHelper { public static void ReportDiagnostic(this SourceProductionContext ctx, DiagnosticInfo info) => ctx.ReportDiagnostic(CreateDiagnostic(info)); + private static Diagnostic CreateDiagnostic(DiagnosticInfo info) { var diagnostic = Diagnostic.Create(info.Descriptor, info.Location); return diagnostic; diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticId.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticId.cs new file mode 100644 index 0000000..1e5ca15 --- /dev/null +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticId.cs @@ -0,0 +1,15 @@ +using NetEscapades.EnumGenerators; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; + +[EnumExtensions] +internal enum DiagnosticId { + // NotPartialDiagnostic + DPEGEN001, + // PrivateClassCanNotBeAParameterDiagnostic + DPEGEN002, + // NullableContextValueDiagnostic + DPEGEN003, + // SuppressWarningCS8669ValueDiagnostic + DPEGEN004, +} diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticInfo.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticInfo.cs index 24724f5..57e8804 100644 --- a/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticInfo.cs +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/DiagnosticInfo.cs @@ -2,4 +2,4 @@ namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; -internal record DiagnosticInfo(DiagnosticDescriptor Descriptor, Location Location); \ No newline at end of file +internal record DiagnosticInfo(DiagnosticDescriptor Descriptor, Location? Location); \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/NotPartialDiagnostic.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/NotPartialDiagnostic.cs index 508b636..a55a175 100644 --- a/src/Csla.DataPortalExtensionGenerator/Diagnostics/NotPartialDiagnostic.cs +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/NotPartialDiagnostic.cs @@ -3,10 +3,9 @@ namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; internal static class NotPartialDiagnostic { - internal const string Id = "DPEGEN001"; internal const string Message = $"The target of the {GeneratorHelper.MarkerAttributeNameWithSuffix} must be declared as partial."; internal const string Title = "Must be partial"; public static DiagnosticInfo Create(ClassDeclarationSyntax syntax) - => new(new DiagnosticDescriptor(Id, Title, Message, "Usage", defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true), syntax.GetLocation()); + => new(new DiagnosticDescriptor(DiagnosticId.DPEGEN001.ToStringFast(), Title, Message, "Usage", defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true), syntax.GetLocation()); } \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/NullableContextValueDiagnostic.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/NullableContextValueDiagnostic.cs new file mode 100644 index 0000000..554d97d --- /dev/null +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/NullableContextValueDiagnostic.cs @@ -0,0 +1,12 @@ +using Microsoft.CodeAnalysis; +using System.Globalization; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; + +internal static class NullableContextValueDiagnostic { + internal const string Message = $"The value '{{0}}' for setting '{ConfigConstants.NullableContext}' is not known. Only 'Enable' and 'Disable' are allowed. Default of 'Enable' is used."; + internal const string Title = "Nullable context value unknown"; + + public static DiagnosticInfo Create(string configValue) + => new(new DiagnosticDescriptor(DiagnosticId.DPEGEN003.ToStringFast(), Title, string.Format(CultureInfo.InvariantCulture, Message, configValue), "Usage", defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true), null); +} diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/PrivateClassCanNotBeAParameterDiagnostic.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/PrivateClassCanNotBeAParameterDiagnostic.cs index 3a6c9e6..d81cfc6 100644 --- a/src/Csla.DataPortalExtensionGenerator/Diagnostics/PrivateClassCanNotBeAParameterDiagnostic.cs +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/PrivateClassCanNotBeAParameterDiagnostic.cs @@ -5,10 +5,9 @@ namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; internal static class PrivateClassCanNotBeAParameterDiagnostic { - internal const string Id = "DPEGEN002"; internal const string Message = "The {0} method for {1} has a paramter of type {2} which is private and can't be used for generating an extension method."; internal const string Title = "CSLA method parameters must not be private types."; public static DiagnosticInfo Create(MethodDeclarationSyntax syntax, DataPortalMethod dataPortalMethod, string methodName, string invalidClassType) - => new(new DiagnosticDescriptor(Id, Title, string.Format(CultureInfo.InvariantCulture, Message, dataPortalMethod.ToStringFast(), methodName, invalidClassType), "Usage", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true), syntax.GetLocation()); + => new(new DiagnosticDescriptor(DiagnosticId.DPEGEN002.ToStringFast(), Title, string.Format(CultureInfo.InvariantCulture, Message, dataPortalMethod.ToStringFast(), methodName, invalidClassType), "Usage", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true), syntax.GetLocation()); } \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Diagnostics/SuppressWarningCS8669ValueDiagnostic.cs b/src/Csla.DataPortalExtensionGenerator/Diagnostics/SuppressWarningCS8669ValueDiagnostic.cs new file mode 100644 index 0000000..447789f --- /dev/null +++ b/src/Csla.DataPortalExtensionGenerator/Diagnostics/SuppressWarningCS8669ValueDiagnostic.cs @@ -0,0 +1,12 @@ +using Microsoft.CodeAnalysis; +using System.Globalization; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; + +internal static class SuppressWarningCS8669ValueDiagnostic { + internal const string Message = $"The value '{{0}}' for setting '{ConfigConstants.SuppressWarningCS8669}' is not parseable to boolean. Default of false is used."; + internal const string Title = "CS8669 value unknown"; + + public static DiagnosticInfo Create(string configValue) + => new(new DiagnosticDescriptor(DiagnosticId.DPEGEN004.ToStringFast(), Title, string.Format(CultureInfo.InvariantCulture, Message, configValue), "Usage", defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true), null); +} \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Emitter.cs b/src/Csla.DataPortalExtensionGenerator/Emitter.cs index 73d78a0..3d2070c 100644 --- a/src/Csla.DataPortalExtensionGenerator/Emitter.cs +++ b/src/Csla.DataPortalExtensionGenerator/Emitter.cs @@ -22,21 +22,15 @@ public static void EmitExtensionClass(SourceProductionContext context, ((ClassFo } private static string GenerateCode(in ClassForExtensions extensionClass, in ImmutableArray methods, in GeneratorOptions options, CancellationToken ct) { - - var ns = extensionClass.Namespace; - var name = extensionClass.Name; - return new StringBuilder() .AppendLine("// ") - - //.AppendNullableContextDependingOnTarget(/*extensionClass.NullableAnnotation*/ NullableAnnotation.None) - + .AppendNullableContext(in options) .AppendLine() - .AppendLine(string.IsNullOrWhiteSpace(ns) ? "" : $@"namespace {ns}") + .AppendNamespace(in extensionClass) .AppendLine("{") .Append(" [global::System.CodeDom.Compiler.GeneratedCode(\"Ossendorf.Csla.DataportalExtensionsGenerator\", \"").Append(GeneratorHelper.VersionString).AppendLine("\")]") .AppendLine(" [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = \"Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.\")]") - .AppendLine($" static partial class {name}") + .AppendClassDeclaration(in extensionClass) .AppendLine(" {") .AppendMethodsGroupedByClass(in methods, in options, ct) .AppendLine(" }") diff --git a/src/Csla.DataPortalExtensionGenerator/GeneratorHelper.cs b/src/Csla.DataPortalExtensionGenerator/GeneratorHelper.cs index d0aebdf..6b13117 100644 --- a/src/Csla.DataPortalExtensionGenerator/GeneratorHelper.cs +++ b/src/Csla.DataPortalExtensionGenerator/GeneratorHelper.cs @@ -1,8 +1,4 @@ -using Microsoft.CodeAnalysis.CSharp.Syntax; -using System.Collections.Immutable; -using System.Text; - -namespace Ossendorf.Csla.DataPortalExtensionGenerator; +namespace Ossendorf.Csla.DataPortalExtensionGenerator; internal static class GeneratorHelper { public const string FullyQalifiedNameOfMarkerAttribute = "Ossendorf.Csla.DataPortalExtensionGenerator.DataPortalExtensionsAttribute"; @@ -29,90 +25,6 @@ public class {MarkerAttributeNameWithSuffix} : global::System.Attribute {{ }} }}"; - public static StringBuilder AppendMethodsGroupedByClass(this StringBuilder sb, in ImmutableArray foundOperations, in GeneratorOptions options, CancellationToken ct) { - const string intendation = " "; - - var groupedByClass = foundOperations.Cast().GroupBy(o => o.Object).ToImmutableArray(); - - foreach (var operationsByClass in groupedByClass) { - ct.ThrowIfCancellationRequested(); - - if (!operationsByClass.Any()) { - continue; - } - - var boName = operationsByClass.Key.GloballyQualifiedName; - - foreach (var operation in operationsByClass) { - ct.ThrowIfCancellationRequested(); - - var childPrefix = IsChildMethod(operation.PortalMethod) ? "Child" : ""; - string returnType; - if (operation.PortalMethod is DataPortalMethod.Delete) { - returnType = "Task"; - } else { - returnType = $"Task<{boName}>"; - } - - var (parameters, arguments) = GetParametersAndArgumentsToUse(operation.Parameters, ct); - - var visibilityModifier = operationsByClass.Key.HasPublicModifier && operation.Parameters.All(p => p.IsPublic) ? "public" : "internal"; - - _ = sb.Append(intendation) - .Append(visibilityModifier).Append(" static ") - .Append("global::System.Threading.Tasks.").Append(returnType).Append(" ").Append(options.MethodPrefix).Append(operation.MethodName).Append(options.MethodSuffix) - .Append("(this global::Csla.I").Append(childPrefix).Append("DataPortal<").Append(boName).Append("> ") - .Append("portal").Append(parameters).Append(")") - .Append(" => portal.").Append(operation.PortalMethod.ToStringFast()).Append("Async") - .Append("(").Append(arguments).Append(");").AppendLine(); - } - } - - return sb; - - static bool IsChildMethod(DataPortalMethod portalMethod) { - return portalMethod switch { - DataPortalMethod.FetchChild or DataPortalMethod.CreateChild => true, - DataPortalMethod.Fetch or DataPortalMethod.Delete or DataPortalMethod.Create or DataPortalMethod.Execute => false, - _ => throw new InvalidOperationException($"Unknown dataportal method {portalMethod}"), - }; - } - } - - private static (StringBuilder Parameters, StringBuilder Arguments) GetParametersAndArgumentsToUse(EquatableArray parameters, CancellationToken ct) { - var parametersBuilder = new StringBuilder(); - var argumentsBuilder = new StringBuilder(); - if (parameters.Count == 0) { - return (parametersBuilder, argumentsBuilder); - } - - foreach (var parameter in parameters) { - ct.ThrowIfCancellationRequested(); - - if (parametersBuilder.Length > 0) { - parametersBuilder.Append(", "); - argumentsBuilder.Append(", "); - } - - parametersBuilder.Append(parameter.ParameterFormatted); - argumentsBuilder.Append(parameter.ArgumentFormatted); - } - - if (parametersBuilder.Length > 0) { - parametersBuilder.Insert(0, ", "); - } - - return (parametersBuilder, argumentsBuilder); - } - - public static string ExtractAttributeName(NameSyntax? name) { - return name switch { - SimpleNameSyntax ins => ins.Identifier.Text, - QualifiedNameSyntax qns => qns.Right.Identifier.Text, - _ => "" - }; - } - private static readonly Dictionary _methodTranslations = []; static GeneratorHelper() { foreach (var portalMethod in Enum.GetValues(typeof(DataPortalMethod)).Cast()) { diff --git a/src/Csla.DataPortalExtensionGenerator/GeneratorOptions.cs b/src/Csla.DataPortalExtensionGenerator/GeneratorOptions.cs index 7556438..9a58a49 100644 --- a/src/Csla.DataPortalExtensionGenerator/GeneratorOptions.cs +++ b/src/Csla.DataPortalExtensionGenerator/GeneratorOptions.cs @@ -1,11 +1,17 @@ -namespace Ossendorf.Csla.DataPortalExtensionGenerator; +using Microsoft.CodeAnalysis; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator; internal readonly record struct GeneratorOptions { public readonly string MethodPrefix; public readonly string MethodSuffix; + public readonly NullableContextOptions NullableContextOptions; + public readonly bool SuppressWarningCS8669; - public GeneratorOptions(string methodPrefix, string methodSuffix) { + public GeneratorOptions(string methodPrefix, string methodSuffix, NullableContextOptions nullableContextOptions, bool suppressWarningCS8669) { MethodPrefix = methodPrefix; MethodSuffix = methodSuffix; + NullableContextOptions = nullableContextOptions; + SuppressWarningCS8669 = suppressWarningCS8669; } } \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Ossendorf.Csla.DataPortalExtensionGenerator.props b/src/Csla.DataPortalExtensionGenerator/Ossendorf.Csla.DataPortalExtensionGenerator.props index bfd2e66..f24309b 100644 --- a/src/Csla.DataPortalExtensionGenerator/Ossendorf.Csla.DataPortalExtensionGenerator.props +++ b/src/Csla.DataPortalExtensionGenerator/Ossendorf.Csla.DataPortalExtensionGenerator.props @@ -2,5 +2,7 @@ + + \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/Parser.cs b/src/Csla.DataPortalExtensionGenerator/Parser.cs index 9b601a0..0f3a96c 100644 --- a/src/Csla.DataPortalExtensionGenerator/Parser.cs +++ b/src/Csla.DataPortalExtensionGenerator/Parser.cs @@ -3,6 +3,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Ossendorf.Csla.DataPortalExtensionGenerator.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Reflection.Metadata; using System.Text; namespace Ossendorf.Csla.DataPortalExtensionGenerator; @@ -45,7 +46,7 @@ public static bool CouldBeCslaDataPortalAttribute(SyntaxNode node, CancellationT return false; } - var name = GeneratorHelper.ExtractAttributeName(attribute.Name); + var name = ExtractAttributeName(attribute.Name); return name is not null && GeneratorHelper.RecognizedCslaDataPortalAttributes.Keys.Contains(name); } @@ -79,9 +80,8 @@ public static bool CouldBeCslaDataPortalAttribute(SyntaxNode node, CancellationT var parameters = GetRelevantParametersForMethod(methodDeclaration, ctx.SemanticModel, ct, dataPortalMethod, diagnostics); var errors = new EquatableArray([.. diagnostics]); - var hasNullableEnabled = false; var methodName = methodDeclaration.Identifier.ToString(); - return new Result<(PortalOperationToGenerate PortalOperationToGenerate, bool IsValid)>((new PortalOperationToGenerate(methodName, parameters, hasNullableEnabled, dataPortalMethod, portalObject.Value), true), errors); + return new Result<(PortalOperationToGenerate PortalOperationToGenerate, bool IsValid)>((new PortalOperationToGenerate(methodName, parameters, dataPortalMethod, portalObject.Value), true), errors); } private static bool GetPortalObject(SyntaxNode? classDeclarationNode, SemanticModel semanticModel, CancellationToken cancellationToken, [NotNullWhen(true)] out PortalObject? portalObject) { @@ -121,8 +121,12 @@ private static EquatableArray GetRelevantParametersForMethod continue; } + if (semanticModel.GetDeclaredSymbol(parameter, ct) is not IParameterSymbol parameterDeclaredSymbol) { + continue; + } + var hasPublicModifier = HasPublicVisibility(parameterTypeSymbol, diagnostics, dataPortalMethod, methodSyntax); - var parametersFormattedForUsage = FormatForParameterUsage(parameter, parameterTypeSymbol); + var parametersFormattedForUsage = FormatForParameterUsage(parameter, parameterTypeSymbol, parameterDeclaredSymbol); foundParameters.Add(new OperationParameter(parameterTypeSymbol.ContainingNamespace?.ToString() ?? "", parameter.Identifier.ToString(), parametersFormattedForUsage, hasPublicModifier)); } @@ -134,7 +138,7 @@ static bool IsInjectedParameter(ParameterSyntax parameter) { for (var j = 0; j < al.Attributes.Count; j++) { var attr = al.Attributes[j]; - var attrName = EnsureAttributeSuffix(GeneratorHelper.ExtractAttributeName(attr.Name)); + var attrName = EnsureAttributeSuffix(ExtractAttributeName(attr.Name)); if (attrName.Equals("InjectAttribute", StringComparison.Ordinal)) { return true; } @@ -169,8 +173,9 @@ static bool HasPublicVisibility(ITypeSymbol typeSymbol, List dia } } - private static string FormatForParameterUsage(ParameterSyntax parameter, ITypeSymbol parameterTypeSymbol) { + private static string FormatForParameterUsage(ParameterSyntax parameter, ITypeSymbol parameterTypeSymbol, IParameterSymbol parameterDeclaredSymbol) { var typeString = parameterTypeSymbol.ToString(); +#pragma warning disable IDE0066 // Convert switch statement to expression, This is more readable than the switch-expression switch (typeString) { case "string": case "string[]": @@ -217,65 +222,23 @@ private static string FormatForParameterUsage(ParameterSyntax parameter, ITypeSy case "object[]": return parameter.ToString(); } +#pragma warning restore IDE0066 // Convert switch statement to expression - var typeStringBuilder = GetTypeString(parameterTypeSymbol); - - var parameterVariableName = parameter.Identifier.ToString(); - if (parameter.Default is not null) { - if (parameterTypeSymbol is { TypeKind: TypeKind.Enum } && parameter.Default.Value is MemberAccessExpressionSyntax valueOfEnum) { - parameterVariableName += $" = {typeStringBuilder}.{valueOfEnum.Name}"; - } else { - parameterVariableName += $" {parameter.Default}"; - } - //const int NullLiteralExpression = 8754; // See https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.syntaxkind?view=roslyn-dotnet-4.7.0#microsoft-codeanalysis-csharp-syntaxkind-nullliteralexpression - //if (parameter.Default is EqualsValueClauseSyntax { Value.RawKind: NullLiteralExpression }) { - } - - return $"{typeStringBuilder} {parameterVariableName}"; - - static StringBuilder GetTypeString(ITypeSymbol typeSymbol, StringBuilder? sb = null) { - sb ??= new(); - - sb.Append("global::"); - if (!typeSymbol.ContainingNamespace.IsGlobalNamespace) { - sb.Append(typeSymbol.ContainingNamespace).Append("."); - } - - sb.Append(GetTypeWithHierarchy(typeSymbol)); - - if (typeSymbol is INamedTypeSymbol { TypeArguments.Length: > 0 } namedTypeSymbol) { - sb.Append("<"); - - for (var i = 0; i < namedTypeSymbol.TypeArguments.Length; i++) { - if (i > 0) { - sb.Append(", "); - } - - sb = GetTypeString(namedTypeSymbol.TypeArguments[i], sb); - } - - sb.Append(">"); - } - - return sb; - - static StringBuilder GetTypeWithHierarchy(ITypeSymbol? typeSymbol, StringBuilder? sb = null) { - if (typeSymbol is null) { - return sb ?? new(); - } - - sb ??= new(); - - if (sb.Length > 0) { - sb.Insert(0, "."); - } - - sb.Insert(0, typeSymbol.Name); - - return GetTypeWithHierarchy(typeSymbol.ContainingType, sb); - } - } + return new StringBuilder() + .AppendType(parameterTypeSymbol, parameterDeclaredSymbol) + .Append(" ") + .AppendVariableName(parameter) + .AppendDefaultValue(parameter, parameterTypeSymbol, parameterDeclaredSymbol) + .ToString(); } #endregion + + private static string ExtractAttributeName(NameSyntax? name) { + return name switch { + SimpleNameSyntax ins => ins.Identifier.Text, + QualifiedNameSyntax qns => qns.Right.Identifier.Text, + _ => "" + }; + } } \ No newline at end of file diff --git a/src/Csla.DataPortalExtensionGenerator/PortalOperationToGenerate.cs b/src/Csla.DataPortalExtensionGenerator/PortalOperationToGenerate.cs index 3f3e69a..b6aa9ba 100644 --- a/src/Csla.DataPortalExtensionGenerator/PortalOperationToGenerate.cs +++ b/src/Csla.DataPortalExtensionGenerator/PortalOperationToGenerate.cs @@ -4,14 +4,12 @@ internal readonly record struct PortalOperationToGenerate { public readonly string MethodName; public readonly EquatableArray Parameters; - public readonly bool HasNullableEnabled; public readonly DataPortalMethod PortalMethod; public readonly PortalObject Object; - public PortalOperationToGenerate(string methodName, EquatableArray parameters, bool hasNullableEnabled, DataPortalMethod portalMethod, PortalObject @object) { + public PortalOperationToGenerate(string methodName, EquatableArray parameters, DataPortalMethod portalMethod, PortalObject @object) { MethodName = methodName; Parameters = parameters; - HasNullableEnabled = hasNullableEnabled; PortalMethod = portalMethod; Object = @object; } diff --git a/src/Csla.DataPortalExtensionGenerator/StringBuilderExtensions.cs b/src/Csla.DataPortalExtensionGenerator/StringBuilderExtensions.cs new file mode 100644 index 0000000..87610cc --- /dev/null +++ b/src/Csla.DataPortalExtensionGenerator/StringBuilderExtensions.cs @@ -0,0 +1,131 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System.Collections.Immutable; +using System.Text; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator; + +internal static class StringBuilderExtensions { + private static SymbolDisplayFormat FullyQualifiedFormat { get; } = SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier | SymbolDisplayMiscellaneousOptions.UseSpecialTypes); + + public static StringBuilder AppendMethodsGroupedByClass(this StringBuilder sb, in ImmutableArray foundOperations, in GeneratorOptions options, CancellationToken ct) { + const string intendation = " "; + + var groupedByClass = foundOperations.Cast().GroupBy(o => o.Object).ToImmutableArray(); + + foreach (var operationsByClass in groupedByClass) { + ct.ThrowIfCancellationRequested(); + + if (!operationsByClass.Any()) { + continue; + } + + var boName = operationsByClass.Key.GloballyQualifiedName; + + foreach (var operation in operationsByClass) { + ct.ThrowIfCancellationRequested(); + + var childPrefix = IsChildMethod(operation.PortalMethod) ? "Child" : ""; + string returnType; + if (operation.PortalMethod is DataPortalMethod.Delete) { + returnType = "Task"; + } else { + returnType = $"Task<{boName}>"; + } + + var (parameters, arguments) = GetParametersAndArgumentsToUse(operation.Parameters, ct); + + var visibilityModifier = operationsByClass.Key.HasPublicModifier && operation.Parameters.All(p => p.IsPublic) ? "public" : "internal"; + + _ = sb.Append(intendation) + .Append(visibilityModifier).Append(" static ") + .Append("global::System.Threading.Tasks.").Append(returnType).Append(" ").Append(options.MethodPrefix).Append(operation.MethodName).Append(options.MethodSuffix) + .Append("(this global::Csla.I").Append(childPrefix).Append("DataPortal<").Append(boName).Append("> ") + .Append("portal").Append(parameters).Append(")") + .Append(" => portal.").Append(operation.PortalMethod.ToStringFast()).Append("Async") + .Append("(").Append(arguments).Append(");").AppendLine(); + } + } + + return sb; + + static bool IsChildMethod(DataPortalMethod portalMethod) { + return portalMethod switch { + DataPortalMethod.FetchChild or DataPortalMethod.CreateChild => true, + DataPortalMethod.Fetch or DataPortalMethod.Delete or DataPortalMethod.Create or DataPortalMethod.Execute => false, + _ => throw new InvalidOperationException($"Unknown dataportal method {portalMethod}"), + }; + } + } + + private static (StringBuilder Parameters, StringBuilder Arguments) GetParametersAndArgumentsToUse(EquatableArray parameters, CancellationToken ct) { + var parametersBuilder = new StringBuilder(); + var argumentsBuilder = new StringBuilder(); + if (parameters.Count == 0) { + return (parametersBuilder, argumentsBuilder); + } + + foreach (var parameter in parameters) { + ct.ThrowIfCancellationRequested(); + + if (parametersBuilder.Length > 0) { + parametersBuilder.Append(", "); + argumentsBuilder.Append(", "); + } + + parametersBuilder.Append(parameter.ParameterFormatted); + argumentsBuilder.Append(parameter.ArgumentFormatted); + } + + if (parametersBuilder.Length > 0) { + parametersBuilder.Insert(0, ", "); + } + + return (parametersBuilder, argumentsBuilder); + } + + public static StringBuilder AppendNamespace(this StringBuilder sb, in ClassForExtensions classForExtensions) + => sb.AppendLine(string.IsNullOrWhiteSpace(classForExtensions.Namespace) ? "" : $@"namespace {classForExtensions.Namespace}"); + + public static StringBuilder AppendClassDeclaration(this StringBuilder sb, in ClassForExtensions classForExtensions) + => sb.AppendLine($" static partial class {classForExtensions.Name}"); + + public static StringBuilder AppendNullableContext(this StringBuilder sb, in GeneratorOptions options) { + var directiveValue = options.NullableContextOptions.AnnotationsEnabled() ? "enable" : "disable"; + sb.AppendLine($"#nullable {directiveValue}"); + if (options.SuppressWarningCS8669) { + sb.AppendLine("#pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source."); + } + + return sb; + } + + public static StringBuilder AppendType(this StringBuilder sb, ITypeSymbol typeSymbol, IParameterSymbol parameterDeclaredSymbol) { + sb.Append(typeSymbol.ToDisplayString(FullyQualifiedFormat)); + if (parameterDeclaredSymbol.NullableAnnotation == NullableAnnotation.Annotated && !(sb[^1] == '?')) { + sb.Append("?"); + } + + return sb; + } + + public static StringBuilder AppendVariableName(this StringBuilder sb, ParameterSyntax parameter) + => sb.Append(parameter.Identifier.ToString()); + + public static StringBuilder AppendDefaultValue(this StringBuilder sb, ParameterSyntax parameter, ITypeSymbol parameterTypeSymbol, IParameterSymbol parameterDeclaredSymbol) { + if (parameter.Default is null) { + return sb; + } + + if (parameterTypeSymbol is { TypeKind: TypeKind.Enum } && parameter.Default.Value is MemberAccessExpressionSyntax valueOfEnum) { + sb.Append(" = ").AppendType(parameterTypeSymbol, parameterDeclaredSymbol).Append(".").Append(valueOfEnum.Name); + } else { + sb.Append(" ").Append(parameter.Default); + } + + return sb; + + //const int NullLiteralExpression = 8754; // See https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.syntaxkind?view=roslyn-dotnet-4.7.0#microsoft-codeanalysis-csharp-syntaxkind-nullliteralexpression + //if (parameter.Default is EqualsValueClauseSyntax { Value.RawKind: NullLiteralExpression }) { + } +} \ No newline at end of file diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/DiagnosticTests.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/DiagnosticTests.cs index 7c88167..e14fba4 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/DiagnosticTests.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/DiagnosticTests.cs @@ -1,4 +1,7 @@ -namespace Ossendorf.Csla.DataPortalExtensionGenerator.Tests; +using FluentAssertions; +using Microsoft.CodeAnalysis; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Tests; public class DiagnosticTests { private const string ValidExtensionClass = @$" @@ -37,4 +40,63 @@ private class PrivateClass {{ }} TestHelper.Diagnostic(ValidExtensionClass, cslaClass, "DPEGEN002"); } -} + + [Fact] + public void WhenUsingNullableAnnotationsInDisabledContextWithSuppressWarningsCS8632MustNotBeReported() { + const string cslaClass = $@" +#nullable enable +using Csla; + +namespace SomeCslaClass; + +public class Foo {{ + [Fetch] + private void Bar(string? x, string? z = null){{ }} +}} +"; + var globalCompilerOptions = TestAnalyzerConfigOptionsProvider.Create(new[] { + KeyValuePair.Create("DataPortalExtensionGen_SuppressWarningCS8669", bool.TrueString), + KeyValuePair.Create("DataPortalExtensionGen_NullableContext", "disable") + }); + + TestHelper.Diagnostic(ValidExtensionClass, cslaClass, globalCompilerOptions, diagnostics => diagnostics.Should().BeEmpty(), d => d.Should().BeEmpty(), NullableContextOptions.Disable); + } + + [Fact] + public void WhenNullableContextConfigValueIsUnknownItMustGetDiagnosticDPEGEN003() { + const string cslaClass = $@" +using Csla; + +namespace SomeCslaClass; + +public class Foo {{ + [Fetch] + private void Bar(int a){{ }} +}} +"; + var globalCompilerOptions = TestAnalyzerConfigOptionsProvider.Create(new[] { + KeyValuePair.Create("DataPortalExtensionGen_NullableContext", "Unknown") + }); + + TestHelper.Diagnostic(ValidExtensionClass, cslaClass, "DPEGEN003", globalCompilerOptions); + } + + [Fact] + public void WhenSuppressWarningCS8669ConfigValueIsUnknownItMustGetDiagnosticDPEGEN004() { + const string cslaClass = $@" +using Csla; + +namespace SomeCslaClass; + +public class Foo {{ + [Fetch] + private void Bar(int a){{ }} +}} +"; + var globalCompilerOptions = TestAnalyzerConfigOptionsProvider.Create(new[] { + KeyValuePair.Create("DataPortalExtensionGen_SuppressWarningCS8669", "NotBooleanParseable") + }); + + TestHelper.Diagnostic(ValidExtensionClass, cslaClass, "DPEGEN004", globalCompilerOptions); + } +} \ No newline at end of file diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/GeneratorSnapshotTests.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/GeneratorSnapshotTests.cs index 5b3f625..2534dae 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/GeneratorSnapshotTests.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/GeneratorSnapshotTests.cs @@ -150,7 +150,7 @@ namespace MyTest.Greats; public class Foo {{ public class Bar {{ - public string Name {{ get; set; }} + public string Name {{ get; set; }} = """"; }} }} "; @@ -195,6 +195,24 @@ private void Bar({type}? krznbf) {{ return TestHelper.Verify(cslaSource, t => t.UseParameters(type)); } + [Theory] + [MemberData(nameof(CSharpBuiltInTypesNullable))] + public Task NullablePrimitivesArray(string type) { + var cslaSource = $@" +using Csla; + +namespace VerifyTests; + +public class DummyBOWithParams {{ + [Fetch] + private void Bar({type}[]? krznbf = null) {{ + }} +}} +"; + + return TestHelper.Verify(cslaSource, t => t.UseParameters(type)); + } + [Fact] public Task GenericArity1Parameter() { var cslaSource = $@" @@ -233,9 +251,9 @@ private void Bar(TestGenerica {{ - public T1 Type1 {{ get; set; }} - public T2 Type2 {{ get; set; }} - public T3 Type3 {{ get; set; }} + public T1? Type1 {{ get; set; }} + public T2? Type2 {{ get; set; }} + public T3? Type3 {{ get; set; }} }} public class RandomClass {{ @@ -340,7 +358,7 @@ namespace VerifyTests; public class DummyBOWithParams {{ [Fetch] - private void Bar(string a, int b = 1, List list = null, string x = null, string z = """") {{ + private void Bar(string a, int b = 1, List? list = null, string? x = null, string z = """") {{ }} }} "; @@ -357,12 +375,12 @@ namespace VerifyTests; public class DummyBOWithParams {{ [Fetch] - private void Bar(string a, int b = 1, int[] c = null, string x = null) {{ + private void Bar(string a, int b = 1, int[]? c = null, string? x = null) {{ }} }} "; - return TestHelper.Verify(cslaSource); + return TestHelper.Verify(cslaSource, true); } [Fact] @@ -415,4 +433,40 @@ public static partial class DataPortalExtensions2 {{ return TestHelper.Verify(cslaSource, additionalClassToGenerateInto, 3); } + + [Fact] + public Task PrefixConfig() { + var cslaSource = $@" +using Csla; + +namespace VerifyTests; + +public class DummyBOWithParams {{ + [Fetch] + private void Bar(int krznbf) {{ + }} +}} +"; + + var globalCompilerOptions = TestAnalyzerConfigOptionsProvider.Create("DataPortalExtensionGen_MethodPrefix", "Prefix"); + return TestHelper.Verify(cslaSource, globalCompilerOptions); + } + + [Fact] + public Task SuffixConfig() { + var cslaSource = $@" +using Csla; + +namespace VerifyTests; + +public class DummyBOWithParams {{ + [Fetch] + private void Bar(int krznbf) {{ + }} +}} +"; + + var globalCompilerOptions = TestAnalyzerConfigOptionsProvider.Create("DataPortalExtensionGen_MethodSuffix", "Suffix"); + return TestHelper.Verify(cslaSource, globalCompilerOptions); + } } \ No newline at end of file diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArrayDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArrayDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs index 29fe51c..dc5ae5e 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArrayDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArrayDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,11 +1,12 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] static partial class DataPortalExtensions { - public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, string a, int b = 1, int[] c = null, string x = null) => portal.FetchAsync(a, b, c, x); + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, string a, int b = 1, int[]? c = null, string? x = null) => portal.FetchAsync(a, b, c, x); } } diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs index f3a792b..f089d75 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs index c46c7f4..83eec11 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs index cd32847..41b90a8 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs index 38e3e09..0430994 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs index f083379..0f2e03b 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs index 6cb78bc..f841409 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs index 9ecff19..b4d8ea0 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs index c79d1d5..8fe1c40 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=object#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=object#GeneratorTests.DataPortalExtensions.g.verified.cs index 1054d70..9e265ed 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=object#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=object#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs index 851e1c4..fd34060 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs index dd8a637..4601f21 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=string#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=string#GeneratorTests.DataPortalExtensions.g.verified.cs index eee20b7..2254038 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=string#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=string#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs index a4a642c..628bac0 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs index 25703a6..a6206bf 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs index a5abe67..5cebef1 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.BuiltInTypeArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.DefaultValueParameter#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.DefaultValueParameter#GeneratorTests.DataPortalExtensions.g.verified.cs index a4bbe63..4b87a91 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.DefaultValueParameter#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.DefaultValueParameter#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Create#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Create#GeneratorTests.DataPortalExtensions.g.verified.cs index 072942d..825b6cd 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Create#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Create#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index 072942d..825b6cd 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChild#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChild#GeneratorTests.DataPortalExtensions.g.verified.cs index 13f0ffb..36bad0c 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChild#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChild#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index 13f0ffb..36bad0c 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=CreateChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Delete#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Delete#GeneratorTests.DataPortalExtensions.g.verified.cs index 4daa506..a9bed8f 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Delete#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Delete#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=DeleteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=DeleteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index 4daa506..a9bed8f 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=DeleteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=DeleteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Execute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Execute#GeneratorTests.DataPortalExtensions.g.verified.cs index 497fbd6..02a755f 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Execute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Execute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=ExecuteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=ExecuteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index 497fbd6..02a755f 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=ExecuteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=ExecuteAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Fetch#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Fetch#GeneratorTests.DataPortalExtensions.g.verified.cs index ef74c94..1767fdd 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Fetch#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=Fetch#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index ef74c94..1767fdd 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChild#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChild#GeneratorTests.DataPortalExtensions.g.verified.cs index fd7b9e0..2dd3c41 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChild#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChild#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs index fd7b9e0..2dd3c41 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EmptyParameters_portalMethod=FetchChildAttribute#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameter#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameter#GeneratorTests.DataPortalExtensions.g.verified.cs index 9c1cc94..8b3e952 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameter#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameter#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs index 5aeb605..43bf982 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.EnumParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity1Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity1Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs index a6d2a2b..b008bd0 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity1Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity1Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity3Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity3Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs index 3368754..f1fe48d 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity3Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericArity3Parameter#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs index 3de4c20..52042a7 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.GenericParameterDefaultValue#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,11 +1,12 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] static partial class DataPortalExtensions { - public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, string a, int b = 1, global::System.Collections.Generic.List list = null, string x = null, string z = "") => portal.FetchAsync(a, b, list, x, z); + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, string a, int b = 1, global::System.Collections.Generic.List? list = null, string? x = null, string z = "") => portal.FetchAsync(a, b, list, x, z); } } diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InjectedParametersIgnored#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InjectedParametersIgnored#GeneratorTests.DataPortalExtensions.g.verified.cs index 260f209..bc74d9d 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InjectedParametersIgnored#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InjectedParametersIgnored#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InternalParameterMustMakeTheExtensionInternal#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InternalParameterMustMakeTheExtensionInternal#GeneratorTests.DataPortalExtensions.g.verified.cs index 35bce48..f4d41cf 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InternalParameterMustMakeTheExtensionInternal#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.InternalParameterMustMakeTheExtensionInternal#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.MultiplePrimitiveParameters#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.MultiplePrimitiveParameters#GeneratorTests.DataPortalExtensions.g.verified.cs index cce0daa..4986153 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.MultiplePrimitiveParameters#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.MultiplePrimitiveParameters#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsBusinessObjectType#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsBusinessObjectType#GeneratorTests.DataPortalExtensions.g.verified.cs index d057e5a..0d9d20d 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsBusinessObjectType#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsBusinessObjectType#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsParameter#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsParameter#GeneratorTests.DataPortalExtensions.g.verified.cs index 08fd6ee..4f273ed 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsParameter#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NestedTypeAsParameter#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullableEnum#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullableEnum#GeneratorTests.DataPortalExtensions.g.verified.cs index cbaede2..1ddd012 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullableEnum#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullableEnum#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,11 +1,12 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] static partial class DataPortalExtensions { - public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, global::System.Nullable krznbf) => portal.FetchAsync(krznbf); + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, global::TestEnum.SomeEnum? krznbf) => portal.FetchAsync(krznbf); } } diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..a376da7 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, bool[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..ff9154f --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, byte[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..991ab1a --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, char[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..fde7c0d --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, decimal[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..4467f99 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, double[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..315ce7d --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, float[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..fe869a3 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, int[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..8ba225c --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, long[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..a939123 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, sbyte[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..b7ccabe --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, short[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..8529043 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, uint[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..9d80d60 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, ulong[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..df285cc --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitivesArray_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task Bar(this global::Csla.IDataPortal portal, ushort[]? krznbf = null) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs index 2275377..6c1d6e8 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=bool#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs index ecf4ba2..9b13e41 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=byte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs index 696f10a..34b9646 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=char#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs index 3d87124..b4b3647 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=decimal#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs index fbb63a4..839049f 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=double#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs index ef774ad..51122cc 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=float#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs index 6f864f0..66611cb 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=int#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs index 922f4c3..d06646b 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=long#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs index 5f56fec..eb883cf 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=sbyte#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs index c2d0b89..e5d7df9 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=short#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs index 10eb416..05cece7 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=uint#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs index f99a6d0..6d36dfd 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ulong#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs index f7ccdde..0531bef 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.NullablePrimitves_type=ushort#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.OnlyInjectedParameters#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.OnlyInjectedParameters#GeneratorTests.DataPortalExtensions.g.verified.cs index 7ed6711..97aae3b 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.OnlyInjectedParameters#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.OnlyInjectedParameters#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.PrefixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.PrefixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..fbcff9f --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.PrefixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task PrefixBar(this global::Csla.IDataPortal portal, int krznbf) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.SuffixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.SuffixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs new file mode 100644 index 0000000..6935298 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.SuffixConfig#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -0,0 +1,12 @@ +//HintName: GeneratorTests.DataPortalExtensions.g.cs +// +#nullable enable + +namespace GeneratorTests +{ + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage(Justification = "Generated by the Ossendorf.Csla.DataPortalExtensionsGenerators source generator.")] + static partial class DataPortalExtensions + { + public static global::System.Threading.Tasks.Task BarSuffix(this global::Csla.IDataPortal portal, int krznbf) => portal.FetchAsync(krznbf); + } +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests.DataPortalExtensions.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests.DataPortalExtensions.g.verified.cs index 63d1eb2..9f9518b 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests.DataPortalExtensions.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests.DataPortalExtensions.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests.DataPortalExtensions.g.cs // +#nullable enable namespace GeneratorTests { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests2.DataPortalExtensions2.g.verified.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests2.DataPortalExtensions2.g.verified.cs index 4d5ea26..f9e1ec3 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests2.DataPortalExtensions2.g.verified.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/Snapshots/GeneratorSnapshotTests.TwoClassesToGenerateInto#GeneratorTests2.DataPortalExtensions2.g.verified.cs @@ -1,5 +1,6 @@ //HintName: GeneratorTests2.DataPortalExtensions2.g.cs // +#nullable enable namespace GeneratorTests2 { diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptions.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptions.cs new file mode 100644 index 0000000..041df45 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptions.cs @@ -0,0 +1,21 @@ +using Microsoft.CodeAnalysis.Diagnostics; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Tests; + +internal sealed class TestAnalyzerConfigOptions : AnalyzerConfigOptions { + internal static readonly ImmutableDictionary EmptyDictionary = ImmutableDictionary.Create(KeyComparer); + + public static TestAnalyzerConfigOptions Empty { get; } = new TestAnalyzerConfigOptions(EmptyDictionary); + + private readonly ImmutableDictionary _options; + + public TestAnalyzerConfigOptions(ImmutableDictionary options) { + _options = options; + } + + public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) => _options.TryGetValue(key[15..], out value); + + public override IEnumerable Keys => _options.Keys; +} \ No newline at end of file diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptionsProvider.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptionsProvider.cs new file mode 100644 index 0000000..a444739 --- /dev/null +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/TestAnalyzerConfigOptionsProvider.cs @@ -0,0 +1,28 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using System.Collections.Immutable; + +namespace Ossendorf.Csla.DataPortalExtensionGenerator.Tests; + +internal sealed class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider { + + public static TestAnalyzerConfigOptionsProvider Empty { get; } = new TestAnalyzerConfigOptionsProvider(TestAnalyzerConfigOptions.Empty); + + private readonly ImmutableDictionary _treeDict = ImmutableDictionary.Empty; + + public override AnalyzerConfigOptions GlobalOptions { get; } + + private TestAnalyzerConfigOptionsProvider(AnalyzerConfigOptions globalOptions) { + GlobalOptions = globalOptions; + } + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) + => TestAnalyzerConfigOptions.Empty; + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) + => TestAnalyzerConfigOptions.Empty; + + public static TestAnalyzerConfigOptionsProvider Create(string key, string value) => Create(new[] { KeyValuePair.Create(key, value) }); + + public static TestAnalyzerConfigOptionsProvider Create(IEnumerable> config) => new(new TestAnalyzerConfigOptions(ImmutableDictionary.CreateRange(config)) +); +} diff --git a/tests/Csla.DataPortalExtensionGenerator.Tests/TestHelper.cs b/tests/Csla.DataPortalExtensionGenerator.Tests/TestHelper.cs index b042183..73a3b28 100644 --- a/tests/Csla.DataPortalExtensionGenerator.Tests/TestHelper.cs +++ b/tests/Csla.DataPortalExtensionGenerator.Tests/TestHelper.cs @@ -1,7 +1,10 @@ using Csla; using FluentAssertions; +using FluentAssertions.Execution; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; +using System.Collections.Immutable; namespace Ossendorf.Csla.DataPortalExtensionGenerator.Tests; @@ -14,15 +17,23 @@ public static partial class DataPortalExtensions {{ }} }}"; - public static Task Verify(string cslaSource) => Verify(cslaSource, ""); + public static Task Verify(string cslaSource) => Verify(cslaSource, true); - public static Task Verify(string cslaSource, string additionalSource) => Verify(cslaSource, additionalSource, 2); + public static Task Verify(string cslaSource, TestAnalyzerConfigOptionsProvider globalCompilerOptions) => Verify(cslaSource, "", t => t, 2, true, globalCompilerOptions); - public static Task Verify(string cslaSource, string additionalSource, int expectedFileCount) => Verify(cslaSource, additionalSource, s => s, expectedFileCount); + public static Task Verify(string cslaSource, bool enableNullableContext) => Verify(cslaSource, "", enableNullableContext); - public static Task Verify(string cslaSource, Func configureVerify) => Verify(cslaSource, "", configureVerify, 2); + public static Task Verify(string cslaSource, string additionalSource) => Verify(cslaSource, additionalSource, true); - public static Task Verify(string cslaSource, string additionalSource, Func configureVerify, int expectedFileCount) { + public static Task Verify(string cslaSource, string additionalSource, bool enableNullableContext) => Verify(cslaSource, additionalSource, 2, enableNullableContext); + + public static Task Verify(string cslaSource, string additionalSource, int expectedFileCount) => Verify(cslaSource, additionalSource, expectedFileCount, true); + + public static Task Verify(string cslaSource, string additionalSource, int expectedFileCount, bool enableNullableContext) => Verify(cslaSource, additionalSource, s => s, expectedFileCount, enableNullableContext); + + public static Task Verify(string cslaSource, Func configureVerify) => Verify(cslaSource, "", configureVerify, 2, true); + + public static Task Verify(string cslaSource, string additionalSource, Func configureVerify, int expectedFileCount, bool enableNullableContext, TestAnalyzerConfigOptionsProvider? globalCompilerOptions = null) { var syntaxTrees = new List() { CSharpSyntaxTree.ParseText(ClassToGenerateExtensionsInto), // ExtensionClassTree @@ -44,21 +55,25 @@ public static Task Verify(string cslaSource, string additionalSource, Func Diagnostic(portalExtensionClass, "", expectedDiagnosticId); - public static void Diagnostic(string portalExtensionClass, string cslaClass, string expectedDiagnosticId) { + public static void Diagnostic(string portalExtensionClass, string cslaClass, string expectedDiagnosticId) + => Diagnostic(portalExtensionClass, cslaClass, null, diagnostics => diagnostics.Should().OnlyContain(d => d.Id == expectedDiagnosticId), d => { }); + + public static void Diagnostic(string validExtensionClass, string cslaClass, string expectedDiagnosticId, TestAnalyzerConfigOptionsProvider globalCompilerOptions) + => Diagnostic(validExtensionClass, cslaClass, globalCompilerOptions, diagnostics => diagnostics.Should().OnlyContain(d => d.Id == expectedDiagnosticId), d => { }); + + public static void Diagnostic(string portalExtensionClass, string cslaClass, AnalyzerConfigOptionsProvider? globalConfigOptionsProvider, Action> sourceGenReportedDiagnostics, Action> compilerReportedDiagnostics, NullableContextOptions nullableContextOptions = NullableContextOptions.Enable) { var syntaxTrees = new List() { CSharpSyntaxTree.ParseText(portalExtensionClass), // ExtensionClassTree }; @@ -93,14 +114,17 @@ public static void Diagnostic(string portalExtensionClass, string cslaClass, str assemblyName: "GeneratorTests", syntaxTrees: syntaxTrees, references: references, - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(nullableContextOptions) ); var generator = new DataPortalExtensionGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(generator); + var driver = CSharpGeneratorDriver.Create(generator).WithUpdatedAnalyzerConfigOptions(globalConfigOptionsProvider ?? TestAnalyzerConfigOptionsProvider.Empty); driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var diagnostics); - diagnostics.Should().OnlyContain(d => d.Id == expectedDiagnosticId); + using (new AssertionScope()) { + sourceGenReportedDiagnostics(diagnostics); + compilerReportedDiagnostics(outputCompilation.GetDiagnostics()); + } } } \ No newline at end of file