diff --git a/Changelog.md b/Changelog.md
index da05365d..0681d08c 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,5 +1,14 @@
# Changelog
+13/05/2026
+
+Version 8.0.15.2
+
+* Fixed [#47](https://github.com/PWagner1/Windows-API-CodePack-NET/pull/47), `WindowsAPICodePackSensors` throws a `NullReferenceException` when enumerating ambient light sensors (thanks to [xaviergonz](https://github.com/xaviergonz))
+* Fixed file & NuGet package version alignment
+
+=========
+
02/04/2026
Version 8.0.15.1
diff --git a/Directory.Build.props b/Directory.Build.props
index 121bdbe8..5057db7a 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,6 +1,6 @@
- 8.0.17
- 8.0.17
+ 8.0.15.2
+ 8.0.15.2
\ No newline at end of file
diff --git a/Source/Current/Windows API CodePack/Components/Core/AppRestartRecovery/RecoveryData.cs b/Source/Current/Windows API CodePack/Components/Core/AppRestartRecovery/RecoveryData.cs
index ba6df2a5..a1eaa096 100644
--- a/Source/Current/Windows API CodePack/Components/Core/AppRestartRecovery/RecoveryData.cs
+++ b/Source/Current/Windows API CodePack/Components/Core/AppRestartRecovery/RecoveryData.cs
@@ -48,6 +48,6 @@ public RecoveryData(RecoveryCallback callback, object state)
///
public void Invoke()
{
- if (Callback != null) { Callback(State); }
+ Callback?.Invoke(State);
}
}
\ No newline at end of file
diff --git a/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialog.cs b/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialog.cs
index 6a6473c6..483f1f40 100644
--- a/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialog.cs
+++ b/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialog.cs
@@ -1140,10 +1140,7 @@ internal void RaiseButtonClickEvent(int id)
internal void RaiseHyperlinkClickEvent(string link)
{
EventHandler? handler = HyperlinkClick;
- if (handler != null)
- {
- handler(this, new TaskDialogHyperlinkClickedEventArgs(link));
- }
+ handler?.Invoke(this, new TaskDialogHyperlinkClickedEventArgs(link));
}
// Gives event subscriber a chance to prevent
@@ -1193,17 +1190,17 @@ internal int RaiseClosingEvent(int id)
internal void RaiseHelpInvokedEvent()
{
- if (HelpInvoked != null) { HelpInvoked(this, EventArgs.Empty); }
+ HelpInvoked?.Invoke(this, EventArgs.Empty);
}
internal void RaiseOpenedEvent()
{
- if (Opened != null) { Opened(this, EventArgs.Empty); }
+ Opened?.Invoke(this, EventArgs.Empty);
}
internal void RaiseTickEvent(int ticks)
{
- if (Tick != null) { Tick(this, new TaskDialogTickEventArgs(ticks)); }
+ Tick?.Invoke(this, new TaskDialogTickEventArgs(ticks));
}
#endregion
diff --git a/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialogButtonBase.cs b/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialogButtonBase.cs
index 47d1498d..54ea66a7 100644
--- a/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialogButtonBase.cs
+++ b/Source/Current/Windows API CodePack/Components/Core/Dialogs/TaskDialogs/TaskDialogButtonBase.cs
@@ -46,8 +46,8 @@ internal void RaiseClickEvent()
{
// Only perform click if the button is enabled.
if (!_enabled) { return; }
-
- if (Click != null) { Click(this, EventArgs.Empty); }
+
+ Click?.Invoke(this, EventArgs.Empty);
}
private string? _text;
diff --git a/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj b/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj
index 65c134ac..2590c583 100644
--- a/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj
+++ b/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj
@@ -29,26 +29,26 @@
DynamicLibrary
true
- v143
+ v145
Unicode
DynamicLibrary
false
- v143
+ v145
true
Unicode
DynamicLibrary
true
- v143
+ v145
Unicode
DynamicLibrary
false
- v143
+ v145
true
Unicode
diff --git a/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj.filters b/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj.filters
index ecd244cd..99795624 100644
--- a/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj.filters
+++ b/Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj.filters
@@ -1,8 +1,10 @@
-
-
+
+ Resource Files
+
+
diff --git a/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/Sensor.cs b/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/Sensor.cs
index 9694fdce..93684c58 100644
--- a/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/Sensor.cs
+++ b/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/Sensor.cs
@@ -333,26 +333,24 @@ public override string ToString()
/// A property value.
public object? GetProperty(PropertyKey propKey)
{
- using (PropVariant pv = new())
+ using PropVariant pv = new();
+ HResult hr = _nativeISensor.GetProperty(ref propKey, pv);
+ if (hr != HResult.Ok)
{
- HResult hr = _nativeISensor.GetProperty(ref propKey, pv);
- if (hr != HResult.Ok)
+ Exception e = Marshal.GetExceptionForHR((int)hr);
+ if (hr == HResult.ElementNotFound)
+ {
+ throw new ArgumentOutOfRangeException(LocalizedMessages.SensorPropertyNotFound, e);
+ }
+ else
{
- Exception e = Marshal.GetExceptionForHR((int)hr);
- if (hr == HResult.ElementNotFound)
+ if (e != null)
{
- throw new ArgumentOutOfRangeException(LocalizedMessages.SensorPropertyNotFound, e);
- }
- else
- {
- if (e != null)
- {
- throw e;
- }
+ throw e;
}
}
- return pv.Value;
}
+ return pv.Value;
}
///
@@ -403,11 +401,9 @@ public override string ToString()
for (uint i = 0; i < count; i++)
{
PropertyKey propKey = new();
- using (PropVariant propVal = new())
- {
- valuesCollection.GetAt(i, ref propKey, propVal);
- data.Add(propKey, propVal.Value);
- }
+ using PropVariant propVal = new();
+ valuesCollection.GetAt(i, ref propKey, propVal);
+ data.Add(propKey, propVal.Value);
}
}
finally
@@ -517,13 +513,11 @@ public override string ToString()
for (uint i = 0; i < count; i++)
{
PropertyKey propKey = new();
- using (PropVariant propVal = new())
- {
- valuesCollection.GetAt(i, ref propKey, propVal);
+ using PropVariant propVal = new();
+ valuesCollection.GetAt(i, ref propKey, propVal);
- int idx = propKeyToIdx[propKey];
- data[idx] = propVal.Value;
- }
+ int idx = propKeyToIdx[propKey];
+ data[idx] = propVal.Value;
}
}
finally
@@ -570,10 +564,8 @@ public override string ToString()
{
// new PropVariant will throw an ArgumentException if the value can
// not be converted to an appropriate PropVariant.
- using (PropVariant pv = PropVariant.FromObject(value))
- {
- pdv.SetValue(ref propKey, pv);
- }
+ using PropVariant pv = PropVariant.FromObject(value);
+ pdv.SetValue(ref propKey, pv);
}
catch (ArgumentException)
{
@@ -607,11 +599,9 @@ public override string ToString()
for (uint i = 0; i < count; i++)
{
PropertyKey propKey = new();
- using (PropVariant propVal = new())
- {
- pdv2.GetAt(i, ref propKey, propVal);
- results.Add(propKey, propVal.Value);
- }
+ using PropVariant propVal = new();
+ pdv2.GetAt(i, ref propKey, propVal);
+ results.Add(propKey, propVal.Value);
}
}
finally
diff --git a/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/SensorData.cs b/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/SensorData.cs
index dc75e51e..ebc69c12 100644
--- a/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/SensorData.cs
+++ b/Source/Current/Windows API CodePack/Components/Sensors/ObjectModel/SensorData.cs
@@ -24,23 +24,21 @@ public class SensorData : IDictionary>
for (uint index = 0; index < items; index++)
{
PropertyKey key;
- using (PropVariant propValue = new())
- {
- keyCollection.GetAt(index, out key);
- valuesCollection?.GetValue(ref key, propValue);
+ using PropVariant propValue = new();
+ keyCollection.GetAt(index, out key);
+ valuesCollection?.GetValue(ref key, propValue);
- if (data.ContainsKey(key.FormatId))
- {
- if (propValue.Value != null)
- {
- data[key.FormatId].Add(propValue.Value);
- }
- }
- else
+ if (data.ContainsKey(key.FormatId))
+ {
+ if (propValue.Value != null)
{
- data.Add(key.FormatId, new List