Skip to content

Commit

Permalink
feat: Annotate LightSensor
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Nov 25, 2022
1 parent 122744d commit d8ef246
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/Uno.UI/LinkerDefinition.Wasm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
<type fullname="Windows.Devices.Sensors.Magnetometer">
<method name="DispatchReading" />
</type>
<type fullname="Windows.Devices.Sensors.LightSensor">
<method name="DispatchReading" />
</type>
<type fullname="Windows.Networking.Connectivity.NetworkInformation">
<method name="DispatchStatusChanged" />
</type>
Expand Down
4 changes: 4 additions & 0 deletions src/Uno.UWP/Devices/Sensors/LightSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#nullable enable

using System;
using System.Diagnostics.CodeAnalysis;
using Uno.Helpers;
using Windows.Foundation;

Expand All @@ -17,6 +18,9 @@ public partial class LightSensor

private readonly StartStopEventWrapper<TypedEventHandler<LightSensor, LightSensorReadingChangedEventArgs>> _readingChangedWrapper;

#if __WASM__
[DynamicDependency(nameof(DispatchReading))]
#endif
private LightSensor()
{
_readingChangedWrapper = new StartStopEventWrapper<TypedEventHandler<LightSensor, LightSensorReadingChangedEventArgs>>(
Expand Down
1 change: 0 additions & 1 deletion src/Uno.UWP/Devices/Sensors/LightSensor.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ private void StopReading()
Uno.Foundation.WebAssemblyRuntime.InvokeJS(command);
}

[Preserve]
public static int DispatchReading(float lux)
{
var reading = new LightSensorReading(lux, DateTimeOffset.UtcNow);
Expand Down

0 comments on commit d8ef246

Please sign in to comment.