-
Notifications
You must be signed in to change notification settings - Fork 158
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
Migrate to netstandard #1248
Migrate to netstandard #1248
Conversation
I'm happy to announce that non-sync tests pass (except |
Realm/Realm/Native/NativeCommon.cs
Outdated
if (platformPI.GetValue(osVersion).ToString() == "Win32NT") | ||
{ | ||
// We know we're on Win32 so Assembly.Location is available | ||
var assemblyLocationPI = typeof(Assembly).GetProperty("Location", BindingFlags.Public | BindingFlags.Instance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UWP might also report Win32NT, so this should be guarded
6a91d2b
to
52c032b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions and I am sure I am missing things because I can't see the entire diff in my browser, but overall looks good.
using System.Reflection; | ||
|
||
[assembly: AssemblyDescription("Realm is a mobile database: a replacement for SQLite")] | ||
[assembly: AssemblyCopyright("Copyright © 2017 Realm")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read recently that the year you put in a copyright statement is supposed to represent the earliest year from which the copyright applies. Thus, it should not be updated. I am not sure if that info was valid and I don't think it really matters as at least half of the web then gets this wrong, but since we're being overly pedantic on the .net team, I thought I'd bring it up.. :-)
namespace Realms | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented")] | ||
public static class TypeInfoHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called by the woven IReflectableType.GetType
implementation.
<projectUrl>http://github.com/realm/realm-dotnet</projectUrl> | ||
<iconUrl>http://realm.io/img/favicon-32x32.png</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>Realm is a mobile database: a replacement for SQLite and ORMs</description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we'd want a specific description for this package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't feel like coming up with something, so I just copy-pasted the old one.
@@ -503,11 +503,5 @@ protected void RaisePropertyChanged([CallerMemberName] string propertyName = nul | |||
protected virtual void OnPropertyChanged(string propertyName) | |||
{ | |||
} | |||
|
|||
TypeInfo IReflectableType.GetTypeInfo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are automatic transactions not supported any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are - the new package Realm.Databinding contains the logic for automatic transactions and the IReflectableType
implementation is woven to all user types.
@@ -293,13 +293,15 @@ public void Write(Action action) | |||
} | |||
|
|||
/// <summary> | |||
/// Execute an action inside a temporary <see cref="Transaction"/> on a worker thread. If no exception is thrown, | |||
/// Execute an action inside a temporary <see cref="Transaction"/> on a worker thread, <b>if</b> called from UI thread. If no exception is thrown, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "Execute an action in a temporary transaction. If called from the UI thread, this will take place on a worker thread."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from @AndyDentFree's PR: #1253, haven't changed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but you did add to it :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I did - it was merged in this branch which is why you're seeing it compared to master :P
@@ -45,7 +45,7 @@ private static class NativeMethods | |||
|
|||
public unsafe delegate void RefreshAccessTokenCallbackDelegate(IntPtr session_handle_ptr); | |||
|
|||
public unsafe delegate void SessionErrorCallback(IntPtr session_handle_ptr, ErrorCode error_code, sbyte* message_buf, IntPtr message_len, IntPtr user_info_pairs, int user_info_pairs_len); | |||
public unsafe delegate void SessionErrorCallback(IntPtr session_handle_ptr, ErrorCode error_code, byte* message_buf, IntPtr message_len, IntPtr user_info_pairs, int user_info_pairs_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the use of sbyte
just a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say I'm 100% sure :) The thing is, there's no longer a string ctor that accepts sbyte*
in .NET standard, but converting to byte*
and using Encoding.GetString
seems to do the trick (passes the tests at least).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Well those calls look nicer to me anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good and a huge body of work!
[assembly: AssemblyCompany("Realm Inc.")] | ||
[assembly: AssemblyProduct("Realm C#")] | ||
|
||
[assembly: AssemblyVersion("1.0.0.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this correspond to the Realm release version numbers? Maybe add a comment line explaining context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that it should not be tied to the Realm version numbers as that is a package we'll rarely update (I hope). But it does add a bit of complexity to the release procedure if we decide to update it as that would require a bump in the dependency versions (which I'll document once this PR is finalized and merged).
|
||
xbuildCmd = '/usr/local/bin/xbuild' | ||
def nuget = '/usr/local/bin/nuget' | ||
nugetCmd = '/usr/local/bin/nuget' | ||
def windowsNugetCmd = 'C:\\ProgramData\\chocolatey\\bin\\NuGet.exe' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require that nuget was installed on Windows using the Chocolatey package manager? If so, is that documented anywhere? Does it matter to anyone building outside of Realm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - it requires a chocolatey install of nuget on our CI slaves. I'm not sure if we have documentation about CI setup anywhere. Ping @fealebenpae.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, we don't. And this change only matters to Jenkins. People building manually (us, included) will just restore packages like they always would - through Visual Studio.
<projectUrl>http://github.com/realm/realm-dotnet</projectUrl> | ||
<iconUrl>http://realm.io/img/favicon-32x32.png</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>Realm is a mobile database: a replacement for SQLite and ORMs</description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the description could indicate this is useless by itself and is a supporting nuget for Realm.Database?
@@ -17,8 +17,18 @@ | |||
<tags>Realm database db persistence sqlite</tags> | |||
<dependencies> | |||
<dependency id="Fody" version="1.29.4"/> | |||
<dependency id="Realm.DataBinding" version="1.0.0"/> | |||
<dependency id="DotNetCross.Memory.Unsafe" version="0.2.2"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we removing DotNetCross.Memory.Unsafe or leaving that change for a separate PR later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it for later as this one's already huge and would prefer not to add more points where things might break :)
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented")] | ||
public static class TypeInfoHelper | ||
{ | ||
// Holds Type -> RealmObjectTypeInfo map to avoid creating a new TypeDelegator for each IReflectableType.GetTypeInfo invocation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still valid with dropping using IReflectableType directly for RealmObject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - it's still valid, as we're weaving call to TypeInfoHelper.GetInfo
in the user's assembly, so caching types is useful.
* Updated XML comment to clarify behaviour of WriteAsync on threads. * Updated XML comment to clarify behaviour of WriteAsync on threads (in PCL version)
Update jenkinsfile to use Debug
845d1f5
to
a9f6533
Compare
Description
Notable changes:
ModuleWeaver.WeaveSchema
. Had to expose public propertyRealmSchema.DefaultTypes
and set it in the application entry point. Theoretically that would allow people to modify it before the first call toRealm.GetInstance()
.mscorlib
when resolving dependencies. Had to do that as the default assembly resolver fails to resolve dependencies such as System.Runtime, etc. that are just reference assemblies.Fixes #1080
TODO
IReflectableType
(RealmObject.cs
)NativeCommon.cs
)RealmSchema.cs
)mscorlib
if an assembly can't be resolved. Not sure how correct that behavior is.RealmConfigurationBase
,SharedRealmHandleExtensions
)SharedRealmHandleExtensions.ResetForTesting
. Filed a bug report. Works fine in VS. Fixed in mono master.SyncConfiguration.CreateRealm
. Filed a bug report. Works fine in VS. Fixed in mono master.Session_Error_ShouldPassCorrectSession
High-level overview of what's changed
Realm/Realm
andRealm/Realm.Sync
.NET standard 1.4 projects. Those will be packaged in the NuGet and will be the only .dll's we ship.Tests
toManual Tests
as those are run manually rather than by CI.Tests
.try-finally
pattern for assigning handles.mscorlib
if it fails to resolve an assembly (asSystem.Runtime
, etc. are not real ones). As which types we use is very deterministic, it's not an issue, but it's something to watch out for.AppDomain.Current
in .NET Standard, we can't inspect the default types at runtime. The current solution will weave logic to callAddDefaultTypes
either in theAssembly.EntryPoint
or if it doesn't exist, in the module initializer (that's needed for unit tests on windows). It will walk the graph of all referenced assemblies and pull in their types. It's good enough for merging, but should be tested with complex graphs.Environment.SpecialFolder.Personal
(default location of realm files). This will not work on UWP and will need to be extended.IReflectableType
-related implementations. Needed asTypeDelegator
will not be available until netstandard 2.0. The weaver will weaveIReflectableType
implementation to user objects by callingTypeInfoHelper.GetInfo
.After merging
IReflectableType
is properly woven on PCL models as well.