Skip to content

Commit 6b02b74

Browse files
author
dotnet-automerge-bot
authored
Merge pull request #6852 from dotnet/merges/master-to-release/dev16.2
Merge master to release/dev16.2
2 parents 808f232 + 25560f4 commit 6b02b74

File tree

6 files changed

+104
-3
lines changed

6 files changed

+104
-3
lines changed

azure-pipelines.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ jobs:
233233
- script: eng\CIBuild.cmd -configuration Release -noSign /p:DotNetBuildFromSource=true /p:FSharpSourceBuild=true
234234
displayName: Build
235235

236+
# Up-to-date
237+
- job: UpToDate_Windows
238+
pool:
239+
vmImage: windows-2019
240+
steps:
241+
- checkout: self
242+
clean: true
243+
- task: PowerShell@2
244+
displayName: Run up-to-date build check
245+
inputs:
246+
filePath: eng\tests\UpToDate.ps1
247+
arguments: -configuration $(_BuildConfig) -ci -binaryLog
248+
236249
#---------------------------------------------------------------------------------------------------------------------#
237250
# FCS builds #
238251
#---------------------------------------------------------------------------------------------------------------------#

eng/tests/UpToDate.ps1

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This script verifies that subsequent calls to `Build.cmd` don't cause assemblies to be unnecessarily rebuilt.
2+
3+
[CmdletBinding(PositionalBinding=$false)]
4+
param (
5+
[string][Alias('c')]$configuration = "Debug",
6+
[parameter(ValueFromRemainingArguments=$true)][string[]]$properties
7+
)
8+
9+
Set-StrictMode -version 2.0
10+
$ErrorActionPreference = "Stop"
11+
12+
try {
13+
$RepoRoot = Join-Path $PSScriptRoot ".." | Join-Path -ChildPath ".." -Resolve
14+
$BuildScript = Join-Path $RepoRoot "Build.cmd"
15+
16+
# do first build
17+
& $BuildScript -configuration $configuration @properties
18+
if ($LASTEXITCODE -ne 0) {
19+
Write-Host "Error running first build."
20+
exit 1
21+
}
22+
23+
# gather assembly timestamps
24+
$ArtifactsBinDir = Join-Path $RepoRoot "artifacts" | Join-Path -ChildPath "bin" -Resolve
25+
$FSharpAssemblyDirs = Get-ChildItem -Path $ArtifactsBinDir -Filter "FSharp.*"
26+
$FSharpAssemblyPaths = $FSharpAssemblyDirs | ForEach-Object { Get-ChildItem -Path (Join-Path $ArtifactsBinDir $_) -Recurse -Filter "$_.dll" } | ForEach-Object { $_.FullName }
27+
28+
$InitialAssembliesAndTimes = @{}
29+
foreach ($asm in $FSharpAssemblyPaths) {
30+
$LastWriteTime = (Get-Item $asm).LastWriteTimeUtc
31+
$InitialAssembliesAndTimes.Add($asm, $LastWriteTime)
32+
}
33+
34+
$InitialCompiledCount = $FSharpAssemblyPaths.Length
35+
36+
# build again
37+
& $BuildScript -configuration $configuration @properties
38+
if ($LASTEXITCODE -ne 0) {
39+
Write-Host "Error running second build."
40+
exit 1
41+
}
42+
43+
# gather assembly timestamps again
44+
$FinalAssembliesAndTimes = @{}
45+
foreach ($asm in $FSharpAssemblyPaths) {
46+
$LastWriteTime = (Get-Item $asm).LastWriteTimeUtc
47+
$FinalAssembliesAndTimes.Add($asm, $LastWriteTime)
48+
}
49+
50+
# validate that assembly timestamps haven't changed
51+
$RecompiledFiles = @()
52+
foreach ($asm in $InitialAssembliesAndTimes.keys) {
53+
$InitialTime = $InitialAssembliesAndTimes[$asm]
54+
$FinalTime = $FinalAssembliesAndTimes[$asm]
55+
if ($InitialTime -ne $FinalTime) {
56+
$RecompiledFiles += $asm
57+
}
58+
}
59+
60+
$RecompiledCount = $RecompiledFiles.Length
61+
Write-Host "$RecompiledCount of $InitialCompiledCount assemblies were re-compiled"
62+
$RecompiledFiles | ForEach-Object { Write-Host " $_" }
63+
exit $RecompiledCount
64+
}
65+
catch {
66+
Write-Host $_
67+
Write-Host $_.Exception
68+
Write-Host $_.ScriptStackTrace
69+
exit 1
70+
}

src/fsharp/service/ServiceAnalysis.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,27 @@ module UnusedOpens =
9999
| :? FSharpMemberOrFunctionOrValue as fv when fv.IsExtensionMember ->
100100
// Extension members should be taken into account even though they have a prefix (as they do most of the time)
101101
true
102+
102103
| :? FSharpMemberOrFunctionOrValue as fv when not fv.IsModuleValueOrMember ->
103104
// Local values can be ignored
104105
false
106+
105107
| :? FSharpMemberOrFunctionOrValue when su.IsFromDefinition ->
106108
// Value definitions should be ignored
107109
false
110+
108111
| :? FSharpGenericParameter ->
109112
// Generic parameters can be ignored, they never come into scope via 'open'
110113
false
114+
111115
| :? FSharpUnionCase when su.IsFromDefinition ->
112116
false
117+
118+
| :? FSharpField as field when
119+
field.DeclaringEntity.IsSome && field.DeclaringEntity.Value.IsFSharpRecord ->
120+
// Record fields are used in name resolution
121+
true
122+
113123
| _ ->
114124
// For the rest of symbols we pick only those which are the first part of a long ident, because it's they which are
115125
// contained in opened namespaces / modules. For example, we pick `IO` from long ident `IO.File.OpenWrite` because

src/fsharp/symbols/SymbolPatterns.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ module Symbol =
132132
#endif
133133
let (|Enum|_|) (entity: FSharpEntity) = if entity.IsEnum then Some() else None
134134

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

138138
let (|RefCell|_|) (ty: FSharpType) =
139139
match getAbbreviatedType ty with

src/fsharp/symbols/SymbolPatterns.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module public Symbol =
3737
val (|ProvidedAndErasedType|_|) : FSharpEntity -> unit option
3838
#endif
3939
val (|Enum|_|) : FSharpEntity -> unit option
40-
val (|Tuple|_|) : FSharpType option -> unit option
40+
val (|Tuple|_|) : FSharpType -> unit option
4141
val (|RefCell|_|) : FSharpType -> unit option
4242
val (|FunctionType|_|) : FSharpType -> unit option
4343
val (|Pattern|_|) : FSharpSymbol -> unit option

tests/service/ProjectAnalysisTests.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5523,6 +5523,14 @@ type UseTheThings(i:int) =
55235523
member x.UseSomeUsedModuleContainingActivePattern(ActivePattern g) = g
55245524
member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q
55255525
member x.UseSomeUsedModuleContainingUnion() = A
5526+
5527+
module M1 =
5528+
type R = { Field: int }
5529+
5530+
module M2 =
5531+
open M1
5532+
5533+
let foo x = x.Field
55265534
"""
55275535
let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text
55285536
File.WriteAllText(fileName1, fileSource1Text)

0 commit comments

Comments
 (0)