-
Notifications
You must be signed in to change notification settings - Fork 94
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
compilation unit 'FSharp.Core' did not contain the namespace, module or type 'StringModule' #343
Comments
Can you please try to create TP from the template?
Update samples provider with our code, but does not remove
|
@sergey-tihon I'm not sure I understand what this means. Are you asking me to take the provider code from the template and update it with my implementation, but be sure to leave the |
@sergey-tihon I've reimplemented my TP from the template as you suggested here: https://github.com/aggieben/constrainedtypes/tree/tpsdk-343 It fails in the same way.
|
Thank you, it definitely looks like a bug of mapping types from quotation to target runtime types. It is a good practice to keep quotations as small as possible. You can move method implementation into runtime assembly and just call it from quotation. [<AutoOpen>]
module internal Utilities =
let x = 1
let ctorBoundedString length str =
if (length < String.length str) then
sprintf "provided value exceeds the bounds: '%s' > %d"
str length
|> invalidArg "value" simple quotation that call implementation and pass parameters ProvidedConstructor(
[ProvidedParameter("value", typeof<string>)],
fun args -> <@@ ctorBoundedString length %%(args.[0]) @@>
)
|> boundedStringType.AddMember |
@sergey-tihon alright, thanks. I'll give that a go. Is it necessary to have separate runtime and design-time components? |
It it not mandatory, so it should be possible to keep both components in one assembly.
|
@sergey-tihon I moved the bounds-checking function to the utility module in the runtime component as you suggested, but the tests now fail with this error:
This same error is emitted from both the combined provider (on my |
ops, sorry, my typo Replace module internal Utilities = to module Utilities = |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Description
I wrote a simple type provider that references
String.length
in the untyped quotation used to provide a constructor implementation. The type provider library builds, but a consuming project fails to build with the following error:The type provider is implemented as follows:
This implementation can be cloned here: https://github.com/aggieben/constrainedtypes
Repro steps
See implementation above. Clone the linked implementation and build the
ConstrainedTypes.Test
project to repro.Expected behavior
I expected the use of the provided type
BoundedString<10>
to compile.Actual behavior
The type provider fails at consumer compile time.
Known workarounds
None
Related information
The text was updated successfully, but these errors were encountered: