- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在获取以下两种方法的通用参数以在 Intellisence 中显示类型时遇到问题。
对于IEnumerable<T>
我只是希望它显示为 double
.
对于 IDictionary<TKey,TValue>
过载,我希望它显示KeyValuePair<int,string>
但当然不需要对类型进行硬编码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Common.FluentValidation
{
public static partial class Validate
{
/// <summary>
/// Compares two dictionaries are null or contain equal sets of items.
/// Returns true if both instances are null or contain equal sets of <see cref="T:System.Collections.Generic.KeyValuePair'1{TKey}{TValue}"></see> items; otherwise, false.
/// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="A">The first instance to compare</param>
/// <param name="B">The second instance to compare</param>
/// <returns>true if both instances are null or contain equal sets of <see cref="T:System.Collections.Generic.KeyValuePair'1{TKey}{TValue}"></see> items; otherwise, false.</returns>
public static bool AreBothNullOrEqualSets<TKey, TValue>(IDictionary<TKey, TValue> A, IDictionary<TKey, TValue> B)
{
// XOR for null
if ((A == null) ^ (B == null))
return false;
// Compare each value in set
if (A != null)
if (!A.OrderBy(x => x.Key).SequenceEqual(B.OrderBy(x => x.Key)))
return false;
return true;
}
/// <summary>
/// Compares two sequences are null or contain equal sets of items.
/// Returns true if both instances are null or contain equal sets of <see cref="T:Common.FluentValidation.AreBothNullOrEqualSets`1"/> items; otherwise, false.
/// </summary>
/// /// for more information.
/// <typeparam name="T">The type of the enumerable.</typeparam>
/// <param name="A">The first instance to compare</param>
/// <param name="B">The second instance to compare</param>
/// <returns>true if both instances are null or contain equal sets of <see cref="T:Common.FluentValidation.AreBothNullOrEqualSets`1"/> items; otherwise, false.</returns>
public static bool AreBothNullOrEqualSets<T>(IEnumerable<T> A, IEnumerable<T> B)
{
// XOR for null
if ((A == null) ^ (B == null))
return false;
// Compare each value in set
if (A != null)
if (!A.SequenceEqual(B))
return false;
return true;
}
}
}
我搜索并找到了一些提示,但尝试了几件事但没有运气。我能得到的最好的结果就是它只在情报气球中显示“T”,这还有待改进......
编辑:
这是 Microsoft 在类级别类型参数上执行的操作...但不是在构造函数上...那么这对于方法/构造函数来说可能吗? (理想情况下,我想显示与我的评论内联的类型,但下面示例图像中的方式也是完全可以接受的)
最佳答案
虽然这是一个非常古老的问题,但我今天发现自己正在努力解决完全相同的问题 - 我很遗憾地说,它看起来并没有真正的解决方案。
使用 <see cref="Dictionary{int, string}">
将导致以下警告(至少在 VS 2017 上):
CS1584 XML comment has syntactically incorrect cref attribute 'Dictionary{int, string}'
当鼠标悬停在绿色曲线上时,VS 将显示一个工具提示(除其他内容外):
Type parameter declaration must be an identifier not a type. See also error CS0081.
我想出的唯一解决方案就是简单地添加几个段落来指定TKey
的类型。和TValue
:
/// <summary>
/// Gets a <see cref="Dictionary{TKey, TValue}"/> that maps ints to strings.
/// <para>
/// TKey is <see cref="int"/>.
/// </para>
/// <para>
/// TValue is <see cref="string"/>.
/// </para>
/// </summary>
public Dictionary<int, string> Map {get;}
情报会这样显示:
Gets a Dictionary<TKey, TValue> that maps ints to strings.
TKey is int.
TValue is string.
关于c# - 在静态方法的 Intellisense 中显示 XML 注释通用参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23411024/
我现在选择Objective-J Cappuccino开发的编辑器是Sublime Text2。不幸的是,我没有找到Objective-J智能感知自动完成插件的运气。似乎应该可行,因为Objectiv
我想在 VSCode 中使用代码片段。但是,当我在 javascript 文件中键入 for 时,Intellisense 不会建议片段“for-loop” - 我需要手动滚动下拉列表并选择它。有没有
我正在 VisualStudio 中编写一个 dll。该库包含两个名称相同但 namespace 不同的类。 public namespace XCharting { public class
我们正在使用 MVVM Light Toolkit(来自 Galasoft - Laurent Bugnion)。 到目前为止,我们使用的是 Visual Studio 2010。 一切都运行良好(感
我们目前正在 Blend 3 中构建 WPF 解决方案,Intellisense 非常慢。 Visual Studio 2008 和 2010 beta 2 没有任何问题,Blend 2 也没有任何问
我正在为 Visual Studio Code 中的自定义语言编写扩展。语法检测通过 tmLanguage 文件运行良好。我试图弄清楚如何添加智能感知并转到符号支持,我既无法找到清晰的文档,也无法找到
/// <reference path="jquery-1.5.vsdoc.js" /> // IntelliSense works here. function ($, window, doc
我正在尝试为示例 Backbone.js 项目安装 TypeScript 定义。 在项目目录中,我发出了以下命令: npm init npm install typings typings insta
我最近通过 Web 平台安装程序安装了 ASP.NET MVC 3。我在 Razor View 中没有对 ViewBag 的智能感知支持。 Intellisense 适用于 Razor View 中的
我不想在 Visual Studio Code 中对 Markdown 文件进行单词补全,如何禁用它?理想情况下,仅适用于 Markdown,但在最坏的情况下,即使是全局切换也会很好。 最佳答案 VS
我有 VS 2012 的 RTM 版本,它很棒 - 但是 CSS 编辑器中的 VS11 中的智能感知不建议参数信息,但是......其他的东西,我不太确定那实际上是什么,它看起来像一些样本。 需要明确
我在 js 文件中添加了 vsdoc jquery 引用: /// 这工作得很好,但是一旦我在一个无冲突的包装器中写入内部... (function ($) { ...here... })(jQue
烦人的废话。我正在使用 VS 2012;我安装了 ReSharper 和 StyleCop (SC)。如果在一行代码上启用了 StyleCop 警告,除非修复它,否则我无法摆脱它。我想稍后处理 SC
我在 PPT 2013 中的“彩色参数帮助”功能有问题。 http://visualstudiogallery.msdn.microsoft.com/dbcb8670-889e-4a54-a226-a
在 javascript 上下文中查看异步模块定义 (AMD) 后,我想知道如何在 Visual Studio 2010 中为依赖模块获取智能感知。 例如给定模块A: define(function(
我有一个问题:我想将我的 Visual Studio 2012 的 UI 设置为默认(英语)语言,但我还希望有关 .NET 类型的 IntelliSense 提示以另一种语言显示。在 Visual S
可以去Resharper -> Options -> IntelliSense -> General吗并使用 Resharper 5 中的命令从 Resharper 切换到 Visual Studio
使用 Visual Studio 2015 Community edition 它会针对以下内容标记错误: { "type": "Microsoft.Compute/virtualMachi
我无法在Visual Studio 2017中找到该选项。我知道您可以更改正在编写的代码的字体,但是看不到IntelliSense的选项使我认为这是不可能的。 最佳答案 工具–选项–环境–字体和颜色>
我看过相关问题 Intellisense for custom config section problem with namespaces它描述了我遇到的同样问题。虽然解决方案对我不起作用。 我在这
我是一名优秀的程序员,十分优秀!