Skip to content

Commit

Permalink
Merge PR #36 from blockchain/wip/testMiscOnLegacy
Browse files Browse the repository at this point in the history
Fsdk,Fsdk.Tests: enable Misc/Tsv tests on legacy.
  • Loading branch information
knocte authored Aug 23, 2023
2 parents 527ed29 + 7a4b950 commit 3a0f522
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions Fsdk.Tests/Fsdk.Tests-legacy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<ItemGroup>
<Compile Include="FSharpUtil.fs" />
<Compile Include="AsyncExtensions.fs" />
<Compile Include="Tsv.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fsdk\Fsdk-legacy.fsproj" />
Expand Down
35 changes: 28 additions & 7 deletions Fsdk/Misc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,32 @@ module Misc =
#if LEGACY_FRAMEWORK
// this below is crazy but is to avoid # char being ignored in Uri.LocalPath property, see https://stackoverflow.com/a/41203269
let private currentExeUri =
Uri(Uri.EscapeUriString(Assembly.GetEntryAssembly().CodeBase))
let entryAssembly = Assembly.GetEntryAssembly()

if isNull entryAssembly then
None
else
Uri(Uri.EscapeUriString(entryAssembly.CodeBase)) |> Some

let private currentExe =
FileInfo(
sprintf
"%s%s"
(Uri.UnescapeDataString(currentExeUri.PathAndQuery))
(Uri.UnescapeDataString(currentExeUri.Fragment))
)
match currentExeUri with
| None -> None
| Some currentExeUri ->
FileInfo(
sprintf
"%s%s"
(Uri.UnescapeDataString(currentExeUri.PathAndQuery))
(Uri.UnescapeDataString(currentExeUri.Fragment))
)
|> Some

let rec private FsxOnlyArgumentsInternalFsx(args: list<string>) =
let currentExe =
if currentExe.IsNone then
failwith "Could not get EntryAssembly"
else
currentExe.Value

match args with
| [] -> []
| head :: tail ->
Expand Down Expand Up @@ -96,6 +111,12 @@ module Misc =
// likely running a fsxc-ed assembly from an .fsx script (so 'dotnet someFile.fsx.dll someArg1' instead of 'dotnet fsi someFile.fsx someArg1')
List.skip 1 cmdLineArgs
#else
let currentExe =
if currentExe.IsNone then
failwith "Could not get EntryAssembly"
else
currentExe.Value

let isFsi =
String.Equals(
currentExe.Name,
Expand Down

0 comments on commit 3a0f522

Please sign in to comment.