Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
7 changes: 5 additions & 2 deletions FSharpBuild.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@
<!-- nuget -->
<PropertyGroup>
<!-- Point to artifacts folder as an additional nuget package source -->
<RestoreAdditionalProjectSources Condition = "'$(RestoreAdditionalProjectSources)' != ''">$(RestoreAdditionalProjectSources);$(MSBuildThisFileDirectory)\artifacts</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources Condition = "'$(RestoreAdditionalProjectSources)' == ''">$(MSBuildThisFileDirectory)\artifacts</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' != ''">$(RestoreAdditionalProjectSources);$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' == ''">$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>

<!-- default NuGet package restore location -->
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot>
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' == 'Windows_NT'">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' != 'Windows_NT'">$(HOME)/.nuget/packages/</NuGetPackageRoot>

<!-- ensure there is a trailing slash -->
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' == 'Windows_NT'">$(NuGetPackageRoot)\</NuGetPackageRoot>
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' != 'Windows_NT'">$(NuGetPackageRoot)/</NuGetPackageRoot>

<!-- ensure all NuGet packages come from the `$(NuGetPackageRoot)` variable -->
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
Expand All @@ -55,6 +57,7 @@
<StrongNames>true</StrongNames>
<DelaySign>true</DelaySign>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoPackaging)' == 'true'">
<AssemblyOriginatorKeyFile>$(FSharpSourcesRoot)\fsharp\test.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
18 changes: 0 additions & 18 deletions build-nuget-packages.proj

This file was deleted.

2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rem Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
@if "%_echo%"=="" echo off
setlocal enableDelayedExpansion
setlocal enableDelayedExpansion

:ARGUMENTS_VALIDATION
if /I "%1" == "--help" (goto :USAGE)
Expand Down
6 changes: 3 additions & 3 deletions build/targets/ConvertPortablePdbs.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
$(TargetFramework.StartsWith('net')) AND
'$(Configuration)' != 'Proto'">
<PropertyGroup>
<ConvertedPdbsDirectory>$(FinalOutputPath)\ConvertedPdbs\$(TargetFramework)</ConvertedPdbsDirectory>
<ConvertedPdbsDirectory>$(SymStoreDirectory)\$(TargetFramework)</ConvertedPdbsDirectory>
<PdbConverterExe>$(NuGetPackageRoot)Pdb2Pdb\$(Pdb2PdbPackageVersion)\tools\Pdb2Pdb.exe</PdbConverterExe>
<PdbConverterArgs>"$(TargetPath)" /out "$(SymStoreDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public</PdbConverterArgs>
<PdbConverterArgs>"$(TargetPath)" /out "$(ConvertedPdbsDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public</PdbConverterArgs>
</PropertyGroup>

<MakeDir Directories="$(SymStoreDirectory)" />
<MakeDir Directories="$(ConvertedPdbsDirectory)" />
<Exec Command='"$(PdbConverterExe)" $(PdbConverterArgs)' />
</Target>

Expand Down
8 changes: 2 additions & 6 deletions fsharp.proj
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
<ItemGroup Condition="'$(TestFCS)' == 'true' OR '$(_RunningRestore)' == 'true'">
<Projects Include="$(MSBuildThisFileDirectory)fcs\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" />
<Projects Include="$(MSBuildThisFileDirectory)tests\projects\Sample_NETCoreSDK_FSharp_Library_netstandard2_0\Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj" />
<Projects Include="$(MSBuildThisFileDirectory)fcs\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" />
</ItemGroup>

<ItemGroup Condition="'$(TestIDE)' == 'true' OR '$(_RunningRestore)' == 'true'">
Expand All @@ -156,12 +155,9 @@
</Target>

<Target Name="Build" DependsOnTargets="CollectProjects">
<ItemGroup>
<Projects Include="@(NugetProjects)" />
</ItemGroup>

<!-- Nuget projects need to be built before the vsix stuff, so that the vsix build -->
<MSBuild Projects="@(NugetProjects)" Targets="Pack" Properties="Configuration=$(Configuration);BUILD_PUBLICSIGN=$(BUILD_PUBLICSIGN);$(CustomProps)" />
<MSBuild Projects="@(Projects)" Targets="Build" Properties="Configuration=$(Configuration);BUILD_PUBLICSIGN=$(BUILD_PUBLICSIGN);$(CustomProps)" />
<MSBuild Projects="@(Projects);@(NugetProjects)" Targets="Build" Properties="Configuration=$(Configuration);BUILD_PUBLICSIGN=$(BUILD_PUBLICSIGN);$(CustomProps)" />
</Target>

<Target Name="Rebuild" DependsOnTargets="CollectProjects">
Expand Down
3 changes: 0 additions & 3 deletions src/buildtools/Directory.Build.props

This file was deleted.

3 changes: 0 additions & 3 deletions src/buildtools/Directory.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<UseFSharpProductVersion>true</UseFSharpProductVersion>
<UseAssetTargetFallback>true</UseAssetTargetFallback>
<SkipPDBConversion>true</SkipPDBConversion>
<Tailcalls>true</Tailcalls> <!-- .tail annotations always emitted for this binary, even in debug mode -->
<SkipPDBConversion>true</SkipPDBConversion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472' AND '$(OS)' == 'Windows_NT'">
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/TastPickle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,15 +2021,16 @@ and u_attribs_ext extraf st = u_list_ext extraf u_attrib st
and u_unioncase_spec st =
let a = u_rfield_table st
let b = u_ty st
let c = u_string st

// The union case compiled name is now computed from Id field when needed and is not stored in UnionCase record.
let _c = u_string st
let d = u_ident st
// The XmlDoc is only present in the extended in-memory format. We detect its presence using a marker bit here
let xmldoc, e = u_attribs_ext u_xmldoc st
let f = u_string st
let i = u_access st
{ FieldTable=a
ReturnType=b
CompiledName=c
Id=d
Attribs=e
XmlDoc= defaultArg xmldoc XmlDoc.Empty
Expand Down
66 changes: 34 additions & 32 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,21 +1509,26 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche

PublishValueDefn cenv env declKind vspec

let shouldNotifySink (vspec: Val) =
match vspec.MemberInfo with
// `this` reference named `__`. It's either:
// * generated by compiler for auto properties or
// * provided by source code (i.e. `member __.Method = ...`)
// We don't notify sink about it to prevent generating `FSharpSymbol` for it and appearing in completion list.
| None when
let baseOrThisInfo = vspec.BaseOrThisInfo
baseOrThisInfo = ValBaseOrThisInfo.BaseVal || // visualfsharp#3699
baseOrThisInfo = ValBaseOrThisInfo.MemberThisVal && vspec.LogicalName = "__" -> false
| _ -> true

match cenv.tcSink.CurrentSink with
| None -> ()
| Some _ ->
if not vspec.IsCompilerGenerated then
match vspec.MemberInfo with
// `this` reference named `__`. It's either:
// * generated by compiler for auto properties or
// * provided by source code (i.e. `member __.Method = ...`)
// We don't notify sink about it to prevent generating `FSharpSymbol` for it and appearing in completion list.
| None when vspec.BaseOrThisInfo = ValBaseOrThisInfo.MemberThisVal && vspec.LogicalName = "__" -> ()
| _ ->
let nenv = AddFakeNamedValRefToNameEnv vspec.DisplayName env.NameEnv (mkLocalValRef vspec)
CallEnvSink cenv.tcSink (vspec.Range, nenv, env.eAccessRights)
let item = Item.Value(mkLocalValRef vspec)
CallNameResolutionSink cenv.tcSink (vspec.Range, nenv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights)
| Some _ when not vspec.IsCompilerGenerated && shouldNotifySink vspec ->
let nenv = AddFakeNamedValRefToNameEnv vspec.DisplayName env.NameEnv (mkLocalValRef vspec)
CallEnvSink cenv.tcSink (vspec.Range, nenv, env.eAccessRights)
let item = Item.Value(mkLocalValRef vspec)
CallNameResolutionSink cenv.tcSink (vspec.Range, nenv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights)
| _ -> ()

vspec

let MakeAndPublishVals cenv env (altActualParent, inSig, declKind, vrec, valSchemes, attrs, doc, konst) =
Expand Down Expand Up @@ -12254,11 +12259,15 @@ module TcRecdUnionAndEnumDeclarations = begin
// Bind other elements of type definitions (constructors etc.)
//-------------------------------------------------------------------------

let CheckUnionCaseName cenv realUnionCaseName m =
CheckNamespaceModuleOrTypeName cenv.g (mkSynId m realUnionCaseName)
if not (String.isUpper realUnionCaseName) && realUnionCaseName <> opNameCons && realUnionCaseName <> opNameNil then
errorR(NotUpperCaseConstructor(m))

let CheckUnionCaseName cenv (id: Ident) =
let name = id.idText
if name = "Tags" then
errorR(Error(FSComp.SR.tcUnionCaseNameConflictsWithGeneratedType(name, "Tags"), id.idRange))

CheckNamespaceModuleOrTypeName cenv.g id
if not (String.isUpper name) && name <> opNameCons && name <> opNameNil then
errorR(NotUpperCaseConstructor(id.idRange))

let ValidateFieldNames (synFields : SynField list, tastFields : RecdField list) =
let seen = Dictionary()
for (sf, f) in List.zip synFields tastFields do
Expand All @@ -12278,16 +12287,9 @@ module TcRecdUnionAndEnumDeclarations = begin
let attrs = TcAttributes cenv env AttributeTargets.UnionCaseDecl synAttrs // the attributes of a union case decl get attached to the generated "static factory" method
let vis, _ = ComputeAccessAndCompPath env None m vis None parent
let vis = CombineReprAccess parent vis
let realUnionCaseName =
if id.idText = opNameCons then "Cons"
elif id.idText = opNameNil then "Empty"
else id.idText

if realUnionCaseName = "Tags" then
errorR(Error(FSComp.SR.tcUnionCaseNameConflictsWithGeneratedType(realUnionCaseName, "Tags"), m))

CheckUnionCaseName cenv realUnionCaseName id.idRange


CheckUnionCaseName cenv id

let mkName nFields i = if nFields <= 1 then "Item" else "Item"+string (i+1)
let rfields, recordTy =
match args with
Expand All @@ -12311,7 +12313,7 @@ module TcRecdUnionAndEnumDeclarations = begin
if not (typeEquiv cenv.g recordTy thisTy) then
error(Error(FSComp.SR.tcReturnTypesForUnionMustBeSameAsType(), m))
rfields, recordTy
NewUnionCase id realUnionCaseName rfields recordTy attrs (xmldoc.ToXmlDoc()) vis
NewUnionCase id rfields recordTy attrs (xmldoc.ToXmlDoc()) vis


let TcUnionCaseDecls cenv env parent (thisTy : TType) tpenv unionCases =
Expand Down Expand Up @@ -15538,8 +15540,8 @@ module EstablishTypeDefinitionCores =

structLayoutAttributeCheck(false)
noAllowNullLiteralAttributeCheck()
TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName.idText unionCaseName.idRange
let unionCase = NewUnionCase unionCaseName unionCaseName.idText [] thisTy [] XmlDoc.Empty tycon.Accessibility
TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName
let unionCase = NewUnionCase unionCaseName [] thisTy [] XmlDoc.Empty tycon.Accessibility
writeFakeUnionCtorsToSink [ unionCase ]
MakeUnionRepr [ unionCase ], None, NoSafeInitInfo

Expand Down
13 changes: 8 additions & 5 deletions src/fsharp/tast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,6 @@ and
/// Return type constructed by the case. Normally exactly the type of the enclosing type, sometimes an abbreviation of it
ReturnType: TType

/// Name of the case in generated IL code
CompiledName: string

/// Documentation for the case
XmlDoc : XmlDoc

Expand Down Expand Up @@ -1618,6 +1615,13 @@ and

member uc.DisplayName = uc.Id.idText

/// Name of the case in generated IL code.
member uc.CompiledName =
let idText = uc.Id.idText
if idText = opNameCons then "Cons"
elif idText = opNameNil then "Empty"
else idText

member uc.RecdFieldsArray = uc.FieldTable.FieldsByIndex

member uc.RecdFields = uc.FieldTable.FieldsByIndex |> Array.toList
Expand Down Expand Up @@ -5618,9 +5622,8 @@ let NewTypar (kind,rigid,Typar(id,staticReq,isCompGen),isFromError,dynamicReq,at

let NewRigidTypar nm m = NewTypar (TyparKind.Type,TyparRigidity.Rigid,Typar(mkSynId m nm,NoStaticReq,true),false,TyparDynamicReq.Yes,[],false,false)

let NewUnionCase id nm tys rty attribs docOption access : UnionCase =
let NewUnionCase id tys rty attribs docOption access : UnionCase =
{ Id=id
CompiledName=nm
XmlDoc=docOption
XmlDocSig=""
Accessibility=access
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Conformance #TypesAndModules #Unions
// RegressionTest for bug 6308
//<Expects status="error" id="FS1219" span="(7,7-7,19)">The union case named 'Tags' conflicts with the generated type 'Tags'</Expects>
//<Expects status="error" id="FS1219" span="(7,7-7,11)">The union case named 'Tags' conflicts with the generated type 'Tags'</Expects>
[<DefaultAugmentation(false)>]
type BigUnion2 =
| Case0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Conformance #TypesAndModules #Unions
// RegressionTest for bug 6308
//<Expects status="error" id="FS1219" span="(9,7-9,19)">The union case named 'Tags' conflicts with the generated type 'Tags'</Expects>
//<Expects status="error" id="FS1219" span="(9,7-9,11)">The union case named 'Tags' conflicts with the generated type 'Tags'</Expects>
//<Expects status="notin" id="FS0023" span="(21,14-21,17)">The member 'Tag' can not be defined because the name 'Tag' clashes with the generated property 'Tag' in this type or module</Expects>

[<DefaultAugmentation(true)>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<FSharpCoreImplicitPackageVersion>4.6.*</FSharpCoreImplicitPackageVersion>
<FSharpCoreImplicitPackageVersion>4.5.*</FSharpCoreImplicitPackageVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
Expand Down
44 changes: 44 additions & 0 deletions tests/service/EditorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,50 @@ type Test() =
let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true


[<Test>]
let ``Completion in base constructor`` () =
let input =
"""
type A(foo) =
class
end

type B(bar) =
inherit A(bar)"""

// Split the input & define file name
let inputLines = input.Split('\n')
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)

let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], PartialLongName.Empty(17), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true



[<Test>]
let ``Completion in do in base constructor`` () =
let input =
"""
type A() =
class
end

type B(bar) =
inherit A()

do bar"""

// Split the input & define file name
let inputLines = input.Split('\n')
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)

let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 9, inputLines.[8], PartialLongName.Empty(7), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true


[<Test; Ignore("SKIPPED: see #139")>]
let ``Symbol based find function from member 1`` () =
let input =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\..\..\..\artifacts\FSharp.Core.$(FSCorePackageVersion).nupkg">
<Content Include="$(MSBuildThisFileDirectory)\..\..\..\artifacts\packages\$(Configuration)\FSharp.Core.$(FSCorePackageVersion).nupkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>packages\FSharp.Core.$(FSCorePackageVersion).nupkg</Link>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down