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

Commit

Permalink
Add ToString overrides on a bunch of types to improve debugging infor…
Browse files Browse the repository at this point in the history
…mation (#531)

* Add ToString overrides on a bunch of types to improve debugging information

* Remove trailing spaces
  • Loading branch information
Cheesebaron authored and jamesmontemagno committed Oct 4, 2018
1 parent eba3db5 commit 976be95
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Accelerometer/Accelerometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,8 @@ public bool Equals(AccelerometerData other) =>

public override int GetHashCode() =>
Acceleration.GetHashCode();

public override string ToString() =>
$"X: {Acceleration.X}, Y: {Acceleration.Y}, Z: {Acceleration.Z}";
}
}
2 changes: 2 additions & 0 deletions Xamarin.Essentials/Barometer/Barometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,7 @@ public bool Equals(BarometerData other) =>

public override int GetHashCode() =>
Pressure.GetHashCode();

public override string ToString() => $"Pressure: {Pressure}";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Battery/Battery.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ internal BatteryChangedEventArgs(double level, BatteryState state, BatteryPowerS
public BatteryState State { get; }

public BatteryPowerSource PowerSource { get; }

public override string ToString() =>
$"ChargeLevel: {ChargeLevel}, State: {State}, PowerSource: {PowerSource}";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Compass/Compass.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@ public bool Equals(CompassData other) =>

public override int GetHashCode() =>
HeadingMagneticNorth.GetHashCode();

public override string ToString() =>
$"HeadingMagneticNorth: {HeadingMagneticNorth}";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Connectivity/Connectivity.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@ internal ConnectivityChangedEventArgs(NetworkAccess access, IEnumerable<Connecti
public NetworkAccess NetworkAccess { get; }

public IEnumerable<ConnectionProfile> Profiles { get; }

public override string ToString() =>
$"NetworkAccess: {NetworkAccess}, Profiles: [{string.Join(", ", Profiles)}]";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/DeviceDisplay/DeviceDisplay.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public bool Equals(ScreenMetrics other) =>

public override int GetHashCode() =>
(Height, Width, Density, Orientation, Rotation).GetHashCode();

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

public enum ScreenOrientation
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Geolocation/GeolocationRequest.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ public GeolocationRequest(GeolocationAccuracy accuracy, TimeSpan timeout)
public TimeSpan Timeout { get; set; }

public GeolocationAccuracy DesiredAccuracy { get; set; }

public override string ToString() =>
$"DesiredAccuracy: {DesiredAccuracy}, Timeout: {Timeout}";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Gyroscope/Gyroscope.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ public bool Equals(GyroscopeData other) =>

public override int GetHashCode() =>
AngularVelocity.GetHashCode();

public override string ToString() =>
$"X: {AngularVelocity.X}, Y: {AngularVelocity.Y}, Z: {AngularVelocity.Z}";
}
}
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Magnetometer/Magnetometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ public bool Equals(MagnetometerData other) =>

public override int GetHashCode() =>
MagneticField.GetHashCode();

public override string ToString() =>
$"X: {MagneticField.X}, Y: {MagneticField.Y}, Z: {MagneticField.Z}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ public bool Equals(OrientationSensorData other) =>

public override int GetHashCode() =>
Orientation.GetHashCode();

public override string ToString() =>
$"X: {Orientation.X}, Y: {Orientation.Y}, Z: {Orientation.Z}, W: {Orientation.W}";
}
}

0 comments on commit 976be95

Please sign in to comment.