Skip to content

Commit

Permalink
remove exporting of internal nativecallable methods (dotnet#4986)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Dec 27, 2017
1 parent f8106e1 commit 0fad626
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ internal class ExportedMethodsWriter
private string _exportsFilePath;
private string _moduleName;
private TargetDetails _targetDetails;
private static ModuleDesc _systemModule;

private ExportedMethodsWriter(string outputFile, NodeFactory factory)
{
string directory = Path.GetDirectoryName(outputFile);
string filename = Path.GetFileNameWithoutExtension(outputFile);

_targetDetails = factory.Target;
_systemModule = factory.TypeSystemContext.SystemModule;
_moduleName = filename;
_exportsFilePath = Path.Combine(directory, filename + GetExportsFileExtenstion());
}

public static void EmitExportedMethods(string outputFile, NodeFactory factory)
{
var nativeCallables = factory.NodeAliases.Where(n => n.Key is IMethodNode)
.Where(n => (n.Key as IMethodNode).Method.IsNativeCallable);
.Where(n => (n.Key as IMethodNode).Method.IsNativeCallable)
.Where(n => !IsInternalExport((n.Key as IMethodNode).Method));

var exportNames = nativeCallables.Select(n => n.Value);
new ExportedMethodsWriter(outputFile, factory).WriteExportedMethodsToFile(exportNames);
Expand All @@ -41,6 +44,9 @@ public static void EmitExportedMethods(string outputFile, NodeFactory factory)
private string GetExportsFileExtenstion()
=> _targetDetails.IsWindows ? ".def" : ".exports";

private static bool IsInternalExport(MethodDesc method)
=> ((MetadataType)method.OwningType).Module == _systemModule;

private void WriteExportedMethodsToFile(IEnumerable<string> exportNames)
{
StringBuilder stringBuilder = new StringBuilder();
Expand Down

0 comments on commit 0fad626

Please sign in to comment.