This issue has been moved from a ticket on Developer Community.
private static ProgrammingProgress ProgrammingSuccessResponse(ProgrammingProgress currentState, stMsg_t responseMessage) =>
responseMessage.stTxMsg.stHeader.wCmd // not my code
switch
{
(ushort)eMonCommsCommands_t.MC_CMD_PROG_START => FromSuccessfulResponse(currentState, ProgrammingProgressState.StartedReceiving),
(ushort)eMonCommsCommands_t.MC_CMD_PROG_DATA => FromSuccessfulResponse(currentState, ProgrammingProgressState.Receiving),
(ushort)eMonCommsCommands_t.MC_CMD_PROG_END => FromSuccessfulResponse(currentState, ProgrammingProgressState.StoppedReceiving),
_ => ErrorState(currentState, responseMessage)
};
where responseMessage.stTxMsg.stHeader.wCmd is an enum and (ushort)eMonCommsCommands_t.MC_CMD_PROG_START is a ushort.
This works OK because of the cast - however an attempt to increase legibility like this:
private static ProgrammingProgress ProgrammingSuccessResponse(ProgrammingProgress currentState, stMsg_t responseMessage) =>
(eMonCommsCommands_t)responseMessage.stTxMsg.stHeader.wCmd // VS - suggests the case is redundant - but removing it
switch
{
eMonCommsCommands_t.MC_CMD_PROG_START => FromSuccessfulResponse(currentState, ProgrammingProgressState.StartedReceiving),
eMonCommsCommands_t.MC_CMD_PROG_DATA => FromSuccessfulResponse(currentState, ProgrammingProgressState.Receiving),
eMonCommsCommands_t.MC_CMD_PROG_END => FromSuccessfulResponse(currentState, ProgrammingProgressState.StoppedReceiving),
_ => ErrorState(currentState, responseMessage)
};
and Visual Studio ( 2019 16..4.0 Preview 5.0) suggests the cast is redundant - removing the cast causes the each switch clause except the default to barf.
Original Comments
Visual Studio Feedback System on 11/21/2019, 00:06 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
This issue has been moved from a ticket on Developer Community.
where responseMessage.stTxMsg.stHeader.wCmd is an enum and (ushort)eMonCommsCommands_t.MC_CMD_PROG_START is a ushort.
This works OK because of the cast - however an attempt to increase legibility like this:
private static ProgrammingProgress ProgrammingSuccessResponse(ProgrammingProgress currentState, stMsg_t responseMessage) =>
(eMonCommsCommands_t)responseMessage.stTxMsg.stHeader.wCmd // VS - suggests the case is redundant - but removing it
switch
{
eMonCommsCommands_t.MC_CMD_PROG_START => FromSuccessfulResponse(currentState, ProgrammingProgressState.StartedReceiving),
eMonCommsCommands_t.MC_CMD_PROG_DATA => FromSuccessfulResponse(currentState, ProgrammingProgressState.Receiving),
eMonCommsCommands_t.MC_CMD_PROG_END => FromSuccessfulResponse(currentState, ProgrammingProgressState.StoppedReceiving),
_ => ErrorState(currentState, responseMessage)
};
and Visual Studio ( 2019 16..4.0 Preview 5.0) suggests the cast is redundant - removing the cast causes the each switch clause except the default to barf.
Original Comments
Visual Studio Feedback System on 11/21/2019, 00:06 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)