Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Use nameof for all ToString overrides #539

Merged
merged 1 commit into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Xamarin.Essentials/Accelerometer/Accelerometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public override int GetHashCode() =>
Acceleration.GetHashCode();

public override string ToString() =>
$"X: {Acceleration.X}, Y: {Acceleration.Y}, Z: {Acceleration.Z}";
$"{nameof(Acceleration.X)}: {Acceleration.X}, " +
$"{nameof(Acceleration.Y)}: {Acceleration.Y}, " +
$"{nameof(Acceleration.Z)}: {Acceleration.Z}";
}
}
2 changes: 1 addition & 1 deletion Xamarin.Essentials/Barometer/Barometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public bool Equals(BarometerData other) =>
public override int GetHashCode() =>
Pressure.GetHashCode();

public override string ToString() => $"Pressure: {Pressure}";
public override string ToString() => $"{nameof(Pressure)}: {Pressure}";
}
}
4 changes: 3 additions & 1 deletion Xamarin.Essentials/Battery/Battery.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ internal BatteryChangedEventArgs(double level, BatteryState state, BatteryPowerS
public BatteryPowerSource PowerSource { get; }

public override string ToString() =>
$"ChargeLevel: {ChargeLevel}, State: {State}, PowerSource: {PowerSource}";
$"{nameof(ChargeLevel)}: {ChargeLevel}, " +
$"{nameof(State)}: {State}, " +
$"{nameof(PowerSource)}: {PowerSource}";
}
}
2 changes: 1 addition & 1 deletion Xamarin.Essentials/Compass/Compass.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ public override int GetHashCode() =>
HeadingMagneticNorth.GetHashCode();

public override string ToString() =>
$"HeadingMagneticNorth: {HeadingMagneticNorth}";
$"{nameof(HeadingMagneticNorth)}: {HeadingMagneticNorth}";
}
}
3 changes: 2 additions & 1 deletion Xamarin.Essentials/Connectivity/Connectivity.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal ConnectivityChangedEventArgs(NetworkAccess access, IEnumerable<Connecti
public IEnumerable<ConnectionProfile> Profiles { get; }

public override string ToString() =>
$"NetworkAccess: {NetworkAccess}, Profiles: [{string.Join(", ", Profiles)}]";
$"{nameof(NetworkAccess)}: {NetworkAccess}, " +
$"{nameof(Profiles)}: [{string.Join(", ", Profiles)}]";
}
}
4 changes: 3 additions & 1 deletion Xamarin.Essentials/DeviceDisplay/DeviceDisplay.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public override int GetHashCode() =>
(Height, Width, Density, Orientation, Rotation).GetHashCode();

public override string ToString() =>
$"Height: {Height}, Width: {Width}, Density: {Density}, Orientation: {Orientation}, Rotation: {Rotation}";
$"{nameof(Height)}: {Height}, {nameof(Width)}: {Width}, " +
$"{nameof(Density)}: {Density}, {nameof(Orientation)}: {Orientation}, " +
$"{nameof(Rotation)}: {Rotation}";
}

public enum ScreenOrientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public GeolocationRequest(GeolocationAccuracy accuracy, TimeSpan timeout)
public GeolocationAccuracy DesiredAccuracy { get; set; }

public override string ToString() =>
$"DesiredAccuracy: {DesiredAccuracy}, Timeout: {Timeout}";
$"{nameof(DesiredAccuracy)}: {DesiredAccuracy}, {nameof(Timeout)}: {Timeout}";
}
}
4 changes: 3 additions & 1 deletion Xamarin.Essentials/Gyroscope/Gyroscope.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public override int GetHashCode() =>
AngularVelocity.GetHashCode();

public override string ToString() =>
$"X: {AngularVelocity.X}, Y: {AngularVelocity.Y}, Z: {AngularVelocity.Z}";
$"{nameof(AngularVelocity.X)}: {AngularVelocity.X}, " +
$"{nameof(AngularVelocity.Y)}: {AngularVelocity.Y}, " +
$"{nameof(AngularVelocity.Z)}: {AngularVelocity.Z}";
}
}
4 changes: 3 additions & 1 deletion Xamarin.Essentials/Magnetometer/Magnetometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public override int GetHashCode() =>
MagneticField.GetHashCode();

public override string ToString() =>
$"X: {MagneticField.X}, Y: {MagneticField.Y}, Z: {MagneticField.Z}";
$"{nameof(MagneticField.X)}: {MagneticField.X}, " +
$"{nameof(MagneticField.Y)}: {MagneticField.Y}, " +
$"{nameof(MagneticField.Z)}: {MagneticField.Z}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public override int GetHashCode() =>
Orientation.GetHashCode();

public override string ToString() =>
$"X: {Orientation.X}, Y: {Orientation.Y}, Z: {Orientation.Z}, W: {Orientation.W}";
$"{nameof(Orientation.X)}: {Orientation.X}, " +
$"{nameof(Orientation.Y)}: {Orientation.Y}, " +
$"{nameof(Orientation.Z)}: {Orientation.Z}, " +
$"{nameof(Orientation.W)}: {Orientation.W}";
}
}
8 changes: 8 additions & 0 deletions Xamarin.Essentials/Types/Placemark.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,13 @@ public Placemark(Placemark placemark)
public string AdminArea { get; set; }

public string SubAdminArea { get; set; }

public override string ToString() =>
$"{nameof(Location)}: {Location}, {nameof(CountryCode)}: {CountryCode}, " +
$"{nameof(CountryName)}: {CountryName}, {nameof(FeatureName)}: {FeatureName}, " +
$"{nameof(PostalCode)}: {PostalCode}, {nameof(SubLocality)}: {SubLocality}, " +
$"{nameof(Thoroughfare)}: {Thoroughfare}, {nameof(SubThoroughfare)}: {SubThoroughfare}, " +
$"{nameof(Locality)}: {Locality}, {nameof(AdminArea)}: {AdminArea}, " +
$"{nameof(SubAdminArea)}: {SubAdminArea}";
}
}