f#

Code coverage using dotCover throws an error - FAKE F#MAKE

血红的双手。 提交于 2020-01-25 21:26:28
问题 I am trying to use DotCover in FAKE , but it is throwing some error , as I am new to FAKE as well as F# , it's becoming difficult for me to understand the root cause of the problem . Here is the code : #r "D:/FAKEProject/Fake/packages/FAKE/tools/FakeLib.dll" open Fake open Fake.DotCover let testDir = "D:/FAKEProject/Fake/test/" let filters = "" Target "Clean" (fun _ -> CleanDirs [testDir] ) Target "TestCoverage" (fun _ -> !! ("D:/FAKEProject/Fake/UnitTest/UnitTest.dll") |> DotCoverNUnit (fun

xUnit tests under F# : It looks like you're trying to execute an xUnit.net unit test ('System.ArgumentException' occurred in xunit.runner.utility.dll)

▼魔方 西西 提交于 2020-01-25 11:53:29
问题 0. My setup is as follows Visual Studio 2012 Ultimate, update 3, v.11.0.60610.01 Visual F# 2012 04940-004-0038003-02527 TestDriven.Net 3.5 Beta 3 Personal 1. What I have in packages.config: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="FsUnit.xUnit" version="1.2.1.2" targetFramework="net45" /> <package id="xunit" version="1.9.1" targetFramework="net45" /> </packages> 2. What I ran: xunit.installer.exe 3. This is what the packages folder looks like \packages\FsUnit.xUnit.1.2.1

F# Count how Many times a substring Contains within a string

纵饮孤独 提交于 2020-01-25 08:59:06
问题 How could one count how many times a substring exists within a string? I mean if you have a String " one, two, three, one, one, two" how could you make it count "one" being present 3 times? I thought String.Contains would be able to do the job but that only checks if the substring is present at all. String.forall is for chars and therefofre niether an option. So i am really at a complete halt here. Can some enligten me? 回答1: You can use Regex.Escape to turn the string you're searching for

How to convert string array to float array and substitute Double.NaN for non-numeric values?

笑着哭i 提交于 2020-01-25 03:41:16
问题 I'm writing a parser for CSV data, and am trying to determine how to handle records that are blank ("") or contain character data ("C"). The parser code I have below works great, but forces me to deal with the float conversions later. I'd like to be able to just make my string[][] a float[][], and handle the conversions when I parse the file, but I notice that it blows up with any non-numeric data. Ideally there would be no non-numeric or blank values, but they are unavoidable, and as such,

Create an action in F# in order to use a c# method

人走茶凉 提交于 2020-01-24 21:22:19
问题 I would like to use this method from Owin implementation of HttpListener : public static IDisposable Create(AppFunc app, IDictionary<string, object> properties) AppFunc has a signature like this : IDictionnary<string,Object> -> Task I wanted to create a task but it requires an action, and I failed to know how to do it in F#. The best I managed so far was using the code in this question : module CsharpAction open System type Wrapper<'T>(f:'T -> unit) = member x.Invoke(a:'T) = f a let

How to get connection string from head project's app.config/appsettings.json in a class library

耗尽温柔 提交于 2020-01-24 17:33:26
问题 When writing a C# class library that accesses a database, my preferred method of getting a connection string from a head project's app.config/appsettings.json is to have the DB access classes depend on some IConnectionString interface that is registered in an IOC container by the head project. I am currently using F# however, and the above is not a particularly functional approach. Neither is having a static variable on a static class set by the Startup class of the head project (though it's

FSharp.Compiler.CodeDom for VS2008 and VS2010 side-by-side

五迷三道 提交于 2020-01-24 14:16:25
问题 I'm using FSharp.Compiler.CodeDom (from the PowerPack) to dynamically create F# classes. The problem is, that I have both VS2008 and VS2010 on my computer side-by-side (they works fine), and using F# in this configuration is buggy at best: If I don't install InstallFSharp.msi, then under VS2008 the built classes complain about not finding FSharp.Core (even if they're referenced) If I install InstallFSharp.msi, then under VS2008 the built classes will use the F# built for VS2010, and will

How to build F# type fulfilling business rules?

别来无恙 提交于 2020-01-24 14:12:52
问题 I´m trying to build a type in F#, where when I get an object of that type I can be sure it´s in a valid state. The type is called JobId and it just holds a Guid . The business rule is: It must be a Guid - but no empty Guid. I´ve already implemented the type in C# but now I would like to port it to a F# class library. That´s the C# type: public sealed class JobId { public string Value { get; } private JobId(string value) => Value = value; public static JobId Create() => new JobId(Guid.NewGuid(

How to build F# type fulfilling business rules?

陌路散爱 提交于 2020-01-24 14:12:46
问题 I´m trying to build a type in F#, where when I get an object of that type I can be sure it´s in a valid state. The type is called JobId and it just holds a Guid . The business rule is: It must be a Guid - but no empty Guid. I´ve already implemented the type in C# but now I would like to port it to a F# class library. That´s the C# type: public sealed class JobId { public string Value { get; } private JobId(string value) => Value = value; public static JobId Create() => new JobId(Guid.NewGuid(

How to build F# type fulfilling business rules?

本秂侑毒 提交于 2020-01-24 14:12:05
问题 I´m trying to build a type in F#, where when I get an object of that type I can be sure it´s in a valid state. The type is called JobId and it just holds a Guid . The business rule is: It must be a Guid - but no empty Guid. I´ve already implemented the type in C# but now I would like to port it to a F# class library. That´s the C# type: public sealed class JobId { public string Value { get; } private JobId(string value) => Value = value; public static JobId Create() => new JobId(Guid.NewGuid(