Skip to content
Draft
6 changes: 6 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@
<PackageReference Include="SIL.ReleaseTasks" Version="2.5.0" PrivateAssets="All" Condition="'$(Configuration)' != 'Debug'" />
</ItemGroup>

<!-- "Sentry" uses "Polyfill" and gives access to it's internals via "InternalsVisibleTo", but some Polyfills are in a separate namespace -->
<ItemGroup Condition="'$(MSBuildProjectName)' != 'Sentry' And $(MSBuildProjectName.StartsWith('Sentry.'))">
<!-- the latest TargetFramework requires no Polyfills; "Sentry.Compiler.Extensions" has its own Polyfills; "Android" and "Cocoa" projects are referenced by "Sentry" -->
<Using Include="Polyfills" Condition="'$(TargetFramework)' != $(LatestTfm) And $(MSBuildProjectName) != 'Sentry.Compiler.Extensions' And $(MSBuildProjectName) != 'Sentry.Android.AssemblyReader' And $(MSBuildProjectName) != 'Sentry.Bindings.Android' And $(MSBuildProjectName) != 'Sentry.Bindings.Cocoa'" />
</ItemGroup>

</Project>
13 changes: 12 additions & 1 deletion src/Sentry.Analyzers/Sentry.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@
https://github.com/SimonCropp/Polyfill
-->
<ItemGroup>
<PackageReference Include="Polyfill" Version="1.32.0" PrivateAssets="all" />
<PackageReference Include="Polyfill" Version="9.8.1" PrivateAssets="all" />
</ItemGroup>
<!-- We currently don't require Polyfills for System.Memory. Ensure the feature is disabled and suppress the MSBuild Warning from Polyfill. -->
<Target Name="BeforePreparePolyfill" BeforeTargets="PreparePolyfill">
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PolyfillNoWarnIncorrectVersion>true</PolyfillNoWarnIncorrectVersion>
</PropertyGroup>
</Target>
<Target Name="AfterPreparePolyfill" AfterTargets="PreparePolyfill" DependsOnTargets="PreparePolyfill">
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$([System.String]::Copy('$(DefineConstants)').Replace('FeatureMemory','').Replace(';;',';'))</DefineConstants>
</PropertyGroup>
</Target>

<ItemGroup>
<Using Remove="System.Text.Json" />
Expand Down
8 changes: 2 additions & 6 deletions src/Sentry/Internal/Extensions/CollectionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,14 @@ public static IEnumerable<KeyValuePair<TKey, TValue>> WhereNotNullValue<TKey, TV
}
}
}

public static IEnumerable<KeyValuePair<TKey, TValue>> Append<TKey, TValue>(
this IEnumerable<KeyValuePair<TKey, TValue>> source, TKey key, TValue value) =>
source.Append(new KeyValuePair<TKey, TValue>(key, value));

public static IReadOnlyList<T> AsReadOnly<T>(this IList<T> list) =>
list as IReadOnlyList<T> ?? new ReadOnlyCollection<T>(list);

#if !NET7_0_OR_GREATER
public static IReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
where TKey : notnull =>
new ReadOnlyDictionary<TKey, TValue>(dictionary);
#endif

Comment on lines -78 to -83
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: now included via Polyfill

public static IEnumerable<T> ExceptNulls<T>(this IEnumerable<T?> source) =>
source.Where(x => x != null).Select(x => x!);

Expand Down
6 changes: 5 additions & 1 deletion src/Sentry/Sentry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@
https://github.com/SimonCropp/Polyfill
-->
<ItemGroup>
<PackageReference Include="Polyfill" Version="1.32.0" PrivateAssets="all" />
<PackageReference Include="Polyfill" Version="9.8.1" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard2.0'">$(DefineConstants);FeatureHttp</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard2.1'">$(DefineConstants);FeatureHttp</DefineConstants>
</PropertyGroup>

<!--
On .NET Framework, we need a package reference to System.Runtime.InteropServices.RuntimeInformation.
Expand Down
6 changes: 6 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<!-- "Sentry" uses "Polyfill" and gives access to it's internals via "InternalsVisibleTo", but some Polyfills are in a separate namespace -->
<ItemGroup Condition="'$(MSBuildProjectName)' != 'Sentry' And $(MSBuildProjectName.StartsWith('Sentry.'))">
<!-- the latest TargetFramework requires no Polyfills -->
<Using Include="Polyfills" Condition="'$(TargetFramework)' != $(LatestTfm)" />
</ItemGroup>

</Project>
Loading