Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Properties related to build/pack -->
<IsPackable>false</IsPackable>
<Version>10.0.13-pre01</Version>
<Version>10.0.12</Version>
<MapsterPluginsTFMs>netstandard2.0;net10.0;net9.0;net8.0</MapsterPluginsTFMs>
<MapsterTFMs>netstandard2.0;net10.0;net9.0;net8.0</MapsterTFMs>
<MapsterEFCoreTFMs>net10.0;net9.0;net8.0</MapsterEFCoreTFMs>
Expand Down
97 changes: 1 addition & 96 deletions src/ExpressionTranslator/ExpressionTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Xml.Linq;

namespace ExpressionDebugger
{
Expand Down Expand Up @@ -1269,88 +1268,6 @@ public Expression VisitLambda(LambdaExpression node, LambdaType type, string? me
}
}

public Expression VisitLambdaForGenerateMappers(LambdaExpression node, LambdaType type, Type InterfaceType, string? methodName = null,
bool isInternal = false)
{
VisitLambda(node, type, methodName, isInternal);

if (!isInternal)
isInternal = node.ReturnType.GetTypeInfo().IsNotPublic ||
node.Parameters.Any(it => it.Type.GetTypeInfo().IsNotPublic);

if(!isInternal)
return node; // skip create interface implimentation if public only

if (type == LambdaType.PrivateLambda || type == LambdaType.PublicLambda)
{
_inlineCount++;
if (type == LambdaType.PublicLambda)
{
var name = methodName != null ? $"{InterfaceType.FullName}.{methodName}" : "Main";
WriteLine();
var funcType = MakeDelegateType(node.ReturnType, node.Parameters.Select(it => it.Type).ToArray());
var exprType = typeof(Expression<>).MakeGenericType(funcType);
Write(Translate(exprType), " ", name, " => ");
}

IList<ParameterExpression> args;
if (node.Parameters.Count == 1)
{
args = new List<ParameterExpression>();
var arg = VisitParameter(node.Parameters[0]);
args.Add((ParameterExpression)arg);
}
else
{
args = VisitArguments("(", node.Parameters.ToList(), p => (ParameterExpression)VisitParameter(p),
")");
}

Write(" => ");
var body = VisitGroup(node.Body, ExpressionType.Quote);
if (type == LambdaType.PublicLambda)
Write(";");
_inlineCount--;
return Expression.Lambda(body, node.Name, node.TailCall, args);
}
else
{
var name = methodName != null ? $"{InterfaceType.FullName}.{methodName}" : "Main";
if (type == LambdaType.PublicMethod || type == LambdaType.ExtensionMethod)
{
if (!isInternal)
isInternal = node.ReturnType.GetTypeInfo().IsNotPublic ||
node.Parameters.Any(it => it.Type.GetTypeInfo().IsNotPublic);
WriteLine();
Methods[name] = node.Type;
}
else
{
name = GetName(node, name);
WriteModifierNextLine("private");
}

Write(Translate(node.ReturnType), " ", name);
var open = "(";
if (type == LambdaType.ExtensionMethod)
{
if (Definitions?.IsStatic != true)
throw new InvalidOperationException("Extension method requires static class");
if (node.Parameters.Count == 0)
throw new InvalidOperationException("Extension method requires at least 1 parameter");
open = "(this ";
}

var args = VisitArguments(open, node.Parameters, VisitParameterDeclaration, ")");
Indent();
var body = VisitBody(node.Body, true);

Outdent();

return Expression.Lambda(body, name, node.TailCall, args);
}
}

private HashSet<LambdaExpression>? _visitedLambda;
private int _writerLevel;

Expand Down Expand Up @@ -1948,15 +1865,8 @@ public override string ToString()
WriteNextLine("using ", ns, ";");
}

}

foreach (var ns in Definitions.GeneratedAttributes.Select(x => x.NameSpace).Distinct())
{
WriteNextLine("using ", ns, ";");
}

if(_usings != null || Definitions.GeneratedAttributes.Count != 0)
WriteLine();
}

// NOTE: type alias cannot solve all name conflicted case, user should use PrintFullTypeName
// keep logic here for compatibility
Expand All @@ -1981,11 +1891,6 @@ public override string ToString()
Indent();
}

foreach (var gAttr in Definitions.GeneratedAttributes)
{
WriteNextLine(gAttr.Implimentation);
}

var isInternal = Definitions.IsInternal;
if (!isInternal)
isInternal = Definitions.Implements?.Any(it =>
Expand Down

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions src/ExpressionTranslator/Helpers/GeneratedBase.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/ExpressionTranslator/Helpers/MemberInfoExtensions.cs

This file was deleted.

80 changes: 0 additions & 80 deletions src/ExpressionTranslator/Helpers/RandomNamespaceGenerator.cs

This file was deleted.

4 changes: 1 addition & 3 deletions src/ExpressionTranslator/TypeDefinitions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ExpressionDebugger.Helpers.GeneratedAttributes;
using System;
using System;
using System.Collections.Generic;

namespace ExpressionDebugger
Expand All @@ -13,7 +12,6 @@ public class TypeDefinitions
public IEnumerable<Type>? Implements { get; set; }
public bool PrintFullTypeName { get; set; }
public bool IsRecordType { get; set; }
public HashSet<IGeneratedAttribute> GeneratedAttributes { get; set; } = new HashSet<IGeneratedAttribute>();

/// <summary>
/// Set to 2 to mark all properties as nullable
Expand Down
7 changes: 0 additions & 7 deletions src/Mapster.Tool/MapperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ public class MapperOptions
[Option('N', "nullableDirective", Required = false, HelpText = "Set true to add \"#nullable enable\" to the top of generated mapper files")]
public bool GenerateNullableDirective { get; set; }

[Option('h', "helpersCreate", Required = false, HelpText = "Generate helpers features")]
public bool CreateHelpers { get; set; }

[Option('H', "helpersNamespace", Required = false, HelpText = "Specify additional namespace to generated helpers features")]
public string? HelpersNamespace { get; set; }


[Usage(ApplicationAlias = "dotnet mapster mapper")]
public static IEnumerable<Example> Examples =>
new List<Example>
Expand Down
Loading
Loading