Giter Club home page Giter Club logo

fsharp.compiler.codedom's Introduction

Issue Stats Issue Stats

FSharp.Compiler.CodeDom

An F# CodeDOM implementation (based on the one in the F# power pack)

NuGet Travis AppVeyor

Maintainer(s)

The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)

To generate the documentation, build the library from the command line with build Release. The tutorial html page will be under docs\output.

fsharp.compiler.codedom's People

Contributors

drvink avatar dsyme avatar forki avatar fsgit avatar fsprojectsgit avatar lheinman avatar sergey-tihon avatar tonyroberts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fsharp.compiler.codedom's Issues

CompileAssemblyFromFile crashes with "The system cannot find the file specified" even though File.Exists reports that the file exists

Description

When I call CompileAssemblyFromFile on my provider instance, the program throws the following error stack trace:

Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at FSharp.Compiler.CodeDom.Internal.Compiler.compileFiles(String args, CompilerResults res)
   at FSharp.Compiler.CodeDom.Internal.Compiler.compileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames, CompilerResults results, FSharpFunc`2 sortf)
   at Program.main(String[] argv)

This occurs despite the fact that System.IO.File.Exists returns true when passed in the file path.

Here is the full code:

open System.IO
open System.CodeDom.Compiler
open FSharp.Compiler.CodeDom


[<EntryPoint>]
let main argv =
    let sourceFilePath = Array.get argv 0
    if File.Exists(sourceFilePath) then
        let provider = new FSharpCodeProvider()
        let mutable compilerParameters = CompilerParameters()
        compilerParameters.GenerateInMemory <- true
        provider.CompileAssemblyFromFile(compilerParameters, [| sourceFilePath |])
        |> ignore
    else
        printf "File does not exist"
    0

Here is myfsproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Compiler.CodeDom" Version="1.0.0.1" />
  </ItemGroup>

</Project>

Repro steps

  1. Create a new application using: dotnet new console -lang F#.
  2. cd into the application directory.
  3. Paste the above code block into Program.fs.
  4. Paste the above config block into <application>.fsproj.
  5. dotnet build (succeeds).
  6. Create an F# source file in the same directory and save it as foo.fs. I used the following:
namespace Foo

type Bar = { baz : int }
  1. dotnet run foo.fs

Expected behavior

The program executes without throwing an exception.

Actual behavior

The program throws System.ComponentModel.Win32Exception with the above stack trace.

Known workarounds

No known workarounds.

Related information

  • Operating system: Windows 10, 64-bit OS, x64-based processor
  • Branch: Hopefully master? (installed from nuget)
  • .NET Runtime, CoreCLR or Mono Version: dotnet --version returns '3.0.100'

Work on mono (Linux)

It is impossible currently to run it with Mono on Linux.
When .Net exe should be executed on Mono, Process.StartInfo.FileName should be "mono" and real executable name should be passed as first argument.
It would be also great if there would be possibility to pass fsc.exe through environment variable if it was not found in registry - it will give option to use FSharp.Compiler.Tools nuget package.

CI build is broken

@drvink The build is broken, both on Windows and on Travis/Linux, I think in both cases because of the installer

C:\GitHub\fsprojects\FSharp.Compiler.CodeDom\Installer\ModifyMachineConf
ig\ModifyMachineConfig.csproj(71,3): error MSB4019: The imported project
 "C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\Wix.CA.targets" was
not found. Confirm that the path in the <Import> declaration is correct,
 and that the file exists on disk.

Option types

Is it possible to declare parameters as option types?

For example, when creating a method like this:

var method = CodeMemberMethod {
    Name = "Test",
    ReturnType = new CodeTypeReference(typeof(string))
};
var parameter = new CodeParameterDeclarationExpression(typeof(FSharpOption<string>), "x");
method.Parameters.Add(param);

the generated code looks something like

            abstract Invoke : Microsoft.FSharp.Core.FSharpOption<string> -> string
            default this.Invoke  (fund:Microsoft.FSharp.Core.FSharpOption<string>) =

but I would like to be able to use the f# Option type, e.g.

            abstract Invoke : Option<string> -> string
            default this.Invoke  (fund:Option<string>) =

It looks like generateTypeRef or getTypeRef could be modified to map FSharpOption<> to Option<> when outputting the F# code, but is that the right thing to do or is there another way?

thanks!
Tony

Signed binaries

Is it possible to sign binaries in the NuGet package? That would make it easier to use the binary from another project that will be signed (and, therefore, strong-named).

runCompileAssemblyFromSource expects to have outputassembly

Hi, I have observed strange behaviour of FSharpCodeProvider class.
When I try to runCompileAssemblyFromSource for the first time, I got an exception that the outputassembly was not found. ( I assume that it will be generated, so why it should be present?)

But when I run the same code second time, then everything executes proprely...

you can find more details here: https://gist.github.com/severin-wokam/0ae5d22a5ed787a7e11f
or here: https://github.com/severin-wokam/FSharp.Scheduler/blob/master/src/FSharp.Scheduler/BootStrapper.fs

The project needs a logo

Not sure how CodeDom should look like on the image... So I am really appreciate any suggestions. Some initial options:
Option 1:
image
Option 2:
image
Option 3:
image
Option 4:
image
Option 5:
image

duplicate fs file add to tempfiles

Description

when codeStrings has not only one string in it
provider.CompileAssemblyFromSource(params', codeStrings)
would throw exception at CodeProvide.fs

around line 113 when AddExtension("fs", false)

Repro steps

Expected behavior

different .fs file name should be generated and add to tempfiles

Actual behavior

the second Array.map would call AddExtension("fs", false)
but with the same file name

Known workarounds

I use guid string file name with AddFile to replace AddExtension

            sources |> Array.map (fun src ->
                let fn = Guid.NewGuid().ToString() + ".fs"
                res.TempFiles.AddFile(fn, false)
                use wr = new StreamWriter(fn)
                wr.Write(src)
                fn)

Related information

  • Operating system
    Win 2012R2
  • Branch
    master
  • .NET Runtime
    4.6.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.