From 78b506d0670ca2b5ce2afd610df4eb5226a8a979 Mon Sep 17 00:00:00 2001
From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com>
Date: Thu, 10 Mar 2022 01:11:43 +0100
Subject: [PATCH] #84: added AvoidDisableInternalNamespace property
---
src/GUI/AssemblyCollectionControl.xaml | 2 +-
src/GUI/AssemblyCollectionControl.xaml.cs | 18 +++++++-------
src/GUI/MainWindow.xaml | 7 +++++-
src/GUI/MainWindow.xaml.cs | 23 +++++++++---------
src/engine/Reflector.cs | 29 ++++++++++++-----------
src/engine/SharedClasses.cs | 12 ++++++++++
6 files changed, 55 insertions(+), 36 deletions(-)
diff --git a/src/GUI/AssemblyCollectionControl.xaml b/src/GUI/AssemblyCollectionControl.xaml
index ab207a25b1c..e35443a6abf 100644
--- a/src/GUI/AssemblyCollectionControl.xaml
+++ b/src/GUI/AssemblyCollectionControl.xaml
@@ -37,7 +37,7 @@
-
diff --git a/src/GUI/AssemblyCollectionControl.xaml.cs b/src/GUI/AssemblyCollectionControl.xaml.cs
index aa8bde0ae57..412153c3c0c 100644
--- a/src/GUI/AssemblyCollectionControl.xaml.cs
+++ b/src/GUI/AssemblyCollectionControl.xaml.cs
@@ -43,15 +43,15 @@ public int TotalFolders
public static readonly DependencyProperty TotalFoldersProperty =
DependencyProperty.Register("TotalFolders", typeof(int), typeof(AssemblyCollectionControl), new PropertyMetadata(0));
- public AssemblyDataCollection AssemblyDataCollection
+ public AssemblyDataCollection AssemblyCollection
{
- get { return (AssemblyDataCollection)GetValue(AssemblyDataCollectionProperty); }
- set { SetValue(AssemblyDataCollectionProperty, value); }
+ get { return (AssemblyDataCollection)GetValue(AssemblyCollectionProperty); }
+ set { SetValue(AssemblyCollectionProperty, value); }
}
// Using a DependencyProperty as the backing store for UserNodeIds. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty AssemblyDataCollectionProperty =
- DependencyProperty.Register("AssemblyDataCollection", typeof(AssemblyDataCollection), typeof(AssemblyCollectionControl), new PropertyMetadata(PropertyChangedCallback));
+ public static readonly DependencyProperty AssemblyCollectionProperty =
+ DependencyProperty.Register("AssemblyCollection", typeof(AssemblyDataCollection), typeof(AssemblyCollectionControl), new PropertyMetadata(PropertyChangedCallback));
static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
@@ -66,9 +66,9 @@ public AssemblyCollectionControl()
private void btnSelectAll_Click(object sender, RoutedEventArgs e)
{
- if (AssemblyDataCollection != null)
+ if (AssemblyCollection != null)
{
- foreach (var item in AssemblyDataCollection)
+ foreach (AssemblyData item in AssemblyCollection)
{
item.IsSelected = true;
}
@@ -77,9 +77,9 @@ private void btnSelectAll_Click(object sender, RoutedEventArgs e)
private void btnUnselectAll_Click(object sender, RoutedEventArgs e)
{
- if (AssemblyDataCollection != null)
+ if (AssemblyCollection != null)
{
- foreach (var item in AssemblyDataCollection)
+ foreach (AssemblyData item in AssemblyCollection)
{
item.IsSelected = false;
}
diff --git a/src/GUI/MainWindow.xaml b/src/GUI/MainWindow.xaml
index 8ef4265fbd3..b331b845b03 100644
--- a/src/GUI/MainWindow.xaml
+++ b/src/GUI/MainWindow.xaml
@@ -88,6 +88,11 @@
+
+
+
+
+
@@ -132,7 +137,7 @@
-
+
diff --git a/src/GUI/MainWindow.xaml.cs b/src/GUI/MainWindow.xaml.cs
index 186aa067013..85285c0a23a 100644
--- a/src/GUI/MainWindow.xaml.cs
+++ b/src/GUI/MainWindow.xaml.cs
@@ -55,15 +55,15 @@ public string JarDestinationFolder
public static readonly DependencyProperty JarDestinationFolderProperty =
DependencyProperty.Register("JarDestinationFolder", typeof(string), typeof(MainWindow), new PropertyMetadata(JobManager.JarDestinationFolder));
- public AssemblyDataCollection AssemblyDataCollection
+ public AssemblyDataCollection AssemblyCollection
{
- get { return (AssemblyDataCollection)GetValue(AssemblyDataCollectionProperty); }
- set { SetValue(AssemblyDataCollectionProperty, value); }
+ get { return (AssemblyDataCollection)GetValue(AssemblyCollectionProperty); }
+ set { SetValue(AssemblyCollectionProperty, value); }
}
// Using a DependencyProperty as the backing store for UserNodeIds. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty AssemblyDataCollectionProperty =
- DependencyProperty.Register("AssemblyDataCollection", typeof(AssemblyDataCollection), typeof(MainWindow));
+ public static readonly DependencyProperty AssemblyCollectionProperty =
+ DependencyProperty.Register("AssemblyCollection", typeof(AssemblyDataCollection), typeof(MainWindow));
public int MaxDepth
{
@@ -173,6 +173,7 @@ private void btnExecute_Click(object sender, RoutedEventArgs e)
EnableInheritance = cbEnableInheritance.IsChecked.Value,
EnableInterfaceInheritance = cbEnableInterfaceInheritance.IsChecked.Value,
EnableRefOutParameters = cbEnableRefOutParameters.IsChecked.Value,
+ AvoidDisableInternalNamespace = cbAvoidDisableInternalNamespace.IsChecked.Value,
DryRun = cbDryRun.IsChecked.Value
};
@@ -202,7 +203,7 @@ private void btnGetFolders_Click(object sender, RoutedEventArgs e)
var result = JobManager.CreateFolderList(args);
- AssemblyDataCollection = result;
+ AssemblyCollection = result;
}
private void btnBuild_Click(object sender, RoutedEventArgs e)
@@ -217,7 +218,7 @@ private void btnBuild_Click(object sender, RoutedEventArgs e)
JDKToolExtraOptions = tbJDKToolExtraOptions.Text,
SourceFolder = SourceDestinationFolder,
SplitFolderByAssembly = cbEnableSplitFolder.IsChecked.Value,
- AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyDataCollection)
+ AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyCollection)
};
if (cbExportToFile.IsChecked.Value)
@@ -248,7 +249,7 @@ private void btnBuildDoc_Click(object sender, RoutedEventArgs e)
JDKToolExtraOptions = tbJDKToolExtraOptions.Text,
SourceFolder = SourceDestinationFolder,
SplitFolderByAssembly = cbEnableSplitFolder.IsChecked.Value,
- AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyDataCollection),
+ AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyCollection),
CommitVersion = tbCommitVersion.Text
};
@@ -283,7 +284,7 @@ private void btnCreateJars_Click(object sender, RoutedEventArgs e)
WithJARSource = cbWithSource.IsChecked.Value,
EmbeddingJCOBridge = cbWithEmbedding.IsChecked.Value,
- AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyDataCollection)
+ AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyCollection)
};
if (cbExportToFile.IsChecked.Value)
@@ -311,7 +312,7 @@ private void btnGenerateSnapshotPOM_Click(object sender, RoutedEventArgs e)
JDKToolExtraOptions = tbJDKToolExtraOptions.Text,
SourceFolder = SourceDestinationFolder,
SplitFolderByAssembly = cbEnableSplitFolder.IsChecked.Value,
- AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyDataCollection)
+ AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyCollection)
};
if (cbExportToFile.IsChecked.Value)
@@ -335,7 +336,7 @@ private void btnGeneratePOM_Click(object sender, RoutedEventArgs e)
SourceFolder = SourceDestinationFolder,
SplitFolderByAssembly = cbEnableSplitFolder.IsChecked.Value,
POMStagingType = POMStagingType.Release,
- AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyDataCollection)
+ AssembliesToUse = AssemblyDataCollection.CreateList(AssemblyCollection)
};
if (cbExportToFile.IsChecked.Value)
diff --git a/src/engine/Reflector.cs b/src/engine/Reflector.cs
index b6afa5b69c7..5d4913929ad 100644
--- a/src/engine/Reflector.cs
+++ b/src/engine/Reflector.cs
@@ -56,6 +56,7 @@ static class Reflector
static bool AvoidHierarchyTraversing;
static bool CreateExceptionThrownClause;
static int ExceptionThrownClauseDepth;
+ static bool AvoidDisableInternalNamespace;
static long loadedAssemblies = 0;
static long parsedAssemblies = 0;
@@ -85,7 +86,7 @@ static class Reflector
static string reflectorVersion = typeof(Reflector).Assembly.GetName().Version.ToString();
- static string replaceSinglekeyword(string inputName)
+ static string ReplaceSinglekeyword(string inputName)
{
foreach (var item in Const.KeyWords)
{
@@ -302,7 +303,7 @@ static string GetReport(string[] assemblyNames)
return res;
}
- static void writeExtraClasses(ReflectorEventArgs args)
+ static void WriteExtraClasses(ReflectorEventArgs args)
{
string destFolder = assemblyDestinationFolder(SourceDestinationFolder, new AssemblyName(Const.SpecialNames.JCOReflectorGeneratedFolder), SplitByAssembly);
var jcoBridgeOptionsFile = Path.Combine(destFolder, Const.FileNameAndDirectory.OrgSubDirectory,
@@ -367,11 +368,11 @@ public static async Task ExecuteAction(object o)
EnableInterfaceInheritance = args.EnableInterfaceInheritance;
EnableRefOutParameters = args.EnableRefOutParameters;
EnableWrite = !args.DryRun;
+ AvoidDisableInternalNamespace = args.AvoidDisableInternalNamespace;
- writeExtraClasses(args);
+ WriteExtraClasses(args);
string reportStr = string.Empty;
- string statisticsCsv = string.Empty;
try
{
foreach (var item in args.AssemblyNames)
@@ -412,7 +413,7 @@ public static async Task ExecuteAction(object o)
}
string statisticsError;
- statisticsCsv = GetStatisticsCsv(out statisticsError);
+ string statisticsCsv = GetStatisticsCsv(out statisticsError);
if (!String.IsNullOrEmpty(statisticsError))
{
@@ -470,11 +471,11 @@ static string assemblyDestinationFolder(string rootFolder, AssemblyName assembly
return Path.Combine(rootFolder, Const.Framework.RuntimeFolder, splitByAssembly ? assemblyName.ToFolderName() : string.Empty);
}
- static bool typePrefilter(Type type)
+ static bool TypePrefilter(this Type type)
{
if (type.IsPublic
&& !type.IsGenericType
- && !type.ToPackageName().Contains(Const.SpecialNames.Internal) // avoid types with internal namespace name which are public
+ && (AvoidDisableInternalNamespace || !type.ToPackageName().Contains(Const.SpecialNames.Internal)) // avoid types with internal namespace name which are public
)
{
return true;
@@ -554,7 +555,7 @@ public static Assembly ExportAssembly(IList assemblyReferenced, IList assemblyReferenced, IList imports, bool withI
string paramType = convertType(imports, parameter.ParameterType, out isPrimitive, out defaultPrimitiveValue, out isManaged, out isSpecial, out isArray);
if (!isManaged) break; // found not managed type, stop here
- var paramName = replaceSinglekeyword(parameter.Name);
+ var paramName = ReplaceSinglekeyword(parameter.Name);
isPrimitive |= typeof(Delegate).IsAssignableFrom(parameter.ParameterType);
ctorParams.Append(string.Format(Const.Parameters.INPUT_PARAMETER, (isArray) ? paramType + (IsParams(parameter) ? Const.SpecialNames.VarArgsTrailer : Const.SpecialNames.ArrayTrailer) : paramType, paramName));
@@ -1514,7 +1515,7 @@ static string ExportMethods(this Type type, IList imports, IList imp
isPrimitive |= typeof(Delegate).IsAssignableFrom(parameter.ParameterType);
string formatter = string.Empty;
string objectCaster = string.Empty;
- var paramName = replaceSinglekeyword(parameter.Name);
+ var paramName = ReplaceSinglekeyword(parameter.Name);
if (useRefOut)
{
string primitiveParam = Const.Parameters.JCORefOutType;
@@ -1840,7 +1841,7 @@ static string ExportMethods(this Type type, IList imports, IList imp
isPrimitive |= typeof(Delegate).IsAssignableFrom(parameter.ParameterType);
string formatter = string.Empty;
string objectCaster = string.Empty;
- var paramName = replaceSinglekeyword(parameter.Name);
+ var paramName = ReplaceSinglekeyword(parameter.Name);
if (useRefOut)
{
string primitiveParam = Const.Parameters.JCORefOutType;
@@ -1986,7 +1987,7 @@ static string buildPropertySignature(string templateToUse, string propertyJavaNa
StringBuilder inputParams = new StringBuilder();
StringBuilder execParams = new StringBuilder();
- propertyJavaName = replaceSinglekeyword(propertyJavaName);
+ propertyJavaName = ReplaceSinglekeyword(propertyJavaName);
string inputParamStr = inputParams.ToString();
if (!string.IsNullOrEmpty(inputParamStr))
@@ -2424,7 +2425,7 @@ static bool ExportingDelegate(this Type item, string destFolder, string assembly
}
if (!isManaged) break; // found not managed type, stop here
- var paramName = replaceSinglekeyword(parameter.Name);
+ var paramName = ReplaceSinglekeyword(parameter.Name);
if (isArray)
{
diff --git a/src/engine/SharedClasses.cs b/src/engine/SharedClasses.cs
index 934b4c31e1a..88e2c84e7e6 100644
--- a/src/engine/SharedClasses.cs
+++ b/src/engine/SharedClasses.cs
@@ -228,6 +228,7 @@ public class CmdParam
public const string EnableRefOutParameters = "EnableRefOutParameters";
public const string DryRun = "DryRun";
public const string AvoidReportAndStatistics = "AvoidReportAndStatistics";
+ public const string AvoidDisableInternalNamespace = "AvoidDisableInternalNamespace";
// JavaBuilderEventArgs
public const string JDKFolder = "JDKFolder";
@@ -397,6 +398,12 @@ static IArgumentMetadata[] prepareArguments()
Default = false,
Help = "Do not write report and statistics (used from JobType.Reflect).",
},
+ new ArgumentMetadata()
+ {
+ Name = CmdParam.AvoidDisableInternalNamespace,
+ Default = false,
+ Help = "Do not bypass namespace ending with Internal.",
+ },
new ArgumentMetadata()
{
Name = CmdParam.JDKFolder,
@@ -657,6 +664,10 @@ public static CommonEventArgs UpdateFromArgs(this CommonEventArgs arg, IEnumerab
{
newArg.AvoidReportAndStatistics = Parser.Get(args, CmdParam.AvoidReportAndStatistics);
}
+ if (Parser.Exist(args, CmdParam.AvoidDisableInternalNamespace))
+ {
+ newArg.AvoidDisableInternalNamespace = Parser.Get(args, CmdParam.AvoidDisableInternalNamespace);
+ }
}
break;
case JobTypes.Build:
@@ -1612,6 +1623,7 @@ public ReflectorEventArgs(LogLevel logLevel)
public bool EnableRefOutParameters { get; set; }
public bool DryRun { get; set; }
public bool AvoidReportAndStatistics { get; set; }
+ public bool AvoidDisableInternalNamespace { get; set; }
}
#endregion
}