Skip to content

Commit 9d9993b

Browse files
committed
merge
1 parent b846403 commit 9d9993b

21 files changed

Lines changed: 141 additions & 10 deletions

docs/release-notes/.FSharp.Compiler.Service/8.0.200.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Miscellaneous fixes to parentheses analysis. ([PR #16262](https://github.com/dotnet/fsharp/pull/16262), [PR #16391](https://github.com/dotnet/fsharp/pull/16391), [PR #16370](https://github.com/dotnet/fsharp/pull/16370), [PR #16395](https://github.com/dotnet/fsharp/pull/16395))
44
* Correctly handle assembly imports with public key token of 0 length. ([Issue #16359](https://github.com/dotnet/fsharp/issues/16359), [PR #16363](https://github.com/dotnet/fsharp/pull/16363))
5+
* Fix #16398 - The dotnet framework has a limit of ~64K methods in a single class. Introduce a compile-time error if any class has over approx 64K methods in generated IL
56

67
### Added
78
* Raise a new error when interfaces with auto properties are implemented on constructor-less types. ([PR #16352](https://github.com/dotnet/fsharp/pull/16352))

src/Compiler/AbstractIL/ilwrite.fs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ let emitBytesViaBuffer f = use bb = ByteBuffer.Create EmitBytesViaBufferCapacity
5050
/// Alignment and padding
5151
let align alignment n = ((n + alignment - 1) / alignment) * alignment
5252

53+
54+
/// Maximum number of methods in a dotnet type
55+
/// This differs from the spec and file formats slightly which suggests 0xfffe is the maximum
56+
/// this value was identified empirically.
57+
[<Literal>]
58+
let maximumMethodsPerDotNetType = 0xfff0
59+
5360
//---------------------------------------------------------------------
5461
// Concrete token representations etc. used in PE files
5562
//---------------------------------------------------------------------
@@ -672,8 +679,14 @@ let GetTypeNameAsElemPair cenv n =
672679
//=====================================================================
673680

674681
let rec GenTypeDefPass1 enc cenv (tdef: ILTypeDef) =
675-
ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_, n)) -> n) (TdKey (enc, tdef.Name)))
676-
GenTypeDefsPass1 (enc@[tdef.Name]) cenv (tdef.NestedTypes.AsList())
682+
ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_, n)) -> n) (TdKey (enc, tdef.Name)))
683+
684+
// Verify that the typedef contains fewer than maximumMethodsPerDotNetType
685+
let count = tdef.Methods.AsArray().Length
686+
if count > maximumMethodsPerDotNetType then
687+
errorR(Error(FSComp.SR.tooManyMethodsInDotNetTypeWritingAssembly (tdef.Name, count, maximumMethodsPerDotNetType), rangeStartup))
688+
689+
GenTypeDefsPass1 (enc@[tdef.Name]) cenv (tdef.NestedTypes.AsList())
677690

678691
and GenTypeDefsPass1 enc cenv tdefs = List.iter (GenTypeDefPass1 enc cenv) tdefs
679692

@@ -682,7 +695,8 @@ and GenTypeDefsPass1 enc cenv tdefs = List.iter (GenTypeDefPass1 enc cenv) tdefs
682695
//=====================================================================
683696

684697
let rec GetIdxForTypeDef cenv key =
685-
try cenv.typeDefs.GetTableEntry key
698+
try
699+
cenv.typeDefs.GetTableEntry key
686700
with
687701
:? KeyNotFoundException ->
688702
let (TdKey (enc, n) ) = key

src/Compiler/FSComp.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,4 +1738,5 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [<Struct>] di
17381738
3860,chkStaticMembersOnObjectExpressions,"Object expressions cannot implement interfaces with static abstract members or declare static members."
17391739
3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions."
17401740
3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration."
1741-
3863,parsExpectingField,"Expecting record field"
1741+
3863,parsExpectingField,"Expecting record field"
1742+
3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'"

src/Compiler/xlf/FSComp.txt.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ko.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)