Add mpc.exe option to force output map mode #7
This commit is contained in:
Родитель
8bb1c018c2
Коммит
19b5ca1e23
|
@ -875,6 +875,7 @@ mpc arguments help:
|
|||
-c, --conditionalsymbol [optional, default=empty]conditional compiler symbol
|
||||
-r, --resolvername [optional, default=GeneratedResolver]Set resolver name
|
||||
-n, --namespace [optional, default=MessagePack]Set namespace root name
|
||||
-m, --usemapmode [optional, default=false]Force use map mode serialization
|
||||
```
|
||||
|
||||
```
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -42,6 +42,7 @@ namespace MessagePack.CodeGenerator
|
|||
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes);
|
||||
|
||||
readonly string csProjPath;
|
||||
readonly bool isForceUseMap;
|
||||
readonly ReferenceSymbols typeReferences;
|
||||
readonly INamedTypeSymbol[] targetTypes;
|
||||
readonly HashSet<string> embeddedTypes = new HashSet<string>(new string[]
|
||||
|
@ -186,12 +187,13 @@ namespace MessagePack.CodeGenerator
|
|||
|
||||
// ---
|
||||
|
||||
public TypeCollector(string csProjPath, IEnumerable<string> conditinalSymbols, bool disallowInternal)
|
||||
public TypeCollector(string csProjPath, IEnumerable<string> conditinalSymbols, bool disallowInternal, bool isForceUseMap)
|
||||
{
|
||||
this.csProjPath = csProjPath;
|
||||
var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.Concat(new[] { CodegeneratorOnlyPreprocessorSymbol }).ToArray()).GetAwaiter().GetResult();
|
||||
this.typeReferences = new ReferenceSymbols(compilation);
|
||||
this.disallowInternal = disallowInternal;
|
||||
this.isForceUseMap = isForceUseMap;
|
||||
|
||||
targetTypes = compilation.GetNamedTypeSymbols()
|
||||
.Where(x =>
|
||||
|
@ -431,9 +433,9 @@ namespace MessagePack.CodeGenerator
|
|||
var intMemebrs = new Dictionary<int, MemberSerializationInfo>();
|
||||
var stringMembers = new Dictionary<string, MemberSerializationInfo>();
|
||||
|
||||
if ((bool)contractAttr.ConstructorArguments[0].Value)
|
||||
if (isForceUseMap || (bool)contractAttr.ConstructorArguments[0].Value)
|
||||
{
|
||||
// Opt-out: All public members are serialize target except [Ignore] member.
|
||||
// All public members are serialize target except [Ignore] member.
|
||||
isIntKey = false;
|
||||
|
||||
var hiddenIntKey = 0;
|
||||
|
@ -483,7 +485,7 @@ namespace MessagePack.CodeGenerator
|
|||
}
|
||||
else
|
||||
{
|
||||
// Opt-in: Only KeyAttribute members
|
||||
// Only KeyAttribute members
|
||||
var searchFirst = true;
|
||||
var hiddenIntKey = 0;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace MessagePack.CodeGenerator
|
|||
public List<string> ConditionalSymbols { get; private set; }
|
||||
public string ResolverName { get; private set; }
|
||||
public string NamespaceRoot { get; private set; }
|
||||
public bool IsUseMap { get; private set; }
|
||||
|
||||
public bool IsParsed { get; set; }
|
||||
|
||||
|
@ -25,6 +26,7 @@ namespace MessagePack.CodeGenerator
|
|||
ConditionalSymbols = new List<string>();
|
||||
NamespaceRoot = "MessagePack";
|
||||
ResolverName = "GeneratedResolver";
|
||||
IsUseMap = false;
|
||||
|
||||
var option = new OptionSet()
|
||||
{
|
||||
|
@ -33,6 +35,7 @@ namespace MessagePack.CodeGenerator
|
|||
{ "c|conditionalsymbol=", "[optional, default=empty]conditional compiler symbol", x => { ConditionalSymbols.AddRange(x.Split(',')); } },
|
||||
{ "r|resolvername=", "[optional, default=GeneratedResolver]Set resolver name", x => { ResolverName = x; } },
|
||||
{ "n|namespace=", "[optional, default=MessagePack]Set namespace root name", x => { NamespaceRoot = x; } },
|
||||
{ "m|usemapmode", "[optional, default=false]Force use map mode serialization", x => { IsUseMap = true; } },
|
||||
};
|
||||
if (args.Length == 0)
|
||||
{
|
||||
|
@ -76,7 +79,7 @@ namespace MessagePack.CodeGenerator
|
|||
var sw = Stopwatch.StartNew();
|
||||
Console.WriteLine("Project Compilation Start:" + cmdArgs.InputPath);
|
||||
|
||||
var collector = new TypeCollector(cmdArgs.InputPath, cmdArgs.ConditionalSymbols, true);
|
||||
var collector = new TypeCollector(cmdArgs.InputPath, cmdArgs.ConditionalSymbols, true, cmdArgs.IsUseMap);
|
||||
|
||||
Console.WriteLine("Project Compilation Complete:" + sw.Elapsed.ToString());
|
||||
Console.WriteLine();
|
||||
|
|
Загрузка…
Ссылка в новой задаче