繁体   English   中英

如何在 Visual Studio 中从 Go 到 C# 到 F# 的源代码定义(不是元数据)?

[英]How to Go To Source Code Definition (not Metadata) from C# to F# in Visual Studio?

我有一个小的 C# 控制台应用程序,它有一个 F# 项目参考。

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var number = FS.DecodeRomanNumeral("XV");

            Console.WriteLine("Hello World!");
        }
    }
}

在 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'

当我单击DecodeRomanNumeral单词并按 F12 时,它会显示反汇编程序 window,而不是引用项目中的实际 F# 源代码。 我注意到此行为发生在 Visual Studio 2019(版本 16.10.4)和 Visual Studio 2022(版本 17.0.0 预览版 2.1)中

反汇编程序

我仔细检查并在 C# 项目上添加了项目参考,参考了 F#

添加项目参考

当我按F12 (转到定义)时,我需要它从 C# 转到实际的 F# 代码。

怎么做?

不幸的是,VS 还不支持它。 只有从 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

就个人而言,我为此求助于 JetBrains Rider,它运行良好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM