Here is a couple of compiler generated warnings I found on project I was recently reviewing:
- warning CS0618: ‘Device.OS’ is obsolete: ‘TargetPlatform is obsolete as of version 2.3.4. Please use RuntimePlatform instead.’
- warning CS0612: ‘TargetPlatform’ is obsolete
A CS0612 is generated when the code references a type or member to wich the parameterless ObsoleteAttribute was applied.
A CS0618 is generated when the code references a type or member to wich a parameterized ObsoleteAttribute was applied.
In this case, the reference to Device.OS has to be replaced with a reference to Device.RuntimePlatform.
Since Device.OS was an enum of type TargetPlatform and Device.RuntimePlatform is a string, it is necessary to update the right hand of the expression as well.
For that you can use one of the string constants defined on the Device class:
Here’s how the code looked like originally:
And here’s how the looks code after the update: