Skip to content

Commit

Permalink
masesgroup#84: added AvoidDisableInternalNamespace property
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers committed Mar 10, 2022
1 parent 3956da4 commit 78b506d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/GUI/AssemblyCollectionControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Label Content="Total folders" />
<TextBox Text="{Binding ElementName=assemblyCollectionControl, Path=TotalFolders, Mode=OneWay}" VerticalContentAlignment="Center" IsReadOnly="True"/>
</DockPanel>
<ListView Name="propertyMapping" ItemsSource="{Binding ElementName=assemblyCollectionControl, Path=AssemblyDataCollection, Mode=TwoWay}"
<ListView Name="propertyMapping" ItemsSource="{Binding ElementName=assemblyCollectionControl, Path=AssemblyCollection, Mode=TwoWay}"
ScrollViewer.VerticalScrollBarVisibility="Auto" DockPanel.Dock="Bottom">
<ListView.View>
<GridView>
Expand Down
18 changes: 9 additions & 9 deletions src/GUI/AssemblyCollectionControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion src/GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<CheckBox Name="cbEnableRefOutParameters" Content="Ref Out Parameters" IsChecked="False" VerticalContentAlignment="Center" ToolTip="Enable RefOut Parameters"/>
</DockPanel>
</GroupBox>
<GroupBox DockPanel.Dock="Top" Header="Namespace">
<DockPanel Height="30">
<CheckBox Name="cbAvoidDisableInternalNamespace" Content="Reflect namepsace with Internal" IsChecked="False" VerticalContentAlignment="Center" ToolTip="Set to true to disable avoidance of reflection of namespaces ending with Internal"/>
</DockPanel>
</GroupBox>
</DockPanel>
</GroupBox>
<DockPanel DockPanel.Dock="Top" MinHeight="30" LastChildFill="False">
Expand Down Expand Up @@ -132,7 +137,7 @@
<Label Content="External POM Filename" VerticalContentAlignment="Center" VerticalAlignment="Stretch"/>
<TextBox Name="tbPOMFileName" VerticalContentAlignment="Center" VerticalAlignment="Stretch" />
</DockPanel>
<local:AssemblyCollectionControl DockPanel.Dock="Bottom" AssemblyDataCollection="{Binding ElementName=mainWindow, Path=AssemblyDataCollection, Mode=TwoWay}"/>
<local:AssemblyCollectionControl DockPanel.Dock="Bottom" AssemblyCollection="{Binding ElementName=mainWindow, Path=AssemblyCollection, Mode=TwoWay}"/>
</DockPanel>
</TabItem>
</TabControl>
Expand Down
23 changes: 12 additions & 11 deletions src/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
};

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
};

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
29 changes: 15 additions & 14 deletions src/engine/Reflector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -554,7 +555,7 @@ public static Assembly ExportAssembly(IList<string> assemblyReferenced, IList<st

var typeName = item.FullName;

if (typePrefilter(item))
if (item.TypePrefilter())
{
JobManager.AppendToConsole(LogLevel.Verbose, "Store {0} within types to be exported", item.AssemblyQualifiedName);
typesToExport.Add(item);
Expand All @@ -565,7 +566,7 @@ public static Assembly ExportAssembly(IList<string> assemblyReferenced, IList<st
Interlocked.Increment(ref discardedTypes);
if (!item.IsPublic) Interlocked.Increment(ref discardedNonPublicTypes);
else if (item.IsGenericType) Interlocked.Increment(ref discardedGenericTypes);
else if (item.ToPackageName().Contains(Const.SpecialNames.Internal)) Interlocked.Increment(ref discardedInternalTypes);
else if (AvoidDisableInternalNamespace || item.ToPackageName().Contains(Const.SpecialNames.Internal)) Interlocked.Increment(ref discardedInternalTypes);
}
}

Expand Down Expand Up @@ -1105,7 +1106,7 @@ static string ExportConstructors(this Type type, IList<Type> 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));

Expand Down Expand Up @@ -1514,7 +1515,7 @@ static string ExportMethods(this Type type, IList<Type> imports, IList<Type> 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;
Expand Down Expand Up @@ -1840,7 +1841,7 @@ static string ExportMethods(this Type type, IList<Type> imports, IList<Type> 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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
{
Expand Down
12 changes: 12 additions & 0 deletions src/engine/SharedClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -397,6 +398,12 @@ static IArgumentMetadata[] prepareArguments()
Default = false,
Help = "Do not write report and statistics (used from JobType.Reflect).",
},
new ArgumentMetadata<bool>()
{
Name = CmdParam.AvoidDisableInternalNamespace,
Default = false,
Help = "Do not bypass namespace ending with Internal.",
},
new ArgumentMetadata<string>()
{
Name = CmdParam.JDKFolder,
Expand Down Expand Up @@ -657,6 +664,10 @@ public static CommonEventArgs UpdateFromArgs(this CommonEventArgs arg, IEnumerab
{
newArg.AvoidReportAndStatistics = Parser.Get<bool>(args, CmdParam.AvoidReportAndStatistics);
}
if (Parser.Exist(args, CmdParam.AvoidDisableInternalNamespace))
{
newArg.AvoidDisableInternalNamespace = Parser.Get<bool>(args, CmdParam.AvoidDisableInternalNamespace);
}
}
break;
case JobTypes.Build:
Expand Down Expand Up @@ -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
}

0 comments on commit 78b506d

Please sign in to comment.