Skip to content
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
3 changes: 2 additions & 1 deletion src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3998,7 +3998,8 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
// dispatch via a thunk which gets set to a non-resource-capturing
// failing function when the object is disposed.
let systemRuntimeContainsType =
let systemRuntimeContainsTypeRef = ref tcImports.SystemRuntimeContainsType
// NOTE: do not touch this
let systemRuntimeContainsTypeRef = ref (fun typeName -> tcImports.SystemRuntimeContainsType(typeName))
tcImports.AttachDisposeAction(fun () -> systemRuntimeContainsTypeRef := (fun _ -> raise (System.ObjectDisposedException("The type provider has been disposed"))))
fun arg -> systemRuntimeContainsTypeRef.Value arg

Expand Down
22 changes: 18 additions & 4 deletions src/fsharp/FSharp.Core/reflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,29 @@ module internal Impl =
let tupleNames = [|
"System.Tuple`1"; "System.Tuple`2"; "System.Tuple`3";
"System.Tuple`4"; "System.Tuple`5"; "System.Tuple`6";
"System.Tuple`7"; "System.Tuple`8"; "System.Tuple";
"System.Tuple`7"; "System.Tuple`8"; "System.Tuple"
"System.ValueTuple`1"; "System.ValueTuple`2"; "System.ValueTuple`3";
"System.ValueTuple`4"; "System.ValueTuple`5"; "System.ValueTuple`6";
"System.ValueTuple`7"; "System.ValueTuple`8"; "System.ValueTuple" |]

let simpleTupleNames = [|
"Tuple`1"; "Tuple`2"; "Tuple`3";
"Tuple`4"; "Tuple`5"; "Tuple`6";
"Tuple`7"; "Tuple`8";
"ValueTuple`1"; "ValueTuple`2"; "ValueTuple`3";
"ValueTuple`4"; "ValueTuple`5"; "ValueTuple`6";
"ValueTuple`7"; "ValueTuple`8"; |]

let isTupleType (typ:Type) =
// Simple Name Match on typ
if typ.IsEnum || typ.IsArray || typ.IsPointer then false
else tupleNames |> Seq.exists typ.FullName.StartsWith
// We need to be careful that we only rely typ.IsGenericType, typ.Namespace and typ.Name here.
//
// Historically the FSharp.Core reflection utilities get used on implementations of
// System.Type that don't have functionality such as .IsEnum and .FullName fully implemented.
// This happens particularly over TypeBuilderInstantiation types in the ProvideTypes implementation of System.TYpe
// used in F# type providers.
typ.IsGenericType &&
typ.Namespace = "System" &&
simpleTupleNames |> Seq.exists typ.Name.StartsWith

let maxTuple = 8
// Which field holds the nested tuple?
Expand Down
258 changes: 258 additions & 0 deletions tests/fsharp/core/quotes/test.fsx

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions tests/fsharp/core/reflect/test2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module TwoCasedUnionWithNullAsTrueValueAnnotation =
with _ -> false
test "TwoCasedUnionWithNullAsTrueValueAnnotation" result

module TEst = begin
module TEst =

type token =
| X
Expand Down Expand Up @@ -292,9 +292,6 @@ module TEst = begin
let _ = printany (1,true,2.4,"a tuple",("nested",(fun () -> ()),[2;3],rrv))
let _ = printany printany (* =) *)

end


let _ =
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
else (stdout.WriteLine "Test Passed";
Expand Down
12 changes: 6 additions & 6 deletions tests/fsharp/tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ module CoreTests =

peverify cfg "test.exe"

begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end

fsc cfg "%s -o:test-with-debug-data.exe --quotations-debug+ -r cslib.dll -g" cfg.fsc_flags ["test.fsx"]

peverify cfg "test-with-debug-data.exe"
Expand All @@ -657,12 +663,6 @@ module CoreTests =
testOkFile.CheckExists()
end

begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end

begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test-with-debug-data.exe") ""
Expand Down
12 changes: 7 additions & 5 deletions vsintegration/src/FSharp.Editor/ColorizationService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.Classification
open Microsoft.CodeAnalysis.Editor
open Microsoft.CodeAnalysis.Editor.Implementation.Classification
open Microsoft.CodeAnalysis.Editor.Implementation.BlockCommentEditing
open Microsoft.CodeAnalysis.Editor.Shared.Utilities
open Microsoft.CodeAnalysis.Host.Mef
open Microsoft.CodeAnalysis.Text

open Microsoft.VisualStudio.FSharp.LanguageService
open Microsoft.VisualStudio.Text
open Microsoft.VisualStudio.Text.Tagging
open Microsoft.VisualStudio.Text.Operations
open Microsoft.VisualStudio.Utilities

open Microsoft.FSharp.Compiler.SourceCodeServices

Expand Down Expand Up @@ -55,6 +58,7 @@ type private SourceTextData(approxLines: int) =
i <- i + 1



[<ExportLanguageService(typeof<IEditorClassificationService>, FSharpCommonConstants.FSharpLanguageName)>]
type internal FSharpColorizationService() =

Expand Down Expand Up @@ -193,11 +197,6 @@ type internal FSharpColorizationService() =
match FSharpLanguageService.GetOptions(document.Project.Id) with
| Some(options) ->
let! sourceText = document.GetTextAsync(cancellationToken) |> Async.AwaitTask
// REVIEW: ParseFileInProject and CheckFileInProject can cause FSharp.Compiler.Service to become unavailable (i.e. not responding to requests) for
// an arbitrarily long time while they process all files prior to this one in the project (plus dependent projects if we enable
// cross-project checking in multi-project solutions). FCS will not respond to other
// requests unless this task is cancelled. We need to check that this task is cancelled in a timely way by the
// Roslyn UI machinery.
let! parseResults = FSharpLanguageService.Checker.ParseFileInProject(document.Name, sourceText.ToString(), options)
let! textVersion = document.GetTextVersionAsync(cancellationToken) |> Async.AwaitTask
let! checkResultsAnswer = FSharpLanguageService.Checker.CheckFileInProject(parseResults, document.FilePath, textVersion.GetHashCode(), textSpan.ToString(), options)
Expand All @@ -214,3 +213,6 @@ type internal FSharpColorizationService() =

// Do not perform classification if we don't have project options (#defines matter)
member this.AdjustStaleClassification(_: SourceText, classifiedSpan: ClassifiedSpan) : ClassifiedSpan = classifiedSpan



7 changes: 2 additions & 5 deletions vsintegration/src/FSharp.Editor/CompletionProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ type internal FSharpCompletionProvider(workspace: Workspace, serviceProvider: SV
| _ -> true // anything else is a valid classification type

static member ProvideCompletionsAsyncAux(sourceText: SourceText, caretPosition: int, options: FSharpProjectOptions, filePath: string, textVersionHash: int) = async {
// REVIEW: ParseFileInProject and CheckFileInProject can cause FSharp.Compiler.Service to become unavailable (i.e. not responding to requests) for
// an arbitrarily long time while they process all files prior to this one in the project (plus dependent projects
// if we enable cross-project checking in multi-project solutions). FCS will not respond to other
// requests unless this task is cancelled. We need to check that this task is cancelled in a timely way by the
// Roslyn UI machinery.
let! parseResults = FSharpLanguageService.Checker.ParseFileInProject(filePath, sourceText.ToString(), options)
let! checkFileAnswer = FSharpLanguageService.Checker.CheckFileInProject(parseResults, filePath, textVersionHash, sourceText.ToString(), options)
let checkFileResults =
Expand All @@ -100,6 +95,8 @@ type internal FSharpCompletionProvider(workspace: Workspace, serviceProvider: SV
let results = List<CompletionItem>()

for declarationItem in declarations.Items do
// FSROSLYNTODO: This doesn't yet reflect pulbic/private/internal into the glyph
// FSROSLYNTODO: We should really use FSharpSymbol information here. But GetDeclarationListInfo doesn't provide it, and switch to GetDeclarationListSymbols is a bit large at the moment
let glyph =
match declarationItem.GlyphMajor with
| GlyphMajor.Class -> Glyph.ClassPublic
Expand Down
5 changes: 0 additions & 5 deletions vsintegration/src/FSharp.Editor/DocumentDiagnosticAnalyzer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ type internal FSharpDocumentDiagnosticAnalyzer() =
inherit DocumentDiagnosticAnalyzer()

static member GetDiagnostics(filePath: string, sourceText: SourceText, textVersionHash: int, options: FSharpProjectOptions, addSemanticErrors: bool) = async {
// REVIEW: ParseFileInProject and CheckFileInProject can cause FSharp.Compiler.Service to become unavailable (i.e. not responding to requests) for
// an arbitrarily long time while they process all files prior to this one in the project (plus dependent projects
// if we enable cross-project checking in multi-project solutions). FCS will not respond to other
// requests unless this task is cancelled. We need to check that this task is cancelled in a timely way by the
// Roslyn UI machinery.
let! parseResults = FSharpLanguageService.Checker.ParseFileInProject(filePath, sourceText.ToString(), options)
let! errors = async {
if addSemanticErrors then
Expand Down
5 changes: 0 additions & 5 deletions vsintegration/src/FSharp.Editor/GoToDefinitionService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ type internal FSharpGoToDefinitionService [<ImportingConstructor>] ([<ImportMany
match QuickParse.GetCompleteIdentifierIsland true (textLine.ToString()) textLineColumn with
| Some(islandIdentifier, islandColumn, isQuoted) ->
let qualifiers = if isQuoted then [islandIdentifier] else islandIdentifier.Split '.' |> Array.toList
// REVIEW: ParseFileInProject and CheckFileInProject can cause FSharp.Compiler.Service to become unavailable (i.e. not responding to requests) for
// an arbitrarily long time while they process all files prior to this one in the project (plus dependent projects
// if we enable cross-project checking in multi-project solutions). FCS will not respond to other
// requests unless this task is cancelled. We need to check that this task is cancelled in a timely way by the
// Roslyn UI machinery.
let! parseResults = FSharpLanguageService.Checker.ParseFileInProject(filePath, sourceText.ToString(), options)
let! checkFileAnswer = FSharpLanguageService.Checker.CheckFileInProject(parseResults, filePath, textVersionHash, sourceText.ToString(), options)
let checkFileResults =
Expand Down