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

getProjectInfo with relative path does not work. #185

Open
nojaf opened this issue Jan 30, 2023 · 2 comments
Open

getProjectInfo with relative path does not work. #185

nojaf opened this issue Jan 30, 2023 · 2 comments
Labels
bug good first issue Issue for new contributors

Comments

@nojaf
Copy link
Contributor

nojaf commented Jan 30, 2023

Describe the bug
Hello, in fsprojects/FSharp.Formatting#793 we discovered that ProjectLoader.getProjectInfo cannot be called with a relative project path.

Very concretely, it goes wrong in VisualTree.relativePathOf:

image

System.Uri doesn't accept the input:
(dotnet fsi)

> System.Uri(".\\src\\Fantomas.Core\\");;
System.UriFormatException: Invalid URI: The format of the URI could not be determined.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at <StartupCode$FSI_0002>.$FSI_0002.main@() in C:\Users\nojaf\Projects\stdin:line 1
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

To Reproduce

Changing the test project to:

[<EntryPoint>]
let main argv =
    Environment.CurrentDirectory <- @"C:\Users\nojaf\Projects\fantomas"
    
    let _toolsPath =
        Init.init (IO.DirectoryInfo(@"C:\Users\nojaf\Projects\fantomas")) (Some(IO.FileInfo(@"C:\Program Files\dotnet\dotnet.exe")))
        //Init.init (IO.DirectoryInfo Environment.CurrentDirectory) None

    let info = ProjectLoader.getProjectInfo @".\src\Fantomas.Core\Fantomas.Core.fsproj" [] BinaryLogGeneration.Off [
              "TargetPath"
              "OutputType"
              "IsTestProject"
              "IsPackable"
              "RepositoryUrl"
              "UsesMarkdownComments"
              "FsDocsCollectionNameLink"
              "FsDocsLogoSource"
              "FsDocsNavbarPosition"
              "FsDocsTheme"
              "FsDocsLogoLink"
              "FsDocsLicenseLink"
              "FsDocsReleaseNotesLink"
              "FsDocsSourceFolder"
              "FsDocsSourceRepository"
              "FsDocsWarnOnMissingDocs"
              "RepositoryType"
              "RepositoryBranch"
              "PackageProjectUrl"
              "Authors"
              "GenerateDocumentationFile"
              //Removed because this is typically a multi-line string and dotnet-proj-info can't handle this
              //"Description"
              "PackageLicenseExpression"
              "PackageTags"
              "Copyright"
              "PackageVersion"
              "PackageIconUrl"
              //Removed because this is typically a multi-line string and dotnet-proj-info can't handle this
              //"PackageReleaseNotes"
              "RepositoryCommit"
              "TargetFrameworks"
              "RunArguments" ]
    ignore info
    0

reproduces the problem after updating the global json (in Fantomas repository) to

{
  "sdk": {
    "version": "6.0.405"
  }
}

Oh and you probably need to build Fantomas.Core as well.

Expected behaviour

Either we should get an exception in ProjectLoader.getProjectInfo those relative paths are not supported, or this should work.

@nojaf
Copy link
Contributor Author

nojaf commented Mar 29, 2023

@TheAngryByrd what fix would you like to see for this?

@TheAngryByrd
Copy link
Member

I guess you could try let fromUri = Uri(fromPath, UriKind.RelativeOrAbsolute) and see if that fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Issue for new contributors
Projects
None yet
Development

No branches or pull requests

2 participants