Skip to content

Commit f09136c

Browse files
committed
Remove hardwired return type, push up to Program.cs and pass generic type
1 parent 7911eaf commit f09136c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public PublishCommand(ScriptConsole scriptConsole, LogFactory logFactory)
1717
_logFactory = logFactory;
1818
}
1919

20-
public void Execute(PublishCommandOptions options)
20+
public void Execute<TReturn>(PublishCommandOptions options)
2121
{
2222
var absoluteFilePath = options.File.Path;
2323

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

4242
if (options.PublishType == PublishType.Library)
4343
{
44-
publisher.CreateAssembly<int, CommandLineScriptGlobals>(context, _logFactory, options.LibraryName);
44+
publisher.CreateAssembly<TReturn, CommandLineScriptGlobals>(context, _logFactory, options.LibraryName);
4545
}
4646
else
4747
{
48-
publisher.CreateExecutable<int, CommandLineScriptGlobals>(context, _logFactory, options.RuntimeIdentifier, options.LibraryName);
48+
publisher.CreateExecutable<TReturn, CommandLineScriptGlobals>(context, _logFactory, options.RuntimeIdentifier, options.LibraryName);
4949
}
5050
}
5151
}

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)