You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ToString() as an alias to ''.'' (dot inode) for getting a folder path #3
The error you are seing is because ``SlqHydra.Queryy`` is an interface.
So here you are trying to assigned an interface to a variable which is not possible. If you want the folder path you need to use SlnRoot.``SqlHydra.Query``.``.`` .
I am using . because this is the standard inode to represent the current on Unix system which makes sure there are no conflicts with an existing file name.
However, when debugging this issue I found out that VS does not provide completion for double backtick properties. Which is probably why you didn't see the problem with the type being an interface.
It looks like a workaround is to create a new type when necessary:
Just thinking out loud - would it be possible to add or override a ToString method on the generated folder interfaces to return the path?
It would be intuitive, and would also allow this:
It looks like a workaround is to create a new type when necessary:
Indeed, this works because then VS intellisense doesn't deal with the double back tick.
Just thinking out loud - would it be possible to add or override a ToString method on the generated folder interfaces to return the path?
I guess it could be possible yes. I used ``.`` because it is the standard inode for referring to the current repository. At first I was thinking about FullName but there was a risk of conflict with an existing file on the disk. The ToString() method avoid that conflict from happening because a file/folder reference is represented using a property and not method.
I am not sure how the inner directories are represented
If we want to allow something like printfn $"Server path: {Server}", I will need to switch the TP to use instantiated types.
Usage would become something like that:
letCurrentDirectoryDot= RelativeFileSystem<".">()
I suppose should be possible to do, but I am not sure if there are any consequences or not. The way the TP works right now, is by provided all the strings using Literal field so I think it generate no types in the output.
Would having ToString() has a static method for now works or do you think it is not enough and we should go directly with trying to use instantiated types?
Having ToString() has a static method means that you are always expected to explicitly call it:
CurrentDirectoryDot.ToString()
We could also call it GetFullName() to stay consistent with .NET API naming:
changed the title [-]Add `ToString()` as an alias to ` ``.`` ` for getting an folder path[/-][+]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting an folder path[/+]on Apr 23, 2024
changed the title [-]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting an folder path[/-][+]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting a folder path[/+]on Apr 23, 2024
Interesting!
While it would be cool to be able to use in string interpolation, redesigning the type provider sounds like a lot of work. On the other hand, having a ToString() static method would probably be pretty easy and I think would be worth doing.
Ok, for now I will add .ToString() or something equivalent as a static member.
This is the fastest way to have something out, and because EasyBuild.FileSystemProvider is aimed at being used inside of build script I think it will be good enough for now (and probably a long time 🙈).
Regarding the SRTP syntax, I am not 100% sure that the TP generate is a static member ``. `` But I suspect this is something like that.
What the TP generates is a ProvidedField.Literal however what it means in create F# types I am not sure 😅. Perhaps it generates a static member val.
Working on TP is kind of fun but this is a real blackbox to me, I just put code that seems to makes sense and test out the output in the test folder. I don't know if there is a way to look into the generate DLL to get the generated F# type. But I am going side ways here.
Will add the . ToString() stuff later this evening or tomorrow.
For me this is already a game changer not having to deal with string and relative path anymore.
This is the first stone of a new project aiming to make it easier to maintain any projects. For example, in this repository I am already auto generating the changelog based on the Git history and this is just SO nice to press a button and to have nothing special to do to make a release. The version is auto computed if I don't override it and the changelog file is auto generated too.
I am working on making it a tool so it can be used on any project.
Activity
MangelMaxime commentedon Apr 22, 2024
The error you are seing is because
``SlqHydra.Queryy``is an interface.So here you are trying to assigned an interface to a variable which is not possible. If you want the folder path you need to use
SlnRoot.``SqlHydra.Query``.``.``.I am using
.because this is the standard inode to represent the current on Unix system which makes sure there are no conflicts with an existing file name.However, when debugging this issue I found out that VS does not provide completion for double backtick properties. Which is probably why you didn't see the problem with the type being an interface.
JordanMarr commentedon Apr 22, 2024
Ok, I see that now on your readme page.
It looks like a workaround is to create a new type when necessary:
Just thinking out loud - would it be possible to add or override a
ToStringmethod on the generated folder interfaces to return the path?It would be intuitive, and would also allow this:
MangelMaxime commentedon Apr 23, 2024
Indeed, this works because then VS intellisense doesn't deal with the double back tick.
I guess it could be possible yes. I used
``.``because it is the standard inode for referring to the current repository. At first I was thinking aboutFullNamebut there was a risk of conflict with an existing file on the disk. TheToString()method avoid that conflict from happening because a file/folder reference is represented using a property and not method.I will look into it.
MangelMaxime commentedon Apr 23, 2024
@JordanMarr I am able to generate the
ToString()method but it does not allow for syntax likeprintfn $"Server path: {Server}"See #4 for an experimentation about adding
ToString()This is because
type CurrentDirectoryDot = RelativeFileSystem<".">is not an instantiated type but a type definition.From what I understand it is equivalent to something like that:
Note
I am not sure how the inner directories are represented
If we want to allow something like
printfn $"Server path: {Server}", I will need to switch the TP to use instantiated types.Usage would become something like that:
I suppose should be possible to do, but I am not sure if there are any consequences or not. The way the TP works right now, is by provided all the strings using
Literal fieldso I think it generate no types in the output.Would having
ToString()has a static method for now works or do you think it is not enough and we should go directly with trying to use instantiated types?Having
ToString()has a static method means that you are always expected to explicitly call it:CurrentDirectoryDot.ToString()We could also call it
GetFullName()to stay consistent with .NET API naming:feat: explore adding `ToString()` as a static member to directories i…
[-]Generated type "not defined"[/-][+]Add `ToString()` as an alias to ` ``.`` ` for getting an folder path[/+][-]Add `ToString()` as an alias to ` ``.`` ` for getting an folder path[/-][+]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting an folder path[/+][-]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting an folder path[/-][+]Add `ToString()` as an alias to ` ''.'' ` (dot inode) for getting a folder path[/+]JordanMarr commentedon Apr 23, 2024
Interesting!
While it would be cool to be able to use in string interpolation, redesigning the type provider sounds like a lot of work. On the other hand, having a
ToString()static method would probably be pretty easy and I think would be worth doing.JordanMarr commentedon Apr 23, 2024
I was also experimenting with this approach, just for fun, but I ran into a block:
But having a
.ToString()method would be better.MangelMaxime commentedon Apr 23, 2024
Ok, for now I will add
.ToString()or something equivalent as a static member.This is the fastest way to have something out, and because
EasyBuild.FileSystemProvideris aimed at being used inside of build script I think it will be good enough for now (and probably a long time 🙈).Regarding the SRTP syntax, I am not 100% sure that the TP generate is a
static member ``. ``But I suspect this is something like that.What the TP generates is a
ProvidedField.Literalhowever what it means in create F# types I am not sure 😅. Perhaps it generates astatic member val.Working on TP is kind of fun but this is a real blackbox to me, I just put code that seems to makes sense and test out the output in the test folder. I don't know if there is a way to look into the generate DLL to get the generated F# type. But I am going side ways here.
Will add the
. ToString()stuff later this evening or tomorrow.JordanMarr commentedon Apr 23, 2024
This is a really cool type provider library. Thank you for making it!
I've already updated one of my project's builds to use it.
MangelMaxime commentedon Apr 23, 2024
I am glad you are liking it.
For me this is already a game changer not having to deal with string and relative path anymore.
This is the first stone of a new project aiming to make it easier to maintain any projects. For example, in this repository I am already auto generating the changelog based on the Git history and this is just SO nice to press a button and to have nothing special to do to make a release. The version is auto computed if I don't override it and the changelog file is auto generated too.
I am working on making it a tool so it can be used on any project.