2015-01-09 2 views
1

저는 F # noob입니다. 그래서 약간의 기본적인 작업을하는 데 어려움을 겪고 있습니다. 여기서 컨텍스트는 FAKE 빌드 스크립트입니다.F # 형식 유추에 형식 이름이 필요하지만 제공 방법을 모르겠습니다.

생성 된 internal 클래스를 포함하지 않고 AssemblyInfo.cs을 생성하기 위해 AssemblyInfoFile 네임 스페이스를 사용하려고합니다. CreateCSharpAssemblyInfoWithConfig 함수를 호출하고 을 통해 GenerateClass 속성을 꺼야한다는 것을 알고 있습니다. 나는이 있습니다

Target "Build" (fun _ -> 
    CreateCSharpAssemblyInfoWithConfig (srcDir + "TestAssemblyInfo.cs") 
     [Attribute.Version version 
     Attribute.Configuration configuration] 
     { GenerateClass = false } 
) 

을하지만, 다음과 같이 컴파일러는 불평 :

유형 'AssemblyInfoParams를'유형 'AssemblyInfoFileConfig'와 호환되지 않습니다.

처음에는 컴파일러에 특정 유형을 제공해야한다고 생각하여 AssemblyInfoParams으로 해결되지 않았습니다.

Target "Build" (fun _ -> 
    let config : AssemblyInfoFileConfig = { GenerateClass = false } 

    CreateCSharpAssemblyInfoWithConfig (srcDir + "TestAssemblyInfo.cs") 
     [Attribute.Version version 
     Attribute.Configuration configuration)] 
     config 
) 

하지만 지금은 컴파일러가 불평은 다음과 같습니다 :

유형 'AssemblyInfoFileConfig은'필드를 포함하지 않는 그러나, 나는 내가 대신이 시도 그래서 인라인을 수행하는 방법을 알아낼 수

: AssemblyInfoFileConfig의 정의를 살펴보면 'GenerateClass'

, 그것은 분명히 GenerateClass라고 재산 포함

type AssemblyInfoFileConfig 
    (
     generateClass : bool, 
     ?useNamespace : string) = 
     member x.GenerateClass = generateClass 
     member x.UseNamespace = 
      match useNamespace with 
      | Some n -> n 
      | None -> "System" 
     static member Default = AssemblyInfoFileConfig(true) 

누구나 내가 뭘 잘못하고 있는지 말할 수 있습니까?

답변

4

AssemblyInfoFileConfig은 레코드가 아닙니다. 생성자가있는 표준 유형입니다.

당신은이처럼 호출 할 수 있습니다

let config = AssemblyInfoFileConfig(false) 
+0

완벽한 - 감사 존. 내가 멍청하다고 말했어! ;) –