My repository in my organisation's devops project contains a lot of .net solutions and some unity projects as well. When I run my build pipeline, it fails due to several of these:
Error MSB3491: Could not write lines to file "obj\Release\path\to\file". There is not enough space on the disk.
I would like the pipeline to only checkout and fetch parts of the repository that are required for a successful build. This might also help with execution time of the pipeline …
我如何从功能中获取身体
Func<bool> methodCall = () => output.SendToFile();
if (methodCall())
Console.WriteLine("Success!");
Run Code Online (Sandbox Code Playgroud)
我需要将此"output.SendToFile()"作为字符串
另一个例子
string log = "";
public void Foo<T>(Func<T> func)
{
try
{
var t = func();
}
catch (Exception)
{
//here I need to add the body of the lambda
// log += func.body;
}
}
public void Test()
{
var a = 5;
var b = 6;
Foo(() => a > b);
}
Run Code Online (Sandbox Code Playgroud) 我有如下方法。
我想为以下方法编写两个测试用例。
1) A successful transaction with committing data
2) A failed transaction with rollback data
How can I write a test case with transaction involved and make success and fail?
public async Task<List<string>> UpdateRequest(MetaData data, List<string> Ids, string requestedBy)
{
var transaction = await _databaseUtility.CreateTransaction(ConnectionString);
var messages = new List<string>();
try
{
// Update data
await _testDal.Update(data, requestedBy, transaction);
// Update status
await _sampleDal.UpdateStatus(Ids, requestedBy, transaction);
// Update saved data
await _testDal.UpdateSavedData(data, requestedBy, transaction);
_databaseUtility.CommitTransaction(transaction);
}
catch (Exception exception) …Run Code Online (Sandbox Code Playgroud) 我正在编写 XUnit 测试用例。我收到以下错误
错误 CS1061“HttpStatusCode”不包含“应该”的定义,并且找不到接受“HttpStatusCode”类型的第一个参数的可访问扩展方法“应该”(您是否缺少 using 指令或程序集引用?)
错误说明了什么以及如何解决它。请任何人尝试帮助我。
谢谢..
我想并行调用我的API次数,以便可以快速完成处理。我下面有三种方法必须并行调用API。我试图了解哪种是执行此操作的最佳方法。
基本代码
var client = new System.Net.Http.HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.BaseAddress = new Uri("https://jsonplaceholder.typicode.com");
var list = new List<int>();
var listResults = new List<string>();
for (int i = 1; i < 5; i++)
{
list.Add(i);
}
Run Code Online (Sandbox Code Playgroud)
使用Parallel.ForEach的第一种方法
Parallel.ForEach(list,new ParallelOptions() { MaxDegreeOfParallelism = 3 }, index =>
{
var response = client.GetAsync("posts/" + index).Result;
var contents = response.Content.ReadAsStringAsync().Result;
listResults.Add(contents);
Console.WriteLine(contents);
});
Console.WriteLine("After all parallel tasks are done with Parallel for each");
Run Code Online (Sandbox Code Playgroud)
带有任务的第二种方法。我不确定这是否并行。让我知道是否可以
var loadPosts = new List<Task<string>>();
foreach(var post in list)
{ …Run Code Online (Sandbox Code Playgroud) 我下面有一节课,负责根据一些商业状况提出活动。
public class EventRaiserClass : IEventRaiserClass
{
public event EventHandler SendEventToClient;
public void RaiseEventForClient()
{
SendEventToClient?.Invoke(this, EventArgs.Empty);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的客户班
public class Client :IClient
{
EventRaiserClass _eventRaiser;
public Client(EventRaiserClass eventraiser)
{
_eventRaise = eventraise;
_iotGwStatus.SendEventToClient += OnSendEventToClient;
}
private async void OnSendEventToClient(object sender, EventArgs e)
{
await SendEventToClient();
}
public async Task SendEventToClient()
{
//do some operation
}
}
Run Code Online (Sandbox Code Playgroud)
EventRaiserClass 被注入到下面的类中,该类负责处理一些订单
public class ProcessRequest: IProcessRequest
{
IEventRaiserClass _evntRaiser;
public ProcessRequest(IEventRaiserClass evntRaiser)
{
_evntRaiser = evntRaiser;
}
public void Process(JObject json) …Run Code Online (Sandbox Code Playgroud)