Skip to content

Commit afbcb71

Browse files
authored
Fix a possible GC hole (dotnet#1890)
* Fix a possible GC hole See issue dotnet#1886. Will need another update when the new [RefEscapes] attribute is available, to make this finally really safe. Note: This removes the public AsSpan() method for netstandard2.0, because it cannot be made safe at all there. * Some attempt that ... doesn't work Because Span<T> does not implement any interfaces (a ref struct can't), this now fails to compile with the new API. * Remove AsSpan() altogether But rely on ValueArray implementing IReadOnlyList, which works just fine for our use cases. * Avoid an unnecessary boxing conversion * Avoid unnecessary memory allocation for foreach() loops * Add suppression for the now missing AsSpan() method * Remove ValueArray and adjust DHTxx accordingly * Update CompatibilitySuppressions.xml
1 parent 4bb9fa9 commit afbcb71

File tree

9 files changed

+65
-566
lines changed

9 files changed

+65
-566
lines changed

src/Iot.Device.Bindings/CompatibilitySuppressions.xml

+21
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,25 @@
210210
<Right>lib/netstandard2.0/Iot.Device.Bindings.dll</Right>
211211
<IsBaselineSuppression>true</IsBaselineSuppression>
212212
</Suppression>
213+
<Suppression>
214+
<DiagnosticId>CP0001</DiagnosticId>
215+
<Target>T:Iot.Device.Common.ValueArray`1</Target>
216+
<Left>lib/net6.0/Iot.Device.Bindings.dll</Left>
217+
<Right>lib/net6.0/Iot.Device.Bindings.dll</Right>
218+
<IsBaselineSuppression>true</IsBaselineSuppression>
219+
</Suppression>
220+
<Suppression>
221+
<DiagnosticId>CP0001</DiagnosticId>
222+
<Target>T:Iot.Device.Common.ValueArray`1</Target>
223+
<Left>lib/netcoreapp3.1/Iot.Device.Bindings.dll</Left>
224+
<Right>lib/netcoreapp3.1/Iot.Device.Bindings.dll</Right>
225+
<IsBaselineSuppression>true</IsBaselineSuppression>
226+
</Suppression>
227+
<Suppression>
228+
<DiagnosticId>CP0001</DiagnosticId>
229+
<Target>T:Iot.Device.Common.ValueArray`1</Target>
230+
<Left>lib/netstandard2.0/Iot.Device.Bindings.dll</Left>
231+
<Right>lib/netstandard2.0/Iot.Device.Bindings.dll</Right>
232+
<IsBaselineSuppression>true</IsBaselineSuppression>
233+
</Suppression>
213234
</Suppressions>

src/devices/Common/Iot/Device/Common/ValueArray.cs

-293
This file was deleted.

0 commit comments

Comments
 (0)