Repository: OmniSharp/omnisharp-vscode
Pull request #4498 (2021-04-14 02:17:29)

Add OSX-ARM64 support
This PR adds the debugger packages for osx-arm64.

codecov[bot]: # [Codecov](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp) Report
> Merging [#4498](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp) (d4fb00f) into [master](https://codecov.io/gh/OmniSharp/omnisharp-vscode/commit/8dd7f44d99bfc8e0b770a4e7701fa922b65be934?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp) (8dd7f44) will **increase** coverage by `0.03%`.
> The diff coverage is `28.57%`.

[![Impacted file tree graph](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498/graphs/tree.svg?width=650&height=150&src=pr&token=SbGv1c3fpf&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp)](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp)

```diff
@@            Coverage Diff             @@
##           master    #4498      +/-   ##
==========================================
+ Coverage   68.69%   68.72%   +0.03%     
==========================================
  Files         109      109              
  Lines        4287     4288       +1     
  Branches      742      745       +3     
==========================================
+ Hits         2945     2947       +2     
+ Misses       1141     1138       -3     
- Partials      201      203       +2     
```

| Flag | Coverage Δ | |
|---|---|---|
| integration | `52.30% <28.57%> (-0.02%)` | :arrow_down: |
| unit | `85.81% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp) | Coverage Δ | |
|---|---|---|
| [src/coreclr-debug/activate.ts](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp#diff-c3JjL2NvcmVjbHItZGVidWcvYWN0aXZhdGUudHM=) | `36.06% <28.57%> (+1.06%)` | :arrow_up: |
| [src/observers/WarningMessageObserver.ts](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp#diff-c3JjL29ic2VydmVycy9XYXJuaW5nTWVzc2FnZU9ic2VydmVyLnRz) | `95.00% <0.00%> (-5.00%)` | :arrow_down: |
| [src/features/semanticTokensProvider.ts](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp#diff-c3JjL2ZlYXR1cmVzL3NlbWFudGljVG9rZW5zUHJvdmlkZXIudHM=) | `86.00% <0.00%> (+4.00%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp). Last update [8dd7f44...d4fb00f](https://codecov.io/gh/OmniSharp/omnisharp-vscode/pull/4498?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OmniSharp).


Patch:
diff --git a/package.json b/package.json
index c41db6fa..92f39d91 100644
--- a/package.json
+++ b/package.json
@@ -239,8 +239,8 @@
     {
       "id": "Debugger",
       "description": ".NET Core Debugger (Windows / x64)",
-      "url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/8ef4bedc8923b38b9a6ab98d7ec2df16/coreclr-debug-win7-x64.zip",
-      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-win7-x64.zip",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/d133bd53b5360d1041f8a6ab28b82d4e/coreclr-debug-win7-x64.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-win7-x64.zip",
       "installPath": ".debugger",
       "platforms": [
         "win32"
@@ -249,14 +249,14 @@
         "x86_64"
       ],
       "installTestPath": "./.debugger/vsdbg-ui.exe",
-      "integrity": "52D76850494F1F6B04B9CABB4C80B9E63C0762BFA676CFDD16292EBC77462989"
+      "integrity": "D6B804513BA83E10B1428CEEDD6E2AC4749DC2AAFFD5BE56AEB6FD430C916618"
     },
     {
       "id": "Debugger",
       "description": ".NET Core Debugger (macOS / x64)",
-      "url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/c091f9f76df625e2f6cbae32521c7149/coreclr-debug-osx-x64.zip",
-      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-osx-x64.zip",
-      "installPath": ".debugger",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/829575bd3a1e1837b3be4c2d1e02fc85/coreclr-debug-osx-x64.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-osx-x64.zip",
+      "installPath": ".debugger/x86_64",
       "platforms": [
         "darwin"
       ],
@@ -268,14 +268,33 @@
         "./vsdbg-ui",
         "./vsdbg"
       ],
-      "installTestPath": "./.debugger/vsdbg-ui",
-      "integrity": "E728CB6D8374D6F8BD75B23D352CB3C9B30C202C94F928AFB425E0A1CECEB54A"
+      "installTestPath": "./.debugger/x86_64/vsdbg-ui",
+      "integrity": "2C7CD642F8F3B405D0AB95FABD3CCAD51A6DD2B919B9BE221C0F18FC724604AE"
+    },
+    {
+      "id": "Debugger",
+      "description": ".NET Core Debugger (macOS / arm64)",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/55697478c628061578739b1b2ae62dc4/coreclr-debug-osx-arm64.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-osx-arm64.zip",
+      "installPath": ".debugger/arm64",
+      "platforms": [
+        "darwin"
+      ],
+      "architectures": [
+        "arm64"
+      ],
+      "binaries": [
+        "./vsdbg-ui",
+        "./vsdbg"
+      ],
+      "installTestPath": "./.debugger/arm64/vsdbg-ui",
+      "integrity": "1B2954EB75B647D5168AD816A942F61D46EB8DCEF384A8C2514DB9898B1F0022"
     },
     {
       "id": "Debugger",
       "description": ".NET Core Debugger (linux / ARM)",
-      "url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/83983aa140267cbf90b3780dfdf640a8/coreclr-debug-linux-arm.zip",
-      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-arm.zip",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/9ff9dada26542d0d6f3799cbc969339c/coreclr-debug-linux-arm.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-arm.zip",
       "installPath": ".debugger",
       "platforms": [
         "linux"
@@ -288,13 +307,13 @@
         "./vsdbg"
       ],
       "installTestPath": "./.debugger/vsdbg-ui",
-      "integrity": "9CCDD89F495BF8FD2168FBD9D15730B1F98CD03CB2EFC74F57FCA9AD22E278DD"
+      "integrity": "2D45ABEB478F8234854AB2A0E801B9EA0143B47F208F97AFC95F6020BC4E7BB7"
     },
     {
       "id": "Debugger",
       "description": ".NET Core Debugger (linux / ARM64)",
-      "url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/bfa6b939db12aacd40cf2ebda28b621d/coreclr-debug-linux-arm64.zip",
-      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-arm64.zip",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/e64e76d0bfb1e50da16678db728c8bad/coreclr-debug-linux-arm64.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-arm64.zip",
       "installPath": ".debugger",
       "platforms": [
         "linux"
@@ -307,13 +326,13 @@
         "./vsdbg"
       ],
       "installTestPath": "./.debugger/vsdbg-ui",
-      "integrity": "BF4C56C6A74175AC02C4DD96A1602457B318D7FE6309B1331FB535F7DF42E01D"
+      "integrity": "0F1BED966A9FBF308A431995A1CC7EC49D690C8E3986F88F47FF3DA198B4F997"
     },
     {
       "id": "Debugger",
       "description": ".NET Core Debugger (linux / x64)",
-      "url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/5736b04572b255dee1c529cc41623a4b/coreclr-debug-linux-x64.zip",
-      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-x64.zip",
+      "url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/92eeb7715c63c006df2318abeefc15b4/coreclr-debug-linux-x64.zip",
+      "fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-x64.zip",
       "installPath": ".debugger",
       "platforms": [
         "linux"
@@ -326,7 +345,7 @@
         "./vsdbg"
       ],
       "installTestPath": "./.debugger/vsdbg-ui",
-      "integrity": "29F5ABE6D317F956F0BCBF86C1344FD298D66F276597F6A0E15B5462CA8122A7"
+      "integrity": "A1AF7EB043B14DB777108D6B9D91F8CA2DC5551E3BC8340C96477B5BDC974C4B"
     },
     {
       "id": "Razor",
@@ -1605,6 +1624,10 @@
                 "type": "string",
                 "description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
                 "default": "${workspaceFolder}/out.txt"
+              },
+              "targetArchitecture": {
+                "type": "string",
+                "description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
               }
             }
           },
@@ -2702,6 +2725,10 @@
                 "type": "string",
                 "description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
                 "default": "${workspaceFolder}/out.txt"
+              },
+              "targetArchitecture": {
+                "type": "string",
+                "description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
               }
             }
           },
diff --git a/src/coreclr-debug/activate.ts b/src/coreclr-debug/activate.ts
index cfe156f8..8c8ca72d 100644
--- a/src/coreclr-debug/activate.ts
+++ b/src/coreclr-debug/activate.ts
@@ -6,13 +6,13 @@
 import * as path from 'path';
 import * as vscode from 'vscode';
 import * as common from './../common';
-import { CoreClrDebugUtil } from './util';
+import { CoreClrDebugUtil, getTargetArchitecture } from './util';
 import { PlatformInformation } from './../platform';
 import { DebuggerPrerequisiteWarning, DebuggerPrerequisiteFailure, DebuggerNotInstalledFailure } from '../omnisharp/loggingEvents';
 import { EventStream } from '../EventStream';
 import CSharpExtensionExports from '../CSharpExtensionExports';
 import { getRuntimeDependencyPackageWithId } from '../tools/RuntimeDependencyPackageUtils';
-import { DotnetInfo } from '../utils/getDotnetInfo';
+import { getDotnetInfo, DotnetInfo } from '../utils/getDotnetInfo';
 
 let _debugUtil: CoreClrDebugUtil = null;
 
@@ -36,16 +36,22 @@ export async function activate(thisExtension: vscode.Extension<CSharpExtensionEx
 
 async function checkForInvalidArchitecture(platformInformation: PlatformInformation, eventStream: EventStream): Promise<boolean> {
     if (platformInformation) {
-        if (platformInformation.isMacOS() && !CoreClrDebugUtil.isMacOSSupported()) {
-            eventStream.post(new DebuggerPrerequisiteFailure("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."));
-            return true;
+        if (platformInformation.isMacOS()) {
+            if (platformInformation.architecture === "arm64") {
+                eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: arm64 macOS is not officially supported by the .NET Core debugger. You may experience unexpected issues when running in this configuration.`));
+                return false;
+            }
+
+            // Validate we are on compatiable macOS version if we are x86_64
+            if ((platformInformation.architecture !== "x86_64") || 
+                (platformInformation.architecture === "x86_64" && !CoreClrDebugUtil.isMacOSSupported())) {
+                eventStream.post(new DebuggerPrerequisiteFailure("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."));
+                return true;
+            }
         }
         else if (platformInformation.architecture !== "x86_64") {
             if (platformInformation.isWindows() && platformInformation.architecture === "x86") {
                 eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: x86 Windows is not currently supported by the .NET Core debugger. Debugging will not be available.`));
-            } else if (platformInformation.isMacOS() && platformInformation.architecture === "arm64") {
-                eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: arm64 macOS is not officially supported by the .NET Core debugger. You may experience unexpected issues when running in this configuration.`));
-                return false;
             } else {
                 eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: Processor architecture '${platformInformation.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`));
             }
@@ -155,9 +161,12 @@ export class DebugAdapterExecutableFactory implements vscode.DebugAdapterDescrip
 
         // debugger has finished installation, kick off our debugger process
 
+        // Check for targetArchitecture
+        const targetArchitecture: string = getTargetArchitecture(this.platformInfo, _session.configuration.targetArchitecture, await getDotnetInfo());
+
         // use the executable specified in the package.json if it exists or determine it based on some other information (e.g. the session)
         if (!executable) {
-            const command = path.join(common.getExtensionPath(), ".debugger", "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
+            const command = path.join(common.getExtensionPath(), ".debugger", targetArchitecture, "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
             executable = new vscode.DebugAdapterExecutable(command);
         }
 
diff --git a/src/coreclr-debug/util.ts b/src/coreclr-debug/util.ts
index 20f7e616..3d7f4974 100644
--- a/src/coreclr-debug/util.ts
+++ b/src/coreclr-debug/util.ts
@@ -7,6 +7,7 @@ import * as path from 'path';
 import * as fs from 'fs';
 import * as semver from 'semver';
 import * as os from 'os';
+import { PlatformInformation } from './../platform';
 import { getDotnetInfo, DotnetInfo, DOTNET_MISSING_MESSAGE } from '../utils/getDotnetInfo';
 
 const MINIMUM_SUPPORTED_DOTNET_CLI: string = '1.0.0';
@@ -117,3 +118,61 @@ export class CoreClrDebugUtil {
         return '';
     }
 }
+
+const MINIMUM_SUPPORTED_OSX_ARM64_DOTNET_CLI: string = '6.0.0';
+
+export function getTargetArchitecture(platformInfo: PlatformInformation, launchJsonTargetArchitecture: string, dotnetInfo: DotnetInfo): string 
+{
+    if (!platformInfo)
+    {
+        throw new Error(`Unable to retrieve 'TargetArchitecture' without platformInfo.`);
+    }
+
+    let targetArchitecture = "";
+
+    // On Apple M1 Machines, we need to determine if we need to use the 'x86_64' or 'arm64' debugger.
+    if (platformInfo.isMacOS())
+    {
+        // 'targetArchitecture' is specified in launch.json configuration, use that.
+        if (launchJsonTargetArchitecture)
+        {
+            if (launchJsonTargetArchitecture !== "x86_64" && launchJsonTargetArchitecture !== "arm64")
+            {
+                throw new Error(`The value '${launchJsonTargetArchitecture}' for 'targetArchitecture' in launch configuraiton is invalid. Expected 'x86_64' or 'arm64'.`);
+            }
+            targetArchitecture = launchJsonTargetArchitecture;
+        }
+        else if (dotnetInfo)
+        {
+            // Find which targetArchitecture to use based on SDK Version or RID.
+
+            // If we are lower than .NET 6, use 'x86_64' since 'arm64' was not supported until .NET 6
+            if (dotnetInfo.Version && semver.lt(dotnetInfo.Version, MINIMUM_SUPPORTED_OSX_ARM64_DOTNET_CLI))
+            {
+                targetArchitecture = 'x86_64';
+            }
+            else if (dotnetInfo.RuntimeId)
+            {
+                if (dotnetInfo.RuntimeId.includes('arm64'))
+                {
+                    targetArchitecture = 'arm64';
+                }
+                else if (dotnetInfo.RuntimeId.includes('x64'))
+                {
+                    targetArchitecture = 'x86_64';
+                }
+                else
+                {
+                    throw new Error(`Unexpected RuntimeId '${dotnetInfo.RuntimeId}'.`);
+                }
+            }
+        }
+
+        if (!targetArchitecture) {
+            // Unable to retrieve any targetArchitecture, go with platformInfo.
+            targetArchitecture = platformInfo.architecture;
+        }
+    }
+
+    return targetArchitecture;
+}
\ No newline at end of file
diff --git a/src/tools/OptionsSchema.json b/src/tools/OptionsSchema.json
index b7f09c3b..f43342d2 100644
--- a/src/tools/OptionsSchema.json
+++ b/src/tools/OptionsSchema.json
@@ -386,6 +386,10 @@
           "type": "string",
           "description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
           "default": "${workspaceFolder}/out.txt"
+        },
+        "targetArchitecture": {
+          "type": "string",
+          "description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
         }
       }
     },


Test patch:
diff --git a/test/unitTests/coreclr-debug/targetArchitecture.test.ts b/test/unitTests/coreclr-debug/targetArchitecture.test.ts
new file mode 100644
index 00000000..969f104e
--- /dev/null
+++ b/test/unitTests/coreclr-debug/targetArchitecture.test.ts
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { getTargetArchitecture } from '../../../src/coreclr-debug/util';
+import { PlatformInformation } from '../../../src/platform';
+
+import { expect, should, assert } from 'chai';
+import { DotnetInfo } from '../../../src/utils/getDotnetInfo';
+
+suite("getTargetArchitecture Tests", () => {
+    suiteSetup(() => should());
+
+    suite("Error", () => {
+        test("Invalid Call", () => {
+            let fn = function () { getTargetArchitecture(null, null, null); };
+
+            expect(fn).to.throw("Unable to retrieve 'TargetArchitecture' without platformInfo.");
+        });
+    });
+
+    suite("Windows", () => {
+        test("Windows x86_64", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("windows", "x86_64", null);
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, null);
+
+            assert.equal(targetArchitecture, "");
+        });
+    });
+
+    suite("Linux", () => {
+        test("getTargetArchitecture on Linux", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("linux", "x86_64", null);
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, null);
+
+            assert.equal(targetArchitecture, "");
+        });
+    });
+
+    suite("macOS", () => {
+        test("Apple x86_64", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "x86_64", null);
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, null);
+
+            assert.equal(targetArchitecture, "x86_64");
+        });
+
+        test("Apple ARM64 on .NET 5", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "5.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-x64";
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, dotnetInfo);
+
+            assert.equal(targetArchitecture, "x86_64");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-arm64", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-arm64";
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, dotnetInfo);
+
+            assert.equal(targetArchitecture, "arm64");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-x64", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-x64";
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, null, dotnetInfo);
+
+            assert.equal(targetArchitecture, "x86_64");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-arm64 with targetArchitecture: 'arm64'", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-arm64";
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, "arm64", dotnetInfo);
+
+            assert.equal(targetArchitecture, "arm64");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-arm64 with targetArchitecture: 'x86_64'", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-x86_64";
+
+            const targetArchitecture = getTargetArchitecture(platformInfo, "x86_64", dotnetInfo);
+
+            assert.equal(targetArchitecture, "x86_64");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-arm64 with invalid targetArchitecture", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-x86_64";
+
+            let fn = function () { getTargetArchitecture(platformInfo, "x64", dotnetInfo); };
+
+            expect(fn).to.throw("The value 'x64' for 'targetArchitecture' in launch configuraiton is invalid. Expected 'x86_64' or 'arm64'.");
+        });
+
+        test("Apple ARM64 on .NET 6 osx-arm64 with invalid RuntimeId", () => {
+            const platformInfo: PlatformInformation = new PlatformInformation("darwin", "arm64", null);
+            const dotnetInfo: DotnetInfo = new DotnetInfo();
+            dotnetInfo.Version = "6.0.0";
+            dotnetInfo.RuntimeId = "osx.11.0-FUTURE_ISA";
+
+            let fn = function () { getTargetArchitecture(platformInfo, null, dotnetInfo); };
+
+            expect(fn).to.throw(`Unexpected RuntimeId 'osx.11.0-FUTURE_ISA'.`);
+        });
+    });
+});