Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/dev16.2 to release/fsharp47 #6868

Merged
4 commits merged into from
May 26, 2019
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
13 changes: 13 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ jobs:
- script: eng\CIBuild.cmd -configuration Release -noSign /p:DotNetBuildFromSource=true /p:FSharpSourceBuild=true
displayName: Build

# Up-to-date
- job: UpToDate_Windows
pool:
vmImage: windows-2019
steps:
- checkout: self
clean: true
- task: PowerShell@2
displayName: Run up-to-date build check
inputs:
filePath: eng\tests\UpToDate.ps1
arguments: -configuration $(_BuildConfig) -ci -binaryLog

#---------------------------------------------------------------------------------------------------------------------#
# FCS builds #
#---------------------------------------------------------------------------------------------------------------------#
Expand Down
70 changes: 70 additions & 0 deletions eng/tests/UpToDate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This script verifies that subsequent calls to `Build.cmd` don't cause assemblies to be unnecessarily rebuilt.

[CmdletBinding(PositionalBinding=$false)]
param (
[string][Alias('c')]$configuration = "Debug",
[parameter(ValueFromRemainingArguments=$true)][string[]]$properties
)

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

try {
$RepoRoot = Join-Path $PSScriptRoot ".." | Join-Path -ChildPath ".." -Resolve
$BuildScript = Join-Path $RepoRoot "Build.cmd"

# do first build
& $BuildScript -configuration $configuration @properties
if ($LASTEXITCODE -ne 0) {
Write-Host "Error running first build."
exit 1
}

# gather assembly timestamps
$ArtifactsBinDir = Join-Path $RepoRoot "artifacts" | Join-Path -ChildPath "bin" -Resolve
$FSharpAssemblyDirs = Get-ChildItem -Path $ArtifactsBinDir -Filter "FSharp.*"
$FSharpAssemblyPaths = $FSharpAssemblyDirs | ForEach-Object { Get-ChildItem -Path (Join-Path $ArtifactsBinDir $_) -Recurse -Filter "$_.dll" } | ForEach-Object { $_.FullName }

$InitialAssembliesAndTimes = @{}
foreach ($asm in $FSharpAssemblyPaths) {
$LastWriteTime = (Get-Item $asm).LastWriteTimeUtc
$InitialAssembliesAndTimes.Add($asm, $LastWriteTime)
}

$InitialCompiledCount = $FSharpAssemblyPaths.Length

# build again
& $BuildScript -configuration $configuration @properties
if ($LASTEXITCODE -ne 0) {
Write-Host "Error running second build."
exit 1
}

# gather assembly timestamps again
$FinalAssembliesAndTimes = @{}
foreach ($asm in $FSharpAssemblyPaths) {
$LastWriteTime = (Get-Item $asm).LastWriteTimeUtc
$FinalAssembliesAndTimes.Add($asm, $LastWriteTime)
}

# validate that assembly timestamps haven't changed
$RecompiledFiles = @()
foreach ($asm in $InitialAssembliesAndTimes.keys) {
$InitialTime = $InitialAssembliesAndTimes[$asm]
$FinalTime = $FinalAssembliesAndTimes[$asm]
if ($InitialTime -ne $FinalTime) {
$RecompiledFiles += $asm
}
}

$RecompiledCount = $RecompiledFiles.Length
Write-Host "$RecompiledCount of $InitialCompiledCount assemblies were re-compiled"
$RecompiledFiles | ForEach-Object { Write-Host " $_" }
exit $RecompiledCount
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}
10 changes: 10 additions & 0 deletions src/fsharp/service/ServiceAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,27 @@ module UnusedOpens =
| :? FSharpMemberOrFunctionOrValue as fv when fv.IsExtensionMember ->
// Extension members should be taken into account even though they have a prefix (as they do most of the time)
true

| :? FSharpMemberOrFunctionOrValue as fv when not fv.IsModuleValueOrMember ->
// Local values can be ignored
false

| :? FSharpMemberOrFunctionOrValue when su.IsFromDefinition ->
// Value definitions should be ignored
false

| :? FSharpGenericParameter ->
// Generic parameters can be ignored, they never come into scope via 'open'
false

| :? FSharpUnionCase when su.IsFromDefinition ->
false

| :? FSharpField as field when
field.DeclaringEntity.IsSome && field.DeclaringEntity.Value.IsFSharpRecord ->
// Record fields are used in name resolution
true

| _ ->
// For the rest of symbols we pick only those which are the first part of a long ident, because it's they which are
// contained in opened namespaces / modules. For example, we pick `IO` from long ident `IO.File.OpenWrite` because
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/symbols/SymbolPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ module Symbol =
#endif
let (|Enum|_|) (entity: FSharpEntity) = if entity.IsEnum then Some() else None

let (|Tuple|_|) (ty: FSharpType option) =
ty |> Option.bind (fun ty -> if ty.IsTupleType then Some() else None)
let (|Tuple|_|) (ty: FSharpType) =
if ty.IsTupleType then Some() else None

let (|RefCell|_|) (ty: FSharpType) =
match getAbbreviatedType ty with
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/symbols/SymbolPatterns.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module public Symbol =
val (|ProvidedAndErasedType|_|) : FSharpEntity -> unit option
#endif
val (|Enum|_|) : FSharpEntity -> unit option
val (|Tuple|_|) : FSharpType option -> unit option
val (|Tuple|_|) : FSharpType -> unit option
val (|RefCell|_|) : FSharpType -> unit option
val (|FunctionType|_|) : FSharpType -> unit option
val (|Pattern|_|) : FSharpSymbol -> unit option
Expand Down
8 changes: 8 additions & 0 deletions tests/service/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5523,6 +5523,14 @@ type UseTheThings(i:int) =
member x.UseSomeUsedModuleContainingActivePattern(ActivePattern g) = g
member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q
member x.UseSomeUsedModuleContainingUnion() = A

module M1 =
type R = { Field: int }

module M2 =
open M1

let foo x = x.Field
"""
let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text
File.WriteAllText(fileName1, fileSource1Text)
Expand Down