如果我在VS2008下从TestDriven.NET开始我的单元测试,它们会立即运行.
如果我开始使用单元测试nunit-console.exe,NUnit控制台会在实际运行测试之前挂起五分钟.如果我附加一个调试器,它似乎是在一些本机管理的转换的另一端花费时间System.IO.MemoryStream.Read,调用System.Runtime.Serialization.Formatters,调用,来自.有时,它在或.System.Runtime.RemotingNUnit.Core.ProxyTestRunner.Test.getSystem.Runtime.Serialization.ObjectManager.RecordFixup.FindObjectHolder
这是32位XP上的NUnit-2.5.2,完全修补.所有程序集都针对.NET 2.0.
什么是 nunit-console达?有没有办法说服它不这样做?
日!继40781534 之后,接受的答案是设置SameSite=Lax:
即使用户的请求本身是从我的 OAUTH2 提供程序上的登录页面SameSite=Strict重定向,我该如何设置重定向到自己的 cookie,以便我可以从 Chrome 取回 cookie 56.0.2924.87?
完整的请求链是:
POST https://provider.com/callback? 302 FOUND和:
Location: https://me/login?code=xxx&state=yyy
Run Code Online (Sandbox Code Playgroud)GET https://example.com/login?code=xxx&state=yyy? 302 FOUND或303 SEE OTHER(似乎无关紧要)与:
Location: https://example.com/destination
Set-Cookie: sid=zzzz; Secure; HttpOnly; SameSite=Strict; Path=/
Run Code Online (Sandbox Code Playgroud)GET https://example.com/destination? 401 GET OFF MY LAWN因为浏览器没有显示sidcookie
GET https://example.com/destination? 200 OK如果我刷新,因为网站是相同的,我的浏览器会显示sidcookie
我欣赏提出的CSRF潜力sid,以/destination不被用户的最后一次加载页面的一般情况example.com,但我只是刚刚设置的/login,而我是一个现在重定向到/destination。
当然,我可以设置SameSite=Lax,但是如果有人可以找到某种方法通过错误形成 URL …
我想我们大多数人都同意为变量,对象属性和数据库列使用描述性名称是个好主意.如果你想存储某些东西的名字,你也可以调用该属性,Name以便人们知道要放入什么.
如果测量单位不是很明显,我认为你应该更进一步,在名称中包含计量单位.Length_mm例如,应该有助于提醒开发人员,如果用户刚刚以英寸输入,他们最好将长度转换为mm.
但是,我的数据库管理员告诉我,在数据库列名中包含度量单位是"不受欢迎的".我认为这只是疯了,但也许有一些风险DBA知道我没有.
在这里给我一句话:我们应该在属性名称中嵌入测量单位吗?为什么?为什么不?
如何自定义类别的排序PropertyGrid?
如果我设置以下任一项...
propertyGrid.PropertySort = PropertySort.Categorized;
propertyGrid.PropertySort = PropertySort.CategorizedAlphabetical;
Run Code Online (Sandbox Code Playgroud)
...然后类别将按字母顺序排列.("按字母顺序"似乎适用于每个类别中的属性.)如果我使用PropertySort.NoSort,我会失去分类.
我在我的填充PropertyGrid用SelectObject,这是很容易的:
this.propertyGrid1.SelectedObject = options;
Run Code Online (Sandbox Code Playgroud)
options 是具有适当装饰属性的类的实例:
[CategoryAttribute("Category Title"),
DisplayName("Property Name"),
Browsable(true),
ReadOnly(false),
BindableAttribute(true),
DesignOnly(false),
DescriptionAttribute("...")]
public bool PropertyName {
get {
// ...
}
set {
// ...
this.OnPropertyChanged("PropertyName");
}
}
Run Code Online (Sandbox Code Playgroud)
我在六个类别中有几十个属性.
有没有什么方法可以调整类别排序顺序,同时保持我的易用性SelectedObject?
天儿真好!
我希望我的WPF ComboBox在其数据绑定选择时显示一些替代文本null.
视图模型具有预期的属性:
public ThingoSelectionViewModel : INotifyPropertyChanged {
public ThingoSelectionViewModel(IProvideThingos) {
this.Thingos = IProvideThingos.GetThingos();
}
public ObservableCollection<Thingo> Thingos { get; set; }
public Thingo SelectedThingo {
get { return this.selectedThingo; }
set { // set this.selectedThingo and raise the property change notification
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
该视图以预期的方式将XAML绑定到视图模型:
<ComboBox x:Name="ComboboxDrive" SelectedItem="{Binding Path=SelectedThingo}"
IsEditable="false" HorizontalAlignment="Left" MinWidth="100"
IsReadOnly="false" Style="{StaticResource ComboboxStyle}"
Grid.Column="1" Grid.Row="1" Margin="5" SelectedIndex="0">
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem IsEnabled="False">Select a thingo</ComboBoxItem>
<CollectionContainer
Collection="{Binding Source={StaticResource Thingos}}" />
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
该 …
我该如何诊断,减少或预防AppDomainUnloadedException?
AppDomainUnloadedException经过涉及PLINQ的长期(> 10s)测试后,NUnit 2.5.2一直在抛出.
回到2008年7月,Stephen Toub说:
是的,CTP中的调度程序不能很好地处理线程中止,这会导致进程在关闭的域中存在实时调度程序时崩溃(因为AppDomain关闭会导致该域中具有堆栈帧的所有线程上的线程中止).我们正努力为将来的版本强化这一点.
我尝试了很多解决方法,包括:
/domain:None为NUNit参数legacyUnhandledAppDomainPolicy从中删除元素nunit-console.exe.config我无法降级NUnit以降低竞争条件的可能性,因为我需要PLINQ来使我的参数测试更快.没有问题的NUnit版本不支持参数测试.
天儿真好!
如何构建一个简单的ANTLR语法处理多行表达式而不需要分号或反斜杠?
我正在尝试为表达式编写一个简单的DSL:
# sh style comments
ThisValue = 1
ThatValue = ThisValue * 2
ThisOtherValue = (1 + 2 + ThisValue * ThatValue)
YetAnotherValue = MAX(ThisOtherValue, ThatValue)
Run Code Online (Sandbox Code Playgroud)
总的来说,我希望我的应用程序为脚本提供一些初始命名值并提取最终结果.不过,我对语法感到很沮丧.我想支持多行表达式,如下所示:
# Note: no backslashes required to continue expression, as we're in brackets
# Note: no semicolon required at end of expression, either
ThisValueWithAReallyLongName = (ThisOtherValueWithASimilarlyLongName
+AnotherValueWithAGratuitouslyLongName)
Run Code Online (Sandbox Code Playgroud)
我开始使用这样的ANTLR语法:
exprlist
: ( assignment_statement | empty_line )* EOF!
;
assignment_statement
: assignment NL!?
;
empty_line
: NL;
assignment
: ID '=' expr
;
// …Run Code Online (Sandbox Code Playgroud) 我需要得出7个潜在投入的重要价值.鲍勃叔叔敦促我避免使用那么多参数的函数,所以我已经提取了这个类.所有参数现在都是属性,我留下了一个没有参数的计算方法.
我认为"那个"可能是一个财产,但我不确定这是否是惯用的C#.
我应该将最终结果作为属性公开,还是作为没有参数的方法公开?一般的C#程序员会发现令人困惑或令人反感的属性吗?那么Alt.Net的人群呢?
decimal consumption = calculator.GetConsumption(); // obviously derived
decimal consumption = calculator.Consumption; // not so obvious
Run Code Online (Sandbox Code Playgroud)
如果是后者:我应该将中间结果声明为[私有]属性吗?由于重法提取,我有几个中期结果.其中许多不应该是公共API的一部分.但是,其中一些可能很有趣,如果我可以将它们作为属性访问,我的表达式看起来会更清晰:
decimal interim2 = this.ImportantInterimValue * otherval;
Run Code Online (Sandbox Code Playgroud)
快乐实验部:
在VS2008中调试我的代码时,我注意到我一直将鼠标悬停在计算中间结果的方法调用上,期望将鼠标悬停在返回值上.在将所有方法转换为属性之后,我发现将中间结果公开为属性极大地帮助了调试.我很满意,但对可读性的担忧仍然存在.
临时价值声明看起来更加混乱.但是,没有括号,表达式更容易阅读.我不再觉得有必要用动词启动方法名称.对比:
// Clean method declaration; compulsive verby name; callers need
// parenthesis despite lack of any arguments.
decimal DetermineImportantInterimValue() {
return this.DetermineOtherInterimValue() * this.SomeProperty;
}
// Messier property declaration; clean name; clean access syntax
decimal ImportantInterimValue {
get { …Run Code Online (Sandbox Code Playgroud)