Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4c8243

Browse files
authored
Merge pull request #4889 from TIHan/perf-fixes1
Fixed .NET SDK style project slowness in the editor
2 parentse9b230f +faba1f0 commitd4c8243

File tree

4 files changed

+81
-18
lines changed

4 files changed

+81
-18
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
[FILES]
7+
</ItemGroup>
8+
<ItemGroup>
9+
[PROJECTREFERENCES]
10+
</ItemGroup>
11+
<ItemGroup>
12+
[PACKAGEREFERENCES]
13+
</ItemGroup>
14+
</Project>

‎tests/projects/stress/gen.fsx‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@ open Perf
44
openSystem
55

66
printfn"%A" fsi.CommandLineArgs
7-
if fsi.CommandLineArgs.Length<>3then printfn"usage: fsi gen.fsx <directory> <size>"
7+
if fsi.CommandLineArgs.Length<>4then printfn"usage: fsi gen.fsx <directory> <size> <isNetStandard>"
88
letD= string fsi.CommandLineArgs.[1]
99
letN= int fsi.CommandLineArgs.[2]
10+
letisNetStandard= Boolean.Parse(fsi.CommandLineArgs.[3])
1011

1112
try System.IO.Directory.Delete(D,true)with_->()
1213
System.IO.Directory.CreateDirectory D
1314
System.Environment.CurrentDirectory<- D
1415

16+
letfsharpProjectWrite=
17+
if isNetStandardthen
18+
FSharpProject.writeNetStandard
19+
else
20+
FSharpProject.write
21+
22+
letcsharpProjectWrite=
23+
if isNetStandardthen
24+
CSharpProject.writeNetStandard
25+
else
26+
CSharpProject.write
27+
1528
letwriteDense(dir:string)(projectType:ProjectType)(count:int)=
1629

1730
letextension=match projectTypewith FSharp->"fsproj"| CSharp->"csproj"
@@ -30,7 +43,7 @@ let writeDense (dir : string) (projectType : ProjectType) (count : int) =
3043
letfileName= sprintf"%s.fs" name
3144
yield fileName]
3245
letproject={ Name= name; Guid= guid; Files= files; References= references; BinaryReferences=[]}
33-
letwriter=match projectTypewith FSharp->FSharpProject.write| CSharp->CSharpProject.write
46+
letwriter=match projectTypewith FSharp->fsharpProjectWrite| CSharp->csharpProjectWrite
3447
writer path project
3548

3649
projects|> List.iteri writeProject
@@ -62,7 +75,7 @@ let writeShallow (dir : string) (projectType : ProjectType) (count1 : int) (coun
6275
letwriteAProject(name,guid)=
6376
letpath= sprintf@"%s\%s\%s.%s" dir name name extension
6477
letproject={ Name= name; Guid= guid; Files=[]; References=[]; BinaryReferences=[]}
65-
letwriter=match projectTypewith FSharp->FSharpProject.write| CSharp->CSharpProject.write
78+
letwriter=match projectTypewith FSharp->fsharpProjectWrite| CSharp->csharpProjectWrite
6679
writer path project
6780

6881
letwriteBProject(name,guid)=
@@ -71,7 +84,7 @@ let writeShallow (dir : string) (projectType : ProjectType) (count1 : int) (coun
7184
letmakeRef(name,guid)={ Name= name; Guid= guid; RelativePath= sprintf@"..\%s\%s.%s" name name extension}
7285
aProjects|> List.map makeRef
7386
letproject={ Name= name; Guid= guid; Files=[]; References= references; BinaryReferences=[]}
74-
letwriter=match projectTypewith FSharp->FSharpProject.write| CSharp->CSharpProject.write
87+
letwriter=match projectTypewith FSharp->fsharpProjectWrite| CSharp->csharpProjectWrite
7588
writer path project
7689

7790
aProjects|> List.iter writeAProject
@@ -103,7 +116,7 @@ let writeDenseBin (dir : string) (projectType : ProjectType) (count : int) =
103116
letmakeRef(name,guid):BinaryRef={ Name= name; RelativePath= sprintf@"..\%s\bin\Debug\%s.dll" name name}
104117
projects.[0..i-1]|> List.map makeRef
105118
letproject={ Name= name; Guid= guid; Files=[]; References=[]; BinaryReferences= references}
106-
letwriter=match projectTypewith FSharp->FSharpProject.write| CSharp->CSharpProject.write
119+
letwriter=match projectTypewith FSharp->fsharpProjectWrite| CSharp->csharpProjectWrite
107120
writer path project
108121

109122
projects|> List.iteri writeProject

‎tests/projects/stress/perf.fsx‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ module FSharpProject =
105105

106106
safeWrite path text
107107

108+
letwriteNetStandard path(project:Project)=
109+
110+
letfiles=
111+
letprintFileReference= sprintf" <Compile Include=\"%s\" />"
112+
project.Files|> List.map printFileReference|> String.concat"\n"
113+
114+
for fin project.Filesdo
115+
letfilePath= Path.Combine(Path.GetDirectoryName(path),f)
116+
letfileContents= sprintf"module%s\n\nlet x = 1"(Path.GetFileNameWithoutExtension(f))
117+
safeWrite filePath fileContents
118+
119+
letreferences=
120+
letprintProjectReference(r:ProjectRef)=
121+
sprintf" <ProjectReference Include=\"%s\" />" r.RelativePath
122+
project.References|> List.map printProjectReference|> String.concat"\n"
123+
124+
lettext=
125+
File.ReadAllText(Path.Combine(__SOURCE_DIRECTORY__,@"Templates\netstandard_fsproj.template"))
126+
.Replace("[FILES]", files)
127+
.Replace("[PROJECTREFERENCES]", references)
128+
.Replace("[PACKAGEREFERENCES]", String.Empty)
129+
130+
safeWrite path text
131+
108132
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
109133
moduleCSharpProject=
110134

@@ -135,6 +159,30 @@ module CSharpProject =
135159

136160
safeWrite path text
137161

162+
letwriteNetStandard path(project:Project)=
163+
164+
letfiles=
165+
letprintFileReference= sprintf" <Compile Include=\"%s\" />"
166+
project.Files|> List.map printFileReference|> String.concat"\n"
167+
168+
for fin project.Filesdo
169+
letfilePath= Path.Combine(Path.GetDirectoryName(path),f)
170+
letfileContents= sprintf"module%s\n\nlet x = 1"(Path.GetFileNameWithoutExtension(f))
171+
safeWrite filePath fileContents
172+
173+
letreferences=
174+
letprintProjectReference(r:ProjectRef)=
175+
sprintf" <ProjectReference Include=\"%s\" />" r.RelativePath
176+
project.References|> List.map printProjectReference|> String.concat"\n"
177+
178+
lettext=
179+
File.ReadAllText(Path.Combine(__SOURCE_DIRECTORY__,@"Templates\netstandard_fsproj.template"))
180+
.Replace("[FILES]", files)
181+
.Replace("[PROJECTREFERENCES]", references)
182+
.Replace("[PACKAGEREFERENCES]", String.Empty)
183+
184+
safeWrite path text
185+
138186
moduleTesting=
139187

140188
lettestWrite()=

‎vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ type internal FSharpLanguageService(package : FSharpPackage) =
427427
memberprivatethis.OnProjectAdded(projectId:ProjectId)= projectInfoManager.UpdateProjectInfoWithProjectId(projectId,"OnProjectAdded", invalidateConfig=true)
428428
memberprivatethis.OnProjectReloaded(projectId:ProjectId)= projectInfoManager.UpdateProjectInfoWithProjectId(projectId,"OnProjectReloaded", invalidateConfig=true)
429429
memberprivatethis.OnDocumentAdded(projectId:ProjectId,documentId:DocumentId)= projectInfoManager.UpdateDocumentInfoWithProjectId(projectId, documentId,"OnDocumentAdded", invalidateConfig=true)
430-
memberprivatethis.OnDocumentChanged(projectId:ProjectId,documentId:DocumentId)= projectInfoManager.UpdateDocumentInfoWithProjectId(projectId, documentId,"OnDocumentChanged", invalidateConfig=false)
431430
memberprivatethis.OnDocumentReloaded(projectId:ProjectId,documentId:DocumentId)= projectInfoManager.UpdateDocumentInfoWithProjectId(projectId, documentId,"OnDocumentReloaded", invalidateConfig=true)
432431

433432
overridethis.Initialize()=
@@ -439,7 +438,6 @@ type internal FSharpLanguageService(package : FSharpPackage) =
439438
| WorkspaceChangeKind.ProjectAdded-> this.OnProjectAdded(args.ProjectId)
440439
| WorkspaceChangeKind.ProjectReloaded-> this.OnProjectReloaded(args.ProjectId)
441440
| WorkspaceChangeKind.DocumentAdded-> this.OnDocumentAdded(args.ProjectId, args.DocumentId)
442-
| WorkspaceChangeKind.DocumentChanged-> this.OnDocumentChanged(args.ProjectId, args.DocumentId)
443441
| WorkspaceChangeKind.DocumentReloaded-> this.OnDocumentReloaded(args.ProjectId, args.DocumentId)
444442
| WorkspaceChangeKind.DocumentRemoved
445443
| WorkspaceChangeKind.ProjectRemoved
@@ -686,17 +684,7 @@ type internal FSharpLanguageService(package : FSharpPackage) =
686684

687685
letfileContents= VsTextLines.GetFileContents(textLines, textViewAdapter)
688686
this.SetupStandAloneFile(filename, fileContents, this.Workspace, hier)
689-
| id->
690-
691-
// This is the path when opening in-project .fs/.fsi files in CPS projects when
692-
// there is already an existing DocumentId for that document in the solution (which
693-
// will normally be the case)
694-
//
695-
// However, it is not clear this call to UpdateProjectInfoWithProjectId is needed, and it seems
696-
// harmful as it will cause a complete recheck of the project every time a view for a file in the
697-
// project is freshly opened.
698-
699-
projectInfoManager.UpdateProjectInfoWithProjectId(id.ProjectId,"SetupNewTextView", invalidateConfig=true)
687+
|_->()
700688
|_->
701689

702690
// This is the path for both in-project and out-of-project .fsx files

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp