Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[src] use HashCode.Combine to generate hashcodes #16841

Merged
merged 38 commits into from
Nov 29, 2022

Conversation

haritha-mohan
Copy link
Contributor

Fixes #16677

@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

As your PR has found out, there turned out to be a lot of corner cases with what I thought would be rather simple... so sorry about that. It should be easy enough to change though :) Feel free to ask if you have any questions!

src/AVFoundation/AVEdgeWidths.cs Outdated Show resolved Hide resolved
src/CoreBluetooth/CBUUID.cs Outdated Show resolved Hide resolved
src/Foundation/NSDecimal.cs Outdated Show resolved Hide resolved
src/Foundation/NSNumber2.cs Outdated Show resolved Hide resolved
src/Foundation/NSOperatingSystemVersion.cs Outdated Show resolved Hide resolved
src/Foundation/NSString.cs Outdated Show resolved Hide resolved
src/ObjCRuntime/Class.cs Outdated Show resolved Hide resolved
src/ObjCRuntime/Runtime.CoreCLR.cs Outdated Show resolved Hide resolved
src/OpenGL/OpenTK/Graphics/Color4.cs Outdated Show resolved Hide resolved
Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

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

+1 as long as the comments from @rolfbjarne are taken care of

tj-devel709 and others added 15 commits November 21, 2022 17:07
…xamarin#16835)

I have been testing these changes inside the xamarin-macios-translations
pipeline.
The last run was green (found
[here](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6984912&view=results)).
I had to use some placeholder code for the actual calls for the
OneLocBuild task that will communicate with the Loc Team but it reached
those points as expected!

This PR also rips out calls to the main-stage.yml template to only use
the stages necessary for the OneLocBuild run over the weekend!

I think these changes are set to see if the main branch can trigger the
OneLocBuild Task over the weekend build!

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
This pull request updates the following dependencies

## From https://github.com/dotnet/installer
- **Subscription**: 50c9492e-4671-4d1d-7920-08dabd1031a2
- **Build**: 20221117.23
- **Date Produced**: November 18, 2022 12:09:07 AM UTC
- **Commit**: cf1b55e9735de4935c764e97a95c8fb87b87ebdc
- **Branch**: refs/heads/release/7.0.1xx

- **Updates**:
  - **Microsoft.Dotnet.Sdk.Internal**: [from 7.0.101-servicing.22566.14 to 7.0.101-servicing.22567.23][3]

[3]: dotnet/installer@7a63b1b...cf1b55e

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <github-actions@xamarin.com>
Fixes these tests:

```
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BuildMachineOSBuild: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleDevelopmentRegion: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleExecutable: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleIdentifier: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleInfoDictionaryVersion: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleName: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundlePackageType: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleSignature: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleSupportedPlatforms: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).BundleVersion: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).DeviceFamily: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).MinimumOSVersion: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).MissingBundleIdentifier: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).MissingDisplayName: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).NormalPlist: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).NoWatchCompanion: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).PlistMissing: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).VerifyAllDT: System.InvalidOperationException : Invalid platform: WatchOS
* Xamarin.MacDev.Tasks.GeneratePlistTaskTests_watchOS_WatchKitExtension(True).XamarinVersion: System.InvalidOperationException : Invalid platform: WatchOS
```
Fixes these test failures:

    1) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/32bits/iOS/Xamarin.iOS.dll")
       CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29

    2) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/64bits/iOS/Xamarin.iOS.dll")
       CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29

    3) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/32bits/watchOS/Xamarin.WatchOS.dll")
       WatchKit.WKExtendedRuntimeSessionErrorCode.MustBeActiveToPrompt, WatchKit.WKExtendedRuntimeSessionErrorCode.UnsupportedSessionType, CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "WatchKit.WKExtendedRuntimeSessionErrorCode.MustBeActiveToPrompt", "WatchKit.WKExtendedRuntimeSessionErrorCode.UnsupportedSessionType", "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29

    4) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/64bits/tvOS/Xamarin.TVOS.dll")
       CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29

    5) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll")
       CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29

    6) Failed : Cecil.Tests.EnumTest.NoAvailabilityOnError("/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll")
       CoreLocation.CLError.HistoricalLocationError
       Expected: <empty>
       But was:  < "CoreLocation.CLError.HistoricalLocationError" >
       at Cecil.Tests.EnumTest.NoAvailabilityOnError (System.String assemblyPath) [0x00067] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/cecil-tests/EnumTest.cs:29
…ts.TestCallback to ignore timeouts in CI. (xamarin#16816)

Fixes:

    MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback
    	[FAIL] TestCallback(True) :   timed out
      Expected: True
      But was:  False
    		   at MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback(Boolean stronglyTyped) in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/VideoToolbox/VTCompressionSessionTests.cs:line 171
    	[FAIL] TestCallback(False) :   timed out
      Expected: True
      But was:  False
    		   at MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback(Boolean stronglyTyped) in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/VideoToolbox/VTCompressionSessionTests.cs:line 171
    		   at InvokeStub_VTCompressionSessionTests.TestCallback(Object, Object, IntPtr*)
…bots. (xamarin#16815)

Fixes:

    [FAIL] Bug12221 : System.AggregateException : One or more errors occurred. (Response status code does not indicate success: 403 (Forbidden).)
    ----> System.Net.Http.HttpRequestException : Response status code does not indicate success: 403 (Forbidden).
          at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean )
          at System.Threading.Tasks.Task.Wait(Int32 , CancellationToken )
          at System.Threading.Tasks.Task.Wait()
          at LinkSdk.AsyncTests.Bug12221() in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/linker/ios/link sdk/AsyncTest.cs:line 25
          at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
       --HttpRequestException
          at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
          at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage , CancellationToken )
          at LinkSdk.AsyncTests.<>c.<<LoadCategories>b__0_0>d.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/linker/ios/link sdk/AsyncTest.cs:line 16

One important detail is the change from calling 'Wait ()' to calling
'GetAwaiter ().GetResult ()': this is to avoid the AggregateException in the
stack trace above.

Fixes xamarin/maccore#2570.
Also add 'run-packaged-macos-tests' to the labels we care about.

This fixes an issue where the label combination
'skip-all-tests,run-packaged-macos-tests' would not run any tests.
…cy are enabled. (xamarin#16812)

Fixes this on the bots when iOS is not enabled even though legacy is:

    + make -C /Users/builder/azdo/_work/1/s/xamarin-macios/tools/mtouch package-introspection-dependencies.zip
    make: *** No rule to make target `../../runtime/.libs/iphonesimulator/libxamarin-debug.a', needed by `simlauncher32-sgen'.  Stop.
…amarin#16805)

This fixes an issue where emojis weren't rendered as such in some browsers,
because the browser would use a different character set than utf8.
dotnet-maestro bot and others added 2 commits November 22, 2022 14:58
This pull request updates the following dependencies

## From https://github.com/dotnet/installer
- **Subscription**: 50c9492e-4671-4d1d-7920-08dabd1031a2
- **Build**: 20221121.1
- **Date Produced**: November 21, 2022 5:57:30 PM UTC
- **Commit**: d02d33e069bf59d00b6374e304d39d6ceb20e18a
- **Branch**: refs/heads/release/7.0.1xx

- **Updates**:
  - **Microsoft.Dotnet.Sdk.Internal**: [from 7.0.101-servicing.22570.11 to 7.0.101-servicing.22571.1][1]

[1]: dotnet/installer@3894bc5...d02d33e

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <github-actions@xamarin.com>
@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

This looks great!

@Therzok
Copy link
Contributor

Therzok commented Nov 23, 2022

This looks great! 🎉

@rolfbjarne does this have any impact on assembly size? (HashCode is generic, so it would add some code size). This is more of a question than anything.

The reason I'm asking is because I was curious if something like record struct would achieve the same goals, with less code. And it seems that the C# codegen is actually using a custom hash implementation, but still uses generics via EqualityComparer.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [PR Build] Build failed 🔥

Build failed for the job 'Detect API changes'

Pipeline on Agent
Hash: $(GIT_HASH) [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: e9d3ffe66877cd636066746160f39aa9bdbada49 [PR build]

@rolfbjarne
Copy link
Member

This looks great! 🎉

@rolfbjarne does this have any impact on assembly size? (HashCode is generic, so it would add some code size). This is more of a question than anything.

The reason I'm asking is because I was curious if something like record struct would achieve the same goals, with less code. And it seems that the C# codegen is actually using a custom hash implementation, but still uses generics via EqualityComparer.

That's a good question to which I have no answer, but I'll investigate a bit.

Although I'm almost certain we can't use record structs for existing structs, because that would be a breaking change.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1181.Monterey'
Hash: e9d3ffe66877cd636066746160f39aa9bdbada49 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: e9d3ffe66877cd636066746160f39aa9bdbada49 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@Therzok
Copy link
Contributor

Therzok commented Nov 28, 2022

Although I'm almost certain we can't use record structs for existing structs, because that would be a breaking change.

Got it. I suppose it's the immutability and property vs field issue.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

❗ API diff vs stable (Breaking changes)

Legacy Xamarin (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
.NET (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
Legacy Xamarin (stable) vs .NET

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: e9d3ffe66877cd636066746160f39aa9bdbada49 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 223 tests passed 🎉

Tests counts

✅ bcl: All 69 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 23 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: e9d3ffe66877cd636066746160f39aa9bdbada49 [PR build]

@haritha-mohan haritha-mohan merged commit 64bb06c into xamarin:main Nov 29, 2022
@haritha-mohan haritha-mohan deleted the hashcode-combine branch November 29, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use HashCode.Combine instead of our own computations for hash codes
7 participants