我试图从Sonars静态代码和单元测试覆盖率分析中排除一些自动生成的代码(服务引用).该项目是C#.Net和Sonar在Windows服务器上通过Jenkins运行.
在我的sonar-project.properties文件中,我可以使用sonar.exclusions属性排除各种其他文件和目录,但这不适用于路径中有空格的文件.
sonar.exclusions=**/Global.asax.cs, **/MyProject/Service References/*
Run Code Online (Sandbox Code Playgroud)
鉴于上面的示例,解决方案中的所有项目都排除了Global.asax.cs文件,但服务引用却没有.
我试过用单引号和双引号括起路径.我尝试使用反斜杠来逃避空间.我已经尝试将路径作为**/MyProject/Service*/*来利用通配符(可能有风险),但这也不起作用.
有人有解决方案吗?
我已经实现了IErrorHandler来处理在我的restful WCF服务的构造函数中抛出的授权异常.捕获常规异常时,我的自定义类型按预期返回,但ContentType标头不正确.
HTTP/1.1 500 Internal Server Error
Content-Type: application/xml;
...
{"ErrorMessage":"Error!"}
Run Code Online (Sandbox Code Playgroud)
但是,当错误处理程序尝试返回401 Unauthorized http状态代码时,消息正文将被覆盖为默认类型,但ContentType标头应该是它应该的样本.
HTTP/1.1 401 Unauthorized
Content-Type: application/json;
...
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
Run Code Online (Sandbox Code Playgroud)
显然这里有些不对劲,但我不确定是什么.
如何实现IErrorHandler,使其在json中使用正确的标头返回我的自定义类型?
BaseDataResponseContract对象:
[Serializable]
[DataContract( Name = "BaseDataResponseContract" )]
public class BaseDataResponseContract
{
[DataMember]
public string ErrorMessage { get; set; }
} // end
Run Code Online (Sandbox Code Playgroud)
这是我想要返回的对象.我的应用程序中的所有其他对象都继承自此对象.当抛出异常时,我们真正关心的是http状态代码和错误消息.
IErrorHandler实现(为简洁起见,未显示日志记录):
namespace WebServices.BehaviorsAndInspectors
{
public class ErrorHandler : IErrorHandler
{
public bool HandleError(Exception error)
{
return true;
} // end
public void ProvideFault(Exception ex, MessageVersion version, ref Message fault)
{
// Create a …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用react-bootstrap复选框(https://react-bootstrap.github.io/components.html#forms-controls),我需要在更改状态时触发事件.能够以编程方式取消/检查它和/或判断它是否被检查也是很好的.不幸的是,当代码被转换并呈现时,它将输入包装在div中.
我怎样才能在dom中找到它并操纵它?
我的代码看起来类似于:
import React, { PropTypes } from 'react';
import { Checkbox } from 'react-bootstrap';
const EditItem = (props) => {
return (
<div>
<Checkbox style={{ marginLeft: '15px' }} >{props.itemLable}</Checkbox>
</div>
);
};
export default EditItem;
Run Code Online (Sandbox Code Playgroud)
浏览器渲染:
...
<div class="checkbox" style="margin-left: 15px;">
<label>
<input type="checkbox">
</label>
</div>
...
Run Code Online (Sandbox Code Playgroud)
我在文档中看到了inputRef prop,但是我找不到任何这样的例子或让它自己工作.