Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Use HashCode instead of HashHelpers in netstandard libs#41165

Closed
stephentoub wants to merge 1 commit intodotnet:masterfrom
stephentoub:deletehashhelpers
Closed

Use HashCode instead of HashHelpers in netstandard libs#41165
stephentoub wants to merge 1 commit intodotnet:masterfrom
stephentoub:deletehashhelpers

Conversation

@stephentoub
Copy link
Member

Three remaining libraries were using HashHelpers.cs. Move them to netstandard2.1, change to use HashCode, and delete HashHelpers.cs.

UnmanagedType marshalAsType = GetMarshalAsParameterValue(index);
return marshalAsType == UnmanagedType.Interface || marshalAsType == UnmanagedType.IUnknown || marshalAsType == UnmanagedType.IDispatch;
return marshalAsType == UnmanagedType.Interface || marshalAsType == UnmanagedType.IUnknown ||
#pragma warning disable CS0618 // obsolete
Copy link
Member Author

Choose a reason for hiding this comment

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

@terrajobst, @AaronRobinsonMSFT, this surprised me. UnmanagedType.IDispatch is not obsolete in netstandard2.0 nor netcoreapp3.0, but is in netstandard2.1. Was that an explicit choice?

<SupportedFramework>uap10.0.16299;net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Resources.Extensions.csproj" />
<HarvestIncludePaths Include="lib/netstandard2.0" />
Copy link
Member

Choose a reason for hiding this comment

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

This won’t work until we have a stable 3.0 to harvest from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, @ericstj. It's otherwise correct, and we just need to sit on this briefly until it'll work?

Copy link
Member

Choose a reason for hiding this comment

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

You might need to lock the reference assembly version down if it applies to netstandard2.0. You can't have higher version ref than harvested lib. Package testing will fail if this is the case.

Copy link
Member

@ericstj ericstj Oct 3, 2019

Choose a reason for hiding this comment

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

I'm a bit nervous about eliminating the ns2.0 build from master, since MSBuild needs to consume this build for ResGen. If we harvest that means we don't have a way (other than servicing) to deliver changes for MSbuild to consume. I don't think I want to do this. Can we use shared source instead? Apologies for not raising this earlier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we use shared source instead?

You mean use HashCode.cs from shared source instead of HashHelpers from shared source?

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with that, just need a decent hashing method. We don't want a new assembly dependency because MSBuild -> VisualStudio will notice (assuming no one is bringing Microsoft.BCL.HashCode already).

Copy link
Member

@GrabYourPitchforks GrabYourPitchforks left a comment

Choose a reason for hiding this comment

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

HashHelpers -> HashCode conversion LGTM.

@stephentoub stephentoub added the assembly-size Issues related to the size of assemblies, before or after trimming label Sep 19, 2019
Three remaining libraries were using HashHelpers.cs.  Move them to netstandard2.1, change to use HashCode, and delete HashHelpers.cs.
<Project>
<PropertyGroup>
<BuildConfigurations>
netstandard;
Copy link
Member

Choose a reason for hiding this comment

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

Given the build error, it seems like we still need to support netstandard(2.0) in this project. We could harvest the netstandard2.0 assets into the package, or use ifdefs for this code and use HashHelpers whenever TargetGroup == netstandard -- @ericstj thoughts on harvesting? It seems like this package is compat package from core to desktop and that we don't plan to add new API to it and like we don't service it much.

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>netstandard-Debug;netstandard-Release</Configurations>
<DefineConstants>$(DefineConstants);RESOURCES_EXTENSIONS;INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<DefineConstants>$(DefineConstants);RESOURCES_EXTENSIONS;netstandard</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

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

Why is the netstandard define needed here?

@stephentoub
Copy link
Member Author

I'm just going to close this. We can address it if/when we ever update these packages.

@stephentoub stephentoub deleted the deletehashhelpers branch November 23, 2019 18:18
@karelz karelz added this to the 5.0 milestone Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Meta assembly-size Issues related to the size of assemblies, before or after trimming

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants