stable
This commit is contained in:
parent
2ac7524e8b
commit
6fd065fc47
|
@ -31,6 +31,13 @@ namespace BlueWest.EfMethods.Sources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Attribute for generating a method for creating a entity of the target property.")
|
||||||
|
.WriteLine("/// <param name=\"createType\">A typeof with the Create projection type.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection with the return data.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(Type createType = null, Type returnType = null){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(Type createType = null, Type returnType = null){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -29,6 +29,15 @@ namespace BlueWest.EfMethods.EfMethods.AttributeSources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Attribute for generating a function to get many entities.")
|
||||||
|
.WriteLine("/// <param name=\"listPropertyNameof\">The nameof property of the list.</param>")
|
||||||
|
.WriteLine("/// <param name=\"createType\">The projection with the creation data.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection type with the return data.</param>")
|
||||||
|
.WriteLine("/// <param name=\"primaryKeyNameof\">Nameof with look up key of the entity containing the list.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(string listPropertyNameof, Type createType, Type returnType, string primaryKeyNameof){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(string listPropertyNameof, Type createType, Type returnType, string primaryKeyNameof){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -30,6 +30,14 @@ namespace BlueWest.Sources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Gets records of a list.")
|
||||||
|
.WriteLine("/// <param name=\"listPropertyNameof\">A nameof with the containing list.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection with the return data.</param>")
|
||||||
|
.WriteLine("/// <param name=\"primaryKeyNameof\">The lookup key of the main entity.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(string listPropertyNameof, Type returnType, string primaryKeyNameof){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(string listPropertyNameof, Type returnType, string primaryKeyNameof){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -30,7 +30,11 @@ namespace BlueWest.EfMethods.Sources
|
||||||
.WriteLine("[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]")
|
.WriteLine("[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]")
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Gets many records of a entity.")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection with the return data.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(Type returnType){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(Type returnType){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -29,6 +29,13 @@ namespace BlueWest.EfMethods.Sources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Gets one record of a entity by a look up key.")
|
||||||
|
.WriteLine("/// <param name=\"bynameof\">The lookup key.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection with the return data.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(string bynameof, Type returnType)")
|
.WriteLine($"public {AttributeName}Attribute(string bynameof, Type returnType)")
|
||||||
.WriteOpeningBracket()
|
.WriteOpeningBracket()
|
||||||
|
|
|
@ -33,6 +33,15 @@ namespace BlueWest.Sources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Gets one record of a list in a entity by the specified look up keys.")
|
||||||
|
.WriteLine("/// <param name=\"entityPrimaryKeyNameof\">The lookup key of this entity.</param>")
|
||||||
|
.WriteLine("/// <param name=\"listMemberNameof\">A nameof with the list in the main type.</param>")
|
||||||
|
.WriteLine("/// <param name=\"listPrimaryKeyNameof\">A nameof with the lookup key of the the list type.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">The projection with the returning data.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(string entityPrimaryKeyNameof, string listMemberNameof, string listPrimaryKeyNameof, Type returnType){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(string entityPrimaryKeyNameof, string listMemberNameof, string listPrimaryKeyNameof, Type returnType){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -27,6 +27,15 @@ namespace BlueWest.EfMethods.Sources
|
||||||
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
.WriteLine($"public sealed class {AttributeName}Attribute : Attribute")
|
||||||
.WriteOpeningBracket();
|
.WriteOpeningBracket();
|
||||||
|
|
||||||
|
|
||||||
|
builder
|
||||||
|
.WriteLine("/// <summary>")
|
||||||
|
.WriteLine("/// Updates a entity with projection data.")
|
||||||
|
.WriteLine("/// <param name=\"updateType\">A projection type with the update data.</param>")
|
||||||
|
.WriteLine("/// <param name=\"returnType\">Type of the projection with the return data.</param>")
|
||||||
|
.WriteLine("/// <param name=\"keyPropertyMemberName\">A nameof with the lookup key of this entity.</param>")
|
||||||
|
.WriteLine("/// </summary>");
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {AttributeName}Attribute(Type updateType, Type returnType, string keyPropertyMemberName){"{}"}")
|
.WriteLine($"public {AttributeName}Attribute(Type updateType, Type returnType, string keyPropertyMemberName){"{}"}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace BlueWest.EfMethods
|
||||||
public ImmutableArray<Diagnostic> Diagnostics { get; private set; }
|
public ImmutableArray<Diagnostic> Diagnostics { get; private set; }
|
||||||
public EfMethodsModel? Model { get; private set; }
|
public EfMethodsModel? Model { get; private set; }
|
||||||
protected Compilation Compilation { get; }
|
protected Compilation Compilation { get; }
|
||||||
protected INamedTypeSymbol MappingContextTypeSymbol { get; }
|
|
||||||
protected SourceGenerationOptions SourceGenerationOptions { get; }
|
protected SourceGenerationOptions SourceGenerationOptions { get; }
|
||||||
protected TypeDeclarationSyntax TypeSyntax { get; }
|
protected TypeDeclarationSyntax TypeSyntax { get; }
|
||||||
|
|
||||||
|
@ -136,10 +135,10 @@ namespace BlueWest.EfMethods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected string ExtractNameOfMemberName(MemberDeclarationSyntax memberDeclarationSyntax, string attributeName, SemanticModel? semanticModel = null, int skip = 0)
|
protected string ExtractNameOfMemberName(MemberDeclarationSyntax memberDeclarationSyntax, string attributeName, int skip = 0)
|
||||||
{
|
{
|
||||||
var attributeData = memberDeclarationSyntax.GetAttribute(attributeName);
|
var attributeData = memberDeclarationSyntax.GetAttribute(attributeName);
|
||||||
var sourceSymbol = ExtractNameOfMemberName(attributeData, semanticModel, skip);
|
var sourceSymbol = ExtractNameOfMemberName(attributeData, skip);
|
||||||
return sourceSymbol;
|
return sourceSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +189,9 @@ namespace BlueWest.EfMethods
|
||||||
return sourceTypeExpressionSyntax;
|
return sourceTypeExpressionSyntax;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string ExtractNameOfMemberName(SyntaxNode? attributeSyntax, SemanticModel semanticModel, int skip)
|
protected string ExtractNameOfMemberName(SyntaxNode? attributeSyntax, int skip)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (attributeSyntax is null)
|
if (attributeSyntax is null)
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
@ -258,7 +258,7 @@ namespace BlueWest.EfMethods
|
||||||
var semanticModel = Compilation.GetSemanticModel(TypeSyntax.SyntaxTree);
|
var semanticModel = Compilation.GetSemanticModel(TypeSyntax.SyntaxTree);
|
||||||
|
|
||||||
// get containing class type information
|
// get containing class type information
|
||||||
ClassDeclarationSyntax classDeclarationSyntax = TypeSyntax as ClassDeclarationSyntax;
|
ClassDeclarationSyntax classDeclarationSyntax = (TypeSyntax as ClassDeclarationSyntax)!;
|
||||||
|
|
||||||
// context name
|
// context name
|
||||||
var dbContextName = classDeclarationSyntax.Identifier.ValueText;
|
var dbContextName = classDeclarationSyntax.Identifier.ValueText;
|
||||||
|
@ -392,11 +392,11 @@ namespace BlueWest.EfMethods
|
||||||
var efAddAttributeTypeSymbols =
|
var efAddAttributeTypeSymbols =
|
||||||
GetEntityTypeSymbol(uProperty, EfUpdateMethodsAttributeSource.AttributeName, semanticModel);
|
GetEntityTypeSymbol(uProperty, EfUpdateMethodsAttributeSource.AttributeName, semanticModel);
|
||||||
|
|
||||||
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfUpdateMethodsAttributeSource.AttributeName, semanticModel);
|
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfUpdateMethodsAttributeSource.AttributeName);
|
||||||
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
||||||
//var secondTypeInfo = FindSecondTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
//var secondTypeInfo = FindSecondTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
||||||
|
|
||||||
var keyMemberFullName = keyMemberType.Value.Type.ToDisplayString();
|
var keyMemberFullName = keyMemberType?.Type.ToDisplayString();
|
||||||
//var keyMemberName = keyMemberType.Value.Type.Name;
|
//var keyMemberName = keyMemberType.Value.Type.Name;
|
||||||
|
|
||||||
// Try grabbing string literal if there's no nameof in it
|
// Try grabbing string literal if there's no nameof in it
|
||||||
|
@ -407,8 +407,6 @@ namespace BlueWest.EfMethods
|
||||||
.Token.ValueText ?? "Id";
|
.Token.ValueText ?? "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (efAddAttributeTypeSymbols == null) return null;
|
|
||||||
|
|
||||||
string updateTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string updateTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
string updateTypeFullName = entityDataModel.EntityTypeFullName;
|
string updateTypeFullName = entityDataModel.EntityTypeFullName;
|
||||||
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
|
@ -429,14 +427,13 @@ namespace BlueWest.EfMethods
|
||||||
|
|
||||||
|
|
||||||
return new EfUpdateMethodsModel(entityDataModel, updateTypeFullName, updateTypeIdentifierName, returnTypeFullName,
|
return new EfUpdateMethodsModel(entityDataModel, updateTypeFullName, updateTypeIdentifierName, returnTypeFullName,
|
||||||
returnTypeIdentifierName, keyPropertyName, keyMemberFullName);
|
returnTypeIdentifierName, keyPropertyName, keyMemberFullName ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EfGetOneWithModel ExtractEfGetEntityWithModel(MemberDeclarationSyntax uProperty, SemanticModel semanticModel, EfEntityDataModel entityDataModel)
|
private EfGetOneWithModel ExtractEfGetEntityWithModel(MemberDeclarationSyntax uProperty, SemanticModel semanticModel, EfEntityDataModel entityDataModel)
|
||||||
{
|
{
|
||||||
|
|
||||||
var efTypeofSymbols =GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
var efTypeofSymbols =GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
||||||
if (efTypeofSymbols == null) return null;
|
|
||||||
|
|
||||||
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
||||||
|
@ -458,7 +455,6 @@ namespace BlueWest.EfMethods
|
||||||
{
|
{
|
||||||
|
|
||||||
var efTypeofSymbols =GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
var efTypeofSymbols =GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
||||||
if (efTypeofSymbols == null) return null;
|
|
||||||
|
|
||||||
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
||||||
|
@ -481,20 +477,11 @@ namespace BlueWest.EfMethods
|
||||||
{
|
{
|
||||||
|
|
||||||
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
||||||
var byParamPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneByAttributeSource.AttributeName, semanticModel);
|
var byParamPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneByAttributeSource.AttributeName);
|
||||||
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
||||||
|
|
||||||
var byParamFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
var byParamFullTypeName = keyMemberType?.Type.ToDisplayString();
|
||||||
|
|
||||||
// Try grabbing string literal if there's no nameof in it
|
|
||||||
if (byParamPropertyName == string.Empty)
|
|
||||||
{
|
|
||||||
byParamPropertyName = GetEntityStringLiteralSymbol(TypeSyntax, EfGetOneByAttributeSource.AttributeName, semanticModel)
|
|
||||||
.FirstOrDefault()?
|
|
||||||
.Token.ValueText ?? "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (efTypeofSymbols == null) return null;
|
|
||||||
|
|
||||||
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
string returnTypeFullName = entityDataModel.EntityTypeFullName;
|
||||||
|
@ -508,7 +495,7 @@ namespace BlueWest.EfMethods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new EfGetOneByModel(entityDataModel, byParamPropertyName, byParamFullTypeName, returnTypeFullName, returnTypeIdentifierName);
|
return new EfGetOneByModel(entityDataModel, byParamPropertyName, byParamFullTypeName ?? string.Empty, returnTypeFullName, returnTypeIdentifierName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -517,10 +504,12 @@ namespace BlueWest.EfMethods
|
||||||
|
|
||||||
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetListAttributeSource.AttributeName, semanticModel);
|
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetListAttributeSource.AttributeName, semanticModel);
|
||||||
|
|
||||||
var listPropertyName = ExtractNameOfMemberName(uProperty, EfGetListAttributeSource.AttributeName, semanticModel);
|
var listPropertyName = ExtractNameOfMemberName(uProperty, EfGetListAttributeSource.AttributeName);
|
||||||
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfGetListAttributeSource.AttributeName, semanticModel, 1);;
|
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfGetListAttributeSource.AttributeName, 1);;
|
||||||
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
||||||
|
#pragma warning disable CS8629
|
||||||
var keyFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
var keyFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
||||||
|
#pragma warning restore CS8629
|
||||||
|
|
||||||
|
|
||||||
// Try grabbing string literal if there's no nameof in it
|
// Try grabbing string literal if there's no nameof in it
|
||||||
|
@ -550,11 +539,15 @@ namespace BlueWest.EfMethods
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var listPropertyName = ExtractNameOfMemberName(uProperty, EfAddToListAttributeSource.AttributeName, semanticModel);
|
var listPropertyName = ExtractNameOfMemberName(uProperty, EfAddToListAttributeSource.AttributeName);
|
||||||
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfAddToListAttributeSource.AttributeName, semanticModel, 1);;
|
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfAddToListAttributeSource.AttributeName, 1);;
|
||||||
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax);
|
||||||
|
#pragma warning disable CS8629
|
||||||
var keyFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
var keyFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
||||||
|
#pragma warning restore CS8629
|
||||||
|
#pragma warning disable CS8629
|
||||||
var listEntityTypeInfo = (FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax, 2).Value.Type as INamedTypeSymbol).TypeArguments.FirstOrDefault();
|
var listEntityTypeInfo = (FindTypeInfoOfMemberExpressionSyntax(semanticModel, TypeSyntax, 2).Value.Type as INamedTypeSymbol).TypeArguments.FirstOrDefault();
|
||||||
|
#pragma warning restore CS8629
|
||||||
var listEntityIdentifierName = listEntityTypeInfo.Name;
|
var listEntityIdentifierName = listEntityTypeInfo.Name;
|
||||||
var listEntityFullTypeName = listEntityTypeInfo.ToDisplayString();
|
var listEntityFullTypeName = listEntityTypeInfo.ToDisplayString();
|
||||||
|
|
||||||
|
@ -611,17 +604,19 @@ namespace BlueWest.EfMethods
|
||||||
|
|
||||||
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel);
|
var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel);
|
||||||
var attributeSymbol = uProperty.GetAttribute(EfGetOneFromListAttributeSource.AttributeName);
|
var attributeSymbol = uProperty.GetAttribute(EfGetOneFromListAttributeSource.AttributeName);
|
||||||
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel);
|
var keyPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName);
|
||||||
var listKeyPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel, 2);
|
var listKeyPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName, 2);
|
||||||
|
#pragma warning disable CS8604
|
||||||
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol);
|
var keyMemberType = FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol);
|
||||||
|
#pragma warning restore CS8604
|
||||||
var listKeyTypeInfo = FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol, 0);
|
var listKeyTypeInfo = FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol, 0);
|
||||||
var keyFullTypeName = keyMemberType.Value.Type.ToDisplayString();
|
var keyFullTypeName = keyMemberType?.Type.ToDisplayString();
|
||||||
var listEntityTypeInfo = (FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol, 1).Value.Type as INamedTypeSymbol).TypeArguments.FirstOrDefault();
|
var listEntityTypeInfo = (FindTypeInfoOfMemberExpressionSyntax(semanticModel, attributeSymbol, 1)?.Type as INamedTypeSymbol).TypeArguments.FirstOrDefault();
|
||||||
var listEntityIdentifierName = listEntityTypeInfo.Name;
|
var listEntityIdentifierName = listEntityTypeInfo.Name;
|
||||||
var listEntityFullTypeName = listEntityTypeInfo.ToDisplayString();
|
var listEntityFullTypeName = listEntityTypeInfo.ToDisplayString();
|
||||||
var listKeyFullTypeName =listKeyTypeInfo.Value.Type.ToDisplayString();;
|
var listKeyFullTypeName =listKeyTypeInfo?.Type.ToDisplayString();;
|
||||||
var listKeyTypeName = listKeyTypeInfo.Value.Type.Name;
|
var listKeyTypeName = listKeyTypeInfo?.Type.Name;
|
||||||
var listPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel, 1);;
|
var listPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName, 1);;
|
||||||
|
|
||||||
|
|
||||||
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
string returnTypeIdentifierName = entityDataModel.EntityTypeIdentifierName;
|
||||||
|
@ -640,10 +635,10 @@ namespace BlueWest.EfMethods
|
||||||
listEntityIdentifierName,
|
listEntityIdentifierName,
|
||||||
listEntityFullTypeName,
|
listEntityFullTypeName,
|
||||||
keyPropertyName,
|
keyPropertyName,
|
||||||
keyFullTypeName,
|
keyFullTypeName ?? string.Empty,
|
||||||
listKeyPropertyName,
|
listKeyPropertyName,
|
||||||
listKeyFullTypeName,
|
listKeyFullTypeName?? string.Empty,
|
||||||
listKeyTypeName,
|
listKeyTypeName?? string.Empty,
|
||||||
returnTypeIdentifierName,
|
returnTypeIdentifierName,
|
||||||
returnTypeFullName);
|
returnTypeFullName);
|
||||||
}
|
}
|
||||||
|
@ -653,7 +648,9 @@ namespace BlueWest.EfMethods
|
||||||
{
|
{
|
||||||
var member = (memberDeclarationSyntax as PropertyDeclarationSyntax).Type;
|
var member = (memberDeclarationSyntax as PropertyDeclarationSyntax).Type;
|
||||||
var genericSyntax = member as GenericNameSyntax;
|
var genericSyntax = member as GenericNameSyntax;
|
||||||
|
#pragma warning disable CS8604
|
||||||
var typeInfo = semanticModel.GetTypeInfo( genericSyntax);
|
var typeInfo = semanticModel.GetTypeInfo( genericSyntax);
|
||||||
|
#pragma warning restore CS8604
|
||||||
var firstTypeArgument = (typeInfo.ConvertedType as INamedTypeSymbol).TypeArguments[0];
|
var firstTypeArgument = (typeInfo.ConvertedType as INamedTypeSymbol).TypeArguments[0];
|
||||||
return firstTypeArgument;
|
return firstTypeArgument;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace BlueWest.EfMethods.Sources
|
||||||
.WriteLine($"namespace {model.Namespace}")
|
.WriteLine($"namespace {model.Namespace}")
|
||||||
.WriteOpeningBracket()
|
.WriteOpeningBracket()
|
||||||
// Class declaration
|
// Class declaration
|
||||||
.WriteLine($"public static partial class {model.ContextTypeName}Extensions")
|
.WriteLine($"internal static partial class {model.ContextTypeName}Extensions")
|
||||||
.WriteOpeningBracket()
|
.WriteOpeningBracket()
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue