[英]How to Go To Source Code Definition (not Metadata) from C# to F# in Visual Studio?
I have a small C# Console Application that has a F# Project Reference.我有一个小的 C# 控制台应用程序,它有一个 F# 项目参考。
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var number = FS.DecodeRomanNumeral("XV");
Console.WriteLine("Hello World!");
}
}
}
On the F# project, I have this code:在 F# 项目中,我有这样的代码:
module FS
open System
/// Decodes a Roman Number string to a int number // https://twitter.com/nikoloz_p/status/1421218836896960515
let DecodeRomanNumeral RomanNumeral =
let DigitToNumber = function
| 'I' -> 1
| 'V' -> 5
| 'X' -> 10
| 'L' -> 50
| 'C' -> 100
| 'D' -> 500
| 'M' -> 1000
| c -> failwith (sprintf "Invalid digit %c" c)
let rec sum' Numbers =
match Numbers with
| [] -> 0
| x::y::rest when x < y -> y - x + sum' rest
| x::rest -> x + sum' rest
RomanNumeral
|> Seq.map DigitToNumber
|> Seq.toList
|> sum'
When I click on the DecodeRomanNumeral word and press F12 it brings the Disassembler window, instead of the actual F# source code that is on the referenced project.当我单击DecodeRomanNumeral单词并按 F12 时,它会显示反汇编程序 window,而不是引用项目中的实际 F# 源代码。 I noted that this behavior occurs in Visual Studio 2019 (Version 16.10.4) and also Visual Studio 2022 (Version 17.0.0 Preview 2.1)我注意到此行为发生在 Visual Studio 2019(版本 16.10.4)和 Visual Studio 2022(版本 17.0.0 预览版 2.1)中
I double checked and I added a Project Reference on the C# Project, making a reference to the F#我仔细检查并在 C# 项目上添加了项目参考,参考了 F#
I need that it goes from the C# to the actual F# code when I press F12 (Go To Definition).当我按F12 (转到定义)时,我需要它从 C# 转到实际的 F# 代码。
How to do that?怎么做?
Unfortunately, VS doesn't support that yet.不幸的是,VS 还不支持它。 Only from F# to C# works since VS 16.10: https://devblogs.microsoft.com/do.net/f-and-f-tools-update-for-visual-studio-16-10/#better-mixing-of-c-and-f-projects-in-your-solution只有从 F# 到 C# 从 VS 16.10 开始工作: https://devblogs.microsoft.com/do.net/f-and-f-tools-update-for-visual-studio-16-10/#better-mixing-of -c-and-f-projects-in-your-solution
Personally, I've resorted to JetBrains Rider just for this, where it works very well.就个人而言,我为此求助于 JetBrains Rider,它运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.