diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 37ae0083298..4842a8e5987 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2392,6 +2392,7 @@ type FSharpParsingOptions = StrictIndentation: bool option CompilingFSharpCore: bool IsExe: bool + OnlyUseSpecifiedDefines: bool } member x.LastFileName = @@ -2410,6 +2411,7 @@ type FSharpParsingOptions = StrictIndentation = None CompilingFSharpCore = false IsExe = false + OnlyUseSpecifiedDefines = false } static member FromTcConfig(tcConfig: TcConfig, sourceFiles, isInteractive: bool) = @@ -2424,6 +2426,7 @@ type FSharpParsingOptions = StrictIndentation = tcConfig.strictIndentation CompilingFSharpCore = tcConfig.compilingFSharpCore IsExe = tcConfig.target.IsExe + OnlyUseSpecifiedDefines = false } static member FromTcConfigBuilder(tcConfigB: TcConfigBuilder, sourceFiles, isInteractive: bool) = @@ -2438,6 +2441,7 @@ type FSharpParsingOptions = StrictIndentation = tcConfigB.strictIndentation CompilingFSharpCore = tcConfigB.compilingFSharpCore IsExe = tcConfigB.target.IsExe + OnlyUseSpecifiedDefines = false } module internal ParseAndCheckFile = @@ -2550,8 +2554,11 @@ module internal ParseAndCheckFile = // If we're editing a script then we define INTERACTIVE otherwise COMPILED. // Since this parsing for intellisense we always define EDITING. let conditionalDefines = - SourceFileImpl.GetImplicitConditionalDefinesForEditing options.IsInteractive - @ options.ConditionalDefines + [ + if not options.OnlyUseSpecifiedDefines then + yield! SourceFileImpl.GetImplicitConditionalDefinesForEditing options.IsInteractive + yield! options.ConditionalDefines + ] // Note: we don't really attempt to intern strings across a large scope. let lexResourceManager = LexResourceManager() diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 8cdb304c18a..f13683e1c3e 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -225,6 +225,10 @@ type public FSharpParsingOptions = CompilingFSharpCore: bool IsExe: bool + + /// Don't pass in any other conditional defines other than specified in the parsing options. + /// This avoid the passing `COMPILED` or `INTERACTIVE`. + OnlyUseSpecifiedDefines: bool } static member Default: FSharpParsingOptions diff --git a/src/Compiler/SyntaxTree/PrettyNaming.fsi b/src/Compiler/SyntaxTree/PrettyNaming.fsi index 05478070e1a..657822cac4a 100644 --- a/src/Compiler/SyntaxTree/PrettyNaming.fsi +++ b/src/Compiler/SyntaxTree/PrettyNaming.fsi @@ -173,7 +173,7 @@ val internal isTildeOnlyString: s: string -> bool val internal IsValidPrefixOperatorUse: s: string -> bool -val internal IsValidPrefixOperatorDefinitionName: s: string -> bool +val IsValidPrefixOperatorDefinitionName: s: string -> bool val IsLogicalPrefixOperator: logicalName: string -> bool diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 25a540db859..e0a3d51b4ee 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2118,10 +2118,12 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsExe FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsInteractive +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean OnlyUseSpecifiedDefines FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_ApplyLineDirectives() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_CompilingFSharpCore() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsExe() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsInteractive() +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_OnlyUseSpecifiedDefines() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.CodeAnalysis.FSharpParsingOptions Default FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.CodeAnalysis.FSharpParsingOptions get_Default() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions DiagnosticOptions @@ -2142,7 +2144,7 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String get_LangVersionText() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] SourceFiles FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] get_SourceFiles() -FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean, Boolean) FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions ProjectOptions FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions get_ProjectOptions() FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.Symbols.FSharpAccessibilityRights AccessibilityRights @@ -5918,6 +5920,7 @@ FSharp.Compiler.Syntax.PrettyNaming: Boolean IsLogicalTernaryOperator(System.Str FSharp.Compiler.Syntax.PrettyNaming: Boolean IsLongIdentifierPartCharacter(Char) FSharp.Compiler.Syntax.PrettyNaming: Boolean IsOperatorDisplayName(System.String) FSharp.Compiler.Syntax.PrettyNaming: Boolean IsPunctuation(System.String) +FSharp.Compiler.Syntax.PrettyNaming: Boolean IsValidPrefixOperatorDefinitionName(System.String) FSharp.Compiler.Syntax.PrettyNaming: Microsoft.FSharp.Collections.FSharpList`1[System.String] GetLongNameFromString(System.String) FSharp.Compiler.Syntax.PrettyNaming: Microsoft.FSharp.Core.FSharpOption`1[System.String] TryChopPropertyName(System.String) FSharp.Compiler.Syntax.PrettyNaming: System.String CompileOpName(System.String) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 25a540db859..e0a3d51b4ee 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2118,10 +2118,12 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsExe FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsInteractive +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean OnlyUseSpecifiedDefines FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_ApplyLineDirectives() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_CompilingFSharpCore() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsExe() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsInteractive() +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_OnlyUseSpecifiedDefines() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.CodeAnalysis.FSharpParsingOptions Default FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.CodeAnalysis.FSharpParsingOptions get_Default() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions DiagnosticOptions @@ -2142,7 +2144,7 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String get_LangVersionText() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] SourceFiles FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] get_SourceFiles() -FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean, Boolean) FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions ProjectOptions FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions get_ProjectOptions() FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.Symbols.FSharpAccessibilityRights AccessibilityRights @@ -5918,6 +5920,7 @@ FSharp.Compiler.Syntax.PrettyNaming: Boolean IsLogicalTernaryOperator(System.Str FSharp.Compiler.Syntax.PrettyNaming: Boolean IsLongIdentifierPartCharacter(Char) FSharp.Compiler.Syntax.PrettyNaming: Boolean IsOperatorDisplayName(System.String) FSharp.Compiler.Syntax.PrettyNaming: Boolean IsPunctuation(System.String) +FSharp.Compiler.Syntax.PrettyNaming: Boolean IsValidPrefixOperatorDefinitionName(System.String) FSharp.Compiler.Syntax.PrettyNaming: Microsoft.FSharp.Collections.FSharpList`1[System.String] GetLongNameFromString(System.String) FSharp.Compiler.Syntax.PrettyNaming: Microsoft.FSharp.Core.FSharpOption`1[System.String] TryChopPropertyName(System.String) FSharp.Compiler.Syntax.PrettyNaming: System.String CompileOpName(System.String)