一位团队成员给我分配了一份大型 PR,让我在 github 存储库中进行审查。我希望能够在 Visual Studio 中对其进行审查/评论/批准。
我使用的是 VS 2022,在以前的版本中,团队资源管理器的 github 窗格中有一个 PullRequest 选项。这种情况在 2022 年就消失了,我找不到在新的 VS ide 中处理分配给我的 PR 的选项。
我已经看到了使用一些新的IHttpActionResults for OK,NotFound的例子.我还没有看到任何使用Unauthorized().
我现有的代码如下:
catch (SecurityException ex)
{
request.CreateResponse(HttpStatusCode.Unauthorized, ex.Message);
}
Run Code Online (Sandbox Code Playgroud)
我想用这个替换它:
catch (SecurityException ex)
{
response = Unauthorized();
}
Run Code Online (Sandbox Code Playgroud)
但我没有看到任何超载传递异常细节.
还有,IHttpActionResult相当于返回500错误?
catch (Exception ex)
{
response = request.CreateErrorResponse(HttpStatusCode.InternalServerError,
ex.Message);
}
Run Code Online (Sandbox Code Playgroud) 我有一些具有特定格式的 C# 代码,我不希望 Rider 对其重新格式化。
我可以在代码中添加一些指令来告诉 Rider 此部分不应重新格式化吗?
谢谢。
我刚刚开始使用xUnitClassFixtures中的集合,因此我可能做错了,但我的理解是我可以创建一个,通过将其分配给集合,然后所有具有ICollectionFixture<MyFixture>CollectionDefinitionAttribtueCollection,然后所有具有该属性的相同的连接名称将共享固定装置的相同实例。
首先用一个简单的例子来证明Fixture每个测试类只实例化一次
public class SampleFixture:IDisposable
{
public static int ConstructorCount { get; set; }
public static int DisposeCount { get; set; }
public SampleFixture()
{
ConstructorCount++;
}
public void Dispose()
{
DisposeCount++;
}
}
public class SampleTestClass1 : IClassFixture<SampleFixture>
{
private readonly ITestOutputHelper outputHelper;
private readonly SampleFixture sampleFixture;
public SampleTestClass1(ITestOutputHelper outputHelper, SampleFixture sampleFixture)
{
this.outputHelper = outputHelper;
this.sampleFixture = sampleFixture;
}
[Fact]
public void Test1()
{
this.outputHelper.WriteLine($"Test1 - Constructor Count: {SampleFixture.ConstructorCount} …Run Code Online (Sandbox Code Playgroud) 我已经下载并安装了NServiceBus 4.0,但是当公交车启动时我遇到了一些困难......
2013-09-18 15:53:40,887 [1] WARN NServiceBus.Persistence.Raven.RavenUserInstall er [(null)] <(null)> - 无法将用户添加到raven.处理将继续System.MissingMethodException:找不到方法:'Raven.Abstractions.Data.PutRes ult Raven.Client.Connection.IDatabaseCommands.Put(System.String,System.Nullable`1,Raven.Json.Linq.RavenJObject,Raven. Json.Linq.RavenJObject)".at NServiceBus.Persistence.Raven.RavenUserInstaller.AddUserToDatabase(String identity,DocumentStore documentStore)位于c:\ BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Persistence\Raven中的NServiceBus.Persistence.Raven.RavenUserInstaller.Install(字符串标识)\Ra venUserInstaller.cs:第40行
当我尝试将更改保留到文档存储区时...
public class RavenUnitOfWork: IManageUnitsOfWork
{
public IDocumentSession Session { get; set; }
public void Begin()
{
}
public void End(Exception ex = null)
{
if (ex == null && Session != null)
{
Console.WriteLine("Saving Changes to DB.");
Session.SaveChanges();
}
}
}
produces
2013-09-18 15:57:38,007 [13] INFO NServiceBus.Unicast.Transport.TransportReceiv
er [(null)] <(null)> - Failed to process message
System.InvalidOperationException: Url: "/bulk_docs"
System.FormatException: …Run Code Online (Sandbox Code Playgroud) 我正在通过NSB的PluralSight培训演示.
我已经将解决方案重构为面向服务的解决方案,但是当我运行后端项目并提交订单时,我收到以下内容:
2013-09-20 11:49:59,712 [15] WARN NServiceBus.Unicast.DefaultDispatcherFactory [(null)] <(null)> - 无法从消息头'BusSto p.Sales.InternalMessages.PlaceOrder,BusStop中确定消息类型. Sales.InternalMessages,Version = 1.0 .0.0,Culture = neutral,PublicKeyToken = null'.消息ID:4984ecad-2ae1-423b-8f29- a23f00c30008
我的消息定义为:
using System;
using NServiceBus;
namespace BusStop.Sales.InternalMessages
{
public class PlaceOrder : IMessage
{
public Guid CustomerId { get; set; }
public Guid OrderId { get; set; }
public Guid ProductId { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
如何帮助NSB解析消息类型?
我在某些 DynamoDB 查询的应用程序日志中看到了这种情况。我无法通过谷歌搜索找到任何对此错误消息的引用。
任何人都可以深入了解此异常的原因吗?
谢谢。
开箱即用,当 FV 检测到验证失败时,它会以数组形式显示属性名称、错误消息、尝试值,并将其作为 BadRequest 响应返回。
然而,FV 的 validator.Validate() 方法实际上返回一个更丰富的 ValidationResult 对象,并包含有关错误代码和参数化值的元数据。
我希望能够返回实际的 ValidationResult,包括所有丰富的元数据,而不仅仅是验证失败的一些数据。
我怎样才能改变这种行为?(.net core 2.1 顺便说一句)。
我想利用此处定义的VSTS Rest API开始发布:https : //www.visualstudio.com/zh-cn/docs/integrate/api/rm/releases#create-a-release
但是在创建发行版时,我需要设置一些变量值。查看ReleaseMetadata(https://www.visualstudio.com/zh-cn/docs/integrate/api/rm/contracts#ReleaseStartMetadata),我看到有一个属性集合。这是我要设置变量值的地方吗?我需要在属性名称中使用任何特殊的命名约定来将其转换为变量名称吗?(如## VSTS:[])?
我正在尝试在asp.net core 2.0应用程序中实现自定义授权策略。
在我的Custom AuthorizationHandler中,我有以下检查:
if (!context.User.Identity.IsAuthenticated)
{
this.logger.LogInformation("Failed to authorize user. User is not authenticated.");
return Task.CompletedTask;
}
// ... More authorization checks
Run Code Online (Sandbox Code Playgroud)
这很有意义,因为未经身份验证的用户无权执行我的控制器操作。
我正在使用JWT承载身份验证,并将其配置如下:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(cfg =>
{
cfg.RequireHttpsMetadata = false;
cfg.SaveToken = true;
cfg.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = "<issuer>",
ValidAudience = "<audience>",
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(signingKey)),
ValidateLifetime = false
};
});
Run Code Online (Sandbox Code Playgroud)
我还在注册我的授权要求和处理程序(请注意,这些注册发生在上面配置了身份验证之后,以及在我致电之前serivces.AddMVC():
services.AddAuthorization(options =>
{
options.AddPolicy(Constants.AuthorizationPolicies.MyCustomPolicy,
policy => policy.Requirements.Add(new MyCustomRequirement()));
});
services.AddScoped<IAuthorizationHandler, MyCustomAuthorizationHandler>();
Run Code Online (Sandbox Code Playgroud)
这是我的问题,看来我的授权策略在对jwt令牌进行质询和验证之前正在执行,结果是,由于未对用户进行身份验证,所以我的授权策略失败了。 …
c# ×3
asp.net-core ×2
nservicebus ×2
asp.net ×1
azure-devops ×1
github ×1
jwt ×1
pull-request ×1
ravendb ×1
release ×1
rider ×1
xunit.net ×1