DustinCampbell / CSharpEssentials

C# Essentials is a collection of Roslyn diagnostic analyzers, code fixes and refactorings that make it easy to work with C# 6 language features.
Other
160 stars 26 forks source link

CSE0003 is raised on methods which have conditional compilation #34

Open rmaclean opened 9 years ago

rmaclean commented 9 years ago

In the following code the CSE0003 warning is raised, implying it should be an expression bodied member when it cannot be because it isn't a single line. Worse is the suggested fix removes code.

private static string DeviceID()
{
#if WINDOWS_PHONE_APP
    var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
    var hardwareId = token.Id;
    var dataReader = DataReader.FromBuffer(hardwareId);

    byte[] bytes = new byte[hardwareId.Length];
    dataReader.ReadBytes(bytes);

    return BitConverter.ToString(bytes);
#endif
#if WINDOWS_UWP
    return " arrgggh Windows 10";
#endif

}
DustinCampbell commented 9 years ago

Great bug -- thanks!