Skip to content

Commit

Permalink
revert more TP experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Sep 9, 2021
1 parent 4e08385 commit c59001c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 54 deletions.
53 changes: 8 additions & 45 deletions WebSharper.UI.Templating/TemplatingProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ open System
open System.Collections.Generic
open System.IO
open System.Reflection
open System.Runtime.Loader
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
open ProviderImplementation
Expand Down Expand Up @@ -651,52 +650,16 @@ type TemplatingProvider (cfg: TypeProviderConfig) as this =

override this.ResolveAssembly(args) =
//eprintfn "Type provider looking for assembly: %s" args.Name

let name = AssemblyName(args.Name).Name.ToLowerInvariant()

let asmsProp = typeof<AssemblyLoadContext>.GetProperty("Assemblies", [||])
let assemblies = asmsProp.GetMethod.Invoke(AssemblyLoadContext.Default, [||]) :?> seq<Assembly>

let fromALC =
assemblies
|> Seq.tryFind (fun a -> a.GetName().Name.ToLowerInvariant() = name)

match fromALC with
| Some asm -> asm
let an =
cfg.ReferencedAssemblies
|> Seq.tryFind (fun an ->
Path.GetFileNameWithoutExtension(an).ToLowerInvariant() = name)
match an with
| Some f -> Assembly.LoadFrom f
| None ->
let fromRuntimeAsm =
let sysRuntimePath =
let sysRuntimeAsm =
assemblies
|> Seq.find (fun a -> a.GetName().Name = "System.Runtime")
sysRuntimeAsm.Location
let sysRuntimeDir = DirectoryInfo(Path.GetDirectoryName(sysRuntimePath))
let runtimeVersion = sysRuntimeDir.Name
sysRuntimeDir.Parent.Parent.GetDirectories()
|> Seq.choose (fun fwdir ->
fwdir.GetDirectories() |> Seq.tryFind (fun vdir -> vdir.Name = runtimeVersion)
)
|> Seq.tryPick (fun vdir ->
vdir.EnumerateFiles("*.dll") |> Seq.tryPick (fun fi ->
if Path.GetFileNameWithoutExtension(fi.Name).ToLowerInvariant() = name then
Some (Assembly.LoadFrom fi.FullName)
else
None
)
)

match fromRuntimeAsm with
| Some asm -> asm
| None ->
let an =
cfg.ReferencedAssemblies
|> Seq.tryFind (fun an ->
Path.GetFileNameWithoutExtension(an).ToLowerInvariant() = name)
match an with
| Some f -> Assembly.LoadFrom f
| None ->
//eprintfn "Type provider didn't find assembly: %s" args.Name
null
//eprintfn "Type provider didn't find assembly: %s" args.Name
null

[<assembly:TypeProviderAssembly>]
do ()
1 change: 0 additions & 1 deletion WebSharper.UI.Templating/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ WebSharper
WebSharper.FSharp
HtmlAgilityPack
FSharp.Core
System.Runtime.Loader
1 change: 0 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ nuget WebSharper.FSharp prerelease
nuget WebSharper.Testing prerelease
nuget WebSharper.AspNetCore prerelease
nuget HtmlAgilityPack 1.11.0
nuget System.Runtime.Loader 4.3.0
nuget Microsoft.CodeAnalysis.CSharp ~> 3.9.0
github fsprojects/FSharp.TypeProviders.SDK src/ProvidedTypes.fsi
github fsprojects/FSharp.TypeProviders.SDK src/ProvidedTypes.fs
Expand Down
9 changes: 2 additions & 7 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ NUGET
System.Reflection.Primitives (>= 4.3)
System.Runtime (>= 4.3)
System.Runtime.Handles (>= 4.3)
System.Runtime.Loader (4.3)
System.IO (>= 4.3)
System.Reflection (>= 4.3)
System.Runtime (>= 4.3)
System.Runtime.Numerics (4.3)
System.Globalization (>= 4.3)
System.Resources.ResourceManager (>= 4.3)
Expand Down Expand Up @@ -468,7 +464,6 @@ NUGET
System.Xml.ReaderWriter (>= 4.3)
System.Xml.XmlDocument (>= 4.3)
System.Xml.XPath (>= 4.3)
remote: https://nuget.pkg.github.com/dotnet-websharper/index.json
WebSharper (5.0.0.100-preview1)
FSharp.Core (>= 5.0)
Microsoft.AspNetCore.Mvc.Abstractions (>= 2.0)
Expand All @@ -492,9 +487,9 @@ GROUP includes
REFERENCES: STRICT
GITHUB
remote: dotnet-websharper/websharper
src/htmllib/tags.csv (821edf4f5a9b5047e0e2826a8978f336c197c90e)
src/htmllib/tags.csv (a4e4f9ae6f494defc029847578d4d937c65024ff)
GROUP wsbuild

GIT
remote: https://github.com/dotnet-websharper/build-script
(bb49d04e155f762421568eeb581e72294e02622b)
(f8cfb297118279a3e20a48d90071d879ffe3b6ad)

0 comments on commit c59001c

Please sign in to comment.