Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ProjectViewer #50

Merged
merged 4 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -8,7 +8,7 @@
"tasks": [
{
"taskName": "build",
"args": [ "src/dotnet-proj" ],
"args": [ "src/dotnet-proj.sln" ],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
Expand Down
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>
Expand Down
44 changes: 39 additions & 5 deletions src/Dotnet.ProjInfo.Workspace/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Up @@ -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")

Expand Down Expand Up @@ -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))
Expand Down
9 changes: 3 additions & 6 deletions src/Dotnet.ProjInfo.Workspace/ProjectCrackerTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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:
Expand Down
Loading