Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-88…
Browse files Browse the repository at this point in the history
…1a-475b-bcce-fe098498f1ec
  • Loading branch information
rolfbjarne committed Jun 1, 2021
2 parents 5383e31 + 640467a commit 747c239
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 106 deletions.
33 changes: 7 additions & 26 deletions msbuild/Xamarin.Localization.MSBuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,15 @@

Messages for new MSBuild error codes live in `MSBStrings.resx`.

If changes are made to `MBStrings.resx`, you will hit:
* You can now make changes to `MSBStrings.resx` in the Visual Studio for Mac IDE or from any text editor.

XliffTasks.targets(91,5): error : 'xlf\MSBStrings.cs.xlf' is out-of-date with 'MSBStrings.resx'.
Run `msbuild /t:UpdateXlf` to update .xlf files or set UpdateXlfOnBuild=true to update them on every build,
but note that it is strongly discouraged to set UpdateXlfOnBuild=true in official/CI build environments
as they should not modify source code during the build.
* If you make changes in the IDE, you should see changes automatically copy into MSBStrings.Designer.cs. Be sure to rebuild the project after making your changes.

To regenerate the `.xlf` files run:
* If you make changes from a text editor, be sure to run `make` inside the xamarin-macios/msbuild/Xamarin.Localization.MSBuild directory.

$ msbuild msbuild/Xamarin.Localization.MSBuild/Xamarin.Localization.MSBuild.csproj -restore -t:UpdateXlf
See [Localization Wiki][Localization-wiki] for more details on our localization process

For `mtouch`, `Errors.resx` contains the localizable strings. Use
these commands instead to update `.xlf` files:
or the [OneLocBuild Wiki][OneLocBuild-wiki] for information on OneLocBuild.

$ nuget restore tools
$ msbuild tools/mtouch/mtouch.csproj -t:UpdateXlf

For `generator`, `src/Resources.resx`, contains the localizable
strings. To update the `.xlf` files:

$ nuget restore src
$ msbuild src/generator.csproj -t:UpdateXlf

*NOTE: `nuget restore` can be used instead of the MSBuild `-restore`
switch for projects using `packages.config`*

See [dotnet/xliff-tasks][xliff-tasks] or [Xamarin.Android's
documentation][xamarin-android] for details.

[xliff-tasks]: https://github.com/dotnet/xliff-tasks
[xamarin-android]: https://github.com/xamarin/xamarin-android/blob/master/Documentation/workflow/Localization.md
[Localization-wiki]: https://github.com/xamarin/maccore/wiki/Localization
[OneLocBuild-wiki]: https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task
31 changes: 29 additions & 2 deletions runtime/coreclr-bridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
#if defined (CORECLR_RUNTIME)

#include <inttypes.h>
#include <pthread.h>

#include "product.h"
#include "runtime-internal.h"
#include "slinked-list.h"
#include "xamarin/xamarin.h"
#include "xamarin/coreclr-bridge.h"

#include "coreclrhost.h"

unsigned int coreclr_domainId = 0;
void *coreclr_handle = NULL;
pthread_mutex_t monoobject_lock = PTHREAD_MUTEX_INITIALIZER;
SList *release_at_exit = NULL; // A list of MonoObject*s to be released at process exit

#if defined (TRACK_MONOOBJECTS)

Expand All @@ -30,12 +34,10 @@
// MONOOBJECT_TRACKING_WITH_STACKTRACES environment variable.

#include <execinfo.h>
#include <pthread.h>

static int _Atomic monoobject_created = 0;
static int _Atomic monoobject_destroyed = 0;
static CFMutableDictionaryRef monoobject_dict = NULL;
static pthread_mutex_t monoobject_lock = PTHREAD_MUTEX_INITIALIZER;

struct monoobject_tracked_entry {
char *managed;
Expand Down Expand Up @@ -171,6 +173,22 @@
void
xamarin_bridge_shutdown ()
{
SList *list;

// Free our list of MonoObject*s to free at process exist.
// No need to keep the lock locked while we traverse the list, the only thing we need to protect
// are reads and writes to the 'release_at_exit' variable, so let's do just that.
pthread_mutex_lock (&monoobject_lock);
list = release_at_exit;
release_at_exit = NULL;
pthread_mutex_unlock (&monoobject_lock);

while (list) {
xamarin_mono_object_release ((MonoObject **) &list->data);
list = list->next;
}
s_list_free (list);

#if defined (TRACK_MONOOBJECTS)
xamarin_bridge_dump_monoobjects ();
#endif
Expand Down Expand Up @@ -357,6 +375,14 @@
*mobj_ref = NULL;
}

void
xamarin_mono_object_release_at_process_exit (MonoObject *mobj)
{
pthread_mutex_lock (&monoobject_lock);
release_at_exit = s_list_prepend (release_at_exit, mobj);
pthread_mutex_unlock (&monoobject_lock);
}

/* Implementation of the Mono Embedding API */

// returns a retained MonoAssembly *
Expand Down Expand Up @@ -667,6 +693,7 @@
if (sig == NULL)
return;

xamarin_mono_object_release (&sig->method);
for (int i = 0; i < sig->parameter_count; i++) {
xamarin_mono_object_release (&sig->parameters [i]);
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/monotouch-main.m
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ - (void) memoryWarning: (NSNotification *) sender

xamarin_mono_object_release (&assembly);

xamarin_release_static_dictionaries ();

xamarin_bridge_shutdown ();

return rv;
Expand Down
16 changes: 16 additions & 0 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,22 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
return rv;
}

void
xamarin_release_static_dictionaries ()
{
#if defined (CORECLR_RUNTIME)
// Release static dictionaries of cached objects. If we end up trying to
// add objects to these dictionaries after this point (on a background
// thread), the dictionaries will be re-created (and leak) - which
// shouldn't be a problem, because at this point the process is about to
// exit anyway.
pthread_mutex_lock (&wrapper_hash_lock);
xamarin_mono_object_release (&block_wrapper_queue);
xamarin_mono_object_release (&xamarin_wrapper_hash);
pthread_mutex_unlock (&wrapper_hash_lock);
#endif
}

void
xamarin_set_use_sgen (bool value)
{
Expand Down
3 changes: 3 additions & 0 deletions runtime/xamarin/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ bool xamarin_set_gchandle_with_flags_safe (id self, GCHandle gchandle, enum Xa
void xamarin_create_gchandle (id self, void *managed_object, enum XamarinGCHandleFlags flags, bool force_weak);
void xamarin_release_managed_ref (id self, bool user_type);
void xamarin_notify_dealloc (id self, GCHandle gchandle);
void xamarin_release_static_dictionaries ();

int xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode);

Expand Down Expand Up @@ -306,10 +307,12 @@ void xamarin_mono_object_retain (MonoObject *mobj);
// Use C++ linking to be able to use method overloading, so that callers don't have to cast their variables to 'MonoObject**' (which improves type safety a lot).
extern "C++" void xamarin_mono_object_release (MonoObject **mobj);
extern "C++" void xamarin_mono_object_release (MonoString **mobj);
void xamarin_mono_object_release_at_process_exit (MonoObject *mobj);
#else
// Nothing to do here.
#define xamarin_mono_object_retain(x)
#define xamarin_mono_object_release(x) do { *x = NULL; } while (0);
#define xamarin_mono_object_release_at_process_exit(x)
#endif


Expand Down
4 changes: 2 additions & 2 deletions src/NativeTypes/Drawing.tt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace CoreGraphics
#if !COREBUILD
public static bool TryParse (NSDictionary dictionaryRepresentation, out <#= type.Name #> <#= type.ArgName #>)
{
if (dictionaryRepresentation == null){
if (dictionaryRepresentation is null) {
<#= type.ArgName #> = Empty;
return false;
}
Expand Down Expand Up @@ -597,7 +597,7 @@ namespace CoreGraphics
#if !COREBUILD
public static bool TryParse (NSDictionary dictionaryRepresentation, out CGRect rect)
{
if (dictionaryRepresentation == null){
if (dictionaryRepresentation is null) {
rect = Empty;
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/NativeTypes/Primitives.tt
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace System
{
if (source == IntPtr.Zero)
throw new ArgumentNullException ("source");
if (destination == null)
if (destination is null)
throw new ArgumentNullException ("destination");
if (destination.Rank != 1)
throw new ArgumentException ("destination", "array is multi-dimensional");
Expand All @@ -410,7 +410,7 @@ namespace System

public static void CopyArray (<#= type.NSName #> [] source, int startIndex, IntPtr destination, int length)
{
if (source == null)
if (source is null)
throw new ArgumentNullException ("source");
if (destination == IntPtr.Zero)
throw new ArgumentNullException ("destination");
Expand Down
11 changes: 11 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,14 @@ For example, to build an API for all of iOS but only 64-bit OS X (Xamarin.Mac):
...
#endif
```


## Source Localization ##
Coming soon!

See [Localization Wiki][Localization-wiki] for more details on our localization process

or the [OneLocBuild Wiki][OneLocBuild-wiki] for information on OneLocBuild.

[Localization-wiki]: https://github.com/xamarin/maccore/wiki/Localization
[OneLocBuild-wiki]: https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task
4 changes: 2 additions & 2 deletions src/generator-enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void GenerateEnum (Type type)
print ("public static NSString? GetDomain (this {0} self)", type.Name);
print ("{");
indent++;
print ("if (_domain == null)");
print ("if (_domain is null)");
indent++;
print ("_domain = Dlfcn.GetStringConstant (Libraries.{0}.Handle, \"{1}\");", library_name, error.ErrorDomain);
indent--;
Expand Down Expand Up @@ -191,7 +191,7 @@ void GenerateEnum (Type type)
print ("public static {0} GetValue (NSString{1} constant)", type.Name, nullable ? "?" : "");
print ("{");
indent++;
print ("if (constant == null)");
print ("if (constant is null)");
indent++;
// if we do not have a enum value that maps to a null field then we throw
if (!nullable)
Expand Down
4 changes: 2 additions & 2 deletions src/generator-filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void GenerateFilter (Type type)
print ("public {0} (NSCoder coder) : base (NSObjectFlag.Empty)", type_name);
print ("{");
indent++;
print ("if (coder == null)");
print ("if (coder is null)");
indent++;
print ("throw new ArgumentNullException (nameof (coder));");
indent--;
Expand Down Expand Up @@ -359,7 +359,7 @@ void GenerateFilterSetter (string propertyType, string propertyName)
indent--;
break;
case "CIVector[]":
print ("if (value == null) {");
print ("if (value is null) {");
indent++;
print ($"SetHandle (\"{propertyName}\", IntPtr.Zero);");
indent--;
Expand Down
Loading

6 comments on commit 747c239

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
ℹ️ Generator Diff (please review changes)

Packages generated

View packages

Test results

2 tests failed, 219 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2618 Passed: 2459 Inconclusive: 32 Failed: 1 Ignored: 158)
  • monotouch-test/iOS Unified 32-bits - simulator/Debug: Failed

Pipeline on Agent XAMBOT-1023.BigSur'
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on macOS Mac Mojave (10.14) ❌

Tests failed on Mac Mojave (10.14).

Failed tests are:

  • introspection

Pipeline on Agent
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on macOS Mac High Sierra (10.13) ❌

Tests failed on Mac High Sierra (10.13).

Failed tests are:

  • introspection

Pipeline on Agent
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS32b). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
Merge remote-tracking branch 'origin/main' into darc-main-9db02e1b-881a-475b-bcce-fe098498f1ec

Please sign in to comment.