I have code much like this in a Visual Studio test project (so it has a reference to Microsoft.QualityTools.Testing.Fakes), with a fakes assembly generated for System.Data:
enum DbPicStatus { UnknownPic, InvalidPic, ValidPic }
IDataReader Demo(DbPicStatus a_dbPicStatus)
{
int readCalled = 0;
return new System.Data.Fakes.StubIDataReader
{
GetOrdinalString = (a_colName) =>
{
if (readCalled != 1) { throw new InvalidOperationException("Read did not return true."); }
if (a_colName.ToUpper() == "IMPB") { return 1; }
throw new InvalidDataException($"Column {a_colName} is unknown.");
},
GetStringInt32 = (a_idx) =>
{
if (a_idx != 1) { throw new ArgumentException($"Unknown column {a_idx}.", nameof(a_idx)); }
switch (a_dbPicStatus)
{
case DbPicStatus.ValidPic: return "IMPB";
case DbPicStatus.InvalidPic: return "INVALID_IMPB";
default:
Assert.Fail($"Unknown PIC status {a_dbPicStatus}.");
break/* Try to add a semicolon to this line, either before or after this comment. */
}
return null;
},
Read = () => a_dbPicStatus == DbPicStatus.UnknownPic ? false : ++readCalled == 1,
};/* Insertion point incorrectly moves to the beginning of this comment. */
}
The testing tools and fakes assemblies are not necessary for demonstrating this issue. When you paste this into a class with the necessary references and usings, there will be two errors. One on the nameof expression, and one at the end of the break statement. If you don't have those references and usings, there will be more errors, but the reproduction will still work just fine:
With Smart semicolon turned on, try to add a semicolon after the break statement.
The expected behavior is that a semicolon appears. The actual behavior is that the insertion point is moved right after the semicolon on the second-to-last line, as indicated by the comment on that line.
Hi Dale,
Thank you for the code snippet. I have reproduced the issue, and we are working on it. We will update this ticket once we make any progress.