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

Commitdf1276e

Browse files
dsymeKevinRansom
authored andcommitted
Add signature file and fix 2498 (dotnet#2508)
* add signature file* fix 2489* another sig file* another sig file* error logger for GetProjectOptionsFromScript* fix build* fix build (2)
1 parented338d2 commitdf1276e

22 files changed

+509
-285
lines changed

‎src/absil/illib.fs‎

Lines changed: 142 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,85 @@ module Array =
151151
look(i+1) hi
152152
look0 arr.Length
153153

154+
/// pass an array byref to reverse it in place
155+
letrevInPlace(array:'T[])=
156+
if Array.isEmpty arraythen()else
157+
letarrlen,revlen= array.Length-1, array.Length/2-1
158+
for idxin0.. revlendo
159+
lett1= array.[idx]
160+
lett2= array.[arrlen-idx]
161+
array.[idx]<- t2
162+
array.[arrlen-idx]<- t1
163+
164+
/// Async implementation of Array.map.
165+
letmapAsync(mapping:'T->Async<'U>)(array:'T[]):Async<'U[]>=
166+
letlen= Array.length array
167+
letresult= Array.zeroCreate len
168+
169+
async{// Apply the mapping function to each array element.
170+
for iin0.. len-1do
171+
let!mappedValue= mapping array.[i]
172+
result.[i]<- mappedValue
173+
174+
// Return the completed results.
175+
return result
176+
}
177+
178+
/// Returns a new array with an element replaced with a given value.
179+
letreplace index value(array:_[])=
180+
if index>= array.Lengththen raise(IndexOutOfRangeException"index")
181+
letres= Array.copy array
182+
res.[index]<- value
183+
res
184+
185+
/// Optimized arrays equality. ~100x faster than `array1 = array2` on strings.
186+
/// ~2x faster for floats
187+
/// ~0.8x slower for ints
188+
let inlineareEqual(xs:'T[])(ys:'T[])=
189+
match xs, yswith
190+
|null,null->true
191+
|[||],[||]->true
192+
|null,_|_,null->false
193+
|_when xs.Length<> ys.Length->false
194+
|_->
195+
let mutablebreak'=false
196+
let mutablei=0
197+
let mutableresult=true
198+
while i< xs.Length&&not break'do
199+
if xs.[i]<> ys.[i]then
200+
break'<-true
201+
result<-false
202+
i<- i+1
203+
result
204+
205+
/// Returns all heads of a given array.
206+
/// For [|1;2;3|] it returns [|[|1; 2; 3|]; [|1; 2|]; [|1|]|]
207+
letheads(array:'T[])=
208+
letres= Array.zeroCreate<'T[]> array.Length
209+
for i= array.Length-1downto0do
210+
res.[i]<- array.[0..i]
211+
res
212+
213+
/// check if subArray is found in the wholeArray starting
214+
/// at the provided index
215+
let inlineisSubArray(subArray:'T[])(wholeArray:'T[])index=
216+
if isNull subArray|| isNull wholeArraythenfalse
217+
elif subArray.Length=0thentrue
218+
elif subArray.Length> wholeArray.Lengththenfalse
219+
elif subArray.Length= wholeArray.Lengththen areEqual subArray wholeArrayelse
220+
let recloop subidx idx=
221+
if subidx= subArray.Lengththentrue
222+
elif subArray.[subidx]= wholeArray.[idx]then loop(subidx+1)(idx+1)
223+
elsefalse
224+
loop0 index
225+
226+
/// Returns true if one array has another as its subset from index 0.
227+
letstartsWith(prefix:_[])(whole:_[])=
228+
isSubArray prefix whole0
229+
230+
/// Returns true if one array has trailing elements equal to another's.
231+
letendsWith(suffix:_[])(whole:_[])=
232+
isSubArray suffix whole(whole.Length-suffix.Length)
154233

155234
moduleOption=
156235
letmapFold f s opt=
@@ -163,16 +242,12 @@ module Option =
163242
| None-> dflt
164243
| Some x-> x
165244

166-
letorElse dflt opt=
167-
match optwith
168-
| None-> dflt()
169-
| res-> res
170-
171245
letfold f z x=
172246
match xwith
173247
| None-> z
174248
| Some x-> f z x
175249

250+
letattempt(f:unit->'T)=try Some(f())with_-> None
176251

177252
moduleList=
178253

@@ -440,6 +515,68 @@ module String =
440515

441516
letdropSuffix s t=match(tryDropSuffix s t)with Some(res)-> res| None-> failwith"dropSuffix"
442517

518+
openSystem
519+
openSystem.IO
520+
521+
let inlinetoCharArray(str:string)= str.ToCharArray()
522+
523+
letlowerCaseFirstChar(str:string)=
524+
if String.IsNullOrEmpty str
525+
|| Char.IsLower(str,0)then strelse
526+
letstrArr= toCharArray str
527+
match Array.tryHead strArrwith
528+
| None-> str
529+
| Some c->
530+
strArr.[0]<- Char.ToLower c
531+
String(strArr)
532+
533+
letextractTrailingIndex(str:string)=
534+
match strwith
535+
|null->null, None
536+
|_->
537+
letcharr= str.ToCharArray()
538+
Array.revInPlace charr
539+
letdigits= Array.takeWhile Char.IsDigit charr
540+
Array.revInPlace digits
541+
String digits
542+
|>function
543+
|""-> str, None
544+
| index-> str.Substring(0, str.Length- index.Length), Some(int index)
545+
546+
/// Remove all trailing and leading whitespace from the string
547+
/// return null if the string is null
548+
lettrim(value:string)=if isNull valuethennullelse value.Trim()
549+
550+
/// Splits a string into substrings based on the strings in the array separators
551+
letsplit options(separator:string[])(value:string)=
552+
if isNull valuethennullelse value.Split(separator, options)
553+
554+
let(|StartsWith|_|)pattern value=
555+
if String.IsNullOrWhiteSpace valuethen
556+
None
557+
elif value.StartsWith patternthen
558+
Some()
559+
else None
560+
561+
let(|Contains|_|)pattern value=
562+
if String.IsNullOrWhiteSpace valuethen
563+
None
564+
elif value.Contains patternthen
565+
Some()
566+
else None
567+
568+
letgetLines(str:string)=
569+
use reader=new StringReader(str)
570+
[|
571+
letline= ref(reader.ReadLine())
572+
whilenot(isNull!line)do
573+
yield!line
574+
line:= reader.ReadLine()
575+
if str.EndsWith("\n")then
576+
// last trailing space not returned
577+
// http://stackoverflow.com/questions/19365404/stringreader-omits-trailing-linebreak
578+
yield String.Empty
579+
|]
443580
moduleDictionary=
444581

445582
let inlinenewWithSize(size:int)= System.Collections.Generic.Dictionary<_,_>(size, HashIdentity.Structural)

‎src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,15 @@
550550
<CompileInclude="..\MSBuildReferenceResolver.fs">
551551
<Link>Service/MSBuildReferenceResolver.fs</Link>
552552
</Compile>
553+
<CompileInclude="..\vs\ServiceAssemblyContent.fsi">
554+
<Link>Service/ServiceAssemblyContent.fsi</Link>
555+
</Compile>
553556
<CompileInclude="..\vs\ServiceAssemblyContent.fs">
554557
<Link>Service/ServiceAssemblyContent.fs</Link>
555558
</Compile>
559+
<CompileInclude="..\vs\ServiceXmlDocParser.fsi">
560+
<Link>Service/ServiceXmlDocParser.fsi</Link>
561+
</Compile>
556562
<CompileInclude="..\vs\ServiceXmlDocParser.fs">
557563
<Link>Service/ServiceXmlDocParser.fs</Link>
558564
</Compile>
@@ -562,6 +568,9 @@
562568
<CompileInclude="..\vs\service.fs">
563569
<Link>Service/service.fs</Link>
564570
</Compile>
571+
<CompileInclude="..\vs\ServiceInterfaceStubGenerator.fsi">
572+
<Link>Service/ServiceInterfaceStubGenerator.fsi</Link>
573+
</Compile>
565574
<CompileInclude="..\vs\ServiceInterfaceStubGenerator.fs">
566575
<Link>Service/ServiceInterfaceStubGenerator.fs</Link>
567576
</Compile>
@@ -633,19 +642,19 @@
633642
</ItemGroup>
634643
<ItemGroupCondition=" '$(TargetFramework)' != 'coreclr' AND '$(MonoPackaging)' == 'true'">
635644
<ReferenceInclude="Microsoft.Build.Framework, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
636-
<Private>True</Private>
645+
<Private>True</Private>
637646
</Reference>
638647
<ReferenceInclude="Microsoft.Build.Engine, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
639-
<Private>True</Private>
648+
<Private>True</Private>
640649
</Reference>
641650
<ReferenceInclude="Microsoft.Build, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
642-
<Private>True</Private>
651+
<Private>True</Private>
643652
</Reference>
644653
<ReferenceInclude="Microsoft.Build.Utilities.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
645-
<Private>True</Private>
654+
<Private>True</Private>
646655
</Reference>
647656
<ReferenceInclude="Microsoft.Build.Tasks.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
648-
<Private>True</Private>
657+
<Private>True</Private>
649658
</Reference>
650659
</ItemGroup>
651660
</Project>

‎src/fsharp/vs/ServiceAssemblyContent.fs‎

Lines changed: 41 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
namespaceMicrosoft.FSharp.Compiler.SourceCodeServices
99

1010
openSystem
11-
openMicrosoft.FSharp.Compiler.Ast
1211
openSystem.Collections.Generic
12+
1313
openMicrosoft.FSharp.Compiler
14+
openMicrosoft.FSharp.Compiler.Ast
1415
openMicrosoft.FSharp.Compiler.Range
16+
openMicrosoft.FSharp.Compiler.AbstractIL.Internal.Library
1517

1618
typeinternalShortIdent= string
1719
typeIdents= ShortIdent[]
@@ -21,70 +23,7 @@ type IsAutoOpen = bool
2123

2224
[<AutoOpen>]
2325
moduleinternalExtensions=
24-
[<RequireQualifiedAccess>]
25-
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
26-
moduleOption=
27-
letattempt(f:unit->'T)=try Some(f())with_-> None
28-
29-
[<RequireQualifiedAccess>]
30-
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
31-
moduleArray=
32-
/// Returns a new array with an element replaced with a given value.
33-
letreplace index value(array:_[])=
34-
if index>= array.Lengththen raise(IndexOutOfRangeException"index")
35-
letres= Array.copy array
36-
res.[index]<- value
37-
res
38-
39-
/// Optimized arrays equality. ~100x faster than `array1 = array2` on strings.
40-
/// ~2x faster for floats
41-
/// ~0.8x slower for ints
42-
let inlineareEqual(xs:'T[])(ys:'T[])=
43-
match xs, yswith
44-
|null,null->true
45-
|[||],[||]->true
46-
|null,_|_,null->false
47-
|_when xs.Length<> ys.Length->false
48-
|_->
49-
let mutablebreak'=false
50-
let mutablei=0
51-
let mutableresult=true
52-
while i< xs.Length&&not break'do
53-
if xs.[i]<> ys.[i]then
54-
break'<-true
55-
result<-false
56-
i<- i+1
57-
result
58-
59-
/// Returns all heads of a given array.
60-
/// For [|1;2;3|] it returns [|[|1; 2; 3|]; [|1; 2|]; [|1|]|]
61-
letheads(array:'T[])=
62-
letres= Array.zeroCreate<'T[]> array.Length
63-
for i= array.Length-1downto0do
64-
res.[i]<- array.[0..i]
65-
res
6626

67-
/// check if subArray is found in the wholeArray starting
68-
/// at the provided index
69-
let inlineisSubArray(subArray:'T[])(wholeArray:'T[])index=
70-
if isNull subArray|| isNull wholeArraythenfalse
71-
elif subArray.Length=0thentrue
72-
elif subArray.Length> wholeArray.Lengththenfalse
73-
elif subArray.Length= wholeArray.Lengththen areEqual subArray wholeArrayelse
74-
let recloop subidx idx=
75-
if subidx= subArray.Lengththentrue
76-
elif subArray.[subidx]= wholeArray.[idx]then loop(subidx+1)(idx+1)
77-
elsefalse
78-
loop0 index
79-
80-
/// Returns true if one array has another as its subset from index 0.
81-
letstartsWith(prefix:_[])(whole:_[])=
82-
isSubArray prefix whole0
83-
84-
/// Returns true if one array has trailing elements equal to another's.
85-
letendsWith(suffix:_[])(whole:_[])=
86-
isSubArray suffix whole(whole.Length-suffix.Length)
87-
8827
typeFSharpEntitywith
8928
memberx.TryGetFullName()=
9029
try x.TryFullName
@@ -387,10 +326,22 @@ module internal AssemblyContentProvider =
387326
yield! traverseEntity contentType currentParent e
388327
|_->()}
389328

329+
390330
letgetAssemblySignatureContent contentType(signature:FSharpAssemblySignature)=
391-
signature.TryGetEntities()
392-
|> Seq.collect(traverseEntity contentType Parent.Empty)
393-
|> Seq.distinctBy(fun{FullName=fullName;CleanedIdents=cleanIdents}->(fullName, cleanIdents))
331+
332+
// We ignore all diagnostics during this operation
333+
//
334+
// CLEANUP: this function is run on the API user's calling thread. It potentially accesses TAST data structures
335+
// concurrently with other threads. On an initial review this is not a problem since type provider computations
336+
// are not triggered (see "if not entity.IsProvided") and the other data accessed is immutable or computed safely
337+
// on-demand. However a more compete review may be warranted.
338+
339+
use _ignoreAllDiagnostics=new ErrorScope()
340+
341+
signature.TryGetEntities()
342+
|> Seq.collect(traverseEntity contentType Parent.Empty)
343+
|> Seq.distinctBy(fun{FullName=fullName;CleanedIdents=cleanIdents}->(fullName, cleanIdents))
344+
|> Seq.toList
394345

395346
letprivategetAssemblySignaturesContent contentType(assemblies:FSharpAssembly list)=
396347
assemblies
@@ -399,6 +350,15 @@ module internal AssemblyContentProvider =
399350

400351
letgetAssemblyContent(withCache:(IAssemblyContentCache-> _)->_)
401352
contentType(fileName:string option)(assemblies:FSharpAssembly list)=
353+
354+
// We ignore all diagnostics during this operation
355+
//
356+
// CLEANUP: this function is run on the API user's calling thread. It potentially accesses TAST data structures
357+
// concurrently with other threads. On an initial review this is not a problem since type provider computations
358+
// are not triggered (see "if not entity.IsProvided") and the other data accessed is immutable or computed safely
359+
// on-demand. However a more compete review may be warranted.
360+
use _ignoreAllDiagnostics=new ErrorScope()
361+
402362
match assemblies|> List.filter(fun x->not x.IsProviderGenerated), fileNamewith
403363
|[],_->[]
404364
| assemblies, Some fileName->
@@ -902,7 +862,13 @@ module internal ParsedInput =
902862
{ Idents:Idents
903863
Kind:ScopeKind}
904864

905-
lettryFindInsertionContext(currentLine:int)(ast:ParsedInput)=
865+
lettryFindInsertionContext(currentLine:int)(ast:ParsedInput)(partiallyQualifiedName:MaybeUnresolvedIdents)=
866+
867+
// We ignore all diagnostics during this operation
868+
//
869+
// Based on an initial review, no diagnostics should be generated. However the code should be checked more closely.
870+
use _ignoreAllDiagnostics=new ErrorScope()
871+
906872
letresult:(Scope* Point<FCS>)option ref= ref None
907873
letns:string[]option ref= ref None
908874
letmodules= ResizeArray<Idents* EndLine* Col>()
@@ -1005,8 +971,13 @@ module internal ParsedInput =
1005971
|> Seq.sortBy(fun(m,_,_)->-m.Length)
1006972
|> Seq.toList
1007973

1008-
fun(partiallyQualifiedName: MaybeUnresolvedIdents)
1009-
(requiresQualifiedAccessParent: Idents option,autoOpenParent: Idents option,entityNamespace: Idents option,entity: Idents)->
974+
// CLEANUP: does this realy need to be a partial application with pre-computation? Can this be made more expicit?
975+
fun(requiresQualifiedAccessParent: Idents option,autoOpenParent: Idents option,entityNamespace: Idents option,entity: Idents)->
976+
977+
// We ignore all diagnostics during this operation
978+
//
979+
// Based on an initial review, no diagnostics should be generated. However the code should be checked more closely.
980+
use _ignoreAllDiagnostics=new ErrorScope()
1010981
match reswith
1011982
| None->[||]
1012983
| Some(scope, ns, pos)->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp