Skip to content

Commit cc8e9e7

Browse files
authored
Merge pull request #725 from isaacvale/master
Remove hardwired return type in ExecuteScriptCommand
2 parents 703d0fa + c131c74 commit cc8e9e7

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task<TReturn> Run<TReturn, THost>(ExecuteScriptCommandOptions optio
3131
return await DownloadAndRunCode<TReturn>(options);
3232
}
3333

34-
var pathToLibrary = GetLibrary(options);
34+
var pathToLibrary = GetLibrary<TReturn>(options);
3535

3636
var libraryOptions = new ExecuteLibraryCommandOptions(pathToLibrary, options.Arguments, options.NoCache)
3737
{
@@ -50,7 +50,7 @@ private async Task<TReturn> DownloadAndRunCode<TReturn>(ExecuteScriptCommandOpti
5050
return await new ExecuteCodeCommand(_scriptConsole, _logFactory).Execute<TReturn>(options);
5151
}
5252

53-
private string GetLibrary(ExecuteScriptCommandOptions executeOptions)
53+
private string GetLibrary<TReturn>(ExecuteScriptCommandOptions executeOptions)
5454
{
5555
var projectFolder = FileUtils.GetPathToScriptTempFolder(executeOptions.File.Path);
5656
var executionCacheFolder = Path.Combine(projectFolder, "execution-cache");
@@ -70,7 +70,7 @@ private string GetLibrary(ExecuteScriptCommandOptions executeOptions)
7070
AssemblyLoadContext = executeOptions.AssemblyLoadContext
7171
#endif
7272
};
73-
new PublishCommand(_scriptConsole, _logFactory).Execute(options);
73+
new PublishCommand(_scriptConsole, _logFactory).Execute<TReturn>(options);
7474
if (hash != null)
7575
{
7676
File.WriteAllText(Path.Combine(executionCacheFolder, "script.sha256"), hash);

src/Dotnet.Script.Core/Commands/PublishCommand.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public PublishCommand(ScriptConsole scriptConsole, LogFactory logFactory)
1818
}
1919

2020
public void Execute(PublishCommandOptions options)
21+
{
22+
Execute<int>(options);
23+
}
24+
25+
public void Execute<TReturn>(PublishCommandOptions options)
2126
{
2227
var absoluteFilePath = options.File.Path;
2328

@@ -41,11 +46,11 @@ public void Execute(PublishCommandOptions options)
4146

4247
if (options.PublishType == PublishType.Library)
4348
{
44-
publisher.CreateAssembly<int, CommandLineScriptGlobals>(context, _logFactory, options.LibraryName);
49+
publisher.CreateAssembly<TReturn, CommandLineScriptGlobals>(context, _logFactory, options.LibraryName);
4550
}
4651
else
4752
{
48-
publisher.CreateExecutable<int, CommandLineScriptGlobals>(context, _logFactory, options.RuntimeIdentifier, options.LibraryName);
53+
publisher.CreateExecutable<TReturn, CommandLineScriptGlobals>(context, _logFactory, options.RuntimeIdentifier, options.LibraryName);
4954
}
5055
}
5156
}

src/Dotnet.Script/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private static int Wain(string[] args)
188188
);
189189

190190
var logFactory = CreateLogFactory(verbosity.Value(), debugMode.HasValue());
191-
new PublishCommand(ScriptConsole.Default, logFactory).Execute(options);
191+
new PublishCommand(ScriptConsole.Default, logFactory).Execute<int>(options);
192192
return 0;
193193
});
194194
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy