我非常喜欢记录IDE功能的正确行为,这些功能对编码流有微妙但重要的影响 - 例如自动完成选择和注释/取消注释代码,你可能没有意识到你利用了这些功能,但最终那天你比你可能做得更多.我这样做是希望我必须使用的其他语言服务包含这些功能,从而改善了我的日常编码生活."Real"Smart Indent,即Visual Studio 2008 C#编辑器,就是其中一项功能.
基本的块代码缩进相当简单,可以在合理的时间内完成黑客攻击,以完成工作.另一方面,True Smart Indent可能是迄今为止我必须在IDE中实现的技术上最具挑战性的任务,并且我已经实现了我的公平份额.即使是全面的动态自动代码重新格式化也更容易; 它只是按照Smart Indent进行繁重的提升.
我正在寻找通用智能缩进算法的高级讨论.特别是,我正在寻找关于智能缩进策略的研究,或者对所有正常和"边缘"案例的客观描述,这些案例可以通过测试来确保可重复,无错误的结果.最后,我想提供功能的详细工作流程,实际实现该功能的具体基础,最后组装一个特定于语言的版本并将其集成到我的语言服务中.
PS:Visual Studio 2010的C#编辑器在此功能中有几个小错误.自己实施之后,我对完成它所需的工作有了全新的尊重.
编辑(8/25):我设法写下了一个草案,规定当智能缩进在代码注释中时我应该如何处理事情.我可能会从C++/C#角度对规则进行工作,但后来它们应该能够针对其他语言的方面进行参数化.
假设我有一个二叉树,其中数据结构的根只是一个树节点.对于每个节点,孩子都可以通过Children酒店进入.这是我尝试过的.它TreeRoot是继承数据上下文的属性,但它是单个节点(不是集合).
<UserControl.Resources>
<HierarchicalDataTemplate x:Key="TreeNodeTemplate" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
</UserControl.Resources>
<Grid>
<TreeView ItemsSource="{Binding TreeRoot}" ItemTemplate="{StaticResource TreeNodeTemplate}" />
</Grid>
Run Code Online (Sandbox Code Playgroud) 如何在操作栏中使微调器具有所选的不同项目(显示在操作栏顶部),然后是下拉列表中的项目?示例是带有微调器的google mail在操作栏中:
任何源代码,教程或文档都会非常有用.我已经在操作栏中有绑定微调器和适配器,我在下拉菜单中有列表,但我不能以任何方式修改项目而不影响下拉列表中的项目(因为它们是相同的东西).
我需要使用Reflection.Emit生成一个实现以下接口的类.
public interface IObject
{
T Get<T>(string propertyName);
}
Run Code Online (Sandbox Code Playgroud)
有没有人有一个例子,我将如何发出以下作为一个简单的测试用例?
class GeneratedObject : IObject
{
public T Get<T>(string propertyName)
{
// this is the simplest possible implementation
return default(T);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个球队桌和一个球员桌,我想找到所有没有球员的球队.玩家表通过team_id列关联.我正在使用Ruby on Rails,所以我有一个Team和一个Player模型.
所以我只是在C#和Python中学习一些新东西.结果证明两种语言都支持嵌套方法(C#sort of do).
蟒蛇:
def MyMethod():
print 'Hello from a method.'
def MyInnerMethod():
print 'Hello from a nested method.'
MyInnerMethod()
Run Code Online (Sandbox Code Playgroud)
C#(使用.NET 3.5中的新功能):*
static void Main()
{
Console.WriteLine("Hello from main.");
Func<int, int> NestedMethod =
(x) =>
{
Console.WriteLine("In nested method. Value of x is {0}.", x);
return x;
};
int result = NestedMethod(3);
}
Run Code Online (Sandbox Code Playgroud)
那么为什么嵌套方法如此重要?是什么让他们有用?
**C#代码尚未经过测试.如果不编译,请随意编辑.*
我在Windows 7 64位专业版上使用Visual Studio 2010.我在调试自定义PowerShell cmdlet时遇到问题.
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe-noexit -command Add-PSSnapIn MyCustomSnapIn问题1:按F5时无法连接(调试→开始调试)
问题2:当我按下Ctrl + F5时,意外启动为32位进程(Debug→Start Without Debugging)
The annoying way to debug right now: The only way I've found to debug my cmdlet is to press F5, then select Debug→Detach All, then …
我想在脚本运行后清除一些目录,删除当前目录中的某些文件夹和文件(如果存在).最初,我构建了这样的脚本:
if (Test-Path Folder1) {
Remove-Item -r Folder1
}
if (Test-Path Folder2) {
Remove-Item -r Folder2
}
if (Test-Path File1) {
Remove-Item File1
}
Run Code Online (Sandbox Code Playgroud)
现在我已经在本节中列出了很多项目,我想清理代码.我怎么能这样做?
附注:在脚本运行之前清理这些项目,因为它们是从上一次运行中遗留下来的,以防我需要检查它们.
在Visual Studio(2012)中使用WPP时,每个出现的TraceEvents(...)都有一个波浪下划线,帮助文本是例如
#define TraceEvents WPP_(CALL)
error: identifier WPP_Call_Foo_cppNNN not defined
Run Code Online (Sandbox Code Playgroud)
好吧,它是在WPP预处理器创建的.tmh头文件中定义的,项目编译得很好.但Visual Studio不扫描和/或识别此文件.
是否有摆脱那些波浪的实用方法?
我正在努力解决这个错误:https:
//github.com/openstacknetsdk/openstack.net/issues/333
该问题涉及ProtocolViolationException以下消息:
HTTP/1.0协议不支持分块编码上载.
我发现我能够可靠地重现我发出生成502响应代码的Web请求的问题,然后调用使用带有分块编码的POST请求.我将其追溯到ServicePoint.HttpBehaviour具有HttpBehaviour.HTTP10502响应之后的值的属性.
我能够使用以下hack解决问题(在catch块中).此代码"隐藏" ServicePoint由失败请求创建的实例ServicePointManager,强制它ServicePoint为下一个请求创建新的实例.
public void TestProtocolViolation()
{
try
{
TestTempUrlWithSpecialCharactersInObjectName();
}
catch (WebException ex)
{
ServicePoint servicePoint = ServicePointManager.FindServicePoint(ex.Response.ResponseUri);
FieldInfo table = typeof(ServicePointManager).GetField("s_ServicePointTable", BindingFlags.Static | BindingFlags.NonPublic);
WeakReference weakReference = (WeakReference)((Hashtable)table.GetValue(null))[servicePoint.Address.GetLeftPart(UriPartial.Authority)];
if (weakReference != null)
weakReference.Target = null;
}
TestTempUrlExpired();
}
Run Code Online (Sandbox Code Playgroud)
问题:
.net ×3
c# ×2
powershell ×2
algorithm ×1
android ×1
cmdlets ×1
debugging ×1
hierarchy ×1
ide ×1
indentation ×1
intellisense ×1
interface ×1
python ×1
reflection ×1
servicepoint ×1
spinner ×1
sql ×1
treeview ×1
wdk ×1
wpf ×1
xaml ×1