Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ITypeResolver to support Fable 4 #313

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Fable.Remoting.ClientV2/Remoting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ module Remoting =
{ options with CustomResponseSerialization = Some serializer }

type Remoting() =
static member buildProxy<'t>(options: RemoteBuilderOptions, [<Inject>] ?resolver: ITypeResolver<'t>) : 't =
let resolvedType = resolver.Value.ResolveType()
/// For internal library use only.
static member buildProxy(options: RemoteBuilderOptions, resolvedType: Type) =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made private?

let schemaType = createTypeInfo resolvedType
match schemaType with
| TypeInfo.Record getFields ->
Expand Down Expand Up @@ -98,3 +98,5 @@ type Remoting() =
| _ ->
failwithf "Cannot build proxy. Exepected type %s to be a valid protocol definition which is a record of functions" resolvedType.FullName

static member inline buildProxy<'t>(options: RemoteBuilderOptions) : 't =
Remoting.buildProxy(options, typeof<'t>)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've extracted the body of the function so that the rest of the code is not unnecessarily inlined and duplicated when using multiple remoting endpoints. Because of the inlining the extracted method has to be public too, but it should not cause any problems.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though in this case I don't believe inlining has much benefit so we can remove the inline modifier here