dotnet-installer/src/SourceBuild/tarball/patches/linker/0001-Fix-exception-when-generating-warning-for-method-definition.patch
Michael Simons fd587269d0
Source-build runtime patch to support newer compiler (#14319)
* Source-build runtime patch to support newer compiler

* Add linker source-build patch

* Fix linker patch

* Revert Roslyn change that added restrictions on managed types.

* Add related issues to patch.

* Switch to the official linker patch for the InvalidOperationException.

* Add linker patch to remove prebuilts

Co-authored-by: Chris Rummel <crummel@microsoft.com>
2022-08-13 08:42:39 +00:00

26 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: vitek-karas <10670590+vitek-karas@users.noreply.github.com>
Date: Fri, 12 Aug 2022 13:12:09 -0700
Subject: [PATCH] Fix exception when generating warning for method definition
If we produce a warning for the method itself (no IL offset) and the method has debug symbols, it can happen that there's no sequence point for the first instruction. In that case the current code will crash because we expect to always find sequence point for offset 0.
Fix this by looking for the first sequence point instead.
This patch is originally PR https://github.com/dotnet/linker/pull/2972.
---
src/linker/Linker/MessageOrigin.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/linker/Linker/MessageOrigin.cs b/src/linker/Linker/MessageOrigin.cs
index 24d18c065d..402e529e7f 100644
--- a/src/linker/Linker/MessageOrigin.cs
+++ b/src/linker/Linker/MessageOrigin.cs
@@ -83,7 +83,7 @@ public MessageOrigin (MessageOrigin other, int ilOffset)
string? fileName = FileName;
if (Provider is MethodDefinition method &&
method.DebugInformation.HasSequencePoints) {
- var offset = ILOffset ?? 0;
+ var offset = ILOffset ?? method.DebugInformation.SequencePoints[0].Offset;
SequencePoint? correspondingSequencePoint = method.DebugInformation.SequencePoints
.Where (s => s.Offset <= offset)?.Last ();