diff --git a/inferredbugs-0045/instruction.md b/inferredbugs-0045/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..71ebeb8cdda0226a22d7c6ffd24224387c63aa41
--- /dev/null
+++ b/inferredbugs-0045/instruction.md
@@ -0,0 +1,473 @@
+# InferredBugs Task - Csharp
+
+## Project Information
+
+**Project:** ecommon
+**Bug ID:** 2
+**Language:** csharp
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```csharp
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using ECommon.Extensions;
+using ECommon.Logging;
+using ECommon.Utilities;
+
+namespace ECommon.IO
+{
+ /// An IO action helper class.
+ ///
+ public class IOHelper
+ {
+ private readonly ILogger _logger;
+
+ public IOHelper(ILoggerFactory loggerFactory)
+ {
+ _logger = loggerFactory.Create(GetType().FullName);
+ }
+
+ public void TryIOAction(string actionName, Func getContextInfo, Action action, int maxRetryTimes, bool continueRetryWhenRetryFailed = false, int retryInterval = 1000)
+ {
+ Ensure.NotNull(actionName, "actionName");
+ Ensure.NotNull(getContextInfo, "getContextInfo");
+ Ensure.NotNull(action, "action");
+ TryIOActionRecursivelyInternal(actionName, getContextInfo, (x, y, z) => action(), 0, maxRetryTimes, continueRetryWhenRetryFailed, retryInterval);
+ }
+ public T TryIOFunc(string funcName, Func getContextInfo, Func func, int maxRetryTimes, bool continueRetryWhenRetryFailed = false, int retryInterval = 1000)
+ {
+ Ensure.NotNull(funcName, "funcName");
+ Ensure.NotNull(getContextInfo, "getContextInfo");
+ Ensure.NotNull(func, "func");
+ return TryIOFuncRecursivelyInternal(funcName, getContextInfo, (x, y, z) => func(), 0, maxRetryTimes, continueRetryWhenRetryFailed, retryInterval);
+ }
+
+ #region TryAsyncActionRecursively
+
+ public void TryAsyncActionRecursively(
+ string asyncActionName,
+ Func> asyncAction,
+ Action mainAction,
+ Action successAction,
+ Func getContextInfoFunc,
+ Action failedAction,
+ int retryTimes,
+ bool retryWhenFailed = false,
+ int maxRetryTimes = 3,
+ int retryInterval = 1000) where TAsyncResult : AsyncTaskResult
+ {
+ try
+ {
+ asyncAction().ContinueWith(TaskContinueAction, new TaskExecutionContext
+ {
+ AsyncActionName = asyncActionName,
+ MainAction = mainAction,
+ SuccessAction = successAction,
+ GetContextInfoFunc = getContextInfoFunc,
+ FailedAction = failedAction,
+ RetryTimes = retryTimes,
+ RetryWhenFailed = retryWhenFailed,
+ MaxRetryTimes = maxRetryTimes,
+ RetryInterval = retryInterval
+ });
+ }
+ catch (IOException ex)
+ {
+ _logger.Error(string.Format("IOException raised when executing async task '{0}', contextInfo:{1}, current retryTimes:{2}, try to execute the async task again.", asyncActionName, GetContextInfo(getContextInfoFunc), retryTimes), ex);
+ ExecuteRetryAction(asyncActionName, getContextInfoFunc, mainAction, retryTimes, maxRetryTimes, retryInterval);
+ }
+ catch (Exception ex)
+ {
+ _logger.Error(string.Format("Unknown exception raised when executing async task '{0}', contextInfo:{1}, current retryTimes:{2}", asyncActionName, GetContextInfo(getContextInfoFunc), retryTimes), ex);
+ if (retryWhenFailed)
+ {
+ ExecuteRetryAction(asyncActionName, getContextInfoFunc, mainAction, retryTimes, maxRetryTimes, retryInterval);
+ }
+ else
+ {
+ ExecuteFailedAction(asyncActionName, getContextInfoFunc, failedAction, ex.Message);
+ }
+ }
+ }
+
+ private string GetContextInfo(Func func)
+ {
+ try
+ {
+ return func();
+ }
+ catch (Exception ex)
+ {
+ _logger.Error("Failed to execute the getContextInfoFunc.", ex);
+ return null;
+ }
+ }
+ private void ExecuteFailedAction(string asyncActionName, Func getContextInfoFunc, Action failedAction, string errorMessage)
+ {
+ try
+ {
+ if (failedAction != null)
+ {
+ failedAction(errorMessage);
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.Error(string.Format("Failed to execute the failedAction of asyncAction:{0}, contextInfo:{1}", asyncActionName, GetContextInfo(getContextInfoFunc)), ex);
+ }
+ }
+ private void ExecuteRetryAction(string asyncActionName, Func getContextInfoFunc, Action mainAction, int currentRetryTimes, int maxRetryTimes, int retryInterval)
+ {
+ try
+ {
+ if (currentRetryTimes >= maxRetryTimes)
+ {
+ Task.Factory.StartDelayedTask(retryInterval, () => mainAction(currentRetryTimes + 1));
+ }
+ else
+ {
+ mainAction(currentRetryTimes + 1);
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.Error(string.Format("Failed to execute the retryAction, asyncActionName:{0}, contextInfo:{1}", asyncActionName, GetContextInfo(getContextInfoFunc)), ex);
+ }
+ }
+ private void ProcessTaskException(string asyncActionName, Func getContextInfoFunc, Action mainAction, Action failedAction, Exception exception, int currentRetryTimes, int maxRetryTimes, int retryInterval, bool retryWhenFailed)
+ {
+ if (exception is IOException)
+ {
+ _logger.Error(string.Format("Async task '{0}' has io exception, contextInfo:{1}, current retryTimes:{2}, try to run the async task again.", asyncActionName, GetContextInfo(getContextInfoFunc), currentRetryTimes), exception);
+ ExecuteRetryAction(asyncActionName, getContextInfoFunc, mainAction, currentRetryTimes, maxRetryTimes, retryInterval);
+ }
+ else
+ {
+ _logger.Error(string.Format("Async task '{0}' has unknown exception, contextInfo:{1}, current retryTimes:{2}", asyncActionName, GetContextInfo(getContextInfoFunc), currentRetryTimes), exception);
+ if (retryWhenFailed)
+ {
+ ExecuteRetryAction(asyncActionName, getContextInfoFunc, mainAction, currentRetryTimes, maxRetryTimes, retryInterval);
+ }
+ else
+ {
+ ExecuteFailedAction(asyncActionName, getContextInfoFunc, failedAction, exception.Message);
+ }
+ }
+ }
+ private void TaskContinueAction(Task task, object obj) where TAsyncResult : AsyncTaskResult
+ {
+ var context = obj as TaskExecutionContext;
+ try
+ {
+ if (task.Exception != null)
+ {
+ ProcessTaskException(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.MainAction,
+ context.FailedAction,
+ task.Exception,
+ context.RetryTimes,
+ context.MaxRetryTimes,
+ context.RetryInterval,
+ context.RetryWhenFailed);
+ return;
+ }
+ if (task.IsCanceled)
+ {
+ _logger.ErrorFormat("Async task '{0}' was cancelled, contextInfo:{1}, current retryTimes:{2}.",
+ context.AsyncActionName,
+ GetContextInfo(context.GetContextInfoFunc),
+ context.RetryTimes);
+ ExecuteFailedAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.FailedAction,
+ string.Format("Async task '{0}' was cancelled.", context.AsyncActionName));
+ return;
+ }
+ var result = task.Result;
+ if (result == null)
+ {
+ _logger.ErrorFormat("Async task '{0}' result is null, contextInfo:{1}, current retryTimes:{2}",
+ context.AsyncActionName,
+ GetContextInfo(context.GetContextInfoFunc),
+ context.RetryTimes);
+ if (context.RetryWhenFailed)
+ {
+ ExecuteRetryAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.MainAction,
+ context.RetryTimes,
+ context.MaxRetryTimes,
+ context.RetryInterval);
+ }
+ else
+ {
+ ExecuteFailedAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.FailedAction,
+ string.Format("Async task '{0}' result is null.", context.AsyncActionName));
+ }
+ return;
+ }
+ if (result.Status == AsyncTaskStatus.Success)
+ {
+ if (context.SuccessAction != null)
+ {
+ context.SuccessAction(result);
+ }
+ }
+ else if (result.Status == AsyncTaskStatus.IOException)
+ {
+ _logger.ErrorFormat("Async task '{0}' result status is io exception, contextInfo:{1}, current retryTimes:{2}, errorMsg:{3}, try to run the async task again.",
+ context.AsyncActionName,
+ GetContextInfo(context.GetContextInfoFunc),
+ context.RetryTimes,
+ result.ErrorMessage);
+ ExecuteRetryAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.MainAction,
+ context.RetryTimes,
+ context.MaxRetryTimes,
+ context.RetryInterval);
+ }
+ else if (result.Status == AsyncTaskStatus.Failed)
+ {
+ _logger.ErrorFormat("Async task '{0}' failed, contextInfo:{1}, current retryTimes:{2}, errorMsg:{3}",
+ context.AsyncActionName,
+ GetContextInfo(context.GetContextInfoFunc),
+ context.RetryTimes,
+ result.ErrorMessage);
+ if (context.RetryWhenFailed)
+ {
+ ExecuteRetryAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.MainAction,
+ context.RetryTimes,
+ context.MaxRetryTimes,
+ context.RetryInterval);
+ }
+ else
+ {
+ ExecuteFailedAction(
+ context.AsyncActionName,
+ context.GetContextInfoFunc,
+ context.FailedAction,
+ result.ErrorMessage);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.Error(string.Format("Failed to execute the taskContinueAction, asyncActionName:{0}, contextInfo:{1}",
+ context.AsyncActionName,
+ GetContextInfo(context.GetContextInfoFunc)), ex);
+ }
+ }
+
+ class TaskExecutionContext
+ {
+ public string AsyncActionName;
+ public Action MainAction;
+ public Action SuccessAction;
+ public Func GetContextInfoFunc;
+ public Action FailedAction;
+ public int RetryTimes;
+ public bool RetryWhenFailed;
+ public int MaxRetryTimes;
+ public int RetryInterval;
+ }
+
+ #endregion
+
+ public void TryIOAction(Action action, string actionName)
+ {
+ Ensure.NotNull(action, "action");
+ Ensure.NotNull(actionName, "actionName");
+ try
+ {
+ action();
+ }
+ catch (IOException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(string.Format("{0} failed.", actionName), ex);
+ }
+ }
+ public Task TryIOActionAsync(Func action, string actionName)
+ {
+ Ensure.NotNull(action, "action");
+ Ensure.NotNull(actionName, "actionName");
+ try
+ {
+ return action();
+ }
+ catch (IOException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(string.Format("{0} failed.", actionName), ex);
+ }
+ }
+ public T TryIOFunc(Func func, string funcName)
+ {
+ Ensure.NotNull(func, "func");
+ Ensure.NotNull(funcName, "funcName");
+ try
+ {
+ return func();
+ }
+ catch (IOException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(string.Format("{0} failed.", funcName), ex);
+ }
+ }
+ public Task TryIOFuncAsync(Func> func, string funcName)
+ {
+ Ensure.NotNull(func, "func");
+ Ensure.NotNull(funcName, "funcName");
+ try
+ {
+ return func();
+ }
+ catch (IOException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException(string.Format("{0} failed.", funcName), ex);
+ }
+ }
+
+ private void TryIOActionRecursivelyInternal(string actionName, Func getContextInfo, Action, int> action, int retryTimes, int maxRetryTimes, bool continueRetryWhenRetryFailed = false, int retryInterval = 1000)
+ {
+ try
+ {
+ action(actionName, getContextInfo, retryTimes);
+ }
+ catch (IOException ex)
+ {
+ var errorMessage = string.Format("IOException raised when executing action '{0}', currentRetryTimes:{1}, maxRetryTimes:{2}, contextInfo:{3}", actionName, retryTimes, maxRetryTimes, getContextInfo());
+ _logger.Error(errorMessage, ex);
+ if (retryTimes >= maxRetryTimes)
+ {
+ if (!continueRetryWhenRetryFailed)
+ {
+ throw;
+ }
+ else
+ {
+ Thread.Sleep(retryInterval);
+ }
+ }
+ retryTimes++;
+ TryIOActionRecursivelyInternal(actionName, getContextInfo, action, retryTimes, maxRetryTimes, continueRetryWhenRetryFailed, retryInterval);
+ }
+ catch (Exception ex)
+ {
+ var errorMessage = string.Format("Unknown exception raised when executing action '{0}', currentRetryTimes:{1}, maxRetryTimes:{2}, contextInfo:{3}", actionName, retryTimes, maxRetryTimes, getContextInfo());
+ _logger.Error(errorMessage, ex);
+ throw;
+ }
+ }
+ private T TryIOFuncRecursivelyInternal(string funcName, Func getContextInfo, Func, long, T> func, int retryTimes, int maxRetryTimes, bool continueRetryWhenRetryFailed = false, int retryInterval = 1000)
+ {
+ try
+ {
+ return func(funcName, getContextInfo, retryTimes);
+ }
+ catch (IOException ex)
+ {
+ var errorMessage = string.Format("IOException raised when executing func '{0}', currentRetryTimes:{1}, maxRetryTimes:{2}, contextInfo:{3}", funcName, retryTimes, maxRetryTimes, getContextInfo());
+ _logger.Error(errorMessage, ex);
+ if (retryTimes >= maxRetryTimes)
+ {
+ if (!continueRetryWhenRetryFailed)
+ {
+ throw;
+ }
+ else
+ {
+ Thread.Sleep(retryInterval);
+ }
+ }
+ retryTimes++;
+ return TryIOFuncRecursivelyInternal(funcName, getContextInfo, func, retryTimes, maxRetryTimes, continueRetryWhenRetryFailed, retryInterval);
+ }
+ catch (Exception ex)
+ {
+ var errorMessage = string.Format("Unknown exception raised when executing func '{0}', currentRetryTimes:{1}, maxRetryTimes:{2}, contextInfo:{3}", funcName, retryTimes, maxRetryTimes, getContextInfo());
+ _logger.Error(errorMessage, ex);
+ throw;
+ }
+ }
+ }
+}
+
+```
+
+### Bug Type:
+NULL_DEREFERENCE
+
+### Qualifier:
+pointer `context` last assigned on line 150 could be null and is dereferenced at line 169, column 21.
+
+### Severity:
+ERROR
+
+### Procedure:
+Void IOHelper.TaskContinueAction(Task`1,Object)
+
+### File:
+src/ECommon/IO/IOHelper.cs
+
+### Key:
+IOHelper.cs|TaskContinueAction|NULL_DEREFERENCE
+
+### Node Key:
+52045082f0df3a0b2de3a487af64e105
+
+### Hash:
+d3b9f93f116fac7f98c718e9ed7e1e65
+
+### Bug Type Hum:
+Null Dereference
+
+## Task
+
+Analyze the bug information provided above. Your task is to:
+
+1. **Understand the Bug**: Examine the buggy code and identify what the issue was
+2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
+3. **Evaluate the Fix**: Understand how the after code addresses the issue
+4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
+
+### Analysis Questions:
+- What was the specific bug or issue in the original code?
+- What scenarios would trigger this bug?
+- How does the fix address the root cause?
+- Are there any potential edge cases the fix might miss?
+- What coding practices could have prevented this bug?
+- Are there alternative ways to implement the fix?
+
+Use the provided environment to explore, test, or reproduce the bug if needed.
diff --git a/inferredbugs-0100/instruction.md b/inferredbugs-0100/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..84dcab8b570536591661a571b8ea4a5f21fcb99f
--- /dev/null
+++ b/inferredbugs-0100/instruction.md
@@ -0,0 +1,130 @@
+# InferredBugs Task - Csharp
+
+## Project Information
+
+**Project:** Aspnetcore
+**Bug ID:** 1
+**Language:** csharp
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```csharp
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.IdentityModel.Tokens;
+using System;
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
+using System.Text;
+
+namespace JWTAuthentication.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class LoginController : Controller
+ {
+ private IConfiguration _config;
+
+ public LoginController(IConfiguration config)
+ {
+ _config = config;
+ }
+ [AllowAnonymous]
+ [HttpPost]
+ public IActionResult Login([FromBody]UserModel login)
+ {
+ IActionResult response = Unauthorized();
+ var user = AuthenticateUser(login);
+
+ if (user != null)
+ {
+ var tokenString = GenerateJSONWebToken(user);
+ response = Ok(new { token = tokenString });
+ }
+
+ return response;
+ }
+
+ private string GenerateJSONWebToken(UserModel userInfo)
+ {
+ var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
+ var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
+
+ var claims = new[] {
+ new Claim(JwtRegisteredClaimNames.Sub, userInfo.Username),
+ new Claim(JwtRegisteredClaimNames.Email, userInfo.EmailAddress),
+ new Claim("DateOfJoing", userInfo.DateOfJoing.ToString("yyyy-MM-dd")),
+ new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
+ };
+
+ var token = new JwtSecurityToken(_config["Jwt:Issuer"],
+ _config["Jwt:Issuer"],
+ claims,
+ expires: DateTime.Now.AddMinutes(120),
+ signingCredentials: credentials);
+
+ return new JwtSecurityTokenHandler().WriteToken(token);
+ }
+
+ private UserModel AuthenticateUser(UserModel login)
+ {
+ UserModel user = null;
+
+ //Validate the User Credentials
+ //Demo Purpose, I have Passed HardCoded User Information
+ if (user.Username == "Jignesh")
+ {
+ user = new UserModel { Username = "Jignesh Trivedi", EmailAddress = "test.btest@gmail.com", DateOfJoing = new DateTime(2010, 08, 02) };
+ }
+ return user;
+ }
+ }
+}
+```
+
+### Bug Type:
+NULLPTR_DEREFERENCE
+
+### Qualifier:
+`user` could be null (last assigned on line 61) and is dereferenced.
+
+### Severity:
+ERROR
+
+### Procedure:
+UserModel LoginController.AuthenticateUser(UserModel)
+
+### File:
+JWTAuthentication/JWTAuthentication/Controllers/LoginController.cs
+
+### Key:
+LoginController.cs|AuthenticateUser|NULLPTR_DEREFERENCE
+
+### Hash:
+1c7006d0e8f65d73bebefe2cbaebf3b0
+
+### Bug Type Hum:
+Null Dereference
+
+## Task
+
+Analyze the bug information provided above. Your task is to:
+
+1. **Understand the Bug**: Examine the buggy code and identify what the issue was
+2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
+3. **Evaluate the Fix**: Understand how the after code addresses the issue
+4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
+
+### Analysis Questions:
+- What was the specific bug or issue in the original code?
+- What scenarios would trigger this bug?
+- How does the fix address the root cause?
+- Are there any potential edge cases the fix might miss?
+- What coding practices could have prevented this bug?
+- Are there alternative ways to implement the fix?
+
+Use the provided environment to explore, test, or reproduce the bug if needed.
diff --git a/inferredbugs-0101/instruction.md b/inferredbugs-0101/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..d85db6e033b7b6889bb2d5e4211c2853531eda63
--- /dev/null
+++ b/inferredbugs-0101/instruction.md
@@ -0,0 +1,206 @@
+# InferredBugs Task - Csharp
+
+## Project Information
+
+**Project:** Mandrill-dotnet
+**Bug ID:** 1
+**Language:** csharp
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```csharp
+using Mandrill.Requests;
+using Mandrill.Utilities;
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Mandrill.Tests.UnitTests
+{
+ public class PostTests : IDisposable
+ {
+ public PostTests()
+ {
+ var responseMessage = new HttpResponseMessage();
+ var messageHandler = new FakeHttpMessageHandler(responseMessage);
+ httpClient = new HttpClient(messageHandler);
+ }
+ public void Dispose() {
+ httpClient?.Dispose();
+ }
+
+ private void RespondWith(MandrillApi api, HttpStatusCode statusCode, string content)
+ {
+ var responseMessage = new HttpResponseMessage(statusCode);
+ responseMessage.Content = new FakeHttpContent(content);
+ var messageHandler = new FakeHttpMessageHandler(responseMessage);
+ api.SetHttpClient(new HttpClient(messageHandler));
+ }
+
+ private HttpClient httpClient;
+
+ private class SampleObject
+ {
+ public string Name { get; set; }
+ public int Id { get; set; }
+ }
+
+ private class SamplePayload : RequestBase
+ {
+ }
+
+ [Fact]
+ public async Task Should_Serialize_Response_When_Json_Content_Is_Recieved()
+ {
+ string responseString = @"{
+ ""Name"": ""Shawn"",
+ ""Id"": 1
+ }";
+ var api = new MandrillApi("");
+ RespondWith(api, HttpStatusCode.OK, responseString);
+
+ SampleObject response = await api.Post("", new SamplePayload());
+
+ Assert.Equal("Shawn", response.Name);
+ Assert.Equal(1, response.Id);
+ }
+
+ [Fact]
+ public async Task Should_Throw_Mandrill_Exception_When_Server_Error()
+ {
+ string responseString = @"{
+ ""code"": ""501"",
+ ""message"": ""m1"",
+ ""name"": ""n1"",
+ ""status"": ""s1""
+ }";
+
+ var api = new MandrillApi("");
+ RespondWith(api, HttpStatusCode.InternalServerError, responseString);
+
+ var ex = await Assert.ThrowsAsync(async () => await api.Post