I have to replace ~250 instances of object initializers with a constructor with the same parameters.
This is an example of my object initializer:
throw new FaultException<DTFaultDetail>(new DTFaultDetail
{
IsUserWarning = true,
HttpStatusCode = (int)HttpStatusCode.Forbidden,
Category = (int)FaultCategory.User,
ErrorCode = (int)FaultCode.Jobs_TimesheetOverlapsExisting,
UserMessage = UserStrings.TimesheetOverlapsExisting,
DebugMessage = $"",
TicksUsedBeforeFailure = DbContext.RequestInfo.TotalTicksUsed,
Origin = new DTFaultDetail.FaultOrigin
{
Session = Session,
ThreadID = Thread.CurrentThread.ManagedThreadId,
Source = $"{FullNameOfThisClass}.{MethodBase.GetCurrentMethod()})"
}
});
And I had to replace it with this:
throw new FaultException<DTFaultDetail>(new DTFaultDetail(
isUserWarning: true,
httpStatusCode: (int)HttpStatusCode.Forbidden,
category: (int)FaultCategory.User,
errorCode: (int)FaultCode.Jobs_TimesheetOverlapsExisting,
userMessage: UserStrings.TimesheetOverlapsExisting,
debugMessage: $"",
ticksUsedBeforeFailure: DbContext.RequestInfo.TotalTicksUsed,
origin: new DTFaultDetail.FaultOrigin
{
Session = Session,
ThreadID = Thread.CurrentThread.ManagedThreadId,
Source = $"{FullNameOfThisClass}.{MethodBase.GetCurrentMethod()})"
}));
How can I do that quickly, using built-in features of Visual Studio (2015)?
Besides manual replacement, of course.