Skip to content

Commit

Permalink
Nullness - reading+writing metadata for 'inherits' and interface impl…
Browse files Browse the repository at this point in the history
…ementations (#16597)
  • Loading branch information
T-Gro authored Jan 30, 2024
1 parent cf735db commit e0f1634
Show file tree
Hide file tree
Showing 30 changed files with 755 additions and 87 deletions.
6 changes: 2 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<BUILDING_USING_DOTNET>true</BUILDING_USING_DOTNET>
</PropertyGroup>

<PropertyGroup Condition="'$(SolutionName)' == 'FSharp.Benchmarks' and '$(BUILDING_USING_DOTNET)' != 'false'">
<BUILDING_USING_DOTNET>true</BUILDING_USING_DOTNET>
</PropertyGroup>

<!-- Temporary workaround if proj-info is used, allows Ionide's evaluation to work correctly. -->
<PropertyGroup Condition="'$(BUILDING_USING_DOTNET)' != 'false' and '$(DotnetProjInfo)' == 'true'">
<BUILDING_USING_DOTNET>true</BUILDING_USING_DOTNET>
Expand All @@ -28,6 +24,8 @@
<Import Project="$(RepoRoot)/Directory.Build.props.user" Condition = "Exists('$(RepoRoot)/Directory.Build.props.user')" />

<PropertyGroup Condition="'$(BUILDING_USING_DOTNET)' == 'true'">
<BUILDING_WITH_LKG>true</BUILDING_WITH_LKG>
<BUILD_FROM_SOURCE>true</BUILD_FROM_SOURCE>
<DisableAutoSetFscCompilerPath>false</DisableAutoSetFscCompilerPath>
<FSHARPCORE_USE_PACKAGE Condition="'$(FSHARPCORE_USE_PACKAGE)' == ''">true</FSHARPCORE_USE_PACKAGE>
<DISABLE_ARCADE Condition="'$(DISABLE_ARCADE)' == ''">true</DISABLE_ARCADE>
Expand Down
27 changes: 3 additions & 24 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CI and PR triggers
# CI and PR triggers
trigger:
branches:
include:
Expand Down Expand Up @@ -110,13 +110,10 @@ stages:
demands: ImageOverride -equals windows.vs2022preview.amd64
timeoutInMinutes: 300
variables:
- group: DotNet-Blob-Feed
- group: DotNet-Symbol-Server-Pats
- group: DotNet-DevDiv-Insertion-Workflow-Variables
- name: _SignType
value: Real
- name: _DotNetPublishToBlobFeed
value: true
steps:
- checkout: self
clean: true
Expand All @@ -131,9 +128,6 @@ stages:
/p:MicroBuild_SigningEnabled=true
/p:OverridePackageSource=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
/p:TeamName=$(_TeamName)
/p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1)
/p:DotNetPublishBlobFeedUrl=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
/p:DotNetPublishToBlobFeed=true
/p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines)
/p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory)
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
Expand Down Expand Up @@ -724,25 +718,10 @@ stages:
steps:
- checkout: self
clean: true
- script: dotnet --list-sdks
displayName: Report dotnet SDK versions
- task: UseDotNet@2
displayName: install SDK
inputs:
packageType: sdk
useGlobalJson: true
includePreviewVersions: true
workingDirectory: $(Build.SourcesDirectory)
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: dotnet build -c $(_BuildConfig) .\FSharp.Benchmarks.sln /bl:\"artifacts/log/$(_BuildConfig)/BenchmarkBuild.binlog\"
workingDirectory: $(Build.SourcesDirectory)
displayName: Plain build of FSharp.Benchmarks.sln
- script: eng\CIBuild.cmd -configuration $(_BuildConfig) -testBenchmarks
displayName: Smoke test fast benchmarks
continueOnError: true
condition: always()
- script: .\Build.cmd -c $(_BuildConfig)
- pwsh: ./SmokeTestBenchmarks.ps1
workingDirectory: $(Build.SourcesDirectory)/tests/benchmarks
displayName: Smoke test fast benchmarks

# Test trimming on Windows
- job: Build_And_Test_Trimming_Windows
Expand Down
5 changes: 3 additions & 2 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

* Code generated files with > 64K methods and generated symbols crash when loaded. Use infered sequence points for debugging. ([Issue #16399](https://github.com/dotnet/fsharp/issues/16399), [#PR 16514](https://github.com/dotnet/fsharp/pull/16514))
* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550))
* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575))
* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588))
* Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578))

### Added


* Support for nullable reference types ([PR #15181](https://github.com/dotnet/fsharp/pull/15181))
* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583))
* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583))
* Parser recovers on complex primary constructor patterns, better tree representation for primary constructor patterns. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425))
* Name resolution: keep type vars in subsequent checks ([PR #16456](https://github.com/dotnet/fsharp/pull/16456))
* Higher-order-function-based API for working with the untyped abstract syntax tree. ([PR #16462](https://github.com/dotnet/fsharp/pull/16462))
Expand Down
18 changes: 18 additions & 0 deletions eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ param (
[switch]$testAllButIntegration,
[switch]$testpack,
[switch]$testAOT,
[switch]$testBenchmarks,
[string]$officialSkipTests = "false",
[switch]$noVisualStudio,
[switch]$sourceBuild,
Expand Down Expand Up @@ -111,6 +112,7 @@ function Print-Usage() {
Write-Host " -testVs Run F# editor unit tests"
Write-Host " -testpack Verify built packages"
Write-Host " -testAOT Run AOT/Trimming tests"
Write-Host " -testBenchmarks Build and Run Benchmark suite"
Write-Host " -officialSkipTests <bool> Set to 'true' to skip running tests"
Write-Host ""
Write-Host "Advanced settings:"
Expand Down Expand Up @@ -176,6 +178,7 @@ function Process-Arguments() {
$script:testVs = $False
$script:testpack = $False
$script:testAOT = $False
$script:testBenchmarks = $False
$script:verifypackageshipstatus = $True
}

Expand Down Expand Up @@ -211,6 +214,10 @@ function Process-Arguments() {
$script:pack = $True;
}

if ($testBenchmarks) {
$script:testBenchmarks = $True
}

foreach ($property in $properties) {
if (!$property.StartsWith("/p:", "InvariantCultureIgnoreCase")) {
Write-Host "Invalid argument: $property"
Expand Down Expand Up @@ -541,12 +548,17 @@ try {
}
}

if ($testBenchmarks) {
BuildSolution "FSharp.Benchmarks.sln" $False
}

if ($pack) {
$properties_storage = $properties
$properties += "/p:GenerateSbom=false"
BuildSolution "Microsoft.FSharp.Compiler.sln" $True
$properties = $properties_storage
}

if ($build) {
VerifyAssemblyVersionsAndSymbols
}
Expand Down Expand Up @@ -662,6 +674,12 @@ try {
Pop-Location
}

if ($testBenchmarks) {
Push-Location "$RepoRoot\tests\benchmarks"
./SmokeTestBenchmarks.ps1
Pop-Location
}

# verify nupkgs have access to the source code
$nupkgtestFailed = $false
if ($testpack) {
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24073.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24075.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>4c941e2e3ae61502bd4ffd711930f662fd808375</Sha>
<Sha>07cf24f27ee58b5d1a9662334a101d84bd1e07e5</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"perl": "5.38.0.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24073.2",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24075.5",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
11 changes: 10 additions & 1 deletion src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@ type ILTypeDef
attributes: TypeAttributes,
layout: ILTypeDefLayout,
implements: ILTypes,
implementsCustomAttrs: (ILAttributesStored * int) list option,
genericParams: ILGenericParameterDefs,
extends: ILType option,
methods: ILMethodDefs,
Expand All @@ -2632,6 +2633,7 @@ type ILTypeDef
attributes,
layout,
implements,
implementsCustomAttrs,
genericParams,
extends,
methods,
Expand All @@ -2648,6 +2650,7 @@ type ILTypeDef
attributes,
layout,
implements,
implementsCustomAttrs,
genericParams,
extends,
methods,
Expand All @@ -2674,6 +2677,8 @@ type ILTypeDef

member _.Implements = implements

member _.ImplementsCustomAttrs = implementsCustomAttrs

member _.Extends = extends

member _.Methods = methods
Expand Down Expand Up @@ -2710,7 +2715,8 @@ type ILTypeDef
?properties,
?isKnownToBeAttribute,
?customAttrs,
?securityDecls
?securityDecls,
?implementsCustomAttrs
) =
ILTypeDef(
name = defaultArg name x.Name,
Expand All @@ -2719,6 +2725,7 @@ type ILTypeDef
genericParams = defaultArg genericParams x.GenericParams,
nestedTypes = defaultArg nestedTypes x.NestedTypes,
implements = defaultArg implements x.Implements,
implementsCustomAttrs = defaultArg implementsCustomAttrs x.ImplementsCustomAttrs,
extends = defaultArg extends x.Extends,
methods = defaultArg methods x.Methods,
securityDecls = defaultArg securityDecls x.SecurityDecls,
Expand Down Expand Up @@ -4192,6 +4199,7 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes
attributes = attributes,
genericParams = genparams,
implements = impl,
implementsCustomAttrs = None,
layout = ILTypeDefLayout.Auto,
extends = Some extends,
methods = methods,
Expand All @@ -4216,6 +4224,7 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) =
||| TypeAttributes.BeforeFieldInit
||| TypeAttributes.AnsiClass),
implements = [],
implementsCustomAttrs = None,
extends = Some iltyp_ValueType,
layout = ILTypeDefLayout.Explicit { Size = Some size; Pack = Some pack },
methods = emptyILMethods,
Expand Down
6 changes: 5 additions & 1 deletion src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,7 @@ type ILTypeDef =
attributes: TypeAttributes *
layout: ILTypeDefLayout *
implements: ILTypes *
implementsCustomAttrs: (ILAttributesStored * int) list option *
genericParams: ILGenericParameterDefs *
extends: ILType option *
methods: ILMethodDefs *
Expand All @@ -1527,6 +1528,7 @@ type ILTypeDef =
attributes: TypeAttributes *
layout: ILTypeDefLayout *
implements: ILTypes *
implementsCustomAttrs: (ILAttributesStored * int) list option *
genericParams: ILGenericParameterDefs *
extends: ILType option *
methods: ILMethodDefs *
Expand All @@ -1546,6 +1548,7 @@ type ILTypeDef =
member Layout: ILTypeDefLayout
member NestedTypes: ILTypeDefs
member Implements: ILTypes
member ImplementsCustomAttrs: (ILAttributesStored * int) list option
member Extends: ILType option
member Methods: ILMethodDefs
member SecurityDecls: ILSecurityDecls
Expand Down Expand Up @@ -1604,7 +1607,8 @@ type ILTypeDef =
?properties: ILPropertyDefs *
?isKnownToBeAttribute: bool *
?customAttrs: ILAttributes *
?securityDecls: ILSecurityDecls ->
?securityDecls: ILSecurityDecls *
?implementsCustomAttrs: (ILAttributesStored * int) list option ->
ILTypeDef

/// Represents a prefix of information for ILTypeDef.
Expand Down
21 changes: 16 additions & 5 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ type ILMetadataReader =
customAttrsReader_Module: ILAttributesStored
customAttrsReader_Assembly: ILAttributesStored
customAttrsReader_TypeDef: ILAttributesStored
customAttrsReader_InterfaceImpl: ILAttributesStored
customAttrsReader_GenericParam: ILAttributesStored
customAttrsReader_FieldDef: ILAttributesStored
customAttrsReader_MethodDef: ILAttributesStored
Expand Down Expand Up @@ -1450,11 +1451,16 @@ let seekReadParamRow (ctxt: ILMetadataReader) mdv idx =
(flags, seq, nameIdx)

/// Read Table InterfaceImpl.
let seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx =
let private seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx =
let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx
let tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
let intfIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr
(tidx, intfIdx)

struct {|
TypeIdx = tidx
IntfIdx = intfIdx
IntImplIdx = idx
|}

/// Read Table MemberRef.
let seekReadMemberRefRow (ctxt: ILMetadataReader) mdv idx =
Expand Down Expand Up @@ -2144,7 +2150,10 @@ and typeDefReader ctxtH : ILTypeDefStored =
let mdefs = seekReadMethods ctxt numTypars methodsIdx endMethodsIdx
let fdefs = seekReadFields ctxt (numTypars, hasLayout) fieldsIdx endFieldsIdx
let nested = seekReadNestedTypeDefs ctxt idx
let impls = seekReadInterfaceImpls ctxt mdv numTypars idx

let impls, intImplsAttrs =
seekReadInterfaceImpls ctxt mdv numTypars idx |> List.unzip

let mimpls = seekReadMethodImpls ctxt numTypars idx
let props = seekReadProperties ctxt numTypars idx
let events = seekReadEvents ctxt numTypars idx
Expand All @@ -2156,6 +2165,7 @@ and typeDefReader ctxtH : ILTypeDefStored =
layout = layout,
nestedTypes = nested,
implements = impls,
implementsCustomAttrs = Some intImplsAttrs,
extends = super,
methods = mdefs,
securityDeclsStored = ctxt.securityDeclsReader_TypeDef,
Expand Down Expand Up @@ -2192,10 +2202,10 @@ and seekReadInterfaceImpls (ctxt: ILMetadataReader) mdv numTypars tidx =
seekReadIndexedRows (
ctxt.getNumRows TableNames.InterfaceImpl,
seekReadInterfaceImplRow ctxt mdv,
fst,
(fun x -> x.TypeIdx),
simpleIndexCompare tidx,
isSorted ctxt TableNames.InterfaceImpl,
(snd >> seekReadTypeDefOrRef ctxt numTypars AsObject [])
(fun x -> (seekReadTypeDefOrRef ctxt numTypars AsObject [] x.IntfIdx), (ctxt.customAttrsReader_InterfaceImpl, x.IntImplIdx))
)

and seekReadGenericParams ctxt numTypars (a, b) : ILGenericParameterDefs =
Expand Down Expand Up @@ -4487,6 +4497,7 @@ let openMetadataReader
customAttrsReader_Module = customAttrsReader ctxtH hca_Module
customAttrsReader_Assembly = customAttrsReader ctxtH hca_Assembly
customAttrsReader_TypeDef = customAttrsReader ctxtH hca_TypeDef
customAttrsReader_InterfaceImpl = customAttrsReader ctxtH hca_InterfaceImpl
customAttrsReader_GenericParam = customAttrsReader ctxtH hca_GenericParam
customAttrsReader_FieldDef = customAttrsReader ctxtH hca_FieldDef
customAttrsReader_MethodDef = customAttrsReader ctxtH hca_MethodDef
Expand Down
Loading

0 comments on commit e0f1634

Please sign in to comment.