Version Used:
16.5 preview3
Steps to Reproduce:
using System;
public class C {
public string M1(string obj) {
return (string)obj;
}
public string M2(string obj) {
return obj as string;
}
}
Expected Behavior:
The as string in M2 should also be reported as unnessary as it does in M1.
And it does work for Visual Basic
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEA3YaAmIA1AD4AKArsBgJZgAEAwhgIYDObTAsAFD3/1K1OvQBiFAHZgALjQgT6AWQCMACgBCATwBqLDPQjAAVvQCCnAMrSoNCQHMAlGcvXbd3gM/0ASjGkUoBUMjDwEAUQl8MUkZOQleUP4hWgZxKVl5JQAmDR09A2NneisbeydzYtd7RK9ff0D6ABUoTUZ2aVVgtErSxxqIqLTY+V4BplYOXiA=
Actual Behavior:
The as string in M2 is not reported as unnessary in source code, but seems compiler already know that and it's included in output IL.
Version Used:
16.5 preview3
Steps to Reproduce:
Expected Behavior:
The
as stringinM2should also be reported as unnessary as it does inM1.And it does work for Visual Basic
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEA3YaAmIA1AD4AKArsBgJZgAEAwhgIYDObTAsAFD3/1K1OvQBiFAHZgALjQgT6AWQCMACgBCATwBqLDPQjAAVvQCCnAMrSoNCQHMAlGcvXbd3gM/0ASjGkUoBUMjDwEAUQl8MUkZOQleUP4hWgZxKVl5JQAmDR09A2NneisbeydzYtd7RK9ff0D6ABUoTUZ2aVVgtErSxxqIqLTY+V4BplYOXiA=
Actual Behavior:
The
as stringinM2is not reported as unnessary in source code, but seems compiler already know that and it's included in output IL.