提交 82c9492e 编写于 作者: D Don Syme 提交者: Kevin Ransom (msft)

Disable in-memory project references for projects using generative type providers (#3236)

* no in-memory project references for projects using generative type providers

* add test and build FCS as part of 'all'

* remove needless file

* add missing compiled TP dll
上级 8151842f
......@@ -35,6 +35,10 @@
<ProjectsWithNet40 Include="vsintegration/fsharp-vsintegration-vsix-build.proj" />
</ItemGroup>
<ItemGroup Condition="'$(BUILD_FCS)'=='1'">
<ProjectsWithNet40 Include="fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj" />
</ItemGroup>
<ItemGroup Condition="'$(BUILD_SETUP)'=='1'">
<SetupProjects Include="setup/fsharp-setup-build.proj" />
</ItemGroup>
......
......@@ -60,6 +60,7 @@ set BUILD_NET40=0
set BUILD_NET40_FSHARP_CORE=0
set BUILD_CORECLR=0
set BUILD_VS=0
set BUILD_FCS=0
set BUILD_CONFIG=release
set BUILD_CONFIG_LOWERCASE=release
set BUILD_DIAG=
......@@ -152,6 +153,11 @@ if /i "%ARG%" == "vs" (
set BUILD_VS=1
)
if /i "%ARG%" == "fcs" (
set _autoselect=0
set BUILD_FCS=1
)
if /i "%ARG%" == "vstest" (
set TEST_VS_IDEUNIT_SUITE=1
)
......@@ -166,6 +172,7 @@ if /i "%ARG%" == "all" (
set BUILD_NET40=1
set BUILD_CORECLR=1
set BUILD_VS=1
set BUILD_FCS=1
set BUILD_SETUP=%FSC_BUILD_SETUP%
set BUILD_NUGET=1
set CI=1
......@@ -216,6 +223,7 @@ if /i "%ARG%" == "ci_part1" (
set BUILD_NET40=1
set BUILD_NET40_FSHARP_CORE=1
set BUILD_VS=1
set BUILD_FCS=1
set TEST_VS_IDEUNIT_SUITE=1
set CI=1
)
......@@ -287,6 +295,7 @@ if /i "%ARG%" == "test-all" (
set BUILD_NET40_FSHARP_CORE=1
set BUILD_CORECLR=1
set BUILD_VS=1
set BUILD_FCS=1
set BUILD_SETUP=%FSC_BUILD_SETUP%
set BUILD_NUGET=1
......@@ -379,6 +388,7 @@ echo BUILD_NET40=%BUILD_NET40%
echo BUILD_NET40_FSHARP_CORE=%BUILD_NET40_FSHARP_CORE%
echo BUILD_CORECLR=%BUILD_CORECLR%
echo BUILD_VS=%BUILD_VS%
echo BUILD_FCS=%BUILD_FCS%
echo BUILD_SETUP=%BUILD_SETUP%
echo BUILD_NUGET=%BUILD_NUGET%
echo BUILD_CONFIG=%BUILD_CONFIG%
......
......@@ -47,6 +47,9 @@
<!-- FSharp.Data is used in some of the scripts ued for the coreclr build -->
<package id="FSharp.Data" version="2.2.5" />
<!-- FSharp.Configuration is one type provider used in testing -->
<package id="FSharp.Configuration" version="1.3.0" />
<!-- Perl is used for the fsharpqa test suite -->
<package id="StrawberryPerl64" version="5.22.2.1" />
......
......@@ -5163,12 +5163,15 @@ type TcState =
tcsNiceNameGen: NiceNameGenerator
tcsTcSigEnv: TcEnv
tcsTcImplEnv: TcEnv
tcsCreatesGeneratedProvidedTypes: bool
/// The accumulated results of type checking for this assembly
tcsRootSigsAndImpls : TypecheckerSigsAndImpls }
member x.NiceNameGenerator = x.tcsNiceNameGen
member x.TcEnvFromSignatures = x.tcsTcSigEnv
member x.TcEnvFromImpls = x.tcsTcImplEnv
member x.Ccu = x.tcsCcu
member x.CreatesGeneratedProvidedTypes = x.tcsCreatesGeneratedProvidedTypes
member x.PartialAssemblySignature =
let (RootSigsAndImpls(_rootSigs,_rootImpls,_allSigModulTyp,allImplementedSigModulTyp)) = x.tcsRootSigsAndImpls
allImplementedSigModulTyp
......@@ -5217,6 +5220,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports,
tcsNiceNameGen=niceNameGen
tcsTcSigEnv=tcEnv0
tcsTcImplEnv=tcEnv0
tcsCreatesGeneratedProvidedTypes=false
tcsRootSigsAndImpls = RootSigsAndImpls (rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp) }
......@@ -5233,7 +5237,7 @@ let TypeCheckOneInputEventually
let (RootSigsAndImpls(rootSigs,rootImpls,allSigModulTyp,allImplementedSigModulTyp)) = tcState.tcsRootSigsAndImpls
let m = inp.Range
let amap = tcImports.GetImportMap()
let! (topAttrs, mimpls,tcEnvAtEnd,tcSigEnv,tcImplEnv,topSigsAndImpls,ccuType) =
let! (topAttrs, implFiles,tcEnvAtEnd,tcSigEnv,tcImplEnv,topSigsAndImpls,ccuType,createsGeneratedProvidedTypes) =
eventually {
match inp with
| ParsedInput.SigFile (ParsedSigFileInput(_, qualNameOfFile, _, _, _) as file) ->
......@@ -5247,10 +5251,10 @@ let TypeCheckOneInputEventually
errorR(Error(FSComp.SR.buildImplementationAlreadyGivenDetail(qualNameOfFile.Text),m))
// Typecheck the signature file
let! (tcEnvAtEnd,tcEnv,smodulTypeRoot) =
let! (tcEnv,sigFileType,createsGeneratedProvidedTypes) =
TypeCheckOneSigFile (tcGlobals,tcState.tcsNiceNameGen,amap,tcState.tcsCcu,checkForErrors,tcConfig.conditionalCompilationDefines,tcSink) tcState.tcsTcSigEnv file
let rootSigs = Zmap.add qualNameOfFile smodulTypeRoot rootSigs
let rootSigs = Zmap.add qualNameOfFile sigFileType rootSigs
// Open the prefixPath for fsi.exe
let tcEnv =
......@@ -5260,7 +5264,7 @@ let TypeCheckOneInputEventually
let m = qualNameOfFile.Range
TcOpenDecl tcSink tcGlobals amap m m tcEnv prefixPath
let res = (EmptyTopAttrs, [], tcEnvAtEnd, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType)
let res = (EmptyTopAttrs, [], tcEnv, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType, createsGeneratedProvidedTypes)
return res
| ParsedInput.ImplFile (ParsedImplFileInput(filename,_,qualNameOfFile,_,_,_,_) as file) ->
......@@ -5277,7 +5281,7 @@ let TypeCheckOneInputEventually
let tcImplEnv = tcState.tcsTcImplEnv
// Typecheck the implementation file
let! topAttrs,implFile,tcEnvAtEnd =
let! topAttrs, implFile, tcEnvAtEnd, createsGeneratedProvidedTypes =
TypeCheckOneImplFile (tcGlobals,tcState.tcsNiceNameGen,amap,tcState.tcsCcu,checkForErrors,tcConfig.conditionalCompilationDefines,tcSink) tcImplEnv rootSigOpt file
let hadSig = Option.isSome rootSigOpt
......@@ -5320,14 +5324,15 @@ let TypeCheckOneInputEventually
if verbose then dprintf "done TypeCheckOneInputEventually...\n"
let topSigsAndImpls = RootSigsAndImpls(rootSigs,rootImpls,allSigModulTyp,allImplementedSigModulTyp)
let res = (topAttrs,[implFile], tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType)
let res = (topAttrs,[implFile], tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType, createsGeneratedProvidedTypes)
return res }
return (tcEnvAtEnd,topAttrs,mimpls),
return (tcEnvAtEnd,topAttrs,implFiles),
{ tcState with
tcsCcuType=ccuType
tcsTcSigEnv=tcSigEnv
tcsTcImplEnv=tcImplEnv
tcsCreatesGeneratedProvidedTypes=tcState.tcsCreatesGeneratedProvidedTypes || createsGeneratedProvidedTypes
tcsRootSigsAndImpls = topSigsAndImpls }
with e ->
errorRecovery e range0
......@@ -5344,14 +5349,14 @@ let TypeCheckOneInput (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, pre
/// Finish checking multiple files (or one interactive entry into F# Interactive)
let TypeCheckMultipleInputsFinish(results,tcState: TcState) =
let tcEnvsAtEndFile,topAttrs,mimpls = List.unzip3 results
let tcEnvsAtEndFile,topAttrs,implFiles = List.unzip3 results
let topAttrs = List.foldBack CombineTopAttrs topAttrs EmptyTopAttrs
let mimpls = List.concat mimpls
let implFiles = List.concat implFiles
// This is the environment required by fsi.exe when incrementally adding definitions
let tcEnvAtEndOfLastFile = (match tcEnvsAtEndFile with h :: _ -> h | _ -> tcState.TcEnvFromSignatures)
(tcEnvAtEndOfLastFile,topAttrs,mimpls),tcState
(tcEnvAtEndOfLastFile,topAttrs,implFiles),tcState
/// Check multiple files (or one interactive entry into F# Interactive)
let TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) =
......@@ -5378,7 +5383,7 @@ let TypeCheckClosedInputSetFinish (declaredImpls: TypedImplFile list, tcState) =
let TypeCheckClosedInputSet (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) =
// tcEnvAtEndOfLastFile is the environment required by fsi.exe when incrementally adding definitions
let (tcEnvAtEndOfLastFile, topAttrs, mimpls),tcState = TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs)
let tcState, declaredImpls = TypeCheckClosedInputSetFinish (mimpls, tcState)
let (tcEnvAtEndOfLastFile, topAttrs, implFiles),tcState = TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs)
let tcState, declaredImpls = TypeCheckClosedInputSetFinish (implFiles, tcState)
tcState, topAttrs, declaredImpls, tcEnvAtEndOfLastFile
......@@ -724,6 +724,8 @@ type TcState =
member NextStateAfterIncrementalFragment : TcEnv -> TcState
member CreatesGeneratedProvidedTypes : bool
/// Get the initial type checking state for a set of inputs
val GetInitialTcState :
range * string * TcConfig * TcGlobals * TcImports * Ast.NiceNameGenerator * TcEnv -> TcState
......
......@@ -516,7 +516,7 @@ let AddDeclaredTypars check typars env =
let env = ModifyNameResEnv (fun nenv -> AddDeclaredTyparsToNameEnv check nenv typars) env
RegisterDeclaredTypars typars env
/// Compilation environment for typechecking a compilation unit. Contains the
/// Compilation environment for typechecking a single file in an assembly. Contains the
/// F# and .NET modules loaded from disk, the search path, a table indicating
/// how to List.map F# modules to assembly names, and some nasty globals
/// related to type inference. These are:
......@@ -534,6 +534,9 @@ type cenv =
/// Checks to run after all inference is complete.
mutable postInferenceChecks: ResizeArray<unit -> unit>
/// Set to true if this file causes the creation of generated provided types.
mutable createsGeneratedProvidedTypes: bool
/// Are we in a script? if so relax the reporting of discarded-expression warnings at the top level
isScript: bool
......@@ -573,6 +576,7 @@ type cenv =
amap = amap
recUses = ValMultiMap<_>.Empty
postInferenceChecks = ResizeArray()
createsGeneratedProvidedTypes = false
topCcu = topCcu
isScript = isScript
css = ConstraintSolverState.New(g,amap,infoReader,tcVal)
......@@ -14686,6 +14690,8 @@ module EstablishTypeDefinitionCores =
let nm = theRootTypeWithRemapping.PUntaint((fun st -> st.FullName),m)
error(Error(FSComp.SR.etErasedTypeUsedInGeneration(desig,nm),m))
cenv.createsGeneratedProvidedTypes <- true
// In compiled code, all types in the set of generated types end up being both generated and relocated, unless relocation is suppressed
let isForcedSuppressRelocate = theRootTypeWithRemapping.PUntaint((fun st -> st.IsSuppressRelocate),m)
if isForcedSuppressRelocate && canAccessFromEverywhere tycon.Accessibility && not cenv.isScript then
......@@ -17014,14 +17020,14 @@ let TypeCheckOneImplFile
conditionallySuppressErrorReporting (checkForErrors()) (fun () ->
try
let reportErrors = not (checkForErrors())
Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks.CheckTopImpl (g,cenv.amap,reportErrors,cenv.infoReader,env.eInternalsVisibleCompPaths,cenv.topCcu,envAtEnd.DisplayEnv, implFileExprAfterSig,extraAttribs,isLastCompiland)
PostTypeCheckSemanticChecks.CheckTopImpl (g,cenv.amap,reportErrors,cenv.infoReader,env.eInternalsVisibleCompPaths,cenv.topCcu,envAtEnd.DisplayEnv, implFileExprAfterSig,extraAttribs,isLastCompiland)
with e ->
errorRecovery e m
false)
let implFile = TImplFile(qualNameOfFile,scopedPragmas, implFileExprAfterSig, hasExplicitEntryPoint,isScript)
let implFile = TImplFile(qualNameOfFile, scopedPragmas, implFileExprAfterSig, hasExplicitEntryPoint, isScript)
return (topAttrs,implFile,envAtEnd)
return (topAttrs,implFile,envAtEnd,cenv.createsGeneratedProvidedTypes)
}
......@@ -17041,5 +17047,5 @@ let TypeCheckOneSigFile (g,niceNameGen,amap,topCcu,checkForErrors,conditionalDe
try sigFileType |> IterTyconsOfModuleOrNamespaceType (FinalTypeDefinitionChecksAtEndOfInferenceScope(cenv.infoReader, tcEnv.NameEnv, cenv.tcSink, false, tcEnv.DisplayEnv))
with e -> errorRecovery e qualNameOfFile.Range
return (tcEnv,tcEnv,sigFileType)
return (tcEnv,sigFileType,cenv.createsGeneratedProvidedTypes)
}
......@@ -48,13 +48,13 @@ val TypeCheckOneImplFile :
-> TcEnv
-> Tast.ModuleOrNamespaceType option
-> ParsedImplFileInput
-> Eventually<TopAttribs * Tast.TypedImplFile * TcEnv>
-> Eventually<TopAttribs * Tast.TypedImplFile * TcEnv * bool>
val TypeCheckOneSigFile :
TcGlobals * NiceNameGenerator * ImportMap * CcuThunk * (unit -> bool) * ConditionalDefines * NameResolution.TcResultsSink
-> TcEnv
-> ParsedSigFileInput
-> Eventually<TcEnv * TcEnv * ModuleOrNamespaceType >
-> Eventually<TcEnv * ModuleOrNamespaceType * bool>
//-------------------------------------------------------------------------
// Some of the exceptions arising from type checking. These should be moved to
......
......@@ -1442,7 +1442,7 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs
// We return 'None' for the assembly portion of the cross-assembly reference
let hasTypeProviderAssemblyAttrib =
topAttrs.assemblyAttrs |> List.exists (fun (Attrib(tcref,_,_,_,_,_,_)) -> tcref.CompiledRepresentationForNamedType.BasicQualifiedName = typeof<Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute>.FullName)
if hasTypeProviderAssemblyAttrib then
if tcState.CreatesGeneratedProvidedTypes || hasTypeProviderAssemblyAttrib then
None
else
Some (RawFSharpAssemblyDataBackedByLanguageService (tcConfig,tcGlobals,tcState,outfile,topAttrs,assemblyName,ilAssemRef) :> IRawFSharpAssemblyData)
......

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../bin/v4.5/CSharp_Analysis.dll"
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
......
......@@ -99,6 +99,18 @@ let fsCoreDefaultReference() =
sysLib "FSharp.Core"
*)
let mkStandardProjectReferences () =
#if DOTNETCORE
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj"
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6")
readRefs projDir file
#else
[ yield sysLib "mscorlib"
yield sysLib "System"
yield sysLib "System.Core"
yield fsCoreDefaultReference() ]
#endif
let mkProjectCommandLineArgs (dllName, fileNames) =
let args =
[| yield "--simpleresolution"
......@@ -117,17 +129,7 @@ let mkProjectCommandLineArgs (dllName, fileNames) =
yield "--target:library"
for x in fileNames do
yield x
let references =
#if DOTNETCORE
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj"
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6")
readRefs projDir file
#else
[ yield sysLib "mscorlib"
yield sysLib "System"
yield sysLib "System.Core"
yield fsCoreDefaultReference() ]
#endif
let references = mkStandardProjectReferences ()
for r in references do
yield "-r:" + r
|]
......@@ -152,11 +154,7 @@ let mkProjectCommandLineArgsForScript (dllName, fileNames) =
yield "--target:library"
for x in fileNames do
yield x
// let implDir = Path.GetDirectoryName(typeof<System.Object>.Assembly.Location)
let references =
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj"
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6")
readRefs projDir file
let references = mkStandardProjectReferences ()
for r in references do
yield "-r:" + r
|]
......
......@@ -19,7 +19,7 @@
// Use F# Interactive. This only works for FSHarp.Compiler.Service.dll which has a public API
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../Debug/net40/bin/FSharp.Compiler.Service.ProjectCracker.dll"
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
......@@ -866,7 +866,7 @@ let ``Test expressions of declarations stress big expressions`` () =
// This should not stack overflow
printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore
#if FX_ATLEAST_45 && !DOTNETCORE
#if !NO_PROJECTCRACKER && !DOTNETCORE
[<Test>]
let ``Check use of type provider that provides calls to F# code`` () =
......
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......@@ -771,19 +771,180 @@ let ``Test max memory gets triggered`` () =
//------------------------------------------------------------------------------------
#if FX_ATLEAST_45
#if !DOTNETCORE
[<Test>]
let ``Type provider project references should not throw exceptions`` () =
let projectFile = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/TypeProviderConsole.fsproj"
let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")])
//let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")])
let options =
{ProjectFileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/TypeProviderConsole.fsproj";
SourceFiles = [|__SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/Program.fs"|];
Stamp = None
OtherOptions =
[|yield "--simpleresolution";
yield "--noframework";
yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/bin/Debug/TypeProviderConsole.exe";
yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/bin/Debug/TypeProviderConsole.xml";
yield "--subsystemversion:6.00";
yield "--highentropyva+";
yield "--fullpaths";
yield "--flaterrors";
yield "--target:exe";
yield "--define:DEBUG";
yield "--define:TRACE";
yield "--debug+";
yield "--optimize-";
yield "--tailcalls-";
yield "--debug:full";
yield "--platform:anycpu";
for r in mkStandardProjectReferences () do
yield "-r:" + r
yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll"|];
ReferencedProjects =
[|(__SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll",
{ProjectFileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.fsproj";
SourceFiles = [|__SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/Library1.fs"|];
Stamp = None
OtherOptions =
[|yield "--simpleresolution";
yield "--noframework";
yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll";
yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/bin/Debug/TypeProviderLibrary.xml";
yield "--subsystemversion:6.00";
yield "--highentropyva+";
yield "--fullpaths";
yield "--flaterrors";
yield "--target:library";
yield "--define:DEBUG";
yield "--define:TRACE";
yield "--debug+";
yield "--optimize-";
yield "--tailcalls-";
yield "--debug:full";
yield "--platform:anycpu";
for r in mkStandardProjectReferences () do
yield "-r:" + r
yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/FSharp.Data.TypeProviders.dll";
|];
ReferencedProjects = [||];
IsIncompleteTypeCheckEnvironment = false;
UseScriptResolutionRules = false;
LoadTime = System.DateTime.Now
UnresolvedReferences = None;
OriginalLoadReferences = [];
ExtraProjectInfo = None;})|];
IsIncompleteTypeCheckEnvironment = false;
UseScriptResolutionRules = false;
LoadTime = System.DateTime.Now
UnresolvedReferences = None;
OriginalLoadReferences = [];
ExtraProjectInfo = None;}
//printfn "options: %A" options
let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/Program.fs"
let fileSource = File.ReadAllText(fileName)
let fileCheckResults, _ = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously
//printfn "Errors: %A" fileCheckResults.Errors
let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously
let fileCheckResults =
match fileCheckAnswer with
| FSharpCheckFileAnswer.Succeeded(res) -> res
| res -> failwithf "Parsing did not finish... (%A)" res
printfn "Parse Errors: %A" fileParseResults.Errors
printfn "Errors: %A" fileCheckResults.Errors
fileCheckResults.Errors |> Array.exists (fun error -> error.Severity = FSharpErrorSeverity.Error) |> shouldEqual false
//------------------------------------------------------------------------------------
[<Test>]
let ``Projects creating generated types should not utilize cross-project-references but should still analyze oK once project is built`` () =
//let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")])
let options =
{ProjectFileName =
__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/TestConsole.fsproj";
SourceFiles =
[|__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/AssemblyInfo.fs";
__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/Program.fs"|];
OtherOptions =
[|yield "--simpleresolution";
yield "--noframework";
yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/bin/Debug/TestConsole.exe";
yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/bin/Debug/TestConsole.XML";
yield "--subsystemversion:6.00";
yield "--highentropyva+";
yield "--fullpaths";
yield "--flaterrors";
yield "--target:exe";
yield "--define:DEBUG";
yield "--define:TRACE";
yield "--debug+";
yield "--optimize-";
yield "--tailcalls-";
yield "--debug:full";
yield "--platform:anycpu";
yield "-r:" + __SOURCE_DIRECTORY__ + @"/../../packages/FSharp.Configuration.1.3.0/lib/net45/FSharp.Configuration.dll";
for r in mkStandardProjectReferences () do
yield "-r:" + r
yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll"|];
ReferencedProjects =
[|(__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll",
{ProjectFileName =
__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/TypeProvidersBug.fsproj";
SourceFiles =
[|__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/AssemblyInfo.fs";
__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/Library1.fs"|];
OtherOptions =
[|yield "--simpleresolution";
yield "--noframework";
yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll";
yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.XML";
yield "--subsystemversion:6.00";
yield "--highentropyva+";
yield "--fullpaths";
yield "--flaterrors";
yield "--target:library";
yield "--define:DEBUG";
yield "--define:TRACE";
yield "--debug+";
yield "--optimize-";
yield "--tailcalls-";
yield "--debug:full";
yield "--platform:anycpu";
yield "-r:" + __SOURCE_DIRECTORY__ + @"/../../packages/FSharp.Configuration.1.3.0/lib/net45/FSharp.Configuration.dll";
for r in mkStandardProjectReferences () do
yield "-r:" + r |];
ReferencedProjects = [||];
IsIncompleteTypeCheckEnvironment = false;
UseScriptResolutionRules = false;
LoadTime = System.DateTime.Now
UnresolvedReferences = None;
OriginalLoadReferences = [];
Stamp = None;
ExtraProjectInfo = None;})|];
IsIncompleteTypeCheckEnvironment = false;
UseScriptResolutionRules = false;
LoadTime = System.DateTime.Now
UnresolvedReferences = None;
Stamp = None;
OriginalLoadReferences = [];
ExtraProjectInfo = None;}
//printfn "options: %A" options
let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/Program.fs"
let fileSource = File.ReadAllText(fileName)
let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously
let fileCheckResults =
match fileCheckAnswer with
| FSharpCheckFileAnswer.Succeeded(res) -> res
| res -> failwithf "Parsing did not finish... (%A)" res
printfn "Parse Errors: %A" fileParseResults.Errors
printfn "Errors: %A" fileCheckResults.Errors
fileCheckResults.Errors |> Array.exists (fun error -> error.Severity = FSharpErrorSeverity.Error) |> shouldEqual false
#endif
//------------------------------------------------------------------------------------
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......
#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../Debug/net40/bin/FSharp.Compiler.Service.ProjectCracker.dll"
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
......@@ -18,7 +18,6 @@ open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Service.Tests.Common
#if FX_ATLEAST_45
#if !NO_PROJECTCRACKER
let normalizePath s = (new Uri(s)).LocalPath
......@@ -477,7 +476,6 @@ let ``Test SourceFiles order for GetProjectOptionsFromScript`` () = // See #594
test "Main4" [|"BaseLib2"; "Lib5"; "BaseLib1"; "Lib1"; "Lib2"; "Main4"|]
test "MainBad" [|"MainBad"|]
#endif

#if INTERACTIVE
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll"
#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive
#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "FsUnit.fs"
#load "Common.fs"
......
......@@ -4,7 +4,22 @@ open Microsoft.FSharp.Core.CompilerServices
open System
[<TypeProvider>]
type FakeTypeProvider() = class end
type FakeTypeProvider() =
interface ITypeProvider with
member this.GetStaticParameters _ = [||]
member this.ApplyStaticArguments(_,_,_) = raise <| System.InvalidOperationException()
member this.GetNamespaces() = [| |]
member this.GetInvokerExpression(_,_) = failwith "GetInvokerExpression"
[<CLIEvent>]
member this.Invalidate = (new Event<_,_>()).Publish
member this.GetGeneratedAssemblyContents(assembly) = failwith "GetGeneratedAssemblyContents"
interface ITypeProvider2 with
member this.GetStaticParametersForMethod _ = [||]
member this.ApplyStaticArgumentsForMethod(_,_,_) = raise <| System.InvalidOperationException()
interface IDisposable with
member __.Dispose() = ()
[<assembly:TypeProviderAssembly>]
do()
......@@ -32,7 +32,9 @@
<DocumentationFile>bin\Release\TypeProviderLibrary.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Data.TypeProviders, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Compile Include="Library1.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core">
<HintPath>..\..\..\..\$(Configuration)\net40\bin\FSharp.Core.dll</HintPath>
......@@ -41,19 +43,5 @@
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
</ItemGroup>
<Import Project="..\..\..\..\$(Configuration)\net40\bin\Microsoft.FSharp.Targets" />
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And $(TargetFrameworkVersion) == 'v1.6') Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v1.0') Or ($(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5')">
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>
\ No newline at end of file
namespace TestConsole.AssemblyInfo
open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("TestConsole")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("TestConsole")>]
[<assembly: AssemblyCopyright("Copyright © 2017")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("247653e8-fba7-419b-8b7a-8b17ebfe2969")>]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]
do
()
\ No newline at end of file

[<EntryPoint>]
let main _ =
let foo: string = TypeProvidersBug.Test.config.Foo
0
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>247653e8-fba7-419b-8b7a-8b17ebfe2969</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TestConsole</RootNamespace>
<AssemblyName>TestConsole</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>TestConsole</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\TestConsole.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\TestConsole.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Program.fs" />
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="FSharp.Core">
<HintPath>..\..\..\..\..\$(Configuration)\net40\bin\FSharp.Core.dll</HintPath>
</Reference>
<ProjectReference Include="..\TypeProvidersBug\TypeProvidersBug.fsproj">
<Name>TypeProvidersBug</Name>
<Project>{7b36cdd5-14f3-42f0-8118-c279d2315a22}</Project>
<Private>True</Private>
</ProjectReference>
<Reference Include="FSharp.Configuration">
<HintPath>..\..\..\..\..\packages\FSharp.Configuration.1.3.0\lib\net45\FSharp.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Import Project="..\..\..\..\..\$(Configuration)\net40\bin\Microsoft.FSharp.Targets" />
</Project>
\ No newline at end of file
namespace TypeProvidersBug.AssemblyInfo
open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("TypeProvidersBug")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("TypeProvidersBug")>]
[<assembly: AssemblyCopyright("Copyright © 2017")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("7b36cdd5-14f3-42f0-8118-c279d2315a22")>]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]
do
()
\ No newline at end of file
module TypeProvidersBug.Test
open FSharp.Configuration
type Configuration = YamlConfig<YamlText = "Foo: foo">
let config = Configuration()
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>7b36cdd5-14f3-42f0-8118-c279d2315a22</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>TypeProvidersBug</RootNamespace>
<AssemblyName>TypeProvidersBug</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>TypeProvidersBug</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\TypeProvidersBug.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\TypeProvidersBug.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Library1.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="FSharp.Core">
<HintPath>..\..\..\..\..\$(Configuration)\net40\bin\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.Configuration">
<HintPath>..\..\..\..\..\packages\FSharp.Configuration.1.3.0\lib\net45\FSharp.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Import Project="..\..\..\..\..\$(Configuration)\net40\bin\Microsoft.FSharp.Targets" />
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册