Skip to content

Commit

Permalink
Showing 7 changed files with 312 additions and 38 deletions.
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Dotnet.ProjInfo.Workspace.Tests",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/test/Dotnet.ProjInfo.Workspace.Tests/bin/Debug/netcoreapp2.1/Dotnet.ProjInfo.Workspace.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}

]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"tasks": [
{
"taskName": "build",
"args": [ "src/dotnet-proj" ],
"args": [ "src/dotnet-proj.sln" ],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0">

<PropertyGroup>
<Version Condition=" '$(Version)' == '' ">0.33.0$(VersionSuffix)</Version>
<Version Condition=" '$(Version)' == '' ">0.34.0$(VersionSuffix)</Version>
</PropertyGroup>

<PropertyGroup>
44 changes: 39 additions & 5 deletions src/Dotnet.ProjInfo.Workspace/Library.fs
Original file line number Diff line number Diff line change
@@ -86,10 +86,7 @@ type Loader private (msbuildPath, msbuildNetSdkPath) =
Error (GetProjectOptionsErrors.GenericError(proj, "not found"))

match loader notify cache project with
| Ok (po, sources, props, additionalProjs) ->
// TODO sources and props are wrong, because not project specific. but of root proj
let loaded po = WorkspaceProjectState.Loaded (po, sources, props)

| Ok (po, props, additionalProjs) ->
let rec visit (p: ProjectOptions) = seq {
yield p
for p2pRef in p.ReferencedProjects do
@@ -102,7 +99,8 @@ type Loader private (msbuildPath, msbuildNetSdkPath) =
parsedProjects.AddOrUpdate(getKey proj, proj, fun _ _ -> proj) |> ignore

for proj in visit po do
notify (loaded proj)
WorkspaceProjectState.Loaded (proj, props)
|> notify

| Error e ->
let failed = WorkspaceProjectState.Failed (project, e)
@@ -163,3 +161,39 @@ type NetFWInfo private (msbuildPath) =

static member Create(config: NetFWInfoConfig) =
NetFWInfo(config.MSBuildHost)

type ProjectViewerTree =
{ Name: string;
Items: ProjectViewerItem list }
and [<RequireQualifiedAccess>] ProjectViewerItem =
| Compile of string

type ProjectViewer () =

member __.Render(proj: ProjectOptions) =

let compileFiles =
let sources = proj.SourceFiles
match proj.ExtraProjectInfo.ProjectSdkType with
| ProjectSdkType.Verbose _ ->
//compatibility with old behaviour (projectcracker), so test output is exactly the same
//the temp source files (like generated assemblyinfo.fs) are not added to sources
let isTempFile (name: string) =
let tempPath = Path.GetTempPath()
let s = name.ToLower()
s.StartsWith(tempPath.ToLower())
sources
|> List.filter (fun p -> not(isTempFile p))
| ProjectSdkType.DotnetSdk _ ->
//the generated assemblyinfo.fs are not shown as sources
let isGeneratedAssemblyinfo (name: string) =
let projName = proj.ProjectFileName |> Path.GetFileNameWithoutExtension
//TODO check is in `obj` dir for the tfm
//TODO better, get the name from fsproj
//TODO cs too
name.EndsWith(sprintf "%s.AssemblyInfo.fs" projName)
sources
|> List.filter (fun p -> not(isGeneratedAssemblyinfo p))

{ ProjectViewerTree.Name = proj.ProjectFileName |> Path.GetFileNameWithoutExtension
Items = compileFiles |> List.map ProjectViewerItem.Compile }
22 changes: 2 additions & 20 deletions src/Dotnet.ProjInfo.Workspace/ProjectCrackerDotnetSdk.fs
Original file line number Diff line number Diff line change
@@ -229,7 +229,7 @@ module ProjectCrackerDotnetSdk =

let isSourceFile : (string -> bool) =
if Path.GetExtension(file) = ".fsproj" then
(fun n -> n.EndsWith ".fs" || n.EndsWith ".fsx" || n.EndsWith ".fsi")
FscArguments.isCompileFile
else
(fun n -> n.EndsWith ".cs")

@@ -288,25 +288,7 @@ module ProjectCrackerDotnetSdk =
try
let po, log, additionalProjs = getProjectOptionsFromProjectFile msbuildPath notifyState cache parseAsSdk file

let compileFiles =
let sources = FscArguments.compileFiles po.OtherOptions
match po with
| ProjectExtraInfoBySdk extraInfo ->
match extraInfo.ProjectSdkType with
| ProjectSdkType.Verbose _ ->
//compatibility with old behaviour (projectcracker), so test output is exactly the same
//the temp source files (like generated assemblyinfo.fs) are not added to sources
let isTempFile (name: string) =
let tempPath = Path.GetTempPath()
let s = name.ToLower()
s.StartsWith(tempPath.ToLower())
sources
|> List.filter (not << isTempFile)
| ProjectSdkType.DotnetSdk _ ->
sources
| _ -> sources

Ok (po, Seq.toList compileFiles, (log |> Map.ofList), additionalProjs)
Ok (po, (log |> Map.ofList), additionalProjs)
with
| ProjectInspectException d -> Error d
| e -> Error (GenericError(file, e.Message))
9 changes: 3 additions & 6 deletions src/Dotnet.ProjInfo.Workspace/ProjectCrackerTypes.fs
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ and ProjectReference =

type [<RequireQualifiedAccess>] WorkspaceProjectState =
| Loading of string * ((string * string) list)
| Loaded of ProjectOptions * string list * Map<string,string>
| Loaded of ProjectOptions * Map<string,string>
| Failed of string * GetProjectOptionsErrors

module ProjectRecognizer =
@@ -128,11 +128,8 @@ module FscArguments =
|> Option.map (makeAbs projDir)

let isCompileFile (s:string) =
s.EndsWith(".fs") || s.EndsWith (".fsi")

let compileFiles =
//TODO filter the one without initial -
List.filter isCompileFile
//TODO check if is not an option, check prefix `-` ?
s.EndsWith(".fs") || s.EndsWith (".fsi") || s.EndsWith (".fsx")

let references =
//TODO valid also --reference:
Loading

0 comments on commit 2255f4c

Please sign in to comment.