小编bit*_*onk的帖子

如何使用新的 csproj 构建系统在 csproj 中定义 AssemblyProduct

在“旧”世界中,我会定义一个AssemblyProductAttribute并且AssemblyTrademarkAttribute它会在 Windows 资源管理器的文件属性中显示为“产品名称”和“合法商标”。

在 Visual Studio 2017 中用于 netstandard 项目的新简化 msbuild 系统中,首选方法是直接在 csproj 中定义所有这些程序集级别的属性并让 msbuild 生成实际属性。

但是似乎没有办法在 csproj 中定义“产品名称”和“合法商标”。或者有吗?这个 msbuild 目标似乎暗示它应该至少适用于AssemblyProductAttribute.

我怎样才能添加这两个东西?

Udapte: 好的,所以对于AssemblyProductAttribute 中的可以直接写入<Product>Foo</Product>csproj 文件。但是AssemblyTrademarkAttribute呢?

msbuild csproj visual-studio-2017 .net-standard

2
推荐指数
1
解决办法
1285
查看次数

HwndSource不显示Adorner图层

当我托管使用HwndSource中的装饰器(文本框的错误边框)的WPF控件时,不会显示装饰器.似乎装饰层不在那里.为什么会这样,我该怎么做呢?这是一个已知的错误?

wpf interop adorner adornerdecorator adornerlayer

1
推荐指数
1
解决办法
723
查看次数

使用可空文字的真正时髦的C#编译器行为

C#4.0编译器没有抱怨这个(甚至没有警告):

if(10.0 > null + 1)
{       
}

if (myDoubleValue > null)
{
}
Run Code Online (Sandbox Code Playgroud)

而且似乎总是错误的.这里发生了什么?null会自动转换Nullable<double>为什么?

如果是这样,为什么这不起作用呢:

double myDoubleValue = null + 1;
Run Code Online (Sandbox Code Playgroud)

另外,为什么我会想要这样的行为.为什么有可能玩这样的文字是一件好事.

c# compiler-construction null nullable literals

1
推荐指数
1
解决办法
207
查看次数

良好的班级名称的想法

如何使用以下公共接口命名类:

/// <summary>
///     Enqeues and exectutes actions synchronously on seperated threads using the <see cref="ThreadPool"/>. 
/// </summary>
/// <remarks>
///     Syncronism is guaranteed on a per-instance base in that each enqued action will be executed
///     after the previous action has completed execution for each instance of <see cref="ThreadPoolExectutor" /> 
/// </remarks>
internal class ThreadPoolExectutor
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ThreadPoolExectutor"/> class.
    /// </summary>
    /// <param name="capacity">The absolute (not the initial) number of …
Run Code Online (Sandbox Code Playgroud)

.net c# naming-conventions framework-design

1
推荐指数
1
解决办法
1624
查看次数

android中的音频音调变化

我正在开发一个声音相关的应用程序 我正在尝试将音频声音更改为完全不同的机器人声音或使音频回声.我尝试使用soundpool,但不知道,有谁知道如何实现这一目标?我只需要一个基本的想法来实现这一点,请帮助.非常感谢.

android

1
推荐指数
1
解决办法
6350
查看次数

命令 tf vc scorch 有什么作用?

在 TFS 构建的构建日志中,我看到了命令的使用tf vc scorch。这看起来很有趣,似乎有点像git clean并且可能很有帮助,但由于某些奇怪的原因scorch没有记录。这是一些不适合公共使用的内部事物吗?

键入tf vc /?不会列出scorch命令,tf vs scorch /?也不会解释参数。它也未在 docs.microsoft.com 上列出

我在哪里可以找到它的完整文档?

tfs tf-cli

1
推荐指数
1
解决办法
3385
查看次数

链接两个 CancellationToken,无需冗余 CancellationTokenSource

在获取CancellationToken( StartAsync) 的方法内部,我想添加一个内部函数CancellationToken,以便调用者可以在外部或内部取消异步操作(例如,通过调用方法AbortAsync())。

AFAIK,这样做的方法是使用CreateLinkedCancellationTokenSource. 但它的 API 似乎相当不舒服,因为我需要为此创建两个额外的实例,并且因为它们实现了,所以我也必须不要忘记处置它们。因此,我需要将它们都存储为成员以供以后处理。CancellationTokenSourceIDisposable

我错过了什么吗?我觉得应该有一种更简单的方法来将额外的取消机制附加到现有令牌上,而不会迫使我维护两个CancellationTokenSource实例。

public Task StartAsync(CancellationToken externalToken)
{
    this.actualCancellation = new CancellationTokenSource();
    this.linkedCancellation = CancellationTokenSource.CreateLinkedTokenSource(
        actualCancellation.Token, externalToken);
    this.execution = this.ExecuteAsync(this.linkedCancellation.Token);
    return this.execution;
}

public async Task AbortAsync()
{
    try
    {
        this.actualCancellation.Cancel();
        await this.execution;
    }
    catch
    {
    }
    finally
    {
        this.actualCancellation.Dispose();
        this.linkedCancellation.Dispose();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library cancellationtokensource .net-core

1
推荐指数
1
解决办法
1269
查看次数

关于节点位置和属性值的XPath查询

有没有办法构建一个XPath查询,在某个位置找到一个节点并具有某个属性值?

请考虑以下示例xml:

<Item Type="Book">
<!--1st Param node in a Book item is always the autors last name-->
<Param Value="Updike" />
<!--2nd Param node in a Book item is always the autors first name-->
<Param Value="John" />
<!--3rd Param node in a Book item is always the book title-->
<Param Value="Toward the End of Time" /></Item>
Run Code Online (Sandbox Code Playgroud)

现在我可以构建一个查找以下内容的查询:

找到所有项目的节点类型,其中第2个"书" 帕拉姆节点都有一个 "约翰"的.所以我想找到作者名字的所有书籍都是"约翰".

请注意,我使用的是.NET XPathDocument.

xpath xpathdocument

0
推荐指数
1
解决办法
569
查看次数

StyleCop与DependencyProperties

我总是倾向于将属于依赖属性的所有东西(注册,clr属性,更改回调,强制回调等)组合到一个区域中.但这违反了stylecop会员订购规则.这也是生成多个成员的codesnippets的一般问题,因为片段无法在我的文件中的不同位置生成代码.你对此有何看法?你是否取消了stylecop规则,或者你把所有东西放在"正确"的地方?

另外我个人认为stylcop不应该抱怨这个:

/// <summary>
/// RepeatX Dependency Property
/// </summary>
public static readonly DependencyProperty RepeatXProperty =
    DependencyProperty.Register(
        "RepeatX", 
        typeof(int), 
        typeof(GeometryViewbox), 
        new FrameworkPropertyMetadata
            {
                DefaultValue = 1, 
                AffectsRender = true, 
                AffectsParentMeasure = true, 
                PropertyChangedCallback = OnRepeatXChanged, 
                CoerceValueCallback = CoerceRepeatXValue
            });
Run Code Online (Sandbox Code Playgroud)

Stylcop应该为我们做出额外的工作.在上面的例子中,坚持使用stylcecop会降低你的工作效率,而且代码变得不那么可读,因为你不得不将上面的代码放在静态ctor中(而不是字段初始化),以便能够将FrameworkPropertyMetadata转换为临时变量.每个依赖项属性的一个额外临时变量不会使代码更易读/可维护,而且您不能再使用codesnippets.

stylecop

0
推荐指数
1
解决办法
512
查看次数

MFC托管的Windows窗体UserControl的透明背景

我正在使用CWinFormsControl在MFC对话框中托管Windows窗体UserControl.我已将该属性设置DoubleBufferd为true.根据文档,这会导致AllPaintingInWmPaintUserPaint设置为真(不确定这是否重要).如何强制(或伪造)UserControl将其背景透明化?

这是我在UserControl的构造函数中设置的:

this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
this.DoubleBuffered = true;
Run Code Online (Sandbox Code Playgroud)

mfc transparency interop winforms

0
推荐指数
1
解决办法
2649
查看次数

公共事件EventHandler SomeEvent = delegate {};

我有点厌倦了在代码中发现所有这些无用的噪音:

private void RaiseSomeOtherEventIfItIsNotNull()
{
    if (this.SomeOtherEvent != null)
    {
        this.SomeOtherEvent(this, EventArgs.Empty);
    }
}
Run Code Online (Sandbox Code Playgroud)

在99.9%的案例中,我不在乎是否有人附加或者是否为空.刚举起活动!我真的不明白为什么c#编译器会让我写出所有这些噪音.

所以我虽然可以声明这样的事件:

public event EventHandler SomeOtherEvent = delegate { };
Run Code Online (Sandbox Code Playgroud)

这将允许我摆脱无用的空检查和无用的Raise*方法.我可以随时做:

this.SomeOtherEvent(this, EventArgs.Empty);
Run Code Online (Sandbox Code Playgroud)

现在,当我在LutzRöder的Reflector中将标准方法与"我的"方法进行比较时,我发现了一些显着的差异.编译器已覆盖,Add{}并且Remove{}匿名委托有一个额外的静态实例:

[CompilerGenerated] 
private static EventHandler CS$<>9__CachedAnonymousMethodDelegate1;
Run Code Online (Sandbox Code Playgroud)

并且有这样的:

.method private hidebysig static void <.ctor>b__0(object, class [mscorlib]System.EventArgs) cil managed
{
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()
    .maxstack 8
    L_0000: nop 
    L_0001: ret 
}
Run Code Online (Sandbox Code Playgroud)

现在我的问题:您是否在使用默认初始化这样的十进制事件中看到了任何问题或缺点?

c# events

0
推荐指数
1
解决办法
6092
查看次数

为什么要使用附加属性而不是常规依赖项属性?

我刚刚发现自己可以做到以下几点:

var button = new Button();
button.SetValue(TextBlock.TextProperty, "text");
var text = (string)button.GetValue(TextBlock.TextProperty); // text is "text" 
Run Code Online (Sandbox Code Playgroud)

尽管上面的示例有些不切实际,但它确实表明我可以将常规依赖项属性附加到另一个对象上。它不必是附加的属性(TextBlock.TextProperty未在中注册)DependencyProperty.RegisterAttached()

这就提出了一个问题,为什么首先要有附加属性?我现在看到的唯一区别是,我无法在XAML中附加常规依赖项属性。就是这样。还有其他区别吗?

更新:

为了更加清楚,下面的代码可以正常工作,并且从最终用户的角度来看,它看起来非常接近附加属性:

public static class AttachedPropertyDeclarer
{
    public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
        "Text",
        typeof(string),
        typeof(Button), 
        new PropertyMetadata(default(string),OnTextChanged));

    private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        // do something when text changed
    }
}

...
button.SetValue(AttachedPropertyDeclarer.TextProperty, "text");
var text = (string)button.GetValue(AttachedPropertyDeclarer.TextProperty);
Run Code Online (Sandbox Code Playgroud)

将此与附加的属性方式进行比较:

public static class AttachedPropertyDeclarer
{
    public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached(
        "Text",
        typeof(string),
        typeof(AttachedPropertyDeclarer), …
Run Code Online (Sandbox Code Playgroud)

wpf dependency-properties attached-properties

0
推荐指数
1
解决办法
1464
查看次数

SCRUM估计精度

我猜想有很多情况下估计在某些时候是错误的.因为只要深入了解积压项目的细节,您就可能几乎总能找到在规划期间没有考虑过的事情.这可以在任务级别sprint估计期间或在实际sprint期间发生.

在任务级别估计期间,您可能会发现故事/积压项目的许多任务,因此需要调整初始估算. 你现在做什么?您是否回到产品所有者并告诉他他可能想要重新确定其积压物品的优先顺序,现在需要更长时间(甚至更少)?基本上它可能意味着整个团队需要回到故事级别的估计并重新调整故事?

在sprint期间,您可能会发现实现需要比最初想象的更多的努力. 你现在做什么?知道你无法按计划完成它,你是否默默地继续冲刺?从现在开始,您将为所有估算添加"安全缓冲区"?

一般来说,SCRUM如何解决整体估算精度问题?

如果我理解正确,那么SCRUM开发团队就会"承诺"产品所有者将按计划交付.但只有准确估计才能做到这一点.所以估计似乎对SCRUM的成功非常关键,但也非常困难.

scrum estimation

-1
推荐指数
1
解决办法
4062
查看次数