Prepare for Add/Update generators

This commit is contained in:
Wvader 2022-08-23 17:48:47 +01:00
parent 7de9b48c69
commit 1400bd08e0
3 changed files with 12 additions and 3 deletions

View File

@ -6,6 +6,7 @@ using System.Text;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
#pragma warning disable CS8602
namespace MapTo.Extensions namespace MapTo.Extensions
{ {
@ -207,7 +208,9 @@ namespace MapTo.Extensions
private static void HandleEnumerable(SourceBuilder builder, MappedMember property) private static void HandleEnumerable(SourceBuilder builder, MappedMember property)
{ {
var symbol = property.ActualSymbol as IPropertySymbol; var symbol = property.ActualSymbol as IPropertySymbol;
#pragma warning disable CS8602
builder.WriteCommentArray(symbol.Parameters, nameof(symbol.Parameters)); builder.WriteCommentArray(symbol.Parameters, nameof(symbol.Parameters));
#pragma warning restore CS8602
builder.WriteCommentArray(symbol.TypeCustomModifiers, nameof(symbol.TypeCustomModifiers)); builder.WriteCommentArray(symbol.TypeCustomModifiers, nameof(symbol.TypeCustomModifiers));
builder.WriteComment($"Is enumerable {(property.ActualSymbol as IPropertySymbol).Parameters}"); builder.WriteComment($"Is enumerable {(property.ActualSymbol as IPropertySymbol).Parameters}");

View File

@ -6,6 +6,7 @@ using MapTo.Extensions;
using MapTo.Sources; using MapTo.Sources;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
#pragma warning disable CS8602
namespace MapTo namespace MapTo
{ {
@ -52,7 +53,7 @@ namespace MapTo
protected INamedTypeSymbol UseUpdateAttributeTypeSymbol { get; } protected INamedTypeSymbol UseUpdateAttributeTypeSymbol { get; }
public static INamedTypeSymbol JsonExtensionAttributeSymbol { get; set; } public static INamedTypeSymbol JsonExtensionAttributeSymbol { get; set; } = null!;
protected INamedTypeSymbol MappingContextTypeSymbol { get; } protected INamedTypeSymbol MappingContextTypeSymbol { get; }
@ -269,7 +270,7 @@ namespace MapTo
return new MappedMember( return new MappedMember(
property.Name, property.Name,
property.GetTypeSymbol().ToString(), property.GetTypeSymbol()?.ToString() ?? throw new InvalidOperationException(),
ToQualifiedDisplayName(propertyType) ?? propertyType.Name, ToQualifiedDisplayName(propertyType) ?? propertyType.Name,
converterFullyQualifiedName, converterFullyQualifiedName,
converterParameters.ToImmutableArray(), converterParameters.ToImmutableArray(),
@ -315,7 +316,9 @@ namespace MapTo
property, property,
namedType, namedType,
isEnumerable, isEnumerable,
(property as IPropertySymbol).IsReadOnly); #pragma warning disable CS8602
(property as IPropertySymbol).IsReadOnly);
#pragma warning restore CS8602
; ;
} }

View File

@ -2,6 +2,9 @@ using static MapTo.Sources.Constants;
namespace MapTo.Sources namespace MapTo.Sources
{ {
/// <summary>
/// UpdateData Attribute Source
/// </summary>
public class UpdateDataAttributeSource public class UpdateDataAttributeSource
{ {
internal const string AttributeName = "UpdateData"; internal const string AttributeName = "UpdateData";