Uri made from UNIX path and RelativeOrAbsolute is now relative.
monotouch_runtime_SUBDIRS := build class
xammac_SUBDIRS := build class
mobile_SUBDIRS := build class
+mobile_static_SUBDIRS := build class
net_3_5_SUBDIRS := build class tools/xbuild
net_4_0_SUBDIRS := build class
net_4_5_SUBDIRS := build mcs class nunit24 ilasm tools tests errors docs
$(_boot_:%=profile-do--monotouch_runtime--%): profile-do--monotouch_runtime--%: profile-do--build--%
$(_boot_:%=profile-do--xammac--%): profile-do--xammac--%: profile-do--build--%
$(_boot_:%=profile-do--mobile--%): profile-do--mobile--%: profile-do--build--%
+$(_boot_:%=profile-do--mobile_static--%): profile-do--mobile_static--%: profile-do--build--%
$(_boot_:%=profile-do--net_2_0--%): profile-do--net_2_0--%: profile-do--build--%
$(_boot_:%=profile-do--build--%): profile-do--build--%: profile-do--basic--%
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:MOBILE \
+ -d:MOBILE_DYNAMIC \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -nowarn:1699 \
+ -nostdlib \
+ -lib:$(topdir)/class/lib/$(PROFILE) \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
+
FRAMEWORK_VERSION = 2.1
NO_INSTALL = yes
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:FULL_AOT_RUNTIME -d:DISABLE_REMOTING -d:DISABLE_COM -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -d:MOBILE \
+ -d:FULL_AOT_RUNTIME \
+ -d:DISABLE_REMOTING \
+ -d:DISABLE_COM \
+ -nowarn:1699 \
+ -nostdlib \
+ -lib:$(topdir)/class/lib/$(PROFILE) \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
+
FRAMEWORK_VERSION = 2.1
NO_TEST = yes
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MOBILE_DYNAMIC -d:MONODROID -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -d:MOBILE \
+ -d:MOBILE_DYNAMIC \
+ -d:MONODROID \
+ -d:ANDROID \
+ -nowarn:1699 \
+ -nostdlib \
+ -lib:$(topdir)/class/lib/$(PROFILE) \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
+
FRAMEWORK_VERSION = 2.1
NO_TEST = yes
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MONOTOUCH -d:DISABLE_REMOTING -d:DISABLE_COM -d:FULL_AOT_RUNTIME -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -d:MOBILE \
+ -d:MONOTOUCH \
+ -d:DISABLE_REMOTING \
+ -d:DISABLE_COM \
+ -d:FULL_AOT_RUNTIME \
+ -nowarn:1699 \
+ -nostdlib \
+ -lib:$(topdir)/class/lib/$(PROFILE) \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
+
FRAMEWORK_VERSION = 2.1
NO_TEST = yes
# the tuner takes care of the install
-NO_INSTALL = yes
\ No newline at end of file
+NO_INSTALL = yes
pcl_facade_dirs := Facades
-mobile_dirs := \
+mobile_common_dirs := \
corlib \
System \
System.Core \
System.Net \
System.Windows \
System.Xml.Serialization \
+ Mono.CSharp \
+ Microsoft.CSharp \
$(pcl_facade_dirs)
-monodroid_dirs := \
+mobile_static_dirs := \
+ $(mobile_common_dirs) \
+ Mono.Dynamic.Interpreter
+
+mobile_dynamic_dirs := \
+ $(mobile_common_dirs) \
Mono.CompilerServices.SymbolWriter \
- Mono.CSharp \
- Microsoft.CSharp \
System.Net.Http
xammac_dirs := \
- Mono.CompilerServices.SymbolWriter \
- Mono.CSharp \
- Microsoft.CSharp \
- System.Net.Http
+ $(mobile_dynamic_dirs)
+
+monodroid_dirs := \
+ $(mobile_dynamic_dirs)
+
+monotouch_dirs := \
+ $(mobile_static_dirs)
monotouch_runtime_dirs := \
corlib \
System.XML \
Mono.CSharp
-monotouch_dirs := \
- Mono.CSharp \
- Microsoft.CSharp \
- Mono.Dynamic.Interpreter
-
net_4_0_dirs := \
System.Numerics \
Microsoft.CSharp \
Microsoft.Build
net_2_0_SUBDIRS := $(net_2_0_dirs) $(net_2_0_only_dirs) $(xbuild_2_0_dirs) aot-compiler
-monodroid_SUBDIRS := $(mobile_dirs) $(monodroid_dirs)
-monotouch_SUBDIRS := $(mobile_dirs) $(monotouch_dirs)
+monodroid_SUBDIRS := $(monodroid_dirs)
+monotouch_SUBDIRS := $(monotouch_dirs)
monotouch_runtime_SUBDIRS := $(monotouch_runtime_dirs)
-mobile_static_SUBDIRS := $(mobile_dirs)
-mobile_SUBDIRS := $(mobile_dirs)
-xammac_SUBDIRS := $(mobile_dirs) $(xammac_dirs)
+mobile_static_SUBDIRS := $(mobile_static_dirs)
+mobile_SUBDIRS := $(mobile_dynamic_dirs)
+xammac_SUBDIRS := $(xammac_dirs)
net_3_5_SUBDIRS := $(xbuild_2_0_dirs)
net_4_0_SUBDIRS := $(net_2_0_dirs) $(net_4_0_dirs) $(net_4_0_only_dirs) $(xbuild_4_0_dirs)
net_4_5_SUBDIRS := $(net_2_0_dirs) $(net_4_0_dirs) $(net_4_5_dirs) $(xbuild_4_0_dirs) aot-compiler
include ../build/rules.make
-SUBDIRS = $(net_2_0_dirs) $(net_2_0_only_dirs) $(mobile_dirs) $(monotouch_dirs) $(net_4_0_dirs) $(net_4_0_only_dirs) $(net_4_5_dirs)
+SUBDIRS = $(net_2_0_dirs) $(net_2_0_only_dirs) $(mobile_static_dirs) $(mobile_dynamic_dirs) $(monotouch_dirs) $(monodroid_dirs) $(xammac_dirs) $(net_4_0_dirs) $(net_4_0_only_dirs) $(net_4_5_dirs)
DIST_ONLY_SUBDIRS = dlr aot-compiler $(xbuild_4_0_dirs)
if (View != View.Details) {
if (bounds.Left < 0)
h_scroll.Value += bounds.Left;
- else if (bounds.Right > view_rect.Right)
+ // Don't shift right unless right-to-left layout is active. (Xamarin bug 22483)
+ else if (this.RightToLeftLayout && bounds.Right > view_rect.Right)
h_scroll.Value += (bounds.Right - view_rect.Right);
}
if (!StartHandlerHasExecuted)
return;
- if (EventArgs is ProjectStartedEventArgs)
- ConsoleLogger.ProjectFinishedHandler (Sender, finished_args as ProjectFinishedEventArgs);
- else if (EventArgs is TargetStartedEventArgs)
- ConsoleLogger.TargetFinishedHandler (Sender, finished_args as TargetFinishedEventArgs);
- else if (EventArgs is TaskStartedEventArgs)
- ConsoleLogger.TaskFinishedHandler (Sender, finished_args as TaskFinishedEventArgs);
- else if (!(EventArgs is BuildStartedEventArgs))
+ if (EventArgs is ProjectStartedEventArgs) {
+ var pfa = finished_args as ProjectFinishedEventArgs;
+ // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent
+ if (pfa == null)
+ return;
+
+ ConsoleLogger.ProjectFinishedHandler (Sender, pfa);
+ } else if (EventArgs is TargetStartedEventArgs) {
+ var fa = finished_args as TargetFinishedEventArgs;
+ // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent
+ if (fa == null)
+ return;
+
+ ConsoleLogger.TargetFinishedHandler (Sender, fa);
+ } else if (EventArgs is TaskStartedEventArgs) {
+ // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent
+ if (!(finished_args is TaskFinishedEventArgs))
+ return;
+
+ ConsoleLogger.TaskFinishedHandler (Sender, (TaskFinishedEventArgs) finished_args);
+ } else if (!(EventArgs is BuildStartedEventArgs))
throw new InvalidOperationException ("Unexpected event on the stack, type: " + EventArgs.GetType ());
}
}
try {
TaskExecutionMode taskExecutionMode;
string reason;
- if (!BuildTargetNeeded (out reason)) {
+ bool skip_completely;
+ if (!BuildTargetNeeded (out reason, out skip_completely)) {
LogTargetSkipped (target, reason);
+ if (skip_completely)
+ return true;
+
taskExecutionMode = TaskExecutionMode.SkipAndSetOutput;
} else {
taskExecutionMode = TaskExecutionMode.Complete;
//FIXME: parsing attributes repeatedly
IBuildTask bt = target.BuildTasks [i];
+ // HACK: need some form of cross references checks
+ var tem = taskExecutionMode;
+ if (tem == TaskExecutionMode.SkipAndSetOutput) {
+ var bti = bt as BuildTask;
+
+ //
+ // BuildTargetNeeded checks only files timestamps but ignores any metadata dependencies
+ // that way we can end up in the situation when output metadata are populated but from
+ // incomplete dependencies.
+ //
+ // E.g.
+ // <CreateItem Include="$(IntermediateOutputPath)%(_PngImage.LogicalName)" AdditionalMetadata="LogicalName=%(_PngImage.LogicalName)">
+ // <Output TaskParameter="Include" />
+ // </CreateItem>
+ //
+ if (bti != null && bti.Name == "CreateItem")
+ tem = TaskExecutionMode.Complete;
+ }
+
TaskBatchingImpl batchingImpl = new TaskBatchingImpl (project);
- bool task_result = batchingImpl.Build (bt, taskExecutionMode, out executeOnErrors);
+ bool task_result = batchingImpl.Build (bt, tem, out executeOnErrors);
if (task_result)
continue;
ParseAttribute (outputs);
}
- bool BuildTargetNeeded (out string reason)
+ bool BuildTargetNeeded (out string reason, out bool skipCompletely)
{
reason = String.Empty;
ITaskItem [] inputFiles;
ITaskItem [] outputFiles;
DateTime youngestInput, oldestOutput;
+ skipCompletely = false;
- if (String.IsNullOrEmpty (inputs.Trim ()))
+ if (String.IsNullOrEmpty (inputs.Trim ())) {
return true;
+ }
if (String.IsNullOrEmpty (outputs.Trim ())) {
project.ParentEngine.LogError ("Target {0} has inputs but no outputs specified.", name);
}
if (inputFiles == null || inputFiles.Length == 0) {
+ skipCompletely = true;
reason = String.Format ("No input files were specified for target {0}, skipping.", name);
return false;
}
if (string.IsNullOrEmpty (tp))
return null;
- tp = Path.GetDirectoryName (tp);
- if (string.IsNullOrEmpty (tp))
- tp = Directory.GetCurrentDirectory ();
+ //
+ // GenerateFullPathToTool can return path including tool name
+ //
+ if (string.IsNullOrEmpty (ToolExe))
+ return tp;
+ tp = Path.GetDirectoryName (tp);
} else {
tp = ToolPath;
}
var t = new TestExecuteToolTask ();
t.FullPathToTool = "fpt";
t.BuildEngine = new MockBuildEngine ();
- t.ToolExe = "Makefile";
+ t.ToolExe = "Makefile.mk";
t.OnExecuteTool = (pathToTool, responseFileCommands, commandLineCommands) => {
- Assert.AreEqual (Path.Combine (Directory.GetCurrentDirectory (), "Makefile"), pathToTool, "#1");
+ Assert.AreEqual ("Makefile.mk", pathToTool, "#1");
Assert.AreEqual ("", responseFileCommands, "#2");
Assert.AreEqual ("", commandLineCommands, "#3");
};
- Assert.IsTrue (t.Execute (), "result");
+ Assert.IsFalse (t.Execute (), "result");
}
}
LIB_MCS_FLAGS = -r:System.Core.dll -r:System.Xml.dll -r:System.dll
-ifeq (monotouch, $(PROFILE))
+MOBILE_STATIC := $(filter mobile_static monotouch, $(PROFILE))
+
+ifdef MOBILE_STATIC
LIB_MCS_FLAGS += -d:IOS_REFLECTION
endif
--- /dev/null
+#include Mono.CSharp.dll.sources
+../corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
+../corlib/System.Reflection.Emit/FlowControl.cs
+../corlib/System.Reflection.Emit/OpCode.cs
+../corlib/System.Reflection.Emit/OpCodeNames.cs
+../corlib/System.Reflection.Emit/OpCodes.cs
+../corlib/System.Reflection.Emit/OpCodeType.cs
+../corlib/System.Reflection.Emit/OperandType.cs
+../corlib/System.Reflection.Emit/PEFileKinds.cs
+../corlib/System.Reflection.Emit/Label.cs
+../corlib/System.Reflection.Emit/MethodToken.cs
+../corlib/System.Reflection.Emit/StackBehaviour.cs
+monotouch.cs
\ No newline at end of file
-#include Mono.CSharp.dll.sources
-../corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
-../corlib/System.Reflection.Emit/FlowControl.cs
-../corlib/System.Reflection.Emit/OpCode.cs
-../corlib/System.Reflection.Emit/OpCodeNames.cs
-../corlib/System.Reflection.Emit/OpCodes.cs
-../corlib/System.Reflection.Emit/OpCodeType.cs
-../corlib/System.Reflection.Emit/OperandType.cs
-../corlib/System.Reflection.Emit/PEFileKinds.cs
-../corlib/System.Reflection.Emit/Label.cs
-../corlib/System.Reflection.Emit/MethodToken.cs
-../corlib/System.Reflection.Emit/StackBehaviour.cs
-monotouch.cs
\ No newline at end of file
+#include mobile_static_Mono.CSharp.dll.sources
+monotouch.cs
using System.Diagnostics;
using System.Net.Sockets;
using System.Globalization;
+using System.Security;
using System.Text;
+using System.Runtime.InteropServices;
namespace Mono.Data.Tds.Protocol
{
t3.Domain = this.connectionParms.DefaultDomain;
t3.Host = this.connectionParms.Hostname;
t3.Username = this.connectionParms.User;
- t3.Password = this.connectionParms.Password;
+ t3.Password = GetPlainPassword(this.connectionParms.Password);
Comm.StartPacket (TdsPacketType.SspAuth); // 0x11
Comm.Append (t3.GetBytes ());
comm.Skip(4);
}
+ public static string GetPlainPassword(SecureString secPass)
+ {
+ IntPtr plainString = IntPtr.Zero;
+ try
+ {
+ plainString = Marshal.SecureStringToGlobalAllocUnicode(secPass);
+ return Marshal.PtrToStringUni(plainString);
+ }
+ finally
+ {
+ Marshal.ZeroFreeGlobalAllocUnicode(plainString);
+ }
+ }
+
#endregion // Private Methods
#if NET_2_0
//
using System;
+using System.Security;
namespace Mono.Data.Tds.Protocol {
public sealed class Tds42 : Tds
Comm.Append ((byte) (tmp.Length < 30 ? tmp.Length : 30));
// password (offset 62 0x3e)
- tmp = Comm.Append (connectionParameters.Password, 30, pad);
+ tmp = Comm.Append (GetPlainPassword(connectionParameters.Password), 30, pad);
Comm.Append ((byte) (tmp.Length < 30 ? tmp.Length : 30));
// hostproc (offset 93 0x5d)
// remote passwords
Comm.Append (empty, 2, pad);
- tmp = Comm.Append (connectionParameters.Password, 253, pad);
+ tmp = Comm.Append (GetPlainPassword(connectionParameters.Password), 253, pad);
Comm.Append ((byte) (tmp.Length < 253 ? tmp.Length + 2 : 253 + 2));
// tds version
using Mono.Data.Tds;
using System;
using System.Text;
+using System.Security;
namespace Mono.Data.Tds.Protocol
{
// password (offset 62 0x3e)
// 62-92
- tmp = Comm.Append (connectionParameters.Password, 30, pad);
+ tmp = Comm.Append (GetPlainPassword(connectionParameters.Password), 30, pad);
Comm.Append ((byte) (tmp.Length < 30 ? tmp.Length : 30));
// hostproc (offset 93 0x5d)
// remote passwords
// 202-457
Comm.Append (empty, 2, pad);
- tmp = Comm.Append (connectionParameters.Password, 253, pad);
+ tmp = Comm.Append (GetPlainPassword(connectionParameters.Password), 253, pad);
Comm.Append ((byte) (tmp.Length < 253 ? tmp.Length + 2 : 253 + 2));
// tds version
using System;
using System.Globalization;
using System.Text;
+using System.Security;
using Mono.Security.Protocol.Ntlm;
return IsConnected;
}
- private static string EncryptPassword (string pass)
+ private static string EncryptPassword (SecureString secPass)
{
int xormask = 0x5a5a;
- int len = pass.Length;
+ int len = secPass.Length;
char[] chars = new char[len];
+ string pass = GetPlainPassword(secPass);
for (int i = 0; i < len; ++i) {
int c = ((int) (pass[i])) ^ xormask;
//
using System;
+using System.Security;
namespace Mono.Data.Tds.Protocol
{
public string Hostname;
public string Language;
public string LibraryName;
- public string Password;
+ public SecureString Password;
+ public bool PasswordSet;
public string ProgName;
public string User;
public bool DomainLogin;
Hostname = System.Net.Dns.GetHostName();
Language = String.Empty;
LibraryName = "Mono";
- Password = String.Empty;
+ Password = new SecureString();
+ PasswordSet = false;
ProgName = "Mono";
User = String.Empty;
DomainLogin = false;
-d:MONO_INTERPRETER \
-delaysign -keyfile:../mono.pub
-ifeq (monotouch, $(subst _runtime,,$(PROFILE)))
+MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime, $(PROFILE))
+
+ifdef MOBILE_STATIC
mono_dynamic_interpreter_deps = $(the_libdir_base)plaincore/System.Core.dll
LIB_MCS_FLAGS += -lib:$(the_libdir_base)plaincore
endif
$(the_libdir_base)plaincore/System.Core.dll:
(cd ../System.Core; $(MAKE) $@)
-.NOTPARALLEL: $(the_libdir_base)plaincore/System.Core.dll
\ No newline at end of file
+.NOTPARALLEL: $(the_libdir_base)plaincore/System.Core.dll
string msg = Locale.GetText ("Could not create user key store '{0}'.");
throw new CryptographicException (String.Format (msg, _userPath), e);
}
-
- if (!ProtectUser (_userPath)) {
- string msg = Locale.GetText ("Could not secure user key store '{0}'.");
- throw new IOException (String.Format (msg, _userPath));
- }
-
_userPathExists = true;
}
}
+ if (!IsUserProtected (_userPath) && !ProtectUser (_userPath)) {
+ string msg = Locale.GetText ("Could not secure user key store '{0}'.");
+ throw new IOException (String.Format (msg, _userPath));
+ }
}
// is it properly protected ?
if (!IsUserProtected (_userPath)) {
string msg = Locale.GetText ("Could not create machine key store '{0}'.");
throw new CryptographicException (String.Format (msg, _machinePath), e);
}
-
- if (!ProtectMachine (_machinePath)) {
- string msg = Locale.GetText ("Could not secure machine key store '{0}'.");
- throw new IOException (String.Format (msg, _machinePath));
- }
-
_machinePathExists = true;
}
}
+ if (!IsMachineProtected (_machinePath) && !ProtectMachine (_machinePath)) {
+ string msg = Locale.GetText ("Could not secure machine key store '{0}'.");
+ throw new IOException (String.Format (msg, _machinePath));
+ }
}
// is it properly protected ?
if (!IsMachineProtected (_machinePath)) {
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
KeyPairPersistence kpp = new KeyPairPersistence (cspParams);
- if (!kpp.Load ())
+ try {
+ if (!kpp.Load ())
+ return cert;
+ }
+ catch {
return cert;
+ }
if (cert.RSA != null)
cert.RSA = new RSACryptoServiceProvider (cspParams);
EXTRA_DISTFILES = \
src/ComponentModel/Strings.resx
-VALID_PROFILE := $(filter net_4_0 net_4_5 monotouch monodroid xammac mobile_static, $(PROFILE))
+VALID_PROFILE := $(filter net_4_0 net_4_5 monotouch monodroid xammac mobile mobile_static, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.ComponentModel.Composition.dll
NO_INSTALL = yes
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
# This is a .NET 3.5+ assembly
-VALID_PROFILE := $(filter net_2_0 net_4_0 net_4_5 monotouch monodroid xammac mobile_static, $(PROFILE))
+VALID_PROFILE := $(filter net_2_0 net_4_0 net_4_5 monotouch monodroid xammac mobile mobile_static, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.ComponentModel.DataAnnotations.dll
NO_INSTALL = yes
--- /dev/null
+#include net_4_5_System.ComponentModel.DataAnnotations.dll.sources
LIB_MCS_FLAGS += -d:NET_3_5 -nowarn:1720
endif
-ifeq (monodroid, $(PROFILE))
-LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR,FEATURE_REFEMIT,ANDROID
-endif
+MOBILE_DYNAMIC := $(filter monodroid xammac mobile, $(PROFILE))
+MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime, $(PROFILE))
-ifeq (xammac, $(PROFILE))
+ifdef MOBILE_DYNAMIC
LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR,FEATURE_REFEMIT
endif
system_core_plain_libdir = $(the_libdir_base)plaincore
-ifeq (monotouch, $(subst _runtime,,$(PROFILE)))
+ifdef MOBILE_STATIC
extra_test_flags := -exclude:NotWorkingInterpreter
system_core_library_deps = $(the_libdir_base)Mono.Dynamic.Interpreter.dll $(system_core_plain_libdir)/System.Core.dll
LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR
csproj-local:
$(MAKE) csproj-local intermediate=plaincore/
endif
-endif
\ No newline at end of file
+endif
-Assembly/AssemblyInfo.cs
-System/Actions.cs
-System/Funcs.cs
-System/InvalidTimeZoneException.cs
-System/TimeZoneInfo.AdjustmentRule.cs
-System/TimeZoneInfo.cs
-System/TimeZoneInfo.Serialization.cs
-System/TimeZoneInfo.TransitionTime.cs
-System/TimeZoneNotFoundException.cs
-System/Util.cs
-System.Runtime.CompilerServices/DynamicAttribute.cs
-System.Runtime.CompilerServices/ExecutionScope.cs
-System.Runtime.CompilerServices/ExtensionAttribute.cs
-System.Runtime.CompilerServices/IStrongBox.cs
-System.Runtime.CompilerServices/StrongBox_T.cs
-System.Linq/Check.cs
-System.Linq/Enumerable.cs
-System.Linq/QueryableEnumerable.cs
-System.Linq/QueryableTransformer.cs
-System.Linq/Grouping.cs
-System.Linq/IGrouping.cs
-System.Linq/IOrderedQueryable.cs
-System.Linq/IOrderedQueryable_T.cs
-System.Linq/IOrderedEnumerable_T.cs
-System.Linq/IQueryable.cs
-System.Linq/IQueryable_T.cs
-System.Linq/Lookup.cs
-System.Linq/ILookup_T.cs
-System.Linq/OrderedEnumerable.cs
-System.Linq/OrderedSequence.cs
-System.Linq/Queryable.cs
-System.Linq/QuickSort.cs
-System.Linq/SortContext.cs
-System.Linq/SortDirection.cs
-System.Linq/SortSequenceContext.cs
-System.Linq/IQueryProvider.cs
-System.Collections.Generic/HashSet.cs
-System.Security.Cryptography/Aes.cs
-System.Threading/LockRecursionPolicy.cs
-System.Threading/ReaderWriterLockSlim.cs
-System.Threading/ThreadLockState.cs
-System.Threading/ReaderWriterLockSlimExtensions.cs
-System.Linq.Parallel.QueryNodes/QueryBaseNode.cs
-System.Linq.Parallel.QueryNodes/QueryCastNode.cs
-System.Linq.Parallel.QueryNodes/QueryChildNode.cs
-System.Linq.Parallel.QueryNodes/QueryConcatNode.cs
-System.Linq.Parallel.QueryNodes/QueryDefaultEmptyNode.cs
-System.Linq.Parallel.QueryNodes/QueryGroupByNode.cs
-System.Linq.Parallel.QueryNodes/QueryHeadWorkerNode.cs
-System.Linq.Parallel.QueryNodes/QueryJoinNode.cs
-System.Linq.Parallel.QueryNodes/QueryMuxNode.cs
-System.Linq.Parallel.QueryNodes/QueryOptionNode.cs
-System.Linq.Parallel.QueryNodes/QueryOrderByNode.cs
-System.Linq.Parallel.QueryNodes/QueryOrderGuardNode.cs
-System.Linq.Parallel.QueryNodes/QueryOrderedStreamNode.cs
-System.Linq.Parallel.QueryNodes/QueryReverseNode.cs
-System.Linq.Parallel.QueryNodes/QuerySelectManyNode.cs
-System.Linq.Parallel.QueryNodes/QuerySelectNode.cs
-System.Linq.Parallel.QueryNodes/QuerySetNode.cs
-System.Linq.Parallel.QueryNodes/QueryStartNode.cs
-System.Linq.Parallel.QueryNodes/QueryStreamNode.cs
-System.Linq.Parallel.QueryNodes/QueryWhereNode.cs
-System.Linq.Parallel.QueryNodes/QueryZipNode.cs
-System.Linq.Parallel.QueryNodes/SetInclusion.cs
-System.Linq.Parallel.QueryNodes/WrapHelper.cs
-System.Linq.Parallel/AggregationList.cs
-System.Linq.Parallel/ConcurrentGrouping.cs
-System.Linq.Parallel/ConcurrentLookup.cs
-System.Linq.Parallel/INodeVisitor.cs
-System.Linq.Parallel/IVisitableNode.cs
-System.Linq.Parallel/OrderingEnumerator.cs
-System.Linq.Parallel/ParallelExecuter.cs
-System.Linq.Parallel/ParallelPartitioner.cs
-System.Linq.Parallel/ParallelQueryEnumerator.cs
-System.Linq.Parallel/ParallelQuickSort.cs
-System.Linq.Parallel/QueryCheckerVisitor.cs
-System.Linq.Parallel/QueryIsOrderedVisitor.cs
-System.Linq.Parallel/QueryOptions.cs
-System.Linq.Parallel/RangeList.cs
-System.Linq.Parallel/RepeatList.cs
-System.Linq.Parallel/ReverseList.cs
-System.Linq.Parallel/StripPartitioner.cs
-System.Linq.Parallel/TemporaryArea.cs
-System.Linq/EnumerableExecutor.cs
-System.Linq/EnumerableExecutor_T.cs
-System.Linq/EnumerableQuery.cs
-System.Linq/EnumerableQuery_T.cs
-System.Linq/OrderedParallelQuery.cs
-System.Linq/ParallelEnumerable.cs
-System.Linq/ParallelExecutionMode.cs
-System.Linq/ParallelMergeOptions.cs
-System.Linq/ParallelQuery.cs
-System.IO.MemoryMappedFiles/MemoryMappedFile.cs
-System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs
-System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs
-System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs
-System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs
-System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs
-System.IO.MemoryMappedFiles/MemoryMappedViewAccessor.cs
-Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs
-Microsoft.Win32.SafeHandles/SafeMemoryMappedViewHandle.cs
-System.IO/HandleInheritability.cs
-System.Threading.Tasks/TaskExtensions.cs
-System.Linq.Expressions/Extensions.cs
-System.Linq.Expressions/ExpressionTransformer.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/Closure.cs
-System.Linq.Expressions/DynamicExpressionVisitor.cs
+#include mobile_common_System.Core.dll.sources
+
+#include dynamic_System.Core.dll.sources
--- /dev/null
+Assembly/AssemblyInfo.cs
+System/Actions.cs
+System/Funcs.cs
+System/InvalidTimeZoneException.cs
+System/TimeZoneInfo.AdjustmentRule.cs
+System/TimeZoneInfo.cs
+System/TimeZoneInfo.Serialization.cs
+System/TimeZoneInfo.TransitionTime.cs
+System/TimeZoneNotFoundException.cs
+System/Util.cs
+System.Runtime.CompilerServices/DynamicAttribute.cs
+System.Runtime.CompilerServices/ExecutionScope.cs
+System.Runtime.CompilerServices/ExtensionAttribute.cs
+System.Runtime.CompilerServices/IStrongBox.cs
+System.Runtime.CompilerServices/StrongBox_T.cs
+System.Linq/Check.cs
+System.Linq/Enumerable.cs
+System.Linq/QueryableEnumerable.cs
+System.Linq/QueryableTransformer.cs
+System.Linq/Grouping.cs
+System.Linq/IGrouping.cs
+System.Linq/IOrderedQueryable.cs
+System.Linq/IOrderedQueryable_T.cs
+System.Linq/IOrderedEnumerable_T.cs
+System.Linq/IQueryable.cs
+System.Linq/IQueryable_T.cs
+System.Linq/Lookup.cs
+System.Linq/ILookup_T.cs
+System.Linq/OrderedEnumerable.cs
+System.Linq/OrderedSequence.cs
+System.Linq/Queryable.cs
+System.Linq/QuickSort.cs
+System.Linq/SortContext.cs
+System.Linq/SortDirection.cs
+System.Linq/SortSequenceContext.cs
+System.Linq/IQueryProvider.cs
+System.Collections.Generic/HashSet.cs
+System.Security.Cryptography/Aes.cs
+System.Threading/LockRecursionPolicy.cs
+System.Threading/ReaderWriterLockSlim.cs
+System.Threading/ThreadLockState.cs
+System.Threading/ReaderWriterLockSlimExtensions.cs
+System.Linq.Parallel.QueryNodes/QueryBaseNode.cs
+System.Linq.Parallel.QueryNodes/QueryCastNode.cs
+System.Linq.Parallel.QueryNodes/QueryChildNode.cs
+System.Linq.Parallel.QueryNodes/QueryConcatNode.cs
+System.Linq.Parallel.QueryNodes/QueryDefaultEmptyNode.cs
+System.Linq.Parallel.QueryNodes/QueryGroupByNode.cs
+System.Linq.Parallel.QueryNodes/QueryHeadWorkerNode.cs
+System.Linq.Parallel.QueryNodes/QueryJoinNode.cs
+System.Linq.Parallel.QueryNodes/QueryMuxNode.cs
+System.Linq.Parallel.QueryNodes/QueryOptionNode.cs
+System.Linq.Parallel.QueryNodes/QueryOrderByNode.cs
+System.Linq.Parallel.QueryNodes/QueryOrderGuardNode.cs
+System.Linq.Parallel.QueryNodes/QueryOrderedStreamNode.cs
+System.Linq.Parallel.QueryNodes/QueryReverseNode.cs
+System.Linq.Parallel.QueryNodes/QuerySelectManyNode.cs
+System.Linq.Parallel.QueryNodes/QuerySelectNode.cs
+System.Linq.Parallel.QueryNodes/QuerySetNode.cs
+System.Linq.Parallel.QueryNodes/QueryStartNode.cs
+System.Linq.Parallel.QueryNodes/QueryStreamNode.cs
+System.Linq.Parallel.QueryNodes/QueryWhereNode.cs
+System.Linq.Parallel.QueryNodes/QueryZipNode.cs
+System.Linq.Parallel.QueryNodes/SetInclusion.cs
+System.Linq.Parallel.QueryNodes/WrapHelper.cs
+System.Linq.Parallel/AggregationList.cs
+System.Linq.Parallel/ConcurrentGrouping.cs
+System.Linq.Parallel/ConcurrentLookup.cs
+System.Linq.Parallel/INodeVisitor.cs
+System.Linq.Parallel/IVisitableNode.cs
+System.Linq.Parallel/OrderingEnumerator.cs
+System.Linq.Parallel/ParallelExecuter.cs
+System.Linq.Parallel/ParallelPartitioner.cs
+System.Linq.Parallel/ParallelQueryEnumerator.cs
+System.Linq.Parallel/ParallelQuickSort.cs
+System.Linq.Parallel/QueryCheckerVisitor.cs
+System.Linq.Parallel/QueryIsOrderedVisitor.cs
+System.Linq.Parallel/QueryOptions.cs
+System.Linq.Parallel/RangeList.cs
+System.Linq.Parallel/RepeatList.cs
+System.Linq.Parallel/ReverseList.cs
+System.Linq.Parallel/StripPartitioner.cs
+System.Linq.Parallel/TemporaryArea.cs
+System.Linq/EnumerableExecutor.cs
+System.Linq/EnumerableExecutor_T.cs
+System.Linq/EnumerableQuery.cs
+System.Linq/EnumerableQuery_T.cs
+System.Linq/OrderedParallelQuery.cs
+System.Linq/ParallelEnumerable.cs
+System.Linq/ParallelExecutionMode.cs
+System.Linq/ParallelMergeOptions.cs
+System.Linq/ParallelQuery.cs
+System.IO.MemoryMappedFiles/MemoryMappedFile.cs
+System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs
+System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs
+System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs
+System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs
+System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs
+System.IO.MemoryMappedFiles/MemoryMappedViewAccessor.cs
+Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs
+Microsoft.Win32.SafeHandles/SafeMemoryMappedViewHandle.cs
+System.IO/HandleInheritability.cs
+System.Threading.Tasks/TaskExtensions.cs
+System.Linq.Expressions/Extensions.cs
+System.Linq.Expressions/ExpressionTransformer.cs
+../dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs
+../dlr/Runtime/Microsoft.Scripting.Core/Compiler/Closure.cs
+System.Linq.Expressions/DynamicExpressionVisitor.cs
--- /dev/null
+#include mobile_common_System.Core.dll.sources
+#include interpreter_System.Core.dll.sources
-#include mobile_System.Core.dll.sources
+#include mobile_common_System.Core.dll.sources
#include dynamic_System.Core.dll.sources
-#include mobile_System.Core.dll.sources
+#include mobile_common_System.Core.dll.sources
#include interpreter_System.Core.dll.sources
System/TimeZoneInfo.MonoTouch.cs
-#include mobile_System.Core.dll.sources
+#include mobile_common_System.Core.dll.sources
#include dynamic_System.Core.dll.sources
-#include System.Data.Services.Client.dll.sources
-./Client/AssemblyAttributes.cs
+#include net_4_5_System.Data.Services.Client.dll.sources
#if NET_2_0
using System.Collections.Generic;
#endif
+using System.Security;
namespace System.Data.SqlClient
{
// The connection string that identifies this connection
string connectionString;
+ // The connection credentials
+ SqlCredential credentials;
+
// The transaction object for the current transaction
SqlTransaction transaction;
ConnectionString = connectionString;
}
+ public SqlConnection (string connectionString, SqlCredential cred)
+ {
+ ConnectionString = connectionString;
+ Credentials = cred;
+ }
+
#endregion // Constructors
#region Properties
}
}
+ public SqlCredential Credentials {
+ get {
+ return credentials;
+ }
+ set {
+ credentials = value;
+ }
+ }
+
#if !NET_2_0
[DataSysDescription ("Current connection timeout value, 'Connect Timeout=X' in the ConnectionString.")]
#endif
if (!tds.IsConnected) {
try {
+ if (Credentials != null) {
+ if (parms.User != String.Empty)
+ throw new ArgumentException("UserID already specified");
+ if (parms.PasswordSet)
+ throw new ArgumentException("Password already specified");
+ if (parms.DomainLogin != false)
+ throw new ArgumentException("Cannot use credentials with DomainLogin");
+ parms.User = Credentials.UserId;
+ parms.Password = Credentials.Password;
+ }
tds.Connect (parms);
} catch {
if (pooling)
break;
case "password" :
case "pwd" :
- parms.Password = value;
+ parms.Password = new SecureString();
+ foreach (char c in value)
+ parms.Password.AppendChar(c);
+ parms.PasswordSet = true;
break;
case "persistsecurityinfo" :
case "persist security info" :
--- /dev/null
+//
+// System.Data.SqlClient.SqlCredential.cs
+//
+// Author:
+// Neale Ferguson (neale@sinenomine.net)
+//
+// Copyright (C) Neale Ferguson, 2014
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace System.Data.SqlClient {
+ /// <summary>
+ /// Describes an error from a SQL database.
+ /// </summary>
+ [Serializable]
+ public sealed class SqlCredential
+ {
+ #region Fields
+
+ string uid = "";
+ SecureString pwd = null;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public SqlCredential (string user, SecureString password)
+ {
+ if (user == null)
+ throw new ArgumentNullException("UserID");
+ if (password == null)
+ throw new ArgumentNullException("Password");
+ this.uid = user;
+ this.pwd = password;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public string UserId {
+ get { return uid; }
+ }
+
+ public SecureString Password {
+ get { return pwd; }
+ }
+
+ #endregion
+ }
+}
System.Data.SqlClient/SqlCommandBuilder.cs
System.Data.SqlClient/SqlConnection.cs
System.Data.SqlClient/SqlConnectionStringBuilder.cs
+System.Data.SqlClient/SqlCredential.cs
System.Data.SqlClient/SqlDataAdapter.cs
System.Data.SqlClient/SqlDataReader.cs
System.Data.SqlClient/SqlDataSourceConverter.cs
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid mobile mobile_static xammac net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Interactive.Async.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Interactive.Providers.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Interactive.dll
NO_SIGN_ASSEMBLY = yes
NfiUser.PercentNegativePattern = 2;
NfiUser.PercentPositivePattern = 2;
NfiUser.PercentSymbol = "%%%";
+ NfiUser.NumberDecimalSeparator = ".";
}
[Test]
Assert.AreEqual (0m, (decimal)new BigInteger (), "#8");
}
+ [SetCulture ("pt-BR")]
+ [Test]
+ public void Parse_pt_BR ()
+ {
+ Parse ();
+ }
+
[Test]
public void Parse () {
try {
Assert.AreEqual (-23, (int)BigInteger.Parse(" -23 ", NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite), "#19");
Assert.AreEqual (300000, (int)BigInteger.Parse("3E5", NumberStyles.AllowExponent), "#20");
- Assert.AreEqual (250, (int)BigInteger.Parse("2"+Nfi.NumberDecimalSeparator+"5E2", NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint), "#21");//2.5E2 = 250
+ var dsep = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
+ Assert.AreEqual (250, (int)BigInteger.Parse("2" + dsep + "5E2", NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint), "#21");//2.5E2 = 250
Assert.AreEqual (25, (int)BigInteger.Parse("2500E-2", NumberStyles.AllowExponent), "#22");
Assert.AreEqual ("136236974127783066520110477975349088954559032721408", BigInteger.Parse("136236974127783066520110477975349088954559032721408", NumberStyles.None).ToString(), "#23");
}
try {
- Int32.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
+ Int32.Parse ("2" + dsep + "09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
Assert.Fail ("#26");
} catch (OverflowException) {
}
EXTRA_DISTFILES = more_build_args $(RESX_RESOURCES:.resources=.resx) $(PREBUILT)
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.Core.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.Debugger.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.Experimental.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.Interfaces.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args $(RESX_RESOURCES:.resources=.resx) $(PREBUILT)
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.Linq.dll
NO_SIGN_ASSEMBLY = yes
EXTRA_DISTFILES = more_build_args $(RESX_RESOURCES:.resources=.resx) $(PREBUILT)
-VALID_PROFILE := $(filter monotouch monodroid xammac net_4_0 net_4_5, $(PROFILE))
+VALID_PROFILE := $(filter monotouch monodroid xammac mobile mobile_static net_4_0 net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.System.Reactive.PlatformServices.dll
NO_SIGN_ASSEMBLY = yes
foreach (var fd in od.Faults)
o.FaultContractInfos.Add (new FaultContractInfo (fd.Action, fd.DetailType));
+ o.BeginMethod = od.BeginMethod;
+ o.EndMethod = od.EndMethod;
+
// FIXME: at initialization time it does not seem to
// fill default formatter. It should be filled after
// applying all behaviors. (Tthat causes regression, so
for (int i = 0; i < contractMethods.Length; ++i)
{
-
MethodInfo mi = contractMethods [i];
OperationContractAttribute oca = GetOperationContractAttribute (mi);
if (oca == null)
if (GetOperationContractAttribute (end) != null)
throw new InvalidOperationException ("Async 'End' method must not have OperationContractAttribute. It is automatically treated as the EndMethod of the corresponding 'Begin' method.");
}
- OperationDescription od = GetOrCreateOperation (cd, mi, serviceMethods [i], oca, end != null ? end.ReturnType : null, isCallback, givenServiceType);
+ OperationDescription od = GetOrCreateOperation (cd, mi, serviceMethods [i], oca, end, isCallback, givenServiceType);
if (end != null)
od.EndMethod = end;
}
static OperationDescription GetOrCreateOperation (
ContractDescription cd, MethodInfo mi, MethodInfo serviceMethod,
OperationContractAttribute oca,
- Type asyncReturnType,
+ MethodInfo endMethod,
bool isCallback,
Type givenServiceType)
{
od.Messages.Add (GetMessage (od, mi, oca, true, isCallback, null));
if (!od.IsOneWay) {
- var md = GetMessage (od, mi, oca, false, isCallback, asyncReturnType);
+ var asyncReturnType = endMethod != null ? endMethod.ReturnType : null;
+ var md = GetMessage (od, endMethod ?? mi, oca, false, isCallback, asyncReturnType);
od.Messages.Add (md);
var mpa = mi.ReturnParameter.GetCustomAttribute<MessageParameterAttribute> (true);
if (mpa != null) {
int index = 0;
foreach (ParameterInfo pi in plist) {
// AsyncCallback and state are extraneous.
- if (oca.AsyncPattern && pi.Position == plist.Length - 2)
- break;
+ if (oca.AsyncPattern) {
+ if (isRequest && pi.Position == plist.Length - 2)
+ break;
+ if (!isRequest && pi.Position == plist.Length - 1)
+ break;
+ }
// They are ignored:
// - out parameter in request
}
else {
int index = ParamsOffset (md.Body);
- foreach (ParameterInfo pi in requestMethodParams)
+ foreach (ParameterInfo pi in replyMethodParams) {
if (pi.IsOut || pi.ParameterType.IsByRef)
parameters [pi.Position] = parts [index++];
+ }
return HasReturnValue (md.Body) ? parts [0] : null;
}
}
#region delegates
readonly ProcessDelegate _processDelegate;
- delegate object ProcessDelegate (MethodBase method, string operationName, object [] parameters, OperationContext context);
+ delegate object ProcessDelegate (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context);
readonly RequestDelegate requestDelegate;
#region Request/Output processing
- class OperationParameters
- {
- public object[] Parameters;
- public object UserData;
- }
-
public IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters, AsyncCallback callback, object asyncState)
{
- var p = new OperationParameters { Parameters = parameters, UserData = asyncState };
- return _processDelegate.BeginInvoke (method, operationName, parameters, OperationContext.Current, callback, p);
+ var p = parameters;
+ var retval = _processDelegate.BeginInvoke (method, operationName, true, ref p, OperationContext.Current, callback, asyncState);
+ if (p != parameters)
+ throw new InvalidOperationException ();
+ return retval;
}
public object EndProcess (MethodBase method, string operationName, object [] parameters, IAsyncResult result)
if (parameters == null)
throw new ArgumentNullException ("parameters");
- var p = (OperationParameters)result.AsyncState;
- if (p.Parameters.Length != parameters.Length)
- throw new ArgumentException ("Parameter array has invalid length.", "parameters");
+ object[] p = parameters;
+ var retval = _processDelegate.EndInvoke (ref p, result);
+ if (p == parameters)
+ return retval;
- for (int i = 0; i < parameters.Length; i++)
- parameters [i] = p.Parameters [i];
-
- return _processDelegate.EndInvoke (result);
+ if (p.Length != parameters.Length)
+ throw new InvalidOperationException ();
+ Array.Copy (p, parameters, p.Length);
+ return retval;
}
public object Process (MethodBase method, string operationName, object [] parameters, OperationContext context)
+ {
+ var p = parameters;
+ var retval = Process (method, operationName, false, ref p, context);
+ if (p != parameters)
+ throw new InvalidOperationException ();
+ return retval;
+ }
+
+ object Process (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context)
{
var previousContext = OperationContext.Current;
try {
// Inherit the context from the calling thread
OperationContext.Current = context;
- return DoProcess (method, operationName, parameters, context);
+ return DoProcess (method, operationName, isAsync, ref parameters, context);
} catch (Exception ex) {
throw;
} finally {
}
}
- object DoProcess (MethodBase method, string operationName, object [] parameters, OperationContext context)
+ object DoProcess (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context)
{
if (AllowInitializationUI)
DisplayInitializationUI ();
Open ();
if (!od.IsOneWay)
- return Request (od, parameters, context);
+ return Request (od, isAsync, ref parameters, context);
else {
Output (od, parameters, context);
return null;
Send (CreateRequest (op, parameters, context), OperationTimeout);
}
- object Request (OperationDescription od, object [] parameters, OperationContext context)
+ object Request (OperationDescription od, bool isAsync, ref object [] parameters, OperationContext context)
{
ClientOperation op = runtime.Operations [od.Name];
object [] inspections = new object [runtime.MessageInspectors.Count];
for (int i = 0; i < inspections.Length; i++)
runtime.MessageInspectors [i].AfterReceiveReply (ref res, inspections [i]);
- if (op.DeserializeReply)
- return op.Formatter.DeserializeReply (res, parameters);
- else
+ if (!op.DeserializeReply)
return res;
+
+ if (isAsync && od.EndMethod != null) {
+ var endParams = od.EndMethod.GetParameters ();
+ parameters = new object [endParams.Length - 1];
+ }
+
+ return op.Formatter.DeserializeReply (res, parameters);
}
#region Message-based Request() and Send()
LIBRARY_COMPILE = $(BOOT_COMPILE)
endif
-PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac, $(PROFILE))
+PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac mobile mobile_static, $(PROFILE))
LIB_MCS_FLAGS = -r:$(corlib) -r:System.dll -nowarn:0618,0612,0642
ifeq (2.1, $(FRAMEWORK_VERSION))
csproj-local:
$(MAKE) csproj-local intermediate=bare/
endif
-endif
\ No newline at end of file
+endif
Test/XmlFiles/*.xml \
Test/XmlFiles/*.xaml
-VALID_PROFILE := $(filter 4 monodroid monotouch, $(FRAMEWORK_VERSION_MAJOR))
+VALID_PROFILE := $(filter 4 monodroid monotouch mobile mobile_static, $(FRAMEWORK_VERSION_MAJOR))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.Xaml.dll
NO_INSTALL = yes
LIB_MCS_FLAGS = -nowarn:618 -d:CONFIGURATION_2_0 -unsafe $(RESOURCE_FILES:%=-resource:%)
TEST_MCS_FLAGS += -r:System.Configuration
-PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac, $(PROFILE))
-NOT_SL := $(filter net_2_0 net_4_0 net_4_5 monotouch_runtime mobile xammac, $(PROFILE))
+PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammaci mobile mobile_static, $(PROFILE))
ifeq (2.1, $(FRAMEWORK_VERSION))
LIB_MCS_FLAGS += -d:INSIDE_SYSTEM
-ifeq (moonlight_raw, $(PROFILE))
-LIB_MCS_FLAGS += -d:SECURITY_DEP
-endif
endif
ifeq (monotouch, $(subst _runtime,,$(PROFILE)))
LIB_MCS_FLAGS += -d:SECURITY_DEP
$(MAKE) csproj-local intermediate=bare/
$(MAKE) csproj-local intermediate=secxml/
endif
-endif
\ No newline at end of file
+endif
public DiagnosticsConfigurationHandler ()
{
elementHandlers ["assert"] = new ElementHandler (AddAssertNode);
+ elementHandlers ["performanceCounters"] = new ElementHandler (AddPerformanceCountersNode);
elementHandlers ["switches"] = new ElementHandler (AddSwitchesNode);
elementHandlers ["trace"] = new ElementHandler (AddTraceNode);
elementHandlers ["sources"] = new ElementHandler (AddSourcesNode);
ThrowUnrecognizedElement (node.ChildNodes[0]);
}
+ private void AddPerformanceCountersNode (IDictionary d, XmlNode node)
+ {
+ XmlAttributeCollection c = node.Attributes;
+ string filemappingsize = GetAttribute (c, "filemappingsize", false, node);
+ ValidateInvalidAttributes (c, node);
+ if (filemappingsize != null) {
+ try {
+ d ["filemappingsize"] = int.Parse (filemappingsize);
+ }
+ catch (Exception e) {
+ throw new ConfigurationException ("The `filemappingsize' attribute must be an integral value.",
+ e, node);
+ }
+ }
+
+ if (node.ChildNodes.Count > 0)
+ ThrowUnrecognizedElement (node.ChildNodes[0]);
+ }
+
// name and value attributes are required
// Docs do not define "remove" or "clear" elements, but .NET recognizes
// them
ValidateExceptions ("#TAT:BadChildren", "<assert>{0}</assert>", badChildren);
}
+ [Test]
+ [Category ("NotDotNet")]
+ public void PerformanceCountersTag ()
+ {
+ string[] goodAttributes = {
+ "",
+ "filemappingsize=\"1048576\"",
+ "filemappingsize=\"0\""
+ };
+ ValidateSuccess ("#PCT:Good", "<performanceCounters {0}/>", goodAttributes);
+
+ string[] badAttributes = {
+ "FileMappingSize=\"1048576\"",
+ "filemappingsize=\"\"",
+ "filemappingsize=\"non-int-value\""
+ };
+ ValidateExceptions ("#PCT:BadAttrs", "<performanceCounters {0}/>", badAttributes);
+
+ string[] badChildren = {
+ "<any element=\"here\"/>"
+ };
+ ValidateExceptions ("#PCT:BadChildren", "<performanceCounters>{0}</performanceCounters>", badChildren);
+ }
+
[Test]
[Category ("NotDotNet")]
public void TraceTag_Attributes ()
[Test]
[ExpectedException (typeof (InvalidOperationException))]
- public void ReName ()
+ public void Rename ()
{
- Thread t = new Thread (new ThreadStart (ReName));
+ Thread t = new Thread (new ThreadStart (Rename));
t.Name = "a";
t.Name = "b";
}
+ bool rename_finished;
+ bool rename_failed;
+
+ [Test]
+ public void RenameTpThread ()
+ {
+ object monitor = new object ();
+ ThreadPool.QueueUserWorkItem (new WaitCallback (Rename_callback), monitor);
+ lock (monitor) {
+ if (!rename_finished)
+ Monitor.Wait (monitor);
+ }
+ Assert.IsFalse (rename_failed);
+ }
+
+ void Rename_callback (object o) {
+ Thread.CurrentThread.Name = "a";
+ try {
+ Thread.CurrentThread.Name = "b";
+ } catch (Exception) {
+ rename_failed = true;
+ }
+ object monitor = o;
+ lock (monitor) {
+ rename_finished = true;
+ Monitor.Pulse (monitor);
+ }
+ }
+
[Test]
public void TestNestedThreads1()
{
Assert.AreEqual (this, arg, "obj");
}
+ bool set_name_failed;
+
[Test]
public void SetNameTpThread () {
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));
--- /dev/null
+// CS0111: A member `S3.S3(string)' is already defined. Rename this member or use different parameter types
+// Line: 6
+
+struct S3 (string s)
+{
+ public S3 (string s)
+ : this (1)
+ {
+ }
+
+ public S3 (int i)
+ : this ("")
+ {
+ }
+}
--- /dev/null
+// CS0411: The type arguments for method `C.Foo<T>(out T)' cannot be inferred from the usage. Try specifying the type arguments explicitly
+// Line: 8
+
+public class C
+{
+ public static void Main ()
+ {
+ Foo (out var y);
+ }
+
+ static void Foo<T> (out T t)
+ {
+ t = default (T);
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS0516: Constructor `Sample.Sample()' cannot call itself
+// Line: 6
+
+struct Sample {
+ public Sample ()
+ : this ()
+ {
+ }
+}
// CS0516: Constructor `Sample.Sample()' cannot call itself
-// Line: 5
+// Line: 6
class Sample {
- public Sample (): this () {}
+ public Sample ()
+ : this ()
+ {
+ }
}
-
-
-
+++ /dev/null
-// CS0568: Structs cannot contain explicit parameterless constructors
-// Line: 5
-struct A {
- int a;
- A () { a = 1; }
-}
-
-class D {
- static void Main ()
- {
- A [] a = new A [10];
-
- }
-}
--- /dev/null
+// CS0619: `S.S()' is obsolete: `ctor'
+// Line: 18
+
+using System;
+
+struct S
+{
+ [Obsolete ("ctor", true)]
+ public S ()
+ {
+ }
+}
+
+class C
+{
+ public static void Main ()
+ {
+ new S ();
+ }
+}
--- /dev/null
+// CS0815: An implicitly typed local variable declaration cannot be initialized with `void'
+// Line: 8
+
+class X
+{
+ public static void Main ()
+ {
+ Foo (out var x = Main ());
+ }
+
+ static void Foo (out int i)
+ {
+ i = 0;
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS0841: A local variable `x' cannot be used before it is declared
+// Line: 8
+
+class X
+{
+ public static void Main ()
+ {
+ Foo (x, out var x);
+ }
+
+ static void Foo (int arg, out int value)
+ {
+ value = 3;
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1501: No overload for method `Bar' takes `2' arguments
+// Line: 19
+
+using System;
+
+class T
+{
+ void Foo (int arg, Action a)
+ {
+ }
+
+ void Foo (string title, Action a)
+ {
+ }
+
+ void Bar ()
+ {
+ Foo (arg: 1, a: () => {
+ Bar ("a", "b");
+ });
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1501: Argument `#1' cannot convert `ref string' expression to type `ref int'
+// Line: 8
+
+class C
+{
+ public static void Main ()
+ {
+ Foo (ref var x = "");
+ }
+
+ static void Foo (ref int i)
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1615: Argument `#1' does not require `out' modifier. Consider removing `out' modifier
+// Line: 8
+
+public class C
+{
+ public static void Main ()
+ {
+ Foo (out var y);
+ }
+
+ static void Foo (int x)
+ {
+ }
+
+ static void Foo (string x)
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1644: Feature `struct parameterless instance constructor' cannot be used because it is not part of the C# 5.0 language specification
+// Line: 12
+// Compiler options: -langversion:5
+
+struct S
+{
+ public S ()
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1644: Feature `struct instance member initializer' cannot be used because it is not part of the C# 5.0 language specification
+// Line: 12
+// Compiler options: -langversion:5
+
+struct S
+{
+ int i = 0;
+}
\ No newline at end of file
--- /dev/null
+// CS1644: Feature `declaration expression' cannot be used because it is not part of the C# 5.0 language specification
+// Line: 12
+// Compiler options: -langversion:5
+
+class C
+{
+ public static void Main ()
+ {
+ int.TryParse ("0", out var v);
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS8046: An expression tree cannot contain a declaration expression
+// Line: 11
+
+using System;
+using System.Linq.Expressions;
+
+class C
+{
+ static void Main()
+ {
+ Expression<Func<bool>> e = () => Out (out int x);
+ }
+
+ static bool Out (out int value)
+ {
+ value = 3;
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS8047: Declaration expression cannot be used in this context
+// Line: 8
+
+public class C
+{
+ public static void Main ()
+ {
+ dynamic target = 3;
+ var x = new Test (target, out var y);
+ }
+}
+
+class Test
+{
+ public Test (int x, out int y)
+ {
+ y = 0;
+ }
+}
\ No newline at end of file
+++ /dev/null
-// CS0573: `A.a': Structs without explicit constructors cannot contain members with initializers
-// Line: 5
-
-partial struct A {
- int a = 1;
-}
+++ /dev/null
-// CS0573: `A.a': Structs without explicit constructors cannot contain members with initializers
-// Line: 5
-
-struct A {
- int a = 1;
-}
+++ /dev/null
-// CS8054: `S.P': Structs without explicit constructors cannot contain members with initializers
-// Line: 6
-
-struct S
-{
- public decimal P { get; } = -3;
-}
\ No newline at end of file
--- /dev/null
+// CS8075: `A.A()': Structs parameterless instance constructor must be public
+// Line: 6
+
+struct A
+{
+ A ()
+ {
+ }
+}
}
}
- public virtual void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression)
+ public void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression)
{
if (IsPartialPart)
PartialContainer.RegisterFieldForInitialization (field, expression);
initialized_static_fields.Add (expression);
} else {
+ if (Kind == MemberKind.Struct && Compiler.Settings.Version < LanguageVersion.V_6) {
+ Report.FeatureIsNotAvailable (Compiler, expression.Location, "struct instance member initializer");
+ }
+
if (initialized_fields == null)
initialized_fields = new List<FieldInitializer> (4);
//
// Field is re-initialized to its default value => removed
//
- if (fi.IsDefaultInitializer && ec.Module.Compiler.Settings.Optimize)
+ if (fi.IsDefaultInitializer && Kind != MemberKind.Struct && ec.Module.Compiler.Settings.Optimize)
continue;
ec.AssignmentInfoOffset += fi.AssignmentOffset;
if (Kind == MemberKind.Class)
c.Initializer = new GeneratedBaseInitializer (Location, PrimaryConstructorBaseArguments);
- if (PrimaryConstructorParameters != null && !is_static)
+ if (PrimaryConstructorParameters != null && !is_static) {
c.IsPrimaryConstructor = true;
+ c.caching_flags |= Flags.MethodOverloadsExist;
+ }
AddConstructor (c, true);
if (PrimaryConstructorBlock == null) {
CheckProtectedModifier ();
if (PrimaryConstructorParameters != null) {
+
foreach (Parameter p in PrimaryConstructorParameters.FixedParameters) {
if (p.Name == MemberName.Name) {
Report.Error (8039, p.Location, "Primary constructor of type `{0}' has parameter of same name as containing type",
protected override bool DoDefineMembers ()
{
- if (PrimaryConstructorParameters != null)
+ var res = base.DoDefineMembers ();
+
+ if (PrimaryConstructorParameters != null || (initialized_fields != null && !HasUserDefaultConstructor ())) {
generated_primary_constructor = DefineDefaultConstructor (false);
+ generated_primary_constructor.Define ();
+ }
- return base.DoDefineMembers ();
+ return res;
}
public override void Emit ()
base.Emit ();
}
- bool HasExplicitConstructor ()
+ bool HasUserDefaultConstructor ()
{
- foreach (var m in Members) {
+ foreach (var m in PartialContainer.Members) {
var c = m as Constructor;
if (c == null)
continue;
- if (!c.ParameterInfo.IsEmpty)
+ if (!c.IsStatic && c.ParameterInfo.IsEmpty)
return true;
}
base_type = Compiler.BuiltinTypes.ValueType;
return ifaces;
}
-
- public override void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression)
- {
- if ((field.ModFlags & Modifiers.STATIC) == 0 && !HasExplicitConstructor ()) {
- Report.Error (8054, field.Location, "`{0}': Structs without explicit constructors cannot contain members with initializers",
- field.GetSignatureForError ());
-
- return;
- }
-
- base.RegisterFieldForInitialization (field, expression);
- }
}
/// <summary>
;
named_argument
- : identifier_inside_body COLON opt_named_modifier expression_or_error
+ : identifier_inside_body COLON opt_named_modifier named_argument_expr
{
if (lang_version <= LanguageVersion.V_3)
FeatureIsNotAvailable (GetLocation ($1), "named argument");
lbag.AddLocation ($$, GetLocation($2));
}
;
+
+named_argument_expr
+ : expression_or_error
+ | declaration_expression
+ ;
opt_named_modifier
: /* empty */ { $$ = null; }
if (lt.Value != current_container.MemberName.Name) {
report.Error (1520, c.Location, "Class, struct, or interface method must have a return type");
} else if ((mods & Modifiers.STATIC) != 0) {
+ if (!current_local_parameters.IsEmpty) {
+ report.Error (132, c.Location, "`{0}': The static constructor must be parameterless",
+ c.GetSignatureForError ());
+ }
+
if ((mods & Modifiers.AccessibilityMask) != 0){
report.Error (515, c.Location,
"`{0}': static constructor cannot have an access modifier",
c.GetSignatureForError ());
}
+ } else {
+ if (current_type.Kind == MemberKind.Struct && current_local_parameters.IsEmpty) {
+ if (lang_version < LanguageVersion.V_6)
+ FeatureIsNotAvailable (GetLocation ($3), "struct parameterless instance constructor");
+
+ if ((mods & Modifiers.PUBLIC) == 0) {
+ report.Error (8075, c.Location, "`{0}': Structs parameterless instance constructor must be public", c.GetSignatureForError ());
+ }
+ }
}
current_type.AddConstructor (c);
$$ = new Argument ((Expression) $2, Argument.AType.Ref);
lbag.AddLocation ($$, GetLocation ($1));
}
+ | REF declaration_expression
+ {
+ $$ = new Argument ((Expression) $2, Argument.AType.Ref);
+ }
| OUT variable_reference
{
$$ = new Argument ((Expression) $2, Argument.AType.Out);
lbag.AddLocation ($$, GetLocation ($1));
}
+ | OUT declaration_expression
+ {
+ $$ = new Argument ((Expression) $2, Argument.AType.Out);
+ }
| ARGLIST OPEN_PARENS argument_list CLOSE_PARENS
{
$$ = new Argument (new Arglist ((Arguments) $3, GetLocation ($1)));
}
;
+declaration_expression
+ : OPEN_PARENS declaration_expression CLOSE_PARENS
+ {
+ $$ = new ParenthesizedExpression ((Expression) $2, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
+ }
+/*
+ | CHECKED open_parens_any declaration_expression CLOSE_PARENS
+ {
+ $$ = new CheckedExpr ((Expression) $3, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
+ }
+ | UNCHECKED open_parens_any declaration_expression CLOSE_PARENS
+ {
+ $$ = new UnCheckedExpr ((Expression) $3, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
+ }
+*/
+ | variable_type identifier_inside_body
+ {
+ if (lang_version < LanguageVersion.V_6)
+ FeatureIsNotAvailable (GetLocation ($1), "declaration expression");
+
+ var lt = (LocatedToken) $2;
+ var lv = new LocalVariable (current_block, lt.Value, lt.Location);
+ current_block.AddLocalName (lv);
+ $$ = new DeclarationExpression ((FullNamedExpression) $1, lv);
+ }
+ | variable_type identifier_inside_body ASSIGN expression
+ {
+ if (lang_version < LanguageVersion.V_6)
+ FeatureIsNotAvailable (GetLocation ($1), "declaration expression");
+
+ var lt = (LocatedToken) $2;
+ var lv = new LocalVariable (current_block, lt.Value, lt.Location);
+ current_block.AddLocalName (lv);
+ $$ = new DeclarationExpression ((FullNamedExpression) $1, lv) {
+ Initializer = (Expression) $4
+ };
+ }
+ ;
+
variable_reference
: expression
;
protected bool DoResolveCore (ResolveContext rc)
{
+ foreach (var arg in arguments) {
+ if (arg.Type == InternalType.VarOutType) {
+ // Should be special error message about dynamic dispatch
+ rc.Report.Error (8047, arg.Expr.Location, "Declaration expression cannot be used in this context");
+ }
+ }
+
if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter)
context_mvars = rc.CurrentTypeParameters;
if (ctors == null) {
switch (type.Kind) {
case MemberKind.Struct:
+ // Every struct has implicit default constructor if not provided by user
+ if (args == null)
+ return null;
+
rc.Report.SymbolRelatedToPreviousError (type);
// Report meaningful error for struct as they always have default ctor in C# context
OverloadResolver.Error_ConstructorMismatch (rc, type, args == null ? 0 : args.Count, loc);
return null;
}
+ if (args == null && type.IsStruct) {
+ bool includes_empty = false;
+ foreach (MethodSpec ctor in ctors) {
+ if (ctor.Parameters.IsEmpty) {
+ includes_empty = true;
+ }
+ }
+
+ if (!includes_empty)
+ return null;
+ }
+
var r = new OverloadResolver (ctors, OverloadResolver.Restrictions.NoBaseMembers, loc);
if (!rc.HasSet (ResolveContext.Options.BaseInitializer)) {
r.InstanceQualifier = new ConstructorInstanceQualifier (type);
// one being the virtual base for the parameter types and modifiers.
//
// A return value rates candidate method compatibility,
- // 0 = the best, int.MaxValue = the worst
// -1 = fatal error
+ // 0 = the best, int.MaxValue = the worst
//
int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType, bool errorMode)
{
+ //
+ // Each step has allocated 10 values, it can overflow for
+ // more than 10 arguments but that's ok as it's used for
+ // better error reporting only
+ //
+ const int ArgumentCountMismatch = 1000000000;
+ const int NamedArgumentsMismatch = 100000000;
+ const int DefaultArgumentMismatch = 10000000;
+ const int UnexpectedTypeArguments = 1000000;
+ const int TypeArgumentsMismatch = 100000;
+ const int InflatedTypesMismatch = 10000;
+
// Parameters of most-derived type used mainly for named and optional parameters
var pd = pm.Parameters;
param_count--;
} else if (arg_count > param_count) {
int args_gap = System.Math.Abs (arg_count - param_count);
- return int.MaxValue - 10000 + args_gap;
+ return ArgumentCountMismatch + args_gap;
} else if (arg_count < param_count - optional_count) {
int args_gap = System.Math.Abs (param_count - optional_count - arg_count);
- return int.MaxValue - 10000 + args_gap;
+ return ArgumentCountMismatch + args_gap;
}
} else if (arg_count != param_count) {
int args_gap = System.Math.Abs (arg_count - param_count);
if (!cpd.HasParams)
- return int.MaxValue - 10000 + args_gap;
+ return ArgumentCountMismatch + args_gap;
if (arg_count < param_count - 1)
- return int.MaxValue - 10000 + args_gap;
+ return ArgumentCountMismatch + args_gap;
}
// Resize to fit optional arguments
// Named parameter not found
if (index < 0)
- return (i + 1) * 3;
+ return NamedArgumentsMismatch - i;
// already reordered
if (index == i)
++arg_count;
temp = null;
} else {
- if (index == arg_count)
- return (i + 1) * 3;
+ if (index == arg_count)
+ return NamedArgumentsMismatch - i - 1;
temp = arguments [index];
// Don't do any expensive checks when the candidate cannot succeed
//
if (arg_count != param_count && !cpd.HasParams)
- return (param_count - arg_count) * 2 + 1;
+ return DefaultArgumentMismatch - System.Math.Abs (param_count - arg_count);
var dep = candidate.GetMissingDependencies ();
if (dep != null) {
if (type_arguments != null) {
var g_args_count = ms.Arity;
if (g_args_count != type_arguments.Count)
- return int.MaxValue - 20000 + System.Math.Abs (type_arguments.Count - g_args_count);
+ return TypeArgumentsMismatch - System.Math.Abs (type_arguments.Count - g_args_count);
if (type_arguments.Arguments != null)
ms = ms.MakeGenericMethod (ec, type_arguments.Arguments);
TypeSpec[] i_args = ti.InferMethodArguments (ec, ms);
if (i_args == null)
- return ti.InferenceScore - 20000;
+ return TypeArgumentsMismatch - ti.InferenceScore;
//
// Clear any error messages when the result was success
if (i_args.Length != 0) {
if (!errorMode) {
- foreach (var ta in i_args) {
+ for (int i = 0; i < i_args.Length; ++i) {
+ var ta = i_args [i];
if (!ta.IsAccessible (ec))
- return ti.InferenceScore - 10000;
+ return TypeArgumentsMismatch - i;
}
}
//
if (!CheckInflatedArguments (ms)) {
candidate = ms;
- return int.MaxValue - 25000;
+ return InflatedTypesMismatch;
}
//
ptypes = pd.Types;
} else {
if (type_arguments != null)
- return int.MaxValue - 15000;
+ return UnexpectedTypeArguments;
ptypes = cpd.Types;
}
// is used and argument is not of dynamic type
//
if (((argument.Modifier | param_mod) & Parameter.Modifier.RefOutMask) != 0) {
- if (argument.Type != parameter) {
+ var arg_type = argument.Type;
+
+ if ((argument.Modifier & Parameter.Modifier.RefOutMask) != (param_mod & Parameter.Modifier.RefOutMask)) {
+ //
+ // Using dynamic for ref/out parameter can still succeed at runtime
+ //
+ if (arg_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0)
+ return -1;
+
+ return 1;
+ }
+
+ if (arg_type != parameter) {
+ if (arg_type == InternalType.VarOutType)
+ return 0;
+
//
// Do full equality check after quick path
//
- if (!TypeSpecComparer.IsEqual (argument.Type, parameter)) {
+ if (!TypeSpecComparer.IsEqual (arg_type, parameter)) {
//
// Using dynamic for ref/out parameter can still succeed at runtime
//
- if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0)
+ if (arg_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0)
return -1;
return 2;
}
}
- if ((argument.Modifier & Parameter.Modifier.RefOutMask) != (param_mod & Parameter.Modifier.RefOutMask)) {
- //
- // Using dynamic for ref/out parameter can still succeed at runtime
- //
- if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0)
- return -1;
-
- return 1;
- }
-
} else {
if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0)
return -1;
if ((a.Modifier & Parameter.Modifier.RefOutMask) != (p_mod & Parameter.Modifier.RefOutMask))
break;
- if (a.Expr.Type == pt || TypeSpecComparer.IsEqual (a.Expr.Type, pt))
+ var arg_type = a.Type;
+ if (arg_type == pt)
continue;
- break;
+ if (arg_type == InternalType.VarOutType) {
+ //
+ // Set underlying variable type based on parameter type
+ //
+ ((DeclarationExpression)a.Expr).Variable.Type = pt;
+ continue;
+ }
+
+ if (!TypeSpecComparer.IsEqual (arg_type, pt))
+ break;
}
NamedArgument na = a as NamedArgument;
}
if (a_idx != arg_count) {
+ //
+ // Convert all var out argument to error type for less confusing error reporting
+ // when no matching overload is found
+ //
+ for (; a_idx < arg_count; a_idx++) {
+ var arg = args [a_idx];
+ if (arg == null)
+ continue;
+
+ if (arg.Type == InternalType.VarOutType) {
+ ((DeclarationExpression)arg.Expr).Variable.Type = InternalType.ErrorType;
+ }
+ }
+
ReportArgumentMismatch (ec, a_pos, member, a, pd, pt);
return false;
}
return expr;
}
}
+
+ public class DeclarationExpression : Expression, IMemoryLocation
+ {
+ LocalVariableReference lvr;
+
+ public DeclarationExpression (FullNamedExpression variableType, LocalVariable variable)
+ {
+ VariableType = variableType;
+ Variable = variable;
+ this.loc = variable.Location;
+ }
+
+ public LocalVariable Variable { get; set; }
+ public Expression Initializer { get; set; }
+ public FullNamedExpression VariableType { get; set; }
+
+ public void AddressOf (EmitContext ec, AddressOp mode)
+ {
+ Variable.CreateBuilder (ec);
+
+ if (Initializer != null) {
+ lvr.EmitAssign (ec, Initializer, false, false);
+ }
+
+ lvr.AddressOf (ec, mode);
+ }
+
+ protected override void CloneTo (CloneContext clonectx, Expression t)
+ {
+ var target = (DeclarationExpression) t;
+
+ target.VariableType = (FullNamedExpression) VariableType.Clone (clonectx);
+
+ if (Initializer != null)
+ target.Initializer = Initializer.Clone (clonectx);
+ }
+
+ public override Expression CreateExpressionTree (ResolveContext rc)
+ {
+ rc.Report.Error (8046, loc, "An expression tree cannot contain a declaration expression");
+ return null;
+ }
+
+ bool DoResolveCommon (ResolveContext rc)
+ {
+ var var_expr = VariableType as VarExpr;
+ if (var_expr != null) {
+ type = InternalType.VarOutType;
+ } else {
+ type = VariableType.ResolveAsType (rc);
+ if (type == null)
+ return false;
+ }
+
+ if (Initializer != null) {
+ Initializer = Initializer.Resolve (rc);
+
+ if (var_expr != null && Initializer != null && var_expr.InferType (rc, Initializer)) {
+ type = var_expr.Type;
+ }
+ }
+
+ Variable.Type = type;
+ lvr = new LocalVariableReference (Variable, loc);
+
+ eclass = ExprClass.Variable;
+ return true;
+ }
+
+ protected override Expression DoResolve (ResolveContext rc)
+ {
+ if (DoResolveCommon (rc))
+ lvr.Resolve (rc);
+
+ return this;
+ }
+
+ public override Expression DoResolveLValue (ResolveContext rc, Expression right_side)
+ {
+ if (lvr == null && DoResolveCommon (rc))
+ lvr.ResolveLValue (rc, right_side);
+
+ return this;
+ }
+
+ public override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
+ }
//
// C# 2.0 Default value expression
void DoResolveBase (ResolveContext ec)
{
+ eclass = ExprClass.Variable;
+ type = local_info.Type;
+
//
// If we are referencing a variable from the external block
// flag it for capturing
storey.CaptureLocalVariable (ec, local_info);
}
}
-
- eclass = ExprClass.Variable;
- type = local_info.Type;
}
protected override Expression DoResolve (ResolveContext ec)
local_info.SetIsUsed ();
DoResolveBase (ec);
+
+ if (local_info.Type == InternalType.VarOutType) {
+ ec.Report.Error (8048, loc, "Cannot use uninitialized variable `{0}'",
+ GetSignatureForError ());
+
+ type = InternalType.ErrorType;
+ }
+
return this;
}
return null;
}
- //
- // Any struct always defines parameterless constructor
- //
- if (type.IsStruct && arguments == null)
- return this;
-
bool dynamic;
if (arguments != null) {
arguments.Resolve (ec, out dynamic);
foreach (var ta in targs) {
var tps = ta as TypeParameterSpec;
IList<TypeSpec> ifaces;
+ TypeSpec b_type;
if (tps != null) {
- var b_type = tps.GetEffectiveBase ();
- if (b_type != null && b_type.BuiltinType != BuiltinTypeSpec.Type.Object && b_type.BuiltinType != BuiltinTypeSpec.Type.ValueType)
- cache.AddBaseType (b_type);
-
+ b_type = tps.GetEffectiveBase ();
ifaces = tps.InterfacesDefined;
} else {
+ b_type = ta;
ifaces = ta.Interfaces;
}
+ //
+ // Don't add base type which was inflated from base constraints but it's not valid
+ // in C# context
+ //
+ if (b_type != null && b_type.BuiltinType != BuiltinTypeSpec.Type.Object && b_type.BuiltinType != BuiltinTypeSpec.Type.ValueType && !b_type.IsStructOrEnum)
+ cache.AddBaseType (b_type);
+
if (ifaces != null) {
foreach (var iface_type in ifaces) {
cache.AddInterface (iface_type);
//
// Tracks successful rate of type inference
//
- int score = int.MaxValue;
+ int score;
readonly Arguments arguments;
readonly int arg_count;
AnonymousMethodExpression am = a.Expr as AnonymousMethodExpression;
if (am != null) {
if (am.ExplicitTypeInference (tic, method_parameter))
- --score;
+ ++score;
continue;
}
if (a.IsByRef) {
- score -= tic.ExactInference (a.Type, method_parameter);
+ score += tic.ExactInference (a.Type, method_parameter);
continue;
}
continue;
if (TypeSpec.IsValueType (method_parameter)) {
- score -= tic.LowerBoundInference (a.Type, method_parameter);
+ score += tic.LowerBoundInference (a.Type, method_parameter);
continue;
}
//
// Otherwise an output type inference is made
//
- score -= tic.OutputTypeInference (ec, a.Expr, method_parameter);
+ score += tic.OutputTypeInference (ec, a.Expr, method_parameter);
}
//
if (arguments[i] == null)
continue;
- score -= tic.OutputTypeInference (ec, arguments[i].Expr, t_i);
+ score += tic.OutputTypeInference (ec, arguments[i].Expr, t_i);
}
}
// Some types cannot be used as type arguments
//
if ((bound.Type.Kind == MemberKind.Void && !voidAllowed) || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType ||
- bound.Type == InternalType.MethodGroup || bound.Type == InternalType.AnonymousMethod)
+ bound.Type == InternalType.MethodGroup || bound.Type == InternalType.AnonymousMethod || bound.Type == InternalType.VarOutType)
return;
var a = bounds [index];
continue;
}
- if (TypeManager.IsGenericType (t))
- return AllTypesAreFixed (TypeManager.GetTypeArguments (t));
+ if (t.IsGeneric && !AllTypesAreFixed (t.TypeArguments))
+ return false;
}
return true;
"`{0}': Struct constructors cannot call base constructors", caller_builder.GetSignatureForError ());
return this;
}
- } else {
- //
- // It is legal to have "this" initializers that take no arguments
- // in structs
- //
- // struct D { public D (int a) : this () {}
- //
- if (ec.CurrentType.IsStruct && argument_list == null)
- return this;
}
base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
protected override bool CheckBase ()
{
if ((ModFlags & Modifiers.STATIC) != 0) {
- if (!parameters.IsEmpty) {
- Report.Error (132, Location, "`{0}': The static constructor must be parameterless",
- GetSignatureForError ());
- return false;
- }
-
if ((caching_flags & Flags.MethodOverloadsExist) != 0)
Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
if ((caching_flags & Flags.MethodOverloadsExist) != 0)
Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
- if (Parent.PartialContainer.Kind == MemberKind.Struct && parameters.IsEmpty) {
- Report.Error (568, Location,
- "Structs cannot contain explicit parameterless constructors");
- return false;
- }
-
CheckProtectedModifier ();
return true;
public static readonly InternalType FakeInternalType = new InternalType ("<fake$type>");
public static readonly InternalType Namespace = new InternalType ("<namespace>");
public static readonly InternalType ErrorType = new InternalType ("<error>");
+ public static readonly InternalType VarOutType = new InternalType ("var out");
readonly string name;
--- /dev/null
+using System;
+
+class Model
+{
+ public int Value;
+}
+
+class C1<T1>
+{
+ public void Add (Func<T1, int> t)
+ {
+ }
+}
+
+abstract class C2<TModel>
+{
+ public abstract void ApplyImpl<U> (C1<U> c1) where U : TModel;
+}
+
+class C3 : C2<Model>
+{
+ public override void ApplyImpl<Foo> (C1<Foo> c1)
+ {
+ c1.Add (t => t.Value);
+ }
+}
+
+class Program
+{
+ static void Main ()
+ {
+ var v1 = new C1<Model> ();
+ var c3 = new C3 ();
+ c3.ApplyImpl (v1);
+ }
+}
--- /dev/null
+struct S
+{
+ public decimal P { get; } = -3;
+}
+
+class X
+{
+ public static int Main ()
+ {
+ var s = new S ();
+ if (s.P != -3)
+ return 1;
+
+ return 0;
+ }
+}
\ No newline at end of file
}
}
+struct StructWithUserConstructor
+{
+ public StructWithUserConstructor ()
+ {
+
+ }
+}
+
class MemberAccessData
{
public bool BoolValue;
Assert<MyEnum> (0, e.Compile ().Invoke ());
}
+ void NewTest_8 ()
+ {
+ Expression<Func<DateTime>> e = () => new DateTime ();
+ AssertNodeType (e, ExpressionType.New);
+ Assert (null, ((NewExpression)e.Body).Constructor, "default ctor");
+
+ Expression<Func<StructWithUserConstructor>> e2 = () => new StructWithUserConstructor ();
+ AssertNodeType (e2, ExpressionType.New);
+ Assert ("Void .ctor()", ((NewExpression)e2.Body).Constructor.ToString (), "user ctor");
+ }
+
void NotTest ()
{
Expression<Func<bool, bool>> e = (bool a) => !a;
--- /dev/null
+using System;
+
+class D<T>
+{
+ public void S<U, V> (Func<U> ftu, Func<T, U, V> ftuv)
+ {
+ }
+}
+
+class Test
+{
+ static D<V> Factory<V> (V v)
+ {
+ return new D<V> ();
+ }
+
+ static void Main ()
+ {
+ var danon = Factory (new { q = 5 });
+
+ danon.S (
+ () => "x",
+ (l, str) => new { str }
+ );
+ }
+}
\ No newline at end of file
--- /dev/null
+public struct S
+{
+ public S (double left = 0, double top = 0)
+ : this ()
+ {
+ }
+}
+
+class X
+{
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+
+struct S1
+{
+ public readonly int Value;
+
+ public S1 ()
+ {
+ Value = 17;
+ }
+}
+
+struct S2
+{
+ public readonly int Value = 23;
+}
+
+struct S3
+{
+ public readonly int Value = 11;
+
+ public S3 ()
+ {
+ Value = 5;
+ }
+}
+
+struct S4
+{
+ public readonly int Value = 11;
+
+ public S4 (int v)
+ {
+ }
+}
+
+struct S5
+{
+ public readonly int Value = 7;
+
+ public S5 (int v)
+ : this ()
+ {
+ this.Value += v;
+ }
+}
+
+class C
+{
+ static int Main ()
+ {
+ var s = new S1 ();
+ if (s.Value != 17)
+ return 1;
+
+ var s2 = new S2 ();
+ if (s2.Value != 23)
+ return 2;
+
+ var s3 = new S3 ();
+ if (s3.Value != 5)
+ return 3;
+
+ var s4 = new S4 (5);
+ if (s4.Value != 11)
+ return 4;
+
+ var s5 = new S5 (2);
+ if (s5.Value != 9)
+ return 5;
+
+ Console.WriteLine ("ok");
+ return 0;
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+
+class DeclarationExpression
+{
+ public static int Main ()
+ {
+ Out (out int o);
+ if (o != 3)
+ return 1;
+
+ if (Out (out int o1)) {
+ if (o1 != 3)
+ return 2;
+ }
+
+ Out (out int o2 = 2);
+ if (o2 != 3)
+ return 3;
+
+ Out (out var o3);
+ if (o3 != 3)
+ return 4;
+
+ Ref (ref int r = 2);
+ if (r != 7)
+ return 5;
+
+ Ref (ref ((var r2 = 3)));
+ if (r2 != 8)
+ return 6;
+
+ Out2 (str: "b", v: out var o5);
+ if (o5 != 9)
+ return 7;
+
+ Out3 (out var o6 = 9m);
+ if (o6.GetType () != typeof (decimal))
+ return 8;
+
+ Console.WriteLine ("ok");
+ return 0;
+ }
+
+ static bool Out (out int value)
+ {
+ value = 3;
+ return true;
+ }
+
+ static bool Out2 (out int v, string str)
+ {
+ v = 9;
+ return true;
+ }
+
+ static void Out3<T> (out T t)
+ {
+ t = default (T);
+ }
+
+ static void Ref (ref int arg)
+ {
+ arg += 5;
+ }
+}
\ No newline at end of file
}
}
+struct S2 (int arg)
+{
+ public readonly int v = arg;
+}
+
+struct S3 (string s = "arg")
+{
+ public readonly string V2 = s;
+
+ public S3 (int i, string s = "arg2")
+ : this (s)
+ {
+ }
+}
+
class X
{
public static int Main ()
if (new S ('x').y != 1)
return 2;
+ if (new S2 (2).v != 2)
+ return 3;
+
+ if (new S3 ("x").V2 != "x")
+ return 4;
+
+ if (new S3 (0).V2 != "arg2")
+ return 5;
+
return 0;
}
}
\ No newline at end of file
</method>\r
</type>\r
</test>\r
+ <test name="gtest-624.cs">\r
+ <type name="Model">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="C1`1[T1]">\r
+ <method name="Void Add(System.Func`2[T1,System.Int32])" attrs="134">\r
+ <size>2</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="C2`1[TModel]">\r
+ <method name="Void ApplyImpl[U](C1`1[U])" attrs="1478">\r
+ <size>0</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6276">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="C3">\r
+ <method name="Void ApplyImpl[Foo](C1`1[Foo])" attrs="198">\r
+ <size>20</size>\r
+ </method>\r
+ <method name="Int32 <ApplyImpl`1>m__0[Foo](Foo)" attrs="145">\r
+ <size>19</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="Program">\r
+ <method name="Void Main()" attrs="145">\r
+ <size>21</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="gtest-anontype-01.cs">\r
<type name="Test">\r
<method name="Int32 Main()" attrs="150">\r
<size>13</size>\r
</method>\r
</type>\r
+ <type name="S2">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>15</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
+ <test name="gtest-autoproperty-10.cs">\r
+ <type name="S">\r
+ <method name="System.Decimal get_P()" attrs="2182">\r
+ <size>14</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>14</size>\r
+ </method>\r
+ </type>\r
+ <type name="X">\r
+ <method name="Int32 Main()" attrs="150">\r
+ <size>48</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
</test>\r
<test name="gtest-collectioninit-01.cs">\r
<type name="Test">\r
<size>12</size>\r
</method>\r
</type>\r
+ <type name="StructWithUserConstructor">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>2</size>\r
+ </method>\r
+ </type>\r
+ <type name="Tester">\r
+ <method name="Void NewTest_8()" attrs="129">\r
+ <size>140</size>\r
+ </method>\r
+ </type>\r
</test>\r
<test name="gtest-etree-02.cs">\r
<type name="M">\r
</method>\r
</type>\r
</test>\r
+ <test name="gtest-lambda-36.cs">\r
+ <type name="D`1[T]">\r
+ <method name="Void S[U,V](System.Func`1[U], System.Func`3[T,U,V])" attrs="134">\r
+ <size>2</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="Test">\r
+ <method name="D`1[V] Factory[V](V)" attrs="145">\r
+ <size>14</size>\r
+ </method>\r
+ <method name="Void Main()" attrs="145">\r
+ <size>78</size>\r
+ </method>\r
+ <method name="System.String <Main>m__0()" attrs="145">\r
+ <size>13</size>\r
+ </method>\r
+ <method name="<>__AnonType1`1[System.String] <Main>m__1(<>__AnonType0`1[System.Int32], System.String)" attrs="145">\r
+ <size>14</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="<>__AnonType0`1[<q>__T]">\r
+ <method name="<q>__T get_q()" attrs="2182">\r
+ <size>7</size>\r
+ </method>\r
+ <method name="Boolean Equals(System.Object)" attrs="198">\r
+ <size>39</size>\r
+ </method>\r
+ <method name="Int32 GetHashCode()" attrs="198">\r
+ <size>63</size>\r
+ </method>\r
+ <method name="System.String ToString()" attrs="198">\r
+ <size>67</size>\r
+ </method>\r
+ <method name="Void .ctor(<q>__T)" attrs="6278">\r
+ <size>14</size>\r
+ </method>\r
+ </type>\r
+ <type name="<>__AnonType1`1[<str>__T]">\r
+ <method name="<str>__T get_str()" attrs="2182">\r
+ <size>7</size>\r
+ </method>\r
+ <method name="Boolean Equals(System.Object)" attrs="198">\r
+ <size>39</size>\r
+ </method>\r
+ <method name="Int32 GetHashCode()" attrs="198">\r
+ <size>63</size>\r
+ </method>\r
+ <method name="System.String ToString()" attrs="198">\r
+ <size>67</size>\r
+ </method>\r
+ <method name="Void .ctor(<str>__T)" attrs="6278">\r
+ <size>14</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="gtest-linq-01.cs">\r
<type name="from.C">\r
<method name="Void Main()" attrs="150">\r
</method>\r
</type>\r
</test>\r
+ <test name="gtest-optional-34.cs">\r
+ <type name="S">\r
+ <method name="Void .ctor(Double, Double)" attrs="6278">\r
+ <size>9</size>\r
+ </method>\r
+ </type>\r
+ <type name="X">\r
+ <method name="Void Main()" attrs="150">\r
+ <size>2</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="gtest-partial-01.cs">\r
<type name="B`1[U]">\r
<method name="Void .ctor()" attrs="6278">\r
</method>\r
</type>\r
</test>\r
+ <test name="test-906.cs">\r
+ <type name="S1">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>10</size>\r
+ </method>\r
+ </type>\r
+ <type name="S2">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>9</size>\r
+ </method>\r
+ </type>\r
+ <type name="S3">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>17</size>\r
+ </method>\r
+ </type>\r
+ <type name="S4">\r
+ <method name="Void .ctor(Int32)" attrs="6278">\r
+ <size>10</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>9</size>\r
+ </method>\r
+ </type>\r
+ <type name="S5">\r
+ <method name="Void .ctor(Int32)" attrs="6278">\r
+ <size>22</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>8</size>\r
+ </method>\r
+ </type>\r
+ <type name="C">\r
+ <method name="Int32 Main()" attrs="145">\r
+ <size>161</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="test-91.cs">\r
<type name="Abstract">\r
<method name="Void .ctor()" attrs="6276">\r
</method>\r
</type>\r
</test>\r
+ <test name="test-decl-expr-01.cs">\r
+ <type name="DeclarationExpression">\r
+ <method name="Int32 Main()" attrs="150">\r
+ <size>252</size>\r
+ </method>\r
+ <method name="Boolean Out(Int32 ByRef)" attrs="145">\r
+ <size>13</size>\r
+ </method>\r
+ <method name="Boolean Out2(Int32 ByRef, System.String)" attrs="145">\r
+ <size>14</size>\r
+ </method>\r
+ <method name="Void Out3[T](T ByRef)" attrs="145">\r
+ <size>17</size>\r
+ </method>\r
+ <method name="Void Ref(Int32 ByRef)" attrs="145">\r
+ <size>8</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="test-dictinit-01.cs">\r
<type name="Program">\r
<method name="Int32 Main()" attrs="145">\r
</type>\r
<type name="X">\r
<method name="Int32 Main()" attrs="150">\r
- <size>69</size>\r
+ <size>180</size>\r
</method>\r
<method name="Void .ctor()" attrs="6278">\r
<size>7</size>\r
</method>\r
</type>\r
+ <type name="S2">\r
+ <method name="Void .ctor(Int32)" attrs="6278">\r
+ <size>8</size>\r
+ </method>\r
+ </type>\r
+ <type name="S3">\r
+ <method name="Void .ctor(Int32, String)" attrs="6278">\r
+ <size>9</size>\r
+ </method>\r
+ <method name="Void .ctor(String)" attrs="6278">\r
+ <size>8</size>\r
+ </method>\r
+ </type>\r
</test>\r
<test name="test-primary-ctor-08.cs">\r
<type name="S">\r
-rm -Rf Test/en.actual Test/html.actual
-rm -f monodocer1.exe*
+Test/DocTest-DropNS-classic-secondary.dll:
+ @echo $(value @)
+ $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-DropNS-classic-secondary.cs
+
+Test/DocTest-DropNS-classic.dll:
+ @echo $(value @)
+ $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-DropNS-classic.cs
+
+Test/DocTest-DropNS-unified.dll:
+ $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-DropNS-unified.cs
+
Test/DocTest.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest.cs
-rm -f Test/DocTest.dll
$(MAKE) TEST_CSCFLAGS=$(TEST_CSCFLAGS) Test/DocTest.dll
+check-monodocer-dropns-classic: $(PROGRAM)
+ # tests the simplest --dropns case, a single class where the root namespace was dropped.
+ -rm -Rf Test/en.actual
+ $(MAKE) Test/DocTest-DropNS-classic.dll
+ $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll
+ $(MAKE) update-monodocer-dropns-unified
+ diff --exclude=.svn -rup Test/en.expected-dropns-classic-v1 Test/en.actual
+
+check-monodocer-dropns-classic-withsecondary: $(PROGRAM)
+ # tests case where a secondary assembly is included with a --dropns parameter
+ -rm -Rf Test/en.actual
+ $(MAKE) Test/DocTest-DropNS-classic.dll
+ $(MAKE) Test/DocTest-DropNS-classic-secondary.dll
+ $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll
+ $(MAKE) update-monodocer-dropns-unified-withsecondary
+ diff --exclude=.svn -rup Test/en.expected-dropns-classic-withsecondary Test/en.actual
+
+update-monodocer-dropns-unified: $(PROGRAM)
+ $(MAKE) Test/DocTest-DropNS-unified.dll
+ $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --dropns Test/DocTest-DropNS-unified.dll=MyFramework
+
+update-monodocer-dropns-unified-withsecondary: $(PROGRAM)
+ $(MAKE) Test/DocTest-DropNS-unified.dll
+ $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --dropns Test/DocTest-DropNS-unified.dll=MyFramework
+
+update-monodocer-dropns-classic-secondary: $(PROGRAM)
+ $(MAKE) Test/DocTest-DropNS-classic-secondary.dll
+ $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll
+
+
check-monodocer-update: $(PROGRAM)
find Test/en.expected -name \*.xml -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1
check-monodocer-importecmadoc-update \
check-monodocer-importslashdoc-update \
check-monodocer-update \
+ check-monodocer-dropns-classic \
+ check-monodocer-dropns-classic-withsecondary \
check-monodocer-delete-update \
check-mdoc-export-html-update \
check-mdoc-export-msxdoc-update \
- check-mdoc-validate-update
+ check-mdoc-validate-update
+
string typename = t.FullName;
bool isInAssembly = MDocUpdater.IsInAssemblies (t.Module.Name);
- if (isInAssembly && MDocUpdater.HasDroppedNamespace () && !typename.StartsWith ("System")) {
+ if (isInAssembly && !typename.StartsWith ("System") && MDocUpdater.HasDroppedNamespace (t)) {
string nameWithDropped = string.Format ("{0}.{1}", MDocUpdater.droppedNamespace, typename);
return nameWithDropped;
}
HashSet<string> forwardedTypes = new HashSet<string> ();
public static string droppedNamespace = string.Empty;
- public static bool HasDroppedNamespace() {
- return !string.IsNullOrWhiteSpace (droppedNamespace);
+
+ public static bool HasDroppedNamespace(TypeDefinition forType)
+ {
+ return HasDroppedNamespace(forType.Module);
+ }
+
+ public static bool HasDroppedNamespace(MemberReference forMember)
+ {
+ return HasDroppedNamespace(forMember.Module);
+ }
+
+ public static bool HasDroppedNamespace(AssemblyDefinition forAssembly)
+ {
+ return HasDroppedNamespace(forAssembly.MainModule);
+ }
+
+ public static bool HasDroppedNamespace(ModuleDefinition forModule)
+ {
+ return !string.IsNullOrWhiteSpace (droppedNamespace) && droppedAssemblies.Any(da => da == forModule.Name);
}
+
+
+ static List<string> droppedAssemblies = new List<string>();
+
public string PreserveTag { get; set; }
public static MDocUpdater Instance { get; private set; }
public static bool SwitchingToMagicTypes { get; private set; }
"Only update documentation for {TYPE}.",
v => types.Add (v) },
{ "dropns=",
- "Instructs the update process that {NAMESPACE} has been dropped, so that types and members will match existing documentation nodes.",
- v => droppedNamespace = v },
+ "When processing assembly {ASSEMBLY}, strip off leading namespace {PREFIX}:\n" +
+ " e.g. --dropns ASSEMBLY=PREFIX",
+ v => {
+ var parts = v.Split ('=');
+ if (parts.Length != 2) { Console.Error.WriteLine ("Invalid dropns input"); return; }
+ var assembly = Path.GetFileName (parts [0].Trim ());
+ var prefix = parts [1].Trim();
+ droppedAssemblies.Add (assembly);
+ droppedNamespace = prefix;
+ } },
{ "ntypes",
"If the new assembly is switching to 'magic types', then this switch should be defined.",
v => SwitchingToMagicTypes = true },
nsname
};
- if (MDocUpdater.HasDroppedNamespace ()) {
+ if (MDocUpdater.HasDroppedNamespace (type)) {
// If dropping namespace, types may have moved into a couple of different places.
var newSearchLocations = searchLocations.Union (new string[] {
string.Format ("{0}.{1}", droppedNamespace, nsname),
// Add namespace and type nodes into the index file as needed
AddIndexType (type, index_types);
-
+
// Ensure the namespace index file exists
string namespaceToUse = type.Namespace;
- if (HasDroppedNamespace()) {
+ if (HasDroppedNamespace(assembly)) {
namespaceToUse = string.Format ("{0}.{1}", droppedNamespace, namespaceToUse);
}
string onsdoc = DocUtils.PathCombine (dest, namespaceToUse + ".xml");
XmlDocument doc = new XmlDocument ();
doc.Load (typefile.FullName);
XmlElement e = doc.SelectSingleNode("/Type") as XmlElement;
- if (e != null && !no_assembly_versions && UpdateAssemblyVersions(e, GetAssemblyVersions(), false)) {
+ string assemblyName = doc.SelectSingleNode ("/Type/AssemblyInfo/AssemblyName").InnerText;
+ AssemblyDefinition assembly = assemblies.FirstOrDefault (a => a.Name.Name == assemblyName);
+ if (e != null && !no_assembly_versions && assembly != null && assemblyName != null && UpdateAssemblyVersions(e, assembly, GetAssemblyVersions(assemblyName), false)) {
using (TextWriter writer = OpenWrite (typefile.FullName, FileMode.Truncate))
WriteXml(doc.DocumentElement, writer);
goodfiles.Add (relTypeFile);
return w;
}
- private string[] GetAssemblyVersions ()
+ private string[] GetAssemblyVersions (string assemblyName)
{
- return (from a in assemblies select GetAssemblyVersion (a)).ToArray ();
+ return (from a in assemblies
+ where a.Name.Name == assemblyName
+ select GetAssemblyVersion (a)).ToArray ();
}
private static void CleanupIndexTypes (XmlElement index_types, HashSet<string> goodfiles)
// Deleted (or signature changed)
if (oldmember2 == null) {
- if (!no_assembly_versions && UpdateAssemblyVersions (oldmember, new string[]{ GetAssemblyVersion (type.Module.Assembly) }, false))
+ if (!no_assembly_versions && UpdateAssemblyVersions (oldmember, type.Module.Assembly, new string[]{ GetAssemblyVersion (type.Module.Assembly) }, false))
continue;
- DeleteMember ("Member Removed", output, oldmember, todelete);
+ DeleteMember ("Member Removed", output, oldmember, todelete, type);
continue;
}
// ignore, already seen
}
else if (DefaultMemberComparer.Compare (oldmember, seenmembers [sig]) == 0)
- DeleteMember ("Duplicate Member Found", output, oldmember, todelete);
+ DeleteMember ("Duplicate Member Found", output, oldmember, todelete, type);
else
Warning ("TODO: found a duplicate member '{0}', but it's not identical to the prior member found!", sig);
continue;
return null;
}
- void DeleteMember (string reason, string output, XmlNode member, MyXmlNodeList todelete)
+ void DeleteMember (string reason, string output, XmlNode member, MyXmlNodeList todelete, TypeDefinition type)
{
string format = output != null
? "{0}: File='{1}'; Signature='{4}'"
member.SelectSingleNode ("MemberSignature[@Language='C#']/@Value").Value);
if (!delete && MemberDocsHaveUserContent (member)) {
Warning ("Member deletions must be enabled with the --delete option.");
- } else if (HasDroppedNamespace ()) {
+ } else if (HasDroppedNamespace (type)) {
// if we're dropping the namespace, add the "classic style"
var existingAttribute = member.Attributes ["apistyle"];
if (existingAttribute != null) {
member.Attributes.Append (apistyleAttr);
}
- } else if (!HasDroppedNamespace () && member.Attributes ["apistyle"] != null && member.Attributes ["apistyle"].Value == "unified") {
+ } else if (!HasDroppedNamespace (type) && member.Attributes ["apistyle"] != null && member.Attributes ["apistyle"].Value == "unified") {
// do nothing if there's an apistyle=new attribute and we haven't dropped the namespace
} else if (!string.IsNullOrWhiteSpace (PreserveTag)) {
// do nothing
var node = WriteElementAttribute (root, element, "Language", f.Language, forceNewElement: true);
var newnode = WriteElementAttribute (root, node, "Value", valueToUse);
return newnode;
- });
+ },
+ type);
}
- string assemblyInfoNodeFilter = MDocUpdater.HasDroppedNamespace () ? "[@apistyle='unified']" : "[not(@apistyle) or @apistyle='classic']";
+ string assemblyInfoNodeFilter = MDocUpdater.HasDroppedNamespace (type) ? "[@apistyle='unified']" : "[not(@apistyle) or @apistyle='classic']";
AddXmlNode(
root.SelectNodes ("AssemblyInfo" + assemblyInfoNodeFilter).Cast<XmlElement> ().ToArray (),
() => {
XmlElement ass = WriteElement(root, "AssemblyInfo", forceNewElement:true);
- if (MDocUpdater.HasDroppedNamespace ()) ass.SetAttribute ("apistyle", "unified");
+ if (MDocUpdater.HasDroppedNamespace (type)) ass.SetAttribute ("apistyle", "unified");
return ass;
- });
+ },
+ type);
foreach(var ass in root.SelectNodes ("AssemblyInfo" + assemblyInfoNodeFilter).Cast<XmlElement> ())
{
}
if (type.IsGenericType ()) {
- MakeTypeParameters (root, type.GenericParameters, MDocUpdater.HasDroppedNamespace());
+ MakeTypeParameters (root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace(type));
} else {
ClearElement(root, "TypeParameters");
}
MakeAttributes (root, GetCustomAttributes (type), type);
if (DocUtils.IsDelegate (type)) {
- MakeTypeParameters (root, type.GenericParameters, MDocUpdater.HasDroppedNamespace());
- MakeParameters(root, type.GetMethod("Invoke").Parameters);
- MakeReturnValue(root, type.GetMethod("Invoke"));
+ MakeTypeParameters (root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace(type));
+ var member = type.GetMethod ("Invoke");
+ MakeParameters(root, member, member.Parameters);
+ MakeReturnValue(root, member);
}
DocsNodeInfo typeInfo = new DocsNodeInfo (WriteElement(root, "Docs"), type);
var node = WriteElementAttribute (me, element, "Language", f.Language, forceNewElement:true);
var newNode = WriteElementAttribute (me, node, "Value", valueToUse);
return newNode;
- });
+ },
+ mi);
}
MakeAttributes (me, GetCustomAttributes (mi), mi.DeclaringType);
- MakeReturnValue(me, mi, MDocUpdater.HasDroppedNamespace());
+ MakeReturnValue(me, mi, MDocUpdater.HasDroppedNamespace(mi));
if (mi is MethodReference) {
MethodReference mb = (MethodReference) mi;
if (mb.IsGenericMethod ())
- MakeTypeParameters (me, mb.GenericParameters, MDocUpdater.HasDroppedNamespace());
+ MakeTypeParameters (me, mb.GenericParameters, mi, MDocUpdater.HasDroppedNamespace(mi));
}
- MakeParameters(me, mi, MDocUpdater.HasDroppedNamespace());
+ MakeParameters(me, mi, MDocUpdater.HasDroppedNamespace(mi));
string fieldValue;
if (mi is FieldDefinition && GetFieldConstValue ((FieldDefinition)mi, out fieldValue))
UpdateExtensionMethods (me, info);
}
+ static void AddXmlNode (XmlElement[] relevant, Func<XmlElement, bool> valueMatches, Action<XmlElement> setValue, Func<XmlElement> makeNewNode, MemberReference member) {
+ AddXmlNode (relevant, valueMatches, setValue, makeNewNode, member.Module);
+ }
+
+ static void AddXmlNode (XmlElement[] relevant, Func<XmlElement, bool> valueMatches, Action<XmlElement> setValue, Func<XmlElement> makeNewNode, TypeDefinition type) {
+ AddXmlNode (relevant, valueMatches, setValue, makeNewNode, type.Module);
+ }
+
/// <summary>Adds an xml node, reusing the node if it's available</summary>
/// <param name="relevant">The existing set of nodes</param>
/// <param name="valueMatches">Checks to see if the node's value matches what you're trying to write.</param>
/// <param name="setValue">Sets the node's value</param>
/// <param name="makeNewNode">Creates a new node, if valueMatches returns false.</param>
- static void AddXmlNode (XmlElement[] relevant, Func<XmlElement, bool> valueMatches, Action<XmlElement> setValue, Func<XmlElement> makeNewNode)
+ static void AddXmlNode (XmlElement[] relevant, Func<XmlElement, bool> valueMatches, Action<XmlElement> setValue, Func<XmlElement> makeNewNode, ModuleDefinition module)
{
- bool shouldDuplicate = MDocUpdater.HasDroppedNamespace ();
+ bool shouldDuplicate = MDocUpdater.HasDroppedNamespace (module);
var styleToUse = shouldDuplicate ? ApiStyle.Unified : ApiStyle.Classic;
var existing = relevant;
bool done = false;
TypeDefinition type = member as TypeDefinition;
if (type == null)
type = member.DeclaringType as TypeDefinition;
- return UpdateAssemblyVersions(root, new string[]{ GetAssemblyVersion (type.Module.Assembly) }, add);
+ return UpdateAssemblyVersions(root, type.Module.Assembly, new string[]{ GetAssemblyVersion (type.Module.Assembly) }, add);
}
private static string GetAssemblyVersion (AssemblyDefinition assembly)
return assembly.Name.Version.ToString();
}
- private static bool UpdateAssemblyVersions(XmlElement root, string[] assemblyVersions, bool add)
+ private static bool UpdateAssemblyVersions(XmlElement root, AssemblyDefinition assembly, string[] assemblyVersions, bool add)
{
XmlElement av = (XmlElement) root.SelectSingleNode ("AssemblyVersions");
if (av != null) {
string oldNodeFilter = "AssemblyInfo[not(@apistyle) or @apistyle='classic']";
string newNodeFilter = "AssemblyInfo[@apistyle='unified']";
- string thisNodeFilter = MDocUpdater.HasDroppedNamespace () ? newNodeFilter : oldNodeFilter;
- string thatNodeFilter = MDocUpdater.HasDroppedNamespace () ? oldNodeFilter : newNodeFilter;
+ string thisNodeFilter = MDocUpdater.HasDroppedNamespace (assembly) ? newNodeFilter : oldNodeFilter;
+ string thatNodeFilter = MDocUpdater.HasDroppedNamespace (assembly) ? oldNodeFilter : newNodeFilter;
XmlElement e = (XmlElement) root.SelectSingleNode (thisNodeFilter);
if (e == null) {
e = root.OwnerDocument.CreateElement("AssemblyInfo");
- if (MDocUpdater.HasDroppedNamespace ()) {
+ if (MDocUpdater.HasDroppedNamespace (assembly)) {
e.SetAttribute ("apistyle", "unified");
}
}
var thatNode = (XmlElement) root.SelectSingleNode (thatNodeFilter);
- if (MDocUpdater.HasDroppedNamespace () && thatNode != null) {
+ if (MDocUpdater.HasDroppedNamespace (assembly) && thatNode != null) {
// there's a classic node, we should add apistyles
e.SetAttribute ("apistyle", "unified");
thatNode.SetAttribute ("apistyle", "classic");
return Convert.ToInt64 (value);
}
- private void MakeParameters (XmlElement root, IList<ParameterDefinition> parameters, bool shouldDuplicateWithNew=false)
+ private void MakeParameters (XmlElement root, MemberReference member, IList<ParameterDefinition> parameters, bool shouldDuplicateWithNew=false)
{
XmlElement e = WriteElement(root, "Parameters");
MakeAttributes (pe, GetCustomAttributes (p.CustomAttributes, ""));
return pe;
- });
+ },
+ member);
i++;
}
}
- private void MakeTypeParameters (XmlElement root, IList<GenericParameter> typeParams, bool shouldDuplicateWithNew)
+ private void MakeTypeParameters (XmlElement root, IList<GenericParameter> typeParams, MemberReference member, bool shouldDuplicateWithNew)
{
if (typeParams == null || typeParams.Count == 0) {
XmlElement f = (XmlElement) root.SelectSingleNode ("TypeParameters");
}
return pe;
- });
+ },
+ member);
}
}
private void MakeParameters (XmlElement root, MemberReference mi, bool shouldDuplicateWithNew)
{
if (mi is MethodDefinition && ((MethodDefinition) mi).IsConstructor)
- MakeParameters (root, ((MethodDefinition)mi).Parameters, shouldDuplicateWithNew);
+ MakeParameters (root, mi, ((MethodDefinition)mi).Parameters, shouldDuplicateWithNew);
else if (mi is MethodDefinition) {
MethodDefinition mb = (MethodDefinition) mi;
IList<ParameterDefinition> parameters = mb.Parameters;
- MakeParameters(root, parameters, shouldDuplicateWithNew);
+ MakeParameters(root, mi, parameters, shouldDuplicateWithNew);
if (parameters.Count > 0 && DocUtils.IsExtensionMethod (mb)) {
XmlElement p = (XmlElement) root.SelectSingleNode ("Parameters/Parameter[position()=1]");
p.SetAttribute ("RefType", "this");
else if (mi is PropertyDefinition) {
IList<ParameterDefinition> parameters = ((PropertyDefinition)mi).Parameters;
if (parameters.Count > 0)
- MakeParameters(root, parameters, shouldDuplicateWithNew);
+ MakeParameters(root, mi, parameters, shouldDuplicateWithNew);
else
return;
}
MakeAttributes(e, GetCustomAttributes (attributes, ""), type);
return newNode;
- });
+ },
+ type);
}
private void MakeReturnValue (XmlElement root, MemberReference mi, bool shouldDuplicateWithNew=false)
// first, make sure this isn't a type reference to another assembly/module
bool isInAssembly = MDocUpdater.IsInAssemblies(type.Module.Name);
- if (isInAssembly && MDocUpdater.HasDroppedNamespace () && !typeNS.StartsWith ("System")) {
+ if (isInAssembly && !typeNS.StartsWith ("System") && MDocUpdater.HasDroppedNamespace (type)) {
typeNS = string.Format ("{0}.{1}", MDocUpdater.droppedNamespace, typeNS);
}
return typeNS;
// did not match ... if we're dropping the namespace, and the paramType has the dropped
// namespace, we should see if it matches when added
bool stillDoesntMatch = true;
- if (MDocUpdater.HasDroppedNamespace() && paramType.StartsWith (MDocUpdater.droppedNamespace)) {
+ if (MDocUpdater.HasDroppedNamespace(type) && paramType.StartsWith (MDocUpdater.droppedNamespace)) {
string withDroppedNs = string.Format ("{0}.{1}", MDocUpdater.droppedNamespace, xmlMemberType);
stillDoesntMatch = withDroppedNs != paramType;
{
// In case of dropping the namespace, we have to remove the dropped NS
// so that docName will match what's in the assembly/type
- if (MDocUpdater.HasDroppedNamespace () && docName.StartsWith(MDocUpdater.droppedNamespace + ".")) {
+ if (MDocUpdater.HasDroppedNamespace (type) && docName.StartsWith(MDocUpdater.droppedNamespace + ".")) {
int droppedNsLength = MDocUpdater.droppedNamespace.Length;
docName = docName.Substring (droppedNsLength + 1, docName.Length - droppedNsLength - 1);
}
--- /dev/null
+namespace MyFramework.MyOtherNamespace {
+ ///<summary>Make sure the namespace in this assembly doesn't get 'dropped'</summary>
+ public class MyOtherClass {
+ public string MyProperty {get;set;}
+ public float Hello(int value) {
+ return 0.0f;
+ }
+ }
+}
--- /dev/null
+namespace MyFramework.MyNamespace {
+ public class MyClass {
+ public string MyProperty {get;set;}
+ public float Hello(int value) {
+ return 0.0f;
+ }
+ }
+}
--- /dev/null
+namespace MyNamespace {
+ public class MyClass {
+ public string MyProperty {get;set;}
+ public float Hello(int value) {
+ return 0.0f;
+ }
+ }
+}
--- /dev/null
+<Type Name="MyClass" FullName="MyFramework.MyNamespace.MyClass">
+ <TypeSignature Language="C#" Value="public class MyClass" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyClass extends System.Object" />
+ <AssemblyInfo>
+ <AssemblyName>DocTest-DropNS-classic</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public MyClass ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Hello">
+ <MemberSignature Language="C#" Value="public float Hello (int value);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance float32 Hello(int32 value) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Single</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="value" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="value">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="MyProperty">
+ <MemberSignature Language="C#" Value="public string MyProperty { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string MyProperty" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
--- /dev/null
+<Overview>
+ <Assemblies>
+ <Assembly Name="DocTest-DropNS-classic" Version="0.0.0.0">
+ <Attributes>
+ <Attribute>
+ <AttributeName>System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints)</AttributeName>
+ </Attribute>
+ <Attribute>
+ <AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
+ </Attribute>
+ </Attributes>
+ </Assembly>
+ </Assemblies>
+ <Remarks>To be added.</Remarks>
+ <Copyright>To be added.</Copyright>
+ <Types>
+ <Namespace Name="MyFramework.MyNamespace">
+ <Type Name="MyClass" Kind="Class" />
+ </Namespace>
+ </Types>
+ <Title>DocTest-DropNS-classic</Title>
+</Overview>
--- /dev/null
+<Namespace Name="MyFramework.MyNamespace">
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+</Namespace>
--- /dev/null
+<Type Name="MyClass" FullName="MyFramework.MyNamespace.MyClass">
+ <TypeSignature Language="C#" Value="public class MyClass" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyClass extends System.Object" />
+ <AssemblyInfo apistyle="classic">
+ <AssemblyName>DocTest-DropNS-classic</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyName>DocTest-DropNS-unified</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public MyClass ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Hello">
+ <MemberSignature Language="C#" Value="public float Hello (int value);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance float32 Hello(int32 value) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Single</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="value" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="value">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="MyProperty">
+ <MemberSignature Language="C#" Value="public string MyProperty { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string MyProperty" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
--- /dev/null
+<Overview>
+ <Assemblies>
+ <Assembly Name="DocTest-DropNS-unified" Version="0.0.0.0">
+ <Attributes>
+ <Attribute>
+ <AttributeName>System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints)</AttributeName>
+ </Attribute>
+ <Attribute>
+ <AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
+ </Attribute>
+ </Attributes>
+ </Assembly>
+ </Assemblies>
+ <Remarks>To be added.</Remarks>
+ <Copyright>To be added.</Copyright>
+ <Types>
+ <Namespace Name="MyFramework.MyNamespace">
+ <Type Name="MyClass" Kind="Class" />
+ </Namespace>
+ </Types>
+ <Title>DocTest-DropNS-classic</Title>
+</Overview>
--- /dev/null
+<Namespace Name="MyFramework.MyNamespace">
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+</Namespace>
--- /dev/null
+<Type Name="MyClass" FullName="MyFramework.MyNamespace.MyClass">
+ <TypeSignature Language="C#" Value="public class MyClass" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyClass extends System.Object" />
+ <AssemblyInfo apistyle="classic">
+ <AssemblyName>DocTest-DropNS-classic</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyName>DocTest-DropNS-unified</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public MyClass ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Hello">
+ <MemberSignature Language="C#" Value="public float Hello (int value);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance float32 Hello(int32 value) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Single</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="value" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="value">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="MyProperty">
+ <MemberSignature Language="C#" Value="public string MyProperty { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string MyProperty" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo apistyle="classic">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <AssemblyInfo apistyle="unified">
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
--- /dev/null
+<Type Name="MyOtherClass" FullName="MyFramework.MyOtherNamespace.MyOtherClass">
+ <TypeSignature Language="C#" Value="public class MyOtherClass" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyOtherClass extends System.Object" />
+ <AssemblyInfo>
+ <AssemblyName>DocTest-DropNS-classic-secondary</AssemblyName>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public MyOtherClass ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Hello">
+ <MemberSignature Language="C#" Value="public float Hello (int value);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance float32 Hello(int32 value) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Single</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="value" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="value">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="MyProperty">
+ <MemberSignature Language="C#" Value="public string MyProperty { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string MyProperty" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
--- /dev/null
+<Overview>
+ <Assemblies>
+ <Assembly Name="DocTest-DropNS-unified" Version="0.0.0.0">
+ <Attributes>
+ <Attribute>
+ <AttributeName>System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints)</AttributeName>
+ </Attribute>
+ <Attribute>
+ <AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
+ </Attribute>
+ </Attributes>
+ </Assembly>
+ <Assembly Name="DocTest-DropNS-classic-secondary" Version="0.0.0.0">
+ <Attributes>
+ <Attribute>
+ <AttributeName>System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints)</AttributeName>
+ </Attribute>
+ <Attribute>
+ <AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
+ </Attribute>
+ </Attributes>
+ </Assembly>
+ </Assemblies>
+ <Remarks>To be added.</Remarks>
+ <Copyright>To be added.</Copyright>
+ <Types>
+ <Namespace Name="MyFramework.MyNamespace">
+ <Type Name="MyClass" Kind="Class" />
+ </Namespace>
+ <Namespace Name="MyFramework.MyOtherNamespace">
+ <Type Name="MyOtherClass" Kind="Class" />
+ </Namespace>
+ </Types>
+ <Title>Untitled</Title>
+</Overview>
--- /dev/null
+<Namespace Name="MyFramework.MyNamespace">
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+</Namespace>
--- /dev/null
+<Namespace Name="MyFramework.MyOtherNamespace">
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+</Namespace>
if (use_dos2unix == null) {
use_dos2unix = false;
try {
- var dos2unix = Process.Start ("dos2unix");
+ var info = new ProcessStartInfo ("dos2unix");
+ info.CreateNoWindow = true;
+ info.RedirectStandardInput = true;
+ info.UseShellExecute = false;
+ var dos2unix = Process.Start (info);
dos2unix.StandardInput.WriteLine ("aaa");
dos2unix.StandardInput.WriteLine ("\u0004");
+ dos2unix.StandardInput.Close ();
dos2unix.WaitForExit ();
if (dos2unix.ExitCode == 0)
use_dos2unix = true;
LOCAL_MCS_FLAGS = /lib:$(topdir)/class/lib/$(PROFILE) -r:Mono.Security.dll
SECURITY_PROGRAMS = secutil.exe cert2spc.exe sn.exe makecert.exe chktrust.exe crlupdate.exe \
- signcode.exe setreg.exe certmgr.exe caspol.exe permview.exe mozroots.exe
+ signcode.exe setreg.exe certmgr.exe caspol.exe permview.exe mozroots.exe cert-sync.exe
SECURITY_PROGRAMS_2_0 = httpcfg.exe
HELPER_SOURCES = AssemblyInfo.cs $(topdir)/build/common/Consts.cs
--- /dev/null
+//
+// cert-sync.cs: Import the root certificates from Linux SSL store into Mono
+//
+// Authors:
+// Sebastien Pouliot <sebastien@ximian.com>
+// Jo Shields <jo.shields@xamarin.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2014 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
+
+using Mono.Security.X509;
+
+[assembly: AssemblyTitle ("Linux Cert Store Sync")]
+[assembly: AssemblyDescription ("Synchronize local certs with certs from local Linux trust store.")]
+
+namespace Mono.Tools
+{
+
+ class CertSync
+ {
+
+ static string inputFile;
+ static bool quiet;
+
+ static X509Certificate DecodeCertificate (string s)
+ {
+ byte[] rawdata = Convert.FromBase64String (s);
+ return new X509Certificate (rawdata);
+ }
+
+ static Stream GetFile ()
+ {
+ try {
+ if (inputFile != null) {
+ return File.OpenRead (inputFile);
+ } else {
+ return null;
+ }
+ } catch {
+ return null;
+ }
+ }
+
+ static X509CertificateCollection DecodeCollection ()
+ {
+ X509CertificateCollection roots = new X509CertificateCollection ();
+ StringBuilder sb = new StringBuilder ();
+ bool processing = false;
+
+ using (Stream s = GetFile ()) {
+ if (s == null) {
+ WriteLine ("Couldn't retrieve the file using the supplied information.");
+ return null;
+ }
+
+ StreamReader sr = new StreamReader (s);
+ while (true) {
+ string line = sr.ReadLine ();
+ if (line == null)
+ break;
+
+ if (processing) {
+ if (line.StartsWith ("-----END CERTIFICATE-----")) {
+ processing = false;
+ X509Certificate root = DecodeCertificate (sb.ToString ());
+ roots.Add (root);
+
+ sb = new StringBuilder ();
+ continue;
+ }
+ sb.Append (line);
+ } else {
+ processing = line.StartsWith ("-----BEGIN CERTIFICATE-----");
+ }
+ }
+ return roots;
+ }
+ }
+
+ static int Process ()
+ {
+ X509CertificateCollection roots = DecodeCollection ();
+ if (roots == null) {
+ return 1;
+ } else if (roots.Count == 0) {
+ WriteLine ("No certificates were found.");
+ return 0;
+ }
+
+ X509Stores stores = (X509StoreManager.LocalMachine);
+ X509CertificateCollection trusted = stores.TrustedRoot.Certificates;
+ int additions = 0;
+ WriteLine ("I already trust {0}, your new list has {1}", trusted.Count, roots.Count);
+ foreach (X509Certificate root in roots) {
+ if (!trusted.Contains (root)) {
+ try {
+ stores.TrustedRoot.Import (root);
+ WriteLine ("Certificate added: {0}", root.SubjectName);
+ } catch {
+ WriteLine ("Warning: Could not import {0}");
+ }
+ additions++;
+ }
+ }
+ if (additions > 0)
+ WriteLine ("{0} new root certificates were added to your trust store.", additions);
+
+ X509CertificateCollection removed = new X509CertificateCollection ();
+ foreach (X509Certificate trust in trusted) {
+ if (!roots.Contains (trust)) {
+ removed.Add (trust);
+ }
+ }
+ if (removed.Count > 0) {
+ WriteLine ("{0} previously trusted certificates were removed.", removed.Count);
+
+ foreach (X509Certificate old in removed) {
+ stores.TrustedRoot.Remove (old);
+ WriteLine ("Certificate removed: {0}", old.SubjectName);
+ }
+ }
+ WriteLine ("Import process completed.");
+ return 0;
+ }
+
+ static string Thumbprint (string algorithm, X509Certificate certificate)
+ {
+ HashAlgorithm hash = HashAlgorithm.Create (algorithm);
+ byte[] digest = hash.ComputeHash (certificate.RawData);
+ return BitConverter.ToString (digest);
+ }
+
+ static bool ParseOptions (string[] args)
+ {
+ if (args.Length < 1)
+ return false;
+
+ for (int i = 0; i < args.Length - 1; i++) {
+ switch (args [i]) {
+ case "--quiet":
+ quiet = true;
+ break;
+ default:
+ WriteLine ("Unknown option '{0}'.");
+ return false;
+ }
+ }
+ inputFile = args [args.Length - 1];
+ if (!File.Exists (inputFile)) {
+ WriteLine ("Unknown option or file not found '{0}'.");
+ return false;
+ }
+ return true;
+ }
+
+ static void Header ()
+ {
+ Console.WriteLine (new AssemblyInfo ().ToString ());
+ }
+
+ static void Help ()
+ {
+ Console.WriteLine ("Usage: cert-sync [--quiet] system-ca-bundle.crt");
+ Console.WriteLine ("Where system-ca-bundle.crt is in PEM format");
+ }
+
+ static void WriteLine (string str)
+ {
+ if (!quiet)
+ Console.WriteLine (str);
+ }
+
+ static void WriteLine (string format, params object[] args)
+ {
+ if (!quiet)
+ Console.WriteLine (format, args);
+ }
+
+ static int Main (string[] args)
+ {
+ try {
+ if (!ParseOptions (args)) {
+ Header ();
+ Help ();
+ return 1;
+ }
+ if (!quiet) {
+ Header ();
+ }
+ return Process ();
+ } catch (Exception e) {
+ // ignore quiet on exception
+ Console.WriteLine ("Error: {0}", e);
+ return 1;
+ }
+ }
+ }
+}
\ No newline at end of file
}
#endif
-#if (defined(HAVE_STATVFS) || defined(HAVE_STATFS)) && !defined(PLATFORM_ANDROID)
+#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
WapiULargeInteger *total_number_of_bytes,
WapiULargeInteger *total_number_of_free_bytes)
block_size = fsstat.f_frsize;
#elif defined(HAVE_STATFS)
ret = statfs (utf8_path_name, &fsstat);
+#if defined (MNT_RDONLY)
isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY);
+#elif defined (MS_RDONLY)
+ isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY);
+#endif
block_size = fsstat.f_bsize;
#endif
} while(ret == -1 && errno == EINTR);
unload_data *thread_data;
MonoNativeThreadId tid;
MonoDomain *caller_domain = mono_domain_get ();
+ char *name;
/* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, GetCurrentThreadId ()); */
thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, 0, CREATE_SUSPENDED, &tid);
if (thread_handle == NULL)
return;
+ name = g_strdup_printf ("Unload thread for domain %x", domain);
+ mono_thread_info_set_name (tid, name);
mono_thread_info_resume (tid);
+ g_free (name);
/* Wait for the thread */
while (!thread_data->done && WaitForSingleObjectEx (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) {
{3943, 2309, 323, 331, 44, 55, 0, 0, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {36041, 36052, 13523, 36063, 36074, 36081, 36090, 36103, 36110, 36123, 36136, 36149, 0}, {36041, 36052, 13523, 36063, 36074, 36081, 36090, 36103, 36110, 36123, 36136, 36149, 0}, {36041, 36052, 13523, 36063, 36074, 36081, 36090, 36103, 36110, 36123, 36136, 36149, 0}, {36041, 36052, 13523, 36063, 36074, 36081, 36090, 36103, 36110, 36123, 36136, 36149, 0}, 0, 6, 2541, 241, {2309,1236,1210,0,0,0,0,0,0,0,0,0,0,0},{3943,254,0,0,0,0,0,0},{331,274,35,0,0,0,0,0,0,0,0,0},{323,280,23,0,0,0,0,0,0}},
{1344, 2927, 323, 331, 1375, 1391, 1404, 1411, {1418, 1428, 1438, 1448, 1458, 1468, 1478}, {34903, 34910, 34917, 34924, 34931, 34938, 34945}, {1537, 1541, 1545, 1549, 1553, 1557, 1561}, {1655, 1660, 1665, 1670, 1675, 1680, 1685, 1690, 1695, 1700, 1706, 1712, 0}, {1655, 1660, 1665, 1670, 1675, 1680, 1685, 1690, 1695, 1700, 1706, 1712, 0}, {1655, 1660, 1665, 1670, 1675, 1680, 1685, 1690, 1695, 1700, 1706, 1712, 0}, {1655, 1660, 1665, 1670, 1675, 1680, 1685, 1690, 1695, 1700, 1706, 1712, 0}, 0, 0, 239, 241, {2927,1229,14,1765,1779,1366,1736,1210,0,0,0,0,0,0},{1344,36162,36189,2543,0,0,0,0},{331,274,0,0,0,0,0,0,0,0,0,0},{323,280,0,0,0,0,0,0,0}},
{2568, 2587, 280, 274, 1906, 1916, 2598, 2604, {2611, 2619, 2626, 2635, 2644, 2655, 2663}, {2671, 2674, 2677, 2680, 2683, 2686, 2689}, {2018, 2403, 2692, 2403, 2692, 2409, 2018}, {2694, 2701, 2709, 2715, 2721, 2725, 2730, 2735, 2742, 2752, 2760, 2769, 0}, {2694, 2701, 2709, 2715, 2721, 2725, 2730, 2735, 2742, 2752, 2760, 2769, 0}, {2778, 2782, 2786, 2791, 2721, 2795, 2799, 2803, 2807, 2811, 2815, 2819, 0}, {2778, 2782, 2786, 2791, 2721, 2795, 2799, 2803, 2807, 2811, 2815, 2819, 0}, 2, 1, 754, 241, {2587,1245,2835,35120,2843,1210,0,0,0,0,0,0,0,0},{2568,1882,35130,0,0,0,0,0},{274,331,8214,8204,2862,8237,8242,8223,8229,0,0,0},{280,323,8274,8287,2887,2873,2902,0,0}},
- {2909, 14812, 2936, 2947, 1906, 352, 7992, 21969, {3719, 3726, 3733, 3741, 3751, 3760, 3767}, {3776, 3780, 3784, 3788, 3792, 3796, 3800}, {2018, 2403, 2405, 3804, 2405, 2409, 2018}, {3806, 3814, 3823, 2715, 3829, 3833, 3838, 2735, 2742, 3843, 2760, 3851, 0}, {3806, 3814, 3823, 2715, 3829, 3833, 3838, 2735, 2742, 3843, 2760, 3851, 0}, {2778, 2782, 3860, 2791, 3829, 2795, 2799, 2803, 2807, 3864, 2815, 3868, 0}, {2778, 2782, 3860, 2791, 3829, 2795, 2799, 2803, 2807, 3864, 2815, 3868, 0}, 0, 0, 239, 241, {14812,1221,14,2835,1210,0,0,0,0,0,0,0,0,0},{2909,3672,0,0,0,0,0,0},{2947,35,274,331,0,0,0,0,0,0,0,0},{2936,23,280,323,0,0,0,0,0}},
+ {2909, 14812, 2936, 2947, 1906, 352, 7213, 7218, {3719, 3726, 3733, 3741, 3751, 3760, 3767}, {3776, 3780, 3784, 3788, 3792, 3796, 3800}, {2018, 2403, 2405, 3804, 2405, 2409, 2018}, {3806, 3814, 3823, 2715, 3829, 3833, 3838, 2735, 2742, 3843, 2760, 3851, 0}, {3806, 3814, 3823, 2715, 3829, 3833, 3838, 2735, 2742, 3843, 2760, 3851, 0}, {2778, 2782, 3860, 2791, 3829, 2795, 2799, 2803, 2807, 3864, 2815, 3868, 0}, {2778, 2782, 3860, 2791, 3829, 2795, 2799, 2803, 2807, 3864, 2815, 3868, 0}, 0, 0, 239, 241, {14812,1221,14,2835,1210,0,0,0,0,0,0,0,0,0},{2909,3672,0,0,0,0,0,0},{2947,35,274,331,0,0,0,0,0,0,0,0},{2936,23,280,323,0,0,0,0,0}},
{4342, 243, 23, 35, 947, 3985, 962, 968, {3997, 4005, 4011, 4018, 4029, 4036, 4044}, {4052, 4057, 4062, 4067, 4073, 4078, 4083}, {2692, 2411, 2403, 2403, 4089, 4091, 2018}, {4093, 4099, 4107, 4113, 4119, 4124, 4130, 4136, 4143, 4154, 4162, 4172, 0}, {4182, 4188, 4196, 1102, 4202, 4207, 4213, 4219, 4226, 1140, 4237, 4247, 0}, {4257, 4262, 4062, 4267, 4272, 4277, 4282, 4287, 4292, 4298, 4303, 4308, 0}, {4257, 4262, 4062, 4267, 4272, 4277, 4282, 4287, 4292, 4298, 4303, 4308, 0}, 0, 1, 239, 241, {243,14,1229,1236,1210,0,0,0,0,0,0,0,0,0},{4313,4342,4369,0,0,0,0,0},{35,2947,331,274,0,0,0,0,0,0,0,0},{23,2936,323,280,0,0,0,0,0}},
{36205, 243, 280, 274, 1906, 352, 1924, 1927, {4874, 4883, 4889, 4895, 4904, 4910, 4919}, {4926, 4931, 4936, 4941, 4946, 4951, 4956}, {2692, 2411, 2403, 2403, 4089, 4091, 2018}, {4961, 4969, 4978, 4983, 4989, 4993, 4998, 5006, 5012, 5022, 1148, 5030, 0}, {4961, 4969, 4978, 4983, 4989, 4993, 4998, 5006, 5012, 5022, 1148, 5030, 0}, {5040, 5046, 4978, 5053, 4989, 4993, 5058, 5006, 5064, 1195, 1200, 5070, 0}, {5040, 5046, 4978, 5053, 4989, 4993, 5058, 5006, 5064, 1195, 1200, 5070, 0}, 2, 1, 239, 241, {243,14,1245,1236,1210,0,0,0,0,0,0,0,0,0},{4857,5076,3672,0,0,0,0,0},{274,331,5085,5091,5101,0,0,0,0,0,0,0},{280,323,0,0,0,0,0,0,0}},
{1882, 2261, 323, 331, 1906, 11991, 36228, 36238, {9068, 9077, 9089, 9096, 9104, 9114, 9120}, {9127, 9131, 9135, 9139, 9143, 9148, 9152}, {0, 0, 0, 0, 0, 0, 0}, {2413, 2420, 15113, 2434, 2440, 2444, 2449, 11959, 36246, 36256, 36264, 36273, 0}, {2413, 2420, 15113, 2434, 2440, 2444, 2449, 11959, 36246, 36256, 36264, 36273, 0}, {2497, 2501, 2505, 2509, 2440, 2513, 2517, 11966, 2525, 2529, 2533, 2537, 0}, {2497, 2501, 2505, 2509, 2440, 2513, 2517, 11966, 2525, 2529, 2533, 2537, 0}, 0, 1, 754, 241, {2261,2843,1895,2587,9640,1245,11970,1210,0,0,0,0,0,0},{1882,2554,2568,0,0,0,0,0},{331,274,0,0,0,0,0,0,0,0,0,0},{323,280,0,0,0,0,0,0,0}},
if (_BitScanReverse (&bIndex, mask))
return bIndex;
return -1;
-#elif defined(__x86_64__) && defined(_MSC_VER)
+#elif defined(_M_X64) && defined(_MSC_VER)
unsigned long bIndex = 0;
if (_BitScanReverse64 (&bIndex, mask))
return bIndex;
i = sizeof (gsize) * 8;
while (i > 0) {
i --;
- if (mask & (1UL << i))
+ if (mask & (1ULL << i))
return i;
}
return -1;
mono_domain_get_tls_offset (void)
{
int offset = -1;
+
+#ifdef HOST_WIN32
+ if (appdomain_thread_id)
+ offset = appdomain_thread_id;
+#else
MONO_THREAD_VAR_OFFSET (tls_appdomain, offset);
-/* __asm ("jmp 1f; .section writetext, \"awx\"; 1: movl $tls_appdomain@ntpoff, %0; jmp 2f; .previous; 2:"
- : "=r" (offset));*/
+#endif
return offset;
}
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_DEFAULT, &ud);
}
+/*
+ * mono_stack_walk_async_safe:
+ *
+ * Async safe version callable from signal handlers.
+ */
+void
+mono_stack_walk_async_safe (MonoStackWalk func, gpointer user_data)
+{
+ StackWalkUserData ud = { func, user_data };
+ mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_NONE, &ud);
+}
+
static gboolean
last_managed (MonoMethod *m, gint no, gint ilo, gboolean managed, gpointer data)
{
MONO_API void
mono_stack_walk_no_il (MonoStackWalk func, void* user_data);
+MONO_API void
+mono_stack_walk_async_safe (MonoStackWalk func, void* user_data);
+
MONO_END_DECLS
#endif
*/
GSList *apps;
GSList *assemblies;
+ char *aot_options;
} MonoAotCacheConfig;
#define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
for (i = 0; attribute_names [i]; ++i) {
if (!strcmp (attribute_names [i], "app")) {
config->apps = g_slist_prepend (config->apps, g_strdup (attribute_values [i]));
- return;
}
}
config->assemblies = g_slist_prepend (config->assemblies, g_strdup (part));
}
g_strfreev (parts);
+ } else if (!strcmp (attribute_names [i], "options")) {
+ config->aot_options = g_strdup (attribute_values [i]);
}
}
}
mono_class_init (parent);
while ((klass = mono_class_get_nested_types (parent, &iter))) {
- if (ignorecase) {
- if (mono_utf8_strcasecmp (klass->name, mod->data) == 0)
- break;
+ char *lastp;
+ char *nested_name, *nested_nspace;
+ gboolean match = TRUE;
+
+ lastp = strrchr (mod->data, '.');
+ if (lastp) {
+ /* Nested classes can have namespaces */
+ int nspace_len;
+
+ nested_name = g_strdup (lastp + 1);
+ nspace_len = lastp - (char*)mod->data;
+ nested_nspace = g_malloc (nspace_len + 1);
+ memcpy (nested_nspace, mod->data, nspace_len);
+ nested_nspace [nspace_len] = '\0';
+
} else {
- if (strcmp (klass->name, mod->data) == 0)
- break;
+ nested_name = mod->data;
+ nested_nspace = NULL;
}
+
+ if (nested_nspace) {
+ if (ignorecase) {
+ if (!(klass->name_space && mono_utf8_strcasecmp (klass->name_space, nested_nspace) == 0))
+ match = FALSE;
+ } else {
+ if (!(klass->name_space && strcmp (klass->name_space, nested_nspace) == 0))
+ match = FALSE;
+ }
+ }
+ if (match) {
+ if (ignorecase) {
+ if (mono_utf8_strcasecmp (klass->name, nested_name) != 0)
+ match = FALSE;
+ } else {
+ if (strcmp (klass->name, nested_name) != 0)
+ match = FALSE;
+ }
+ }
+ if (lastp) {
+ g_free (nested_name);
+ g_free (nested_nspace);
+ }
+ if (match)
+ break;
}
+
if (!klass)
break;
}
guint8*
mono_gc_get_card_table (int *shift_bits, gpointer *mask)
{
+#ifndef MANAGED_WBARRIER
+ return NULL;
+#else
if (!sgen_cardtable)
return NULL;
#endif
return sgen_cardtable;
+#endif
}
gboolean
* License 2.0 along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
+#include "mono/utils/mono-compiler.h"
+
extern long long stat_copy_object_called_nursery;
extern long long stat_objects_copied_nursery;
* This function can be used even if the vtable of obj is not valid
* anymore, which is the case in the parallel collector.
*/
-static inline void
+static MONO_ALWAYS_INLINE void
par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword objsize, SgenGrayQueue *queue)
{
-#ifdef __GNUC__
- static const void *copy_labels [] = { &&LAB_0, &&LAB_1, &&LAB_2, &&LAB_3, &&LAB_4, &&LAB_5, &&LAB_6, &&LAB_7, &&LAB_8 };
-#endif
-
SGEN_ASSERT (9, vt->klass->inited, "vtable %p for class %s:%s was not initialized", vt, vt->klass->name_space, vt->klass->name);
SGEN_LOG (9, " (to %p, %s size: %lu)", destination, ((MonoObject*)obj)->vtable->klass->name, (unsigned long)objsize);
binary_protocol_copy (obj, destination, vt, objsize);
}
#endif
-#ifdef __GNUC__
- if (objsize <= sizeof (gpointer) * 8) {
- mword *dest = (mword*)destination;
- goto *copy_labels [objsize / sizeof (gpointer)];
- LAB_8:
- (dest) [7] = ((mword*)obj) [7];
- LAB_7:
- (dest) [6] = ((mword*)obj) [6];
- LAB_6:
- (dest) [5] = ((mword*)obj) [5];
- LAB_5:
- (dest) [4] = ((mword*)obj) [4];
- LAB_4:
- (dest) [3] = ((mword*)obj) [3];
- LAB_3:
- (dest) [2] = ((mword*)obj) [2];
- LAB_2:
- (dest) [1] = ((mword*)obj) [1];
- LAB_1:
- ;
- LAB_0:
- ;
- } else {
- /*can't trust memcpy doing word copies */
- mono_gc_memmove_aligned (destination + sizeof (mword), (char*)obj + sizeof (mword), objsize - sizeof (mword));
- }
-#else
- mono_gc_memmove_aligned (destination + sizeof (mword), (char*)obj + sizeof (mword), objsize - sizeof (mword));
-#endif
+ memcpy (destination + sizeof (mword), (char*)obj + sizeof (mword), objsize - sizeof (mword));
+
/* adjust array->bounds */
SGEN_ASSERT (9, vt->gc_descr, "vtable %p for class %s:%s has no gc descriptor", vt, vt->klass->name_space, vt->klass->name);
/*
* This can return OBJ itself on OOM.
*/
-#ifdef _MSC_VER
-static __declspec(noinline) void*
-#else
-static G_GNUC_UNUSED void* __attribute__((noinline))
-#endif
+static MONO_NEVER_INLINE void*
copy_object_no_checks (void *obj, SgenGrayQueue *queue)
{
MonoVTable *vt = ((MonoObject*)obj)->vtable;
extern long long stat_nursery_copy_object_failed_to_space; /* from sgen-gc.c */
+#include "mono/utils/mono-compiler.h"
+
#include "sgen-copy-object.h"
/*
* copy_object could be made into a macro once debugged (use inline for now).
*/
-#ifdef _MSC_VER
-static __forceinline void
-#else
-static inline void __attribute__((always_inline))
-#endif
+static MONO_ALWAYS_INLINE void
SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
{
char *forwarded;
*
* Similar to SERIAL_COPY_OBJECT, but assumes that OBJ_SLOT is part of an object, so it handles global remsets as well.
*/
-#ifdef _MSC_VER
-static __forceinline void
-#else
-static inline void __attribute__((always_inline))
-#endif
+static MONO_ALWAYS_INLINE void
SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
{
char *forwarded;
#include <mono/metadata/marshal.h>
#include <mono/metadata/runtime.h>
#include <mono/io-layer/io-layer.h>
-#ifndef HOST_WIN32
-#include <mono/io-layer/threads.h>
-#endif
#include <mono/metadata/object-internals.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/utils/mono-compiler.h>
{
LOCK_THREAD (this_obj);
- if (this_obj->flags & MONO_THREAD_FLAG_NAME_SET) {
+ if ((this_obj->flags & MONO_THREAD_FLAG_NAME_SET) && !this_obj->threadpool_thread) {
UNLOCK_THREAD (this_obj);
mono_raise_exception (mono_get_exception_invalid_operation ("Thread.Name can only be set once."));
return;
}
+ if (this_obj->name) {
+ g_free (this_obj->name);
+ this_obj->name_len = 0;
+ }
if (name) {
this_obj->name = g_new (gunichar2, mono_string_length (name));
memcpy (this_obj->name, mono_string_chars (name), mono_string_length (name) * 2);
* functions in the io-layer until the signal handler calls QueueUserAPC which will
* make it return.
*/
- wait_handle = wapi_prepare_interrupt_thread (thread->handle);
+ wait_handle = mono_thread_info_prepare_interrupt (thread->handle);
/* fixme: store the state somewhere */
mono_thread_kill (thread, mono_thread_get_abort_signal ());
- wapi_finish_interrupt_thread (wait_handle);
+ mono_thread_info_finish_interrupt (wait_handle);
#endif /* HOST_WIN32 */
}
* to get correct user and system times from getrusage/wait/time(1)).
* This could be removed if we avoid pthread_detach() and use pthread_join().
*/
-#ifndef HOST_WIN32
mono_thread_info_yield ();
-#endif
}
static void terminate_thread (gpointer key, gpointer value, gpointer user)
WaitForSingleObjectEx (GetCurrentThread(), 0, TRUE);
#endif
InterlockedDecrement (&thread_interruption_requested);
-#ifndef HOST_WIN32
/* Clear the interrupted flag of the thread so it can wait again */
- wapi_clear_interruption ();
-#endif
+ mono_thread_info_clear_interruption ();
}
if ((thread->state & ThreadState_AbortRequested) != 0) {
#ifdef HOST_WIN32
QueueUserAPC ((PAPCFUNC)dummy_apc, thread->handle, (ULONG_PTR)NULL);
#else
- wapi_self_interrupt ();
+ mono_thread_info_self_interrupt ();
#endif
return NULL;
}
return NULL;
InterlockedIncrement (&thread_interruption_requested);
-#ifndef HOST_WIN32
- wapi_self_interrupt ();
-#endif
+ mono_thread_info_self_interrupt ();
+
return mono_thread_execute_interruption (thread);
}
MonoException *exc = mono_thread_request_interruption (can_raise_exception);
if (exc)
mono_raise_exception (exc);
-#ifndef HOST_WIN32
- wapi_interrupt_thread (thread->handle);
-#endif
+ mono_thread_info_interrupt (thread->handle);
return;
}
* functions in the io-layer until the signal handler calls QueueUserAPC which will
* make it return.
*/
-#ifndef HOST_WIN32
gpointer interrupt_handle;
- interrupt_handle = wapi_prepare_interrupt_thread (thread->handle);
-#endif
+
+ interrupt_handle = mono_thread_info_prepare_interrupt (thread->handle);
mono_thread_info_finish_suspend_and_resume (info);
-#ifndef HOST_WIN32
- wapi_finish_interrupt_thread (interrupt_handle);
-#endif
+ mono_thread_info_finish_interrupt (interrupt_handle);
}
/*FIXME we need to wait for interruption to complete -- figure out how much into interruption we should wait for here*/
}
if (running_managed && !protected_wrapper) {
transition_to_suspended (thread, info);
} else {
-#ifndef HOST_WIN32
gpointer interrupt_handle;
-#endif
if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 0)
InterlockedIncrement (&thread_interruption_requested);
-#ifndef HOST_WIN32
if (interrupt)
- interrupt_handle = wapi_prepare_interrupt_thread (thread->handle);
-#endif
+ interrupt_handle = mono_thread_info_prepare_interrupt (thread->handle);
mono_thread_info_finish_suspend_and_resume (info);
-#ifndef HOST_WIN32
if (interrupt)
- wapi_finish_interrupt_thread (interrupt_handle);
-#endif
+ mono_thread_info_finish_interrupt (interrupt_handle);
UNLOCK_THREAD (thread);
}
}
gboolean use_trampolines_page;
gboolean no_instances;
gboolean gnu_asm;
+ gboolean llvm;
int nthreads;
int ntrampolines;
int nrgctx_trampolines;
for (i = 0; i < inst->type_argc; ++i) {
MonoType *t = inst->type_argv [i];
- if (t->type == MONO_TYPE_VALUETYPE)
+ if (MONO_TYPE_ISSTRUCT (t) || t->type == MONO_TYPE_VALUETYPE)
return TRUE;
}
return FALSE;
opts->mtriple = g_strdup (arg + strlen ("mtriple="));
} else if (str_begins_with (arg, "llvm-path=")) {
opts->llvm_path = g_strdup (arg + strlen ("llvm-path="));
+ } else if (!strcmp (arg, "llvm")) {
+ opts->llvm = TRUE;
} else if (str_begins_with (arg, "readonly-value=")) {
add_readonly_value (opts, arg + strlen ("readonly-value="));
} else if (str_begins_with (arg, "info")) {
gboolean skip;
int index, depth;
MonoMethod *wrapped;
+ JitFlags flags;
if (acfg->aot_opts.metadata_only)
return;
* the runtime will not see AOT methods during AOT compilation,so it
* does not need to support them by creating a fake GOT etc.
*/
- cfg = mini_method_compile (method, acfg->opts, mono_get_root_domain (), acfg->aot_opts.full_aot ? (JIT_FLAG_AOT|JIT_FLAG_FULL_AOT) : (JIT_FLAG_AOT), 0);
+ flags = JIT_FLAG_AOT;
+ if (acfg->aot_opts.full_aot)
+ flags |= JIT_FLAG_FULL_AOT;
+ if (acfg->llvm)
+ flags |= JIT_FLAG_LLVM;
+ cfg = mini_method_compile (method, acfg->opts, mono_get_root_domain (), flags, 0);
mono_loader_clear_error ();
if (cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) {
acfg->flags |= MONO_AOT_FILE_FLAG_DEBUG;
}
- if (mono_use_llvm) {
+ if (mono_use_llvm || acfg->aot_opts.llvm) {
acfg->llvm = TRUE;
acfg->aot_opts.asm_writer = TRUE;
acfg->flags |= MONO_AOT_FILE_FLAG_WITH_LLVM;
res = emit_llvm_file (acfg);
if (!res)
- return FALSE;
+ return 1;
}
#endif
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loading from cache: '%s'.", fname);
module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
- if (module)
+ if (module) {
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: found in cache: '%s'.", fname);
return module;
+ }
if (!strcmp (assembly->aname.name, "mscorlib") && !mscorlib_aot_loaded)
/*
fclose (failure_file);
}
- mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compiling assembly '%s'... ", assembly->image->name);
+ mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compiling assembly '%s', logfile: '%s.log'... ", assembly->image->name, fname);
/*
* We need to invoke the AOT compiler here. There are multiple approaches:
* - fork a new process and do the work there.
*/
if (in_process) {
- aot_options = g_strdup_printf ("outfile=%s,internal-logfile=%s.log", fname, fname);
+ aot_options = g_strdup_printf ("outfile=%s,internal-logfile=%s.log%s%s", fname, fname, config->aot_options ? "," : "", config->aot_options ? config->aot_options : "");
/* Maybe due this in another thread ? */
res = mono_compile_assembly (assembly, mono_parse_default_optimizations (NULL), aot_options);
- if (!res) {
+ if (res) {
+ mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compilation failed.");
failure_fname = g_strdup_printf ("%s.failure", fname);
failure_file = fopen (failure_fname, "a+");
fclose (failure_file);
g_free (failure_fname);
+ } else {
+ mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compilation succeeded.");
}
} else {
/*
cgt.un: dest:c len:8
clt: dest:c len:8
clt.un: dest:c len:8
-localloc: dest:i src1:i len:84
+localloc: dest:i src1:i len:96
compare: src1:i src2:i len:3
lcompare: src1:i src2:i len:3
icompare: src1:i src2:i len:3
dyn_call: src1:i src2:i len:64 clob:c nacl:128
-localloc_imm: dest:i len:84
+localloc_imm: dest:i len:96
load_mem: dest:i len:16
loadi8_mem: dest:i len:16
long_conv_to_ovf_i4_2: dest:i src1:i src2:i len:36
-vcall2: len:32 clob:c
-vcall2_reg: src1:i len:32 clob:c
-vcall2_membase: src1:b len:32 clob:c
+vcall2: len:40 clob:c
+vcall2_reg: src1:i len:40 clob:c
+vcall2_membase: src1:b len:40 clob:c
dyn_call: src1:i src2:i len:120 clob:c
# This is different from the original JIT opcodes
#endif
/* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
-#ifdef HOST_WIN32
- QueueUserAPC (notify_thread_apc, thread->handle, (ULONG_PTR)NULL);
-#else
if (mono_thread_info_new_interrupt_enabled ()) {
MonoThreadInfo *info;
MonoJitInfo *ji;
mono_thread_info_finish_suspend_and_resume (info);
}
} else {
+#ifdef HOST_WIN32
+ // FIXME: Remove this since new interrupt is used on win32 now
+ QueueUserAPC (notify_thread_apc, thread->handle, (ULONG_PTR)NULL);
+#else
res = mono_thread_kill (thread, mono_thread_get_abort_signal ());
if (res) {
DEBUG(1, fprintf (log_file, "[%p] mono_thread_kill () failed for %p: %d...\n", (gpointer)GetCurrentThreadId (), (gpointer)tid, res));
*/
tls->terminated = TRUE;
}
- }
#endif
+ }
}
static void
void *mono_win_vectored_exception_handle;
#define W32_SEH_HANDLE_EX(_ex) \
- if (_ex##_handler) _ex##_handler(0, ep, sctx)
+ if (_ex##_handler) _ex##_handler(0, ep, ctx)
static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
{
{
EXCEPTION_RECORD* er;
CONTEXT* ctx;
- MonoContext* sctx;
LONG res;
MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
er = ep->ExceptionRecord;
ctx = ep->ContextRecord;
- sctx = g_malloc(sizeof(MonoContext));
-
- /* Copy Win32 context to UNIX style context */
- sctx->rax = ctx->Rax;
- sctx->rbx = ctx->Rbx;
- sctx->rcx = ctx->Rcx;
- sctx->rdx = ctx->Rdx;
- sctx->rbp = ctx->Rbp;
- sctx->rsp = ctx->Rsp;
- sctx->rsi = ctx->Rsi;
- sctx->rdi = ctx->Rdi;
- sctx->rip = ctx->Rip;
- sctx->r12 = ctx->R12;
- sctx->r13 = ctx->R13;
- sctx->r14 = ctx->R14;
- sctx->r15 = ctx->R15;
switch (er->ExceptionCode) {
case EXCEPTION_ACCESS_VIOLATION:
* can correctly chain the exception.
*/
res = EXCEPTION_CONTINUE_SEARCH;
- } else {
- /* Copy context back */
- /* Nonvolatile */
- ctx->Rsp = sctx->rsp;
- ctx->Rdi = sctx->rdi;
- ctx->Rsi = sctx->rsi;
- ctx->Rbx = sctx->rbx;
- ctx->Rbp = sctx->rbp;
- ctx->R12 = sctx->r12;
- ctx->R13 = sctx->r13;
- ctx->R14 = sctx->r14;
- ctx->R15 = sctx->r15;
- ctx->Rip = sctx->rip;
-
- /* Volatile But should not matter?*/
- ctx->Rax = sctx->rax;
- ctx->Rcx = sctx->rcx;
- ctx->Rdx = sctx->rdx;
}
- /* TODO: Find right place to free this in stack overflow case */
- if (er->ExceptionCode != EXCEPTION_STACK_OVERFLOW)
- g_free (sctx);
-
return res;
}
ucontext_t *ctx = (ucontext_t*)sigctx;
return (gpointer)UCONTEXT_REG_RIP (ctx);
+#elif defined(HOST_WIN32)
+ return ((CONTEXT*)sigctx)->Rip;
#else
MonoContext *ctx = sigctx;
return (gpointer)ctx->rip;
#include "mini.h"
#include "mini-arm.h"
#include "mono/utils/mono-sigcontext.h"
+#include "mono/utils/mono-compiler.h"
/*
* arch_get_restore_context:
* This works around a gcc 4.5 bug:
* https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/721531
*/
-#if defined(__GNUC__)
-__attribute__((noinline))
-#endif
-static gpointer
+static MONO_NEVER_INLINE gpointer
get_handle_signal_exception_addr (void)
{
return handle_signal_exception;
#endif
#define W32_SEH_HANDLE_EX(_ex) \
- if (_ex##_handler) _ex##_handler(0, ep, sctx)
+ if (_ex##_handler) _ex##_handler(0, ep, ctx)
LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
{
{
EXCEPTION_RECORD* er;
CONTEXT* ctx;
- struct sigcontext* sctx;
LONG res;
MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
er = ep->ExceptionRecord;
ctx = ep->ContextRecord;
- sctx = g_malloc(sizeof(struct sigcontext));
-
- /* Copy Win32 context to UNIX style context */
- sctx->eax = ctx->Eax;
- sctx->ebx = ctx->Ebx;
- sctx->ecx = ctx->Ecx;
- sctx->edx = ctx->Edx;
- sctx->ebp = ctx->Ebp;
- sctx->esp = ctx->Esp;
- sctx->esi = ctx->Esi;
- sctx->edi = ctx->Edi;
- sctx->eip = ctx->Eip;
switch (er->ExceptionCode) {
case EXCEPTION_STACK_OVERFLOW:
- win32_handle_stack_overflow (ep, sctx);
+ win32_handle_stack_overflow (ep, ctx);
break;
case EXCEPTION_ACCESS_VIOLATION:
W32_SEH_HANDLE_EX(segv);
* can correctly chain the exception.
*/
res = EXCEPTION_CONTINUE_SEARCH;
- } else {
- /* Copy context back */
- ctx->Eax = sctx->eax;
- ctx->Ebx = sctx->ebx;
- ctx->Ecx = sctx->ecx;
- ctx->Edx = sctx->edx;
- ctx->Ebp = sctx->ebp;
- ctx->Esp = sctx->esp;
- ctx->Esi = sctx->esi;
- ctx->Edi = sctx->edi;
- ctx->Eip = sctx->eip;
}
- /* TODO: Find right place to free this in stack overflow case */
- if (er->ExceptionCode != EXCEPTION_STACK_OVERFLOW)
- g_free (sctx);
-
return res;
}
void win32_seh_cleanup()
{
- if (mono_old_win_toplevel_exception_filter) SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
- RemoveVectoredExceptionHandler (seh_unhandled_exception_filter);
+ if (mono_old_win_toplevel_exception_filter)
+ SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
+ RemoveVectoredExceptionHandler (mono_win_vectored_exception_handle);
}
void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
#if defined(__native_client__)
printf("WARNING: mono_arch_ip_from_context() called!\n");
return (NULL);
-#else
-#ifdef MONO_ARCH_USE_SIGACTION
+#elif defined(MONO_ARCH_USE_SIGACTION)
ucontext_t *ctx = (ucontext_t*)sigctx;
return (gpointer)UCONTEXT_REG_EIP (ctx);
+#elif defined(HOST_WIN32)
+ return ((CONTEXT*)sigctx)->Eip;
#else
struct sigcontext *ctx = sigctx;
return (gpointer)ctx->SC_EIP;
#endif
-#endif /* __native_client__ */
}
/*
}
/* Generic sharing */
- /* FIXME: only do this for generic methods if
- they are not shared! */
+
+ /*
+ * Use this if the callee is gsharedvt sharable too, since
+ * at runtime we might find an instantiation so the call cannot
+ * be patched (the 'no_patch' code path in mini-trampolines.c).
+ */
if (context_used && !imt_arg && !array_rank && !delegate_invoke &&
- (!mono_method_is_generic_sharable (cmethod, TRUE) ||
+ (!mono_method_is_generic_sharable_full (cmethod, TRUE, FALSE, FALSE) ||
!mono_class_generic_sharing_enabled (cmethod->klass)) &&
(!virtual || MONO_METHOD_IS_FINAL (cmethod) ||
!(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL))) {
}
case CEE_MONO_JIT_ATTACH: {
MonoInst *args [16], *domain_ins;
- MonoInst *ad_ins, *lmf_ins;
+ MonoInst *ad_ins, *jit_tls_ins;
MonoBasicBlock *next_bb = NULL, *call_bb = NULL;
cfg->orig_domain_var = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
EMIT_NEW_PCONST (cfg, ins, NULL);
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->orig_domain_var->dreg, ins->dreg);
-#if TARGET_WIN32
- ad_ins = NULL;
- lmf_ins = NULL;
-#else
ad_ins = mono_get_domain_intrinsic (cfg);
- lmf_ins = mono_get_lmf_intrinsic (cfg);
-#endif
+ jit_tls_ins = mono_get_jit_tls_intrinsic (cfg);
- if (MONO_ARCH_HAVE_TLS_GET && ad_ins && lmf_ins) {
+ if (MONO_ARCH_HAVE_TLS_GET && ad_ins && jit_tls_ins) {
NEW_BBLOCK (cfg, next_bb);
NEW_BBLOCK (cfg, call_bb);
MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, ad_ins->dreg, domain_ins->dreg);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, call_bb);
- MONO_ADD_INS (cfg->cbb, lmf_ins);
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, lmf_ins->dreg, 0);
+ MONO_ADD_INS (cfg->cbb, jit_tls_ins);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, jit_tls_ins->dreg, 0);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBEQ, call_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, next_bb);
/* The size of the single step instruction causing the actual fault */
static int single_step_fault_size;
-#ifdef HOST_WIN32
-/* On Win64 always reserve first 32 bytes for first four arguments */
-#define ARGS_OFFSET 48
-#else
+/* Offset between fp and the first argument in the callee */
#define ARGS_OFFSET 16
-#endif
#define GP_SCRATCH_REG AMD64_R11
/*
gr = 0;
fr = 0;
+#ifdef HOST_WIN32
+ /* Reserve space where the callee can save the argument registers */
+ stack_size = 4 * sizeof (mgreg_t);
+#endif
+
/* return value */
{
ret_type = mini_type_get_underlying_type (gsctx, sig->ret);
add_valuetype (gsctx, sig, ainfo, sig->params [i], FALSE, &gr, &fr, &stack_size);
break;
case MONO_TYPE_U8:
+
case MONO_TYPE_I8:
add_general (&gr, &stack_size, ainfo);
break;
add_general (&gr, &stack_size, &cinfo->sig_cookie);
}
-#ifdef HOST_WIN32
- // There always is 32 bytes reserved on the stack when calling on Winx64
- stack_size += 0x20;
-#endif
-
-#ifndef MONO_AMD64_NO_PUSHES
- if (stack_size & 0x8) {
- /* The AMD64 ABI requires each stack frame to be 16 byte aligned */
- cinfo->need_stack_align = TRUE;
- stack_size += 8;
- }
-#endif
-
cinfo->stack_usage = stack_size;
cinfo->reg_usage = gr;
cinfo->freg_usage = fr;
cfg->arch.omit_fp = FALSE;
#endif
-#ifdef HOST_WIN32
- cfg->arch.omit_fp = FALSE;
-#endif
-
if (cfg->disable_omit_fp)
cfg->arch.omit_fp = FALSE;
cfg->arch.ss_trigger_page_var = ins;
}
-#ifdef MONO_AMD64_NO_PUSHES
- /*
- * When this is set, we pass arguments on the stack by moves, and by allocating
- * a bigger stack frame, instead of pushes.
- * Pushes complicate exception handling because the arguments on the stack have
- * to be popped each time a frame is unwound. They also make fp elimination
- * impossible.
- * FIXME: This doesn't work inside filter/finally clauses, since those execute
- * on a new frame which doesn't include a param area.
- */
- cfg->arch.no_pushes = TRUE;
-#endif
-
if (cfg->method->save_lmf)
cfg->create_lmf_var = TRUE;
#endif
}
-#ifndef MONO_AMD64_NO_PUSHES
+#ifndef HOST_WIN32
cfg->arch_eh_jit_info = 1;
#endif
}
static void
emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
{
- MonoInst *arg;
MonoMethodSignature *tmp_sig;
int sig_reg;
sig_reg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_SIGNATURECONST (cfg, sig_reg, tmp_sig);
- if (cfg->arch.no_pushes) {
- MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, cinfo->sig_cookie.offset, sig_reg);
- } else {
- MONO_INST_NEW (cfg, arg, OP_X86_PUSH);
- arg->sreg1 = sig_reg;
- MONO_ADD_INS (cfg->cbb, arg);
- }
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, cinfo->sig_cookie.offset, sig_reg);
}
static inline LLVMArgStorage
return;
}
- if (cinfo->need_stack_align) {
- if (!cfg->arch.no_pushes)
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
- }
-
/*
* Emit all arguments which are passed on the stack to prevent register
* allocation problems.
*/
- if (cfg->arch.no_pushes) {
- for (i = 0; i < n; ++i) {
- MonoType *t;
- ainfo = cinfo->args + i;
+ for (i = 0; i < n; ++i) {
+ MonoType *t;
+ ainfo = cinfo->args + i;
- in = call->args [i];
+ in = call->args [i];
- if (sig->hasthis && i == 0)
- t = &mono_defaults.object_class->byval_arg;
- else
- t = sig->params [i - sig->hasthis];
+ if (sig->hasthis && i == 0)
+ t = &mono_defaults.object_class->byval_arg;
+ else
+ t = sig->params [i - sig->hasthis];
- if (ainfo->storage == ArgOnStack && !MONO_TYPE_ISSTRUCT (t) && !call->tail_call) {
- if (!t->byref) {
- if (t->type == MONO_TYPE_R4)
- MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER4_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
- else if (t->type == MONO_TYPE_R8)
- MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
- else
- MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
- } else {
+ if (ainfo->storage == ArgOnStack && !MONO_TYPE_ISSTRUCT (t) && !call->tail_call) {
+ if (!t->byref) {
+ if (t->type == MONO_TYPE_R4)
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER4_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
+ else if (t->type == MONO_TYPE_R8)
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
+ else
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
- }
- if (cfg->compute_gc_maps) {
- MonoInst *def;
+ } else {
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, in->dreg);
+ }
+ if (cfg->compute_gc_maps) {
+ MonoInst *def;
- EMIT_NEW_GC_PARAM_SLOT_LIVENESS_DEF (cfg, def, ainfo->offset, t);
- }
+ EMIT_NEW_GC_PARAM_SLOT_LIVENESS_DEF (cfg, def, ainfo->offset, t);
}
}
}
arg->inst_p1 = mono_mempool_alloc (cfg->mempool, sizeof (ArgInfo));
memcpy (arg->inst_p1, ainfo, sizeof (ArgInfo));
- MONO_ADD_INS (cfg->cbb, arg);
- }
- } else {
- if (cfg->arch.no_pushes) {
- /* Already done */
- } else {
- MONO_INST_NEW (cfg, arg, OP_X86_PUSH);
- arg->sreg1 = in->dreg;
- if (!sig->params [i - sig->hasthis]->byref) {
- if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R4) {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
- arg->opcode = OP_STORER4_MEMBASE_REG;
- arg->inst_destbasereg = X86_ESP;
- arg->inst_offset = 0;
- } else if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R8) {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
- arg->opcode = OP_STORER8_MEMBASE_REG;
- arg->inst_destbasereg = X86_ESP;
- arg->inst_offset = 0;
- }
- }
MONO_ADD_INS (cfg->cbb, arg);
}
}
}
}
-#ifdef HOST_WIN32
- if (call->inst.opcode != OP_TAILCALL) {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUB_IMM, X86_ESP, X86_ESP, 0x20);
- }
-#endif
-
if (cfg->method->save_lmf) {
MONO_INST_NEW (cfg, arg, OP_AMD64_SAVE_SP_TO_LMF);
MONO_ADD_INS (cfg->cbb, arg);
MonoInst *vtaddr, *load;
vtaddr = mono_compile_create_var (cfg, &ins->klass->byval_arg, OP_LOCAL);
- g_assert (!cfg->arch.no_pushes);
-
MONO_INST_NEW (cfg, load, OP_LDADDR);
cfg->has_indirection = TRUE;
load->inst_p0 = vtaddr;
MONO_ADD_INS (cfg->cbb, arg);
mono_call_inst_add_outarg_reg (cfg, call, arg->dreg, ainfo->pair_regs [0], FALSE);
} else {
- MONO_INST_NEW (cfg, arg, OP_X86_PUSH);
- arg->sreg1 = load->dreg;
- MONO_ADD_INS (cfg->cbb, arg);
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, load->dreg);
}
} else {
if (size == 8) {
- if (cfg->arch.no_pushes) {
- int dreg = mono_alloc_ireg (cfg);
+ int dreg = mono_alloc_ireg (cfg);
- MONO_EMIT_NEW_LOAD_MEMBASE (cfg, dreg, src->dreg, 0);
- MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, dreg);
- } else {
- /* Can't use this for < 8 since it does an 8 byte memory load */
- MONO_INST_NEW (cfg, arg, OP_X86_PUSH_MEMBASE);
- arg->inst_basereg = src->dreg;
- arg->inst_offset = 0;
- MONO_ADD_INS (cfg->cbb, arg);
- }
+ MONO_EMIT_NEW_LOAD_MEMBASE (cfg, dreg, src->dreg, 0);
+ MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, dreg);
} else if (size <= 40) {
- if (cfg->arch.no_pushes) {
- mini_emit_memcpy (cfg, AMD64_RSP, ainfo->offset, src->dreg, 0, size, 4);
- } else {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUB_IMM, X86_ESP, X86_ESP, ALIGN_TO (size, 8));
- mini_emit_memcpy (cfg, X86_ESP, 0, src->dreg, 0, size, 4);
- }
+ mini_emit_memcpy (cfg, AMD64_RSP, ainfo->offset, src->dreg, 0, size, 4);
} else {
- if (cfg->arch.no_pushes) {
- // FIXME: Code growth
- mini_emit_memcpy (cfg, AMD64_RSP, ainfo->offset, src->dreg, 0, size, 4);
- } else {
- MONO_INST_NEW (cfg, arg, OP_X86_PUSH_OBJ);
- arg->inst_basereg = src->dreg;
- arg->inst_offset = 0;
- arg->inst_imm = size;
- MONO_ADD_INS (cfg->cbb, arg);
- }
+ // FIXME: Code growth
+ mini_emit_memcpy (cfg, AMD64_RSP, ainfo->offset, src->dreg, 0, size, 4);
}
if (cfg->compute_gc_maps) {
amd64_alu_reg_reg (code, X86_XOR, AMD64_RAX, AMD64_RAX);
amd64_lea_membase (code, AMD64_RDI, AMD64_RSP, offset);
- if (cfg->param_area && cfg->arch.no_pushes)
+ if (cfg->param_area)
amd64_alu_reg_imm (code, X86_ADD, AMD64_RDI, cfg->param_area);
amd64_cld (code);
#if defined(__default_codegen__)
code = emit_call (cfg, code, MONO_PATCH_INFO_ABS, call->fptr, FALSE);
ins->flags |= MONO_INST_GC_CALLSITE;
ins->backend.pc_offset = code - cfg->native_code;
- if (call->stack_usage && !CALLCONV_IS_STDCALL (call->signature->call_convention) && !cfg->arch.no_pushes)
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, call->stack_usage);
code = emit_move_return_value (cfg, ins, code);
break;
case OP_FCALL_REG:
amd64_call_reg (code, ins->sreg1);
ins->flags |= MONO_INST_GC_CALLSITE;
ins->backend.pc_offset = code - cfg->native_code;
- if (call->stack_usage && !CALLCONV_IS_STDCALL (call->signature->call_convention) && !cfg->arch.no_pushes)
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, call->stack_usage);
code = emit_move_return_value (cfg, ins, code);
break;
case OP_FCALL_MEMBASE:
amd64_call_membase (code, ins->sreg1, ins->inst_offset);
ins->flags |= MONO_INST_GC_CALLSITE;
ins->backend.pc_offset = code - cfg->native_code;
- if (call->stack_usage && !CALLCONV_IS_STDCALL (call->signature->call_convention) && !cfg->arch.no_pushes)
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, call->stack_usage);
code = emit_move_return_value (cfg, ins, code);
break;
case OP_DYN_CALL: {
break;
}
case OP_X86_PUSH:
- g_assert (!cfg->arch.no_pushes);
+ g_assert_not_reached ();
amd64_push_reg (code, ins->sreg1);
break;
case OP_X86_PUSH_IMM:
- g_assert (!cfg->arch.no_pushes);
+ g_assert_not_reached ();
g_assert (amd64_is_imm32 (ins->inst_imm));
amd64_push_imm (code, ins->inst_imm);
break;
case OP_X86_PUSH_MEMBASE:
- g_assert (!cfg->arch.no_pushes);
+ g_assert_not_reached ();
amd64_push_membase (code, ins->inst_basereg, ins->inst_offset);
break;
case OP_X86_PUSH_OBJ: {
int size = ALIGN_TO (ins->inst_imm, 8);
- g_assert (!cfg->arch.no_pushes);
+ g_assert_not_reached ();
amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, size);
amd64_push_reg (code, AMD64_RDI);
amd64_alu_reg_imm (code, X86_AND, ins->sreg1, ~(MONO_ARCH_FRAME_ALIGNMENT - 1));
code = mono_emit_stack_alloc (cfg, code, ins);
amd64_mov_reg_reg (code, ins->dreg, AMD64_RSP, 8);
- if (cfg->param_area && cfg->arch.no_pushes)
+ if (cfg->param_area)
amd64_alu_reg_imm (code, X86_ADD, ins->dreg, cfg->param_area);
break;
case OP_LOCALLOC_IMM: {
amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, size);
amd64_mov_reg_reg (code, ins->dreg, AMD64_RSP, 8);
}
- if (cfg->param_area && cfg->arch.no_pushes)
+ if (cfg->param_area)
amd64_alu_reg_imm (code, X86_ADD, ins->dreg, cfg->param_area);
break;
}
if ((MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_FINALLY) ||
MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_FINALLY)) &&
- cfg->param_area && cfg->arch.no_pushes) {
+ cfg->param_area) {
amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT));
}
break;
/* The param area is always at offset 0 from sp */
/* This needs to be allocated here, since it has to come after the spill area */
- if (cfg->arch.no_pushes && cfg->param_area) {
+ if (cfg->param_area) {
if (cfg->arch.omit_fp)
// FIXME:
g_assert_not_reached ();
mono_arch_is_breakpoint_event (void *info, void *sigctx)
{
#ifdef HOST_WIN32
- EXCEPTION_RECORD* einfo = (EXCEPTION_RECORD*)info;
- return FALSE;
+ EXCEPTION_RECORD* einfo = ((EXCEPTION_POINTERS*)info)->ExceptionRecord;
+ if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && (gpointer)einfo->ExceptionInformation [1] == bp_trigger_page)
+ return TRUE;
+ else
+ return FALSE;
#else
siginfo_t* sinfo = (siginfo_t*) info;
/* Sometimes the address is off by 4 */
mono_arch_is_single_step_event (void *info, void *sigctx)
{
#ifdef HOST_WIN32
- EXCEPTION_RECORD* einfo = (EXCEPTION_RECORD*)info;
- return FALSE;
+ EXCEPTION_RECORD* einfo = ((EXCEPTION_POINTERS*)info)->ExceptionRecord;
+ if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && (gpointer)einfo->ExceptionInformation [1] == ss_trigger_page)
+ return TRUE;
+ else
+ return FALSE;
#else
siginfo_t* sinfo = (siginfo_t*) info;
/* Sometimes the address is off by 4 */
#include <signal.h>
#endif
-
+#if !defined(_MSC_VER)
/* sigcontext surrogate */
struct sigcontext {
guint64 eax;
guint64 edi;
guint64 eip;
};
+#endif
typedef void (* MonoW32ExceptionHandler) (int _dummy, EXCEPTION_POINTERS *info, void *context);
void win32_seh_init(void);
gint32 stack_alloc_size;
gint32 sp_fp_offset;
guint32 saved_iregs;
- gboolean omit_fp, omit_fp_computed, no_pushes;
+ gboolean omit_fp, omit_fp_computed;
gpointer cinfo;
gint32 async_point_count;
gpointer vret_addr_loc;
#ifdef HOST_WIN32
#define MONO_AMD64_ARG_REG1 AMD64_RCX
#define MONO_AMD64_ARG_REG2 AMD64_RDX
+#define MONO_AMD64_ARG_REG3 AMD64_R8
#else
#define MONO_AMD64_ARG_REG1 AMD64_RDI
#define MONO_AMD64_ARG_REG2 AMD64_RSI
+#define MONO_AMD64_ARG_REG3 AMD64_RDX
#endif
#define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS
#define MONO_ARCH_HAVE_LIVERANGE_OPS 1
#define MONO_ARCH_HAVE_XP_UNWIND 1
#define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
-#if !defined(HOST_WIN32)
#define MONO_ARCH_MONITOR_OBJECT_REG MONO_AMD64_ARG_REG1
-#endif
#define MONO_ARCH_HAVE_GET_TRAMPOLINES 1
#define MONO_ARCH_AOT_SUPPORTED 1
-#if !defined( HOST_WIN32 ) && !defined( __native_client__ )
+#if !defined( __native_client__ )
#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
#endif
-#if !defined(HOST_WIN32) || defined(__sun)
#define MONO_ARCH_ENABLE_MONITOR_IL_FASTPATH 1
-#endif
#define MONO_ARCH_SUPPORT_TASKLETS 1
-#ifndef HOST_WIN32
-#define MONO_AMD64_NO_PUSHES 1
-#endif
-
#define MONO_ARCH_GSHARED_SUPPORTED 1
#define MONO_ARCH_DYN_CALL_SUPPORTED 1
#define MONO_ARCH_DYN_CALL_PARAM_AREA 0
index = LLVMConstInt (LLVMInt32Type (), ins->inst_offset / size, FALSE);
addr = LLVMBuildGEP (builder, convert (ctx, values [ins->inst_destbasereg], LLVMPointerType (t, 0)), &index, 1, "");
}
- emit_store (ctx, bb, &builder, size, convert (ctx, LLVMConstInt (IntPtrType (), ins->inst_imm, FALSE), t), addr, is_volatile);
+ emit_store (ctx, bb, &builder, size, convert (ctx, LLVMConstInt (IntPtrType (), ins->inst_imm, FALSE), t), convert (ctx, addr, LLVMPointerType (t, 0)), is_volatile);
break;
}
}
- jit_tls = pthread_getspecific (mono_get_jit_tls_key ());
+ jit_tls = mono_get_jit_tls ();
#ifdef MONO_SPARC_THR_TLS
thr_setspecific (lmf_addr_key, &jit_tls->lmf);
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-compiler.h>
#include "mini.h"
/*
* Either IMPL_METHOD or AOT_ADDR will be set on return.
- */
-static gpointer*
-#ifdef __GNUC__
-/*
+ *
+ * MONO_NEVER_INLINE :
* This works against problems when compiling with gcc 4.6 on arm. The 'then' part of
* this line gets executed, even when the condition is false:
* if (impl && mono_method_needs_static_rgctx_invoke (impl, FALSE))
* *need_rgctx_tramp = TRUE;
*/
-__attribute__ ((noinline))
-#endif
- mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
+static MONO_NEVER_INLINE gpointer*
+mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
{
MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code);
MonoVTable *vt = this_argument->vtable;
if (timeBeginPeriod (1) != TIMERR_NOERROR)
return;
- if ((win32_timer = timeSetEvent (1, 0, win32_time_proc, 0, TIME_PERIODIC)) == 0) {
+ if ((win32_timer = timeSetEvent (1, 0, (LPTIMECALLBACK)win32_time_proc, (DWORD_PTR)NULL, TIME_PERIODIC)) == 0) {
timeEndPeriod (1);
return;
}
gboolean
mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo *info)
{
- g_error ("Windows systems haven't been ported to support mono_thread_state_init_from_handle");
- return FALSE;
+ DWORD id = mono_thread_info_get_tid (info);
+ HANDLE handle;
+ CONTEXT context;
+ DWORD result;
+ MonoContext *ctx;
+ MonoJitTlsData *jit_tls;
+ void *domain;
+ MonoLMF *lmf = NULL;
+ gpointer *addr;
+
+ tctx->valid = FALSE;
+ tctx->unwind_data [MONO_UNWIND_DATA_DOMAIN] = NULL;
+ tctx->unwind_data [MONO_UNWIND_DATA_LMF] = NULL;
+ tctx->unwind_data [MONO_UNWIND_DATA_JIT_TLS] = NULL;
+
+ g_assert (id != GetCurrentThreadId ());
+
+ handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
+ g_assert (handle);
+
+ context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
+
+ if (!GetThreadContext (handle, &context)) {
+ CloseHandle (handle);
+ return FALSE;
+ }
+
+ g_assert (context.ContextFlags & CONTEXT_INTEGER);
+ g_assert (context.ContextFlags & CONTEXT_CONTROL);
+
+ ctx = &tctx->ctx;
+
+ memset (ctx, 0, sizeof (MonoContext));
+ mono_sigctx_to_monoctx (&context, ctx);
+
+ /* mono_set_jit_tls () sets this */
+ jit_tls = mono_thread_info_tls_get (info, TLS_KEY_JIT_TLS);
+ /* SET_APPDOMAIN () sets this */
+ domain = mono_thread_info_tls_get (info, TLS_KEY_DOMAIN);
+
+ /*Thread already started to cleanup, can no longer capture unwind state*/
+ if (!jit_tls || !domain)
+ return FALSE;
+
+ /*
+ * The current LMF address is kept in a separate TLS variable, and its hard to read its value without
+ * arch-specific code. But the address of the TLS variable is stored in another TLS variable which
+ * can be accessed through MonoThreadInfo.
+ */
+ /* mono_set_lmf_addr () sets this */
+ addr = mono_thread_info_tls_get (info, TLS_KEY_LMF_ADDR);
+ if (addr)
+ lmf = *addr;
+
+ tctx->unwind_data [MONO_UNWIND_DATA_DOMAIN] = domain;
+ tctx->unwind_data [MONO_UNWIND_DATA_JIT_TLS] = jit_tls;
+ tctx->unwind_data [MONO_UNWIND_DATA_LMF] = lmf;
+ tctx->valid = TRUE;
+
+ return TRUE;
}
#endif
#endif
-MonoNativeTlsKey
-mono_get_jit_tls_key (void)
-{
- return mono_jit_tls_id;
-}
-
gint32
mono_get_jit_tls_offset (void)
{
int offset;
+
+#ifdef HOST_WIN32
+ if (mono_jit_tls_id)
+ offset = mono_jit_tls_id;
+ else
+ /* FIXME: Happens during startup */
+ offset = -1;
+#else
MONO_THREAD_VAR_OFFSET (mono_jit_tls, offset);
+#endif
return offset;
}
offset = mono_thread_get_tls_offset ();
break;
case TLS_KEY_JIT_TLS:
-#ifdef HOST_WIN32
- offset = mono_get_jit_tls_key ();
-#else
offset = mono_get_jit_tls_offset ();
-#endif
break;
case TLS_KEY_DOMAIN:
offset = mono_domain_get_tls_offset ();
gboolean run_cctors = (flags & JIT_FLAG_RUN_CCTORS) ? 1 : 0;
gboolean compile_aot = (flags & JIT_FLAG_AOT) ? 1 : 0;
gboolean full_aot = (flags & JIT_FLAG_FULL_AOT) ? 1 : 0;
+ gboolean llvm = (flags & JIT_FLAG_LLVM) ? 1 : 0;
InterlockedIncrement (&mono_jit_stats.methods_compiled);
if (mono_profiler_get_events () & MONO_PROFILE_JIT_COMPILATION)
}
#ifdef ENABLE_LLVM
- try_llvm = mono_use_llvm;
+ try_llvm = mono_use_llvm || llvm;
#endif
restart_compile:
/* Whenever this is an AOT compilation */
JIT_FLAG_AOT = (1 << 1),
/* Whenever this is a full AOT compilation */
- JIT_FLAG_FULL_AOT = (1 << 2)
+ JIT_FLAG_FULL_AOT = (1 << 2),
+ /* Whenever to compile with LLVM */
+ JIT_FLAG_LLVM = (1 << 3),
} JitFlags;
/* Bit-fields in the MonoBasicBlock.region */
MonoJitTlsData* mono_get_jit_tls (void) MONO_INTERNAL;
MONO_API MonoDomain *mono_jit_thread_attach (MonoDomain *domain);
MONO_API void mono_jit_set_domain (MonoDomain *domain);
-MonoNativeTlsKey mono_get_jit_tls_key (void) MONO_INTERNAL;
gint32 mono_get_jit_tls_offset (void) MONO_INTERNAL;
gint32 mono_get_lmf_tls_offset (void) MONO_INTERNAL;
gint32 mono_get_lmf_addr_tls_offset (void) MONO_INTERNAL;
#ifndef GET_CONTEXT
#ifdef HOST_WIN32
+/* seh_vectored_exception_handler () passes in a CONTEXT* */
#define GET_CONTEXT \
void *ctx = context;
#else
amd64_mov_reg_imm (code, AMD64_R11, 0);
amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, 8);
} else {
- amd64_mov_reg_imm (code, AMD64_RDI, tramp_type);
+ amd64_mov_reg_imm (code, MONO_AMD64_ARG_REG1, tramp_type);
amd64_mov_reg_imm (code, AMD64_R11, stack_unaligned);
amd64_call_reg (code, AMD64_R11);
}
return buf;
}
-#ifdef MONO_ARCH_MONITOR_OBJECT_REG
-
gpointer
mono_arch_create_monitor_enter_trampoline (MonoTrampInfo **info, gboolean aot)
{
int owner_offset, nest_offset, dummy;
MonoJumpInfo *ji = NULL;
GSList *unwind_ops = NULL;
+ int obj_reg = MONO_AMD64_ARG_REG1;
+ int sync_reg = MONO_AMD64_ARG_REG2;
+ int tid_reg = MONO_AMD64_ARG_REG3;
- g_assert (MONO_ARCH_MONITOR_OBJECT_REG == AMD64_RDI);
+ g_assert (MONO_ARCH_MONITOR_OBJECT_REG == obj_reg);
mono_monitor_threads_sync_members_offset (&owner_offset, &nest_offset, &dummy);
g_assert (MONO_THREADS_SYNC_MEMBER_SIZE (owner_offset) == sizeof (gpointer));
unwind_ops = mono_arch_get_cie_program ();
if (!aot && mono_thread_get_tls_offset () != -1) {
- /* MonoObject* obj is in RDI */
+ /* MonoObject* obj is in obj_reg */
/* is obj null? */
- amd64_test_reg_reg (code, AMD64_RDI, AMD64_RDI);
+ amd64_test_reg_reg (code, obj_reg, obj_reg);
/* if yes, jump to actual trampoline */
jump_obj_null = code;
amd64_branch8 (code, X86_CC_Z, -1, 1);
- /* load obj->synchronization to RCX */
- amd64_mov_reg_membase (code, AMD64_RCX, AMD64_RDI, MONO_STRUCT_OFFSET (MonoObject, synchronisation), 8);
+ /* load obj->synchronization to sync_reg */
+ amd64_mov_reg_membase (code, sync_reg, obj_reg, MONO_STRUCT_OFFSET (MonoObject, synchronisation), 8);
if (mono_gc_is_moving ()) {
/*if bit zero is set it's a thin hash*/
/*FIXME use testb encoding*/
- amd64_test_reg_imm (code, AMD64_RCX, 0x01);
+ amd64_test_reg_imm (code, sync_reg, 0x01);
jump_sync_thin_hash = code;
amd64_branch8 (code, X86_CC_NE, -1, 1);
/*clear bits used by the gc*/
- amd64_alu_reg_imm (code, X86_AND, AMD64_RCX, ~0x3);
+ amd64_alu_reg_imm (code, X86_AND, sync_reg, ~0x3);
}
/* is synchronization null? */
- amd64_test_reg_reg (code, AMD64_RCX, AMD64_RCX);
+ amd64_test_reg_reg (code, sync_reg, sync_reg);
/* if yes, jump to actual trampoline */
jump_sync_null = code;
amd64_branch8 (code, X86_CC_Z, -1, 1);
- /* load MonoInternalThread* into RDX */
- code = mono_amd64_emit_tls_get (code, AMD64_RDX, mono_thread_get_tls_offset ());
- /* load TID into RDX */
- amd64_mov_reg_membase (code, AMD64_RDX, AMD64_RDX, MONO_STRUCT_OFFSET (MonoInternalThread, tid), 8);
+ /* load MonoInternalThread* into tid_reg */
+ code = mono_amd64_emit_tls_get (code, tid_reg, mono_thread_get_tls_offset ());
+ /* load TID into tid_reg */
+ amd64_mov_reg_membase (code, tid_reg, tid_reg, MONO_STRUCT_OFFSET (MonoInternalThread, tid), 8);
/* is synchronization->owner null? */
- amd64_alu_membase_imm_size (code, X86_CMP, AMD64_RCX, owner_offset, 0, 8);
+ amd64_alu_membase_imm_size (code, X86_CMP, sync_reg, owner_offset, 0, 8);
/* if not, jump to next case */
jump_tid = code;
amd64_branch8 (code, X86_CC_NZ, -1, 1);
/* if yes, try a compare-exchange with the TID */
+ g_assert (tid_reg != X86_EAX);
/* zero RAX */
amd64_alu_reg_reg (code, X86_XOR, AMD64_RAX, AMD64_RAX);
/* compare and exchange */
amd64_prefix (code, X86_LOCK_PREFIX);
- amd64_cmpxchg_membase_reg_size (code, AMD64_RCX, owner_offset, AMD64_RDX, 8);
+ amd64_cmpxchg_membase_reg_size (code, sync_reg, owner_offset, tid_reg, 8);
/* if not successful, jump to actual trampoline */
jump_cmpxchg_failed = code;
amd64_branch8 (code, X86_CC_NZ, -1, 1);
/* next case: synchronization->owner is not null */
x86_patch (jump_tid, code);
/* is synchronization->owner == TID? */
- amd64_alu_membase_reg_size (code, X86_CMP, AMD64_RCX, owner_offset, AMD64_RDX, 8);
+ amd64_alu_membase_reg_size (code, X86_CMP, sync_reg, owner_offset, tid_reg, 8);
/* if not, jump to actual trampoline */
jump_other_owner = code;
amd64_branch8 (code, X86_CC_NZ, -1, 1);
/* if yes, increment nest */
- amd64_inc_membase_size (code, AMD64_RCX, nest_offset, 4);
+ amd64_inc_membase_size (code, sync_reg, nest_offset, 4);
/* return */
amd64_ret (code);
}
/* jump to the actual trampoline */
-#if MONO_AMD64_ARG_REG1 != AMD64_RDI
- amd64_mov_reg_reg (code, MONO_AMD64_ARG_REG1, AMD64_RDI);
-#endif
+ if (MONO_AMD64_ARG_REG1 != obj_reg)
+ amd64_mov_reg_reg (code, MONO_AMD64_ARG_REG1, obj_reg, sizeof (mgreg_t));
if (aot) {
code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_enter");
int owner_offset, nest_offset, entry_count_offset;
MonoJumpInfo *ji = NULL;
GSList *unwind_ops = NULL;
+ int obj_reg = MONO_AMD64_ARG_REG1;
+ int sync_reg = MONO_AMD64_ARG_REG2;
- g_assert (MONO_ARCH_MONITOR_OBJECT_REG == AMD64_RDI);
+ g_assert (obj_reg == MONO_ARCH_MONITOR_OBJECT_REG);
mono_monitor_threads_sync_members_offset (&owner_offset, &nest_offset, &entry_count_offset);
g_assert (MONO_THREADS_SYNC_MEMBER_SIZE (owner_offset) == sizeof (gpointer));
unwind_ops = mono_arch_get_cie_program ();
if (!aot && mono_thread_get_tls_offset () != -1) {
- /* MonoObject* obj is in RDI */
+ /* MonoObject* obj is in obj_reg */
/* is obj null? */
- amd64_test_reg_reg (code, AMD64_RDI, AMD64_RDI);
+ amd64_test_reg_reg (code, obj_reg, obj_reg);
/* if yes, jump to actual trampoline */
jump_obj_null = code;
amd64_branch8 (code, X86_CC_Z, -1, 1);
/* load obj->synchronization to RCX */
- amd64_mov_reg_membase (code, AMD64_RCX, AMD64_RDI, MONO_STRUCT_OFFSET (MonoObject, synchronisation), 8);
+ amd64_mov_reg_membase (code, sync_reg, obj_reg, MONO_STRUCT_OFFSET (MonoObject, synchronisation), 8);
if (mono_gc_is_moving ()) {
/*if bit zero is set it's a thin hash*/
/*FIXME use testb encoding*/
- amd64_test_reg_imm (code, AMD64_RCX, 0x01);
+ amd64_test_reg_imm (code, sync_reg, 0x01);
jump_sync_thin_hash = code;
amd64_branch8 (code, X86_CC_NE, -1, 1);
/*clear bits used by the gc*/
- amd64_alu_reg_imm (code, X86_AND, AMD64_RCX, ~0x3);
+ amd64_alu_reg_imm (code, X86_AND, sync_reg, ~0x3);
}
/* is synchronization null? */
- amd64_test_reg_reg (code, AMD64_RCX, AMD64_RCX);
+ amd64_test_reg_reg (code, sync_reg, sync_reg);
/* if yes, jump to actual trampoline */
jump_sync_null = code;
amd64_branch8 (code, X86_CC_Z, -1, 1);
/* next case: synchronization is not null */
- /* load MonoInternalThread* into RDX */
- code = mono_amd64_emit_tls_get (code, AMD64_RDX, mono_thread_get_tls_offset ());
- /* load TID into RDX */
- amd64_mov_reg_membase (code, AMD64_RDX, AMD64_RDX, MONO_STRUCT_OFFSET (MonoInternalThread, tid), 8);
+ /* load MonoInternalThread* into RAX */
+ code = mono_amd64_emit_tls_get (code, AMD64_RAX, mono_thread_get_tls_offset ());
+ /* load TID into RAX */
+ amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RAX, MONO_STRUCT_OFFSET (MonoInternalThread, tid), 8);
/* is synchronization->owner == TID */
- amd64_alu_membase_reg_size (code, X86_CMP, AMD64_RCX, owner_offset, AMD64_RDX, 8);
+ amd64_alu_membase_reg_size (code, X86_CMP, sync_reg, owner_offset, AMD64_RAX, 8);
/* if no, jump to actual trampoline */
jump_not_owned = code;
amd64_branch8 (code, X86_CC_NZ, -1, 1);
/* next case: synchronization->owner == TID */
/* is synchronization->nest == 1 */
- amd64_alu_membase_imm_size (code, X86_CMP, AMD64_RCX, nest_offset, 1, 4);
+ amd64_alu_membase_imm_size (code, X86_CMP, sync_reg, nest_offset, 1, 4);
/* if not, jump to next case */
jump_next = code;
amd64_branch8 (code, X86_CC_NZ, -1, 1);
/* if yes, is synchronization->entry_count zero? */
- amd64_alu_membase_imm_size (code, X86_CMP, AMD64_RCX, entry_count_offset, 0, 4);
+ amd64_alu_membase_imm_size (code, X86_CMP, sync_reg, entry_count_offset, 0, 4);
/* if not, jump to actual trampoline */
jump_have_waiters = code;
amd64_branch8 (code, X86_CC_NZ, -1 , 1);
/* if yes, set synchronization->owner to null and return */
- amd64_mov_membase_imm (code, AMD64_RCX, owner_offset, 0, 8);
+ amd64_mov_membase_imm (code, sync_reg, owner_offset, 0, 8);
amd64_ret (code);
/* next case: synchronization->nest is not 1 */
x86_patch (jump_next, code);
/* decrease synchronization->nest and return */
- amd64_dec_membase_size (code, AMD64_RCX, nest_offset, 4);
+ amd64_dec_membase_size (code, sync_reg, nest_offset, 4);
amd64_ret (code);
x86_patch (jump_obj_null, code);
}
/* jump to the actual trampoline */
-#if MONO_AMD64_ARG_REG1 != AMD64_RDI
- amd64_mov_reg_reg (code, MONO_AMD64_ARG_REG1, AMD64_RDI);
-#endif
+ if (MONO_AMD64_ARG_REG1 != obj_reg)
+ amd64_mov_reg_reg (code, MONO_AMD64_ARG_REG1, obj_reg, sizeof (mgreg_t));
if (aot) {
code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_exit");
return buf;
}
-#endif
void
mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
/*
This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
*/
-
if (mono_get_jit_tls_offset () != -1) {
- code = mono_amd64_emit_tls_get (code, AMD64_RDI, mono_get_jit_tls_offset ());
- amd64_mov_reg_membase (code, AMD64_RDI, AMD64_RDI, MONO_STRUCT_OFFSET (MonoJitTlsData, handler_block_return_address), 8);
+ code = mono_amd64_emit_tls_get (code, MONO_AMD64_ARG_REG1, mono_get_jit_tls_offset ());
+ amd64_mov_reg_membase (code, MONO_AMD64_ARG_REG1, MONO_AMD64_ARG_REG1, MONO_STRUCT_OFFSET (MonoJitTlsData, handler_block_return_address), 8);
/* Simulate a call */
amd64_push_reg (code, AMD64_RAX);
amd64_jump_code (code, tramp);
} else {
/*Slow path uses a c helper*/
- amd64_mov_reg_reg (code, AMD64_RDI, AMD64_RSP, 8);
+ amd64_mov_reg_reg (code, MONO_AMD64_ARG_REG1, AMD64_RSP, 8);
amd64_mov_reg_imm (code, AMD64_RAX, tramp);
amd64_push_reg (code, AMD64_RAX);
+ amd64_push_reg (code, AMD64_RAX);
amd64_jump_code (code, handler_block_trampoline_helper);
}
#include "image-writer.h"
#include "dwarfwriter.h"
+#include "mono/utils/mono-compiler.h"
+
#define USE_GDB_JIT_INTERFACE
/* The recommended gdb macro is: */
struct jit_code_entry *first_entry;
};
-
-#ifdef _MSC_VER
-#define MONO_NOINLINE __declspec (noinline)
-#else
-#define MONO_NOINLINE __attribute__((noinline))
-#endif
-
/* GDB puts a breakpoint in this function. */
-void MONO_NOINLINE __jit_debug_register_code(void);
+void MONO_NEVER_INLINE __jit_debug_register_code(void);
#if !defined(MONO_LLVM_LOADED) && defined(ENABLE_LLVM) && !defined(MONO_CROSS_COMPILE)
#else
/* gcc seems to inline/eliminate calls to noinline functions, thus the asm () */
-void MONO_NOINLINE __jit_debug_register_code(void) {
+void MONO_NEVER_INLINE __jit_debug_register_code(void) {
#if defined(__GNUC__)
asm ("");
#endif
#include <linux/ioctl.h>
#include <asm/byteorder.h>
+#include "mono/utils/mono-compiler.h"
+
/*
* User-space ABI bits:
*/
perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
}
-static __always_inline void
+static MONO_ALWAYS_INLINE void
perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
{
struct pt_regs hot_regs;
* event, hence the collect_bt/emit_bt split.
*/
static void
-collect_bt (FrameData *data)
+collect_bt (FrameData *data, gboolean async_safe)
{
data->count = 0;
- mono_stack_walk_no_il (walk_stack, data);
+ if (async_safe)
+ mono_stack_walk_async_safe (walk_stack, data);
+ else
+ mono_stack_walk_no_il (walk_stack, data);
}
static void
len += 7;
len &= ~7;
if (do_bt)
- collect_bt (&data);
+ collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (32 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "gcalloc");
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
- collect_bt (&data);
+ collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "throw");
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
- collect_bt (&data);
+ collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "monitor");
if (in_shutdown)
return;
now = current_time ();
- collect_bt (&bt_data);
+ collect_bt (&bt_data, TRUE);
elapsed = (now - profiler->startup_time) / 10000;
if (do_debug) {
int len;
monitor-stress.cs \
thread-stress.cs \
gc-stress.cs \
+ gc-copy-stress.cs \
gc-graystack-stress.cs \
exit-stress.cs \
process-stress.cs \
if X86
if HOST_WIN32
-PLATFORM_DISABLED_TESTS=async-exc-compilation.exe finally_guard.exe finally_block_ending_in_dead_bb.exe
+PLATFORM_DISABLED_TESTS=async-exc-compilation.exe finally_guard.exe finally_block_ending_in_dead_bb.exe \
+ bug-18026.exe monitor.exe threadpool-exceptions5.exe
endif
endif
--- /dev/null
+using System;
+
+class T {
+
+ static int count = 1000000;
+ static int loops = 20;
+ static int persist_factor = 10;
+
+ static object obj;
+
+ static object[] persist;
+ static int persist_idx;
+
+ static void work () {
+ persist = new object[count / persist_factor + 1];
+ persist_idx = 0;
+ for (int i = 0; i < count; ++i) {
+ obj = new object ();
+ if (i % persist_factor == 0)
+ persist[persist_idx++] = obj;
+ }
+ }
+
+ static void Main (string[] args) {
+ if (args.Length > 0)
+ loops = int.Parse (args [0]);
+ if (args.Length > 1)
+ count = int.Parse (args [1]);
+ if (args.Length > 2)
+ persist_factor = int.Parse (args [2]);
+ for (int i = 0; i < loops; ++i) {
+ work ();
+ }
+ }
+}
'arg-knob' => 2, # loops
'ratio' => 10,
},
+ 'gc-copy-stress' => {
+ 'program' => 'gc-copy-stress.exe',
+ # loops, count, persist_factor
+ 'args' => [250, 500000, 10],
+ 'arg-knob' => 1, # count
+ 'ratio' => 4,
+ },
'thread-stress' => {
'program' => 'thread-stress.exe',
# loops
#define MONO_ALWAYS_INLINE
#endif
+#ifdef __GNUC__
+#define MONO_NEVER_INLINE __attribute__((noinline))
+#elif defined(_MSC_VER)
+#define MONO_NEVER_INLINE __declspec(noinline)
+#else
+#define MONO_NEVER_INLINE
+#endif
+
#endif /* __UTILS_MONO_COMPILER_H__*/
#include <mono/utils/mono-context.h>
+#ifdef HOST_WIN32
+#include <windows.h>
+#endif
+
#ifdef __sun
#define REG_EAX EAX
#define REG_EBX EBX
mctx->esi = UCONTEXT_REG_ESI (ctx);
mctx->edi = UCONTEXT_REG_EDI (ctx);
mctx->eip = UCONTEXT_REG_EIP (ctx);
+#elif defined(HOST_WIN32)
+ CONTEXT *context = (CONTEXT*)sigctx;
+
+ mctx->eip = context->Eip;
+ mctx->edi = context->Edi;
+ mctx->esi = context->Esi;
+ mctx->ebx = context->Ebx;
+ mctx->edx = context->Edx;
+ mctx->ecx = context->Ecx;
+ mctx->eax = context->Eax;
+ mctx->ebp = context->Ebp;
+ mctx->esp = context->Esp;
#else
struct sigcontext *ctx = (struct sigcontext *)sigctx;
UCONTEXT_REG_ESI (ctx) = mctx->esi;
UCONTEXT_REG_EDI (ctx) = mctx->edi;
UCONTEXT_REG_EIP (ctx) = mctx->eip;
+#elif defined(HOST_WIN32)
+ CONTEXT *context = (CONTEXT*)sigctx;
+
+ context->Eip = mctx->eip;
+ context->Edi = mctx->edi;
+ context->Esi = mctx->esi;
+ context->Ebx = mctx->ebx;
+ context->Edx = mctx->edx;
+ context->Ecx = mctx->ecx;
+ context->Eax = mctx->eax;
+ context->Ebp = mctx->ebp;
+ context->Esp = mctx->esp;
#else
struct sigcontext *ctx = (struct sigcontext *)sigctx;
#include <mono/utils/mono-context.h>
+#ifdef HOST_WIN32
+#include <windows.h>
+#endif
+
void
mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
{
mctx->r14 = UCONTEXT_REG_R14 (ctx);
mctx->r15 = UCONTEXT_REG_R15 (ctx);
mctx->rip = UCONTEXT_REG_RIP (ctx);
+#elif defined(HOST_WIN32)
+ CONTEXT *context = (CONTEXT*)sigctx;
+
+ mctx->rip = context->Rip;
+ mctx->rax = context->Rax;
+ mctx->rcx = context->Rcx;
+ mctx->rdx = context->Rdx;
+ mctx->rbx = context->Rbx;
+ mctx->rsp = context->Rsp;
+ mctx->rbp = context->Rbp;
+ mctx->rsi = context->Rsi;
+ mctx->rdi = context->Rdi;
+ mctx->r8 = context->R8;
+ mctx->r9 = context->R9;
+ mctx->r10 = context->R10;
+ mctx->r11 = context->R11;
+ mctx->r12 = context->R12;
+ mctx->r13 = context->R13;
+ mctx->r14 = context->R14;
+ mctx->r15 = context->R15;
#else
MonoContext *ctx = (MonoContext *)sigctx;
UCONTEXT_REG_R14 (ctx) = mctx->r14;
UCONTEXT_REG_R15 (ctx) = mctx->r15;
UCONTEXT_REG_RIP (ctx) = mctx->rip;
+#elif defined(HOST_WIN32)
+ CONTEXT *context = (CONTEXT*)sigctx;
+
+ context->Rip = mctx->rip;
+ context->Rax = mctx->rax;
+ context->Rcx = mctx->rcx;
+ context->Rdx = mctx->rdx;
+ context->Rbx = mctx->rbx;
+ context->Rsp = mctx->rsp;
+ context->Rbp = mctx->rbp;
+ context->Rsi = mctx->rsi;
+ context->Rdi = mctx->rdi;
+ context->R8 = mctx->r8;
+ context->R9 = mctx->r9;
+ context->R10 = mctx->r10;
+ context->R11 = mctx->r11;
+ context->R12 = mctx->r12;
+ context->R13 = mctx->r13;
+ context->R14 = mctx->r14;
+ context->R15 = mctx->r15;
#else
MonoContext *ctx = (MonoContext *)sigctx;
: "rdx", "memory")
#endif
-#if !defined(HOST_WIN32)
#define MONO_ARCH_HAS_MONO_CONTEXT 1
-#endif
#elif (defined(__arm__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM)) /* defined(__x86_64__) */
ctx.pc = ctx.regs [15]; \
} while (0)
+#define MONO_ARCH_HAS_MONO_CONTEXT 1
+
#elif (defined(__aarch64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM64))
#include <mono/arch/arm64/arm64-codegen.h>
#endif
+/*
+ * The naming is misleading, the SIGCTX argument should be the platform's context
+ * structure (ucontext_c on posix, CONTEXT on windows).
+ */
void mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) MONO_INTERNAL;
+
+/*
+ * This will not completely initialize SIGCTX since MonoContext contains less
+ * information that the system context. The caller should obtain a SIGCTX from
+ * the system, and use this function to override the parts of it which are
+ * also in MonoContext.
+ */
void mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx) MONO_INTERNAL;
#endif /* __MONO_MONO_CONTEXT_H__ */
wchar_t* buf = NULL;
DWORD code = GetLastError ();
- if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, 0, NULL))
{
ret = g_utf16_to_utf8 (buf, wcslen(buf), NULL, NULL, NULL);
return handle;
}
+gpointer
+mono_threads_core_prepare_interrupt (HANDLE thread_handle)
+{
+ return wapi_prepare_interrupt_thread (thread_handle);
+}
+
+void
+mono_threads_core_finish_interrupt (gpointer wait_handle)
+{
+ wapi_finish_interrupt_thread (wait_handle);
+}
+
+void
+mono_threads_core_self_interrupt (void)
+{
+ wapi_self_interrupt ();
+}
+
+void
+mono_threads_core_clear_interruption (void)
+{
+ wapi_clear_interruption ();
+}
+
#if !defined (__MACH__)
#if !defined(__native_client__)
#if defined(HOST_WIN32)
#include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-compiler.h>
#include <limits.h>
{
}
+static void CALLBACK
+interrupt_apc (ULONG_PTR param)
+{
+}
+
void
mono_threads_core_interrupt (MonoThreadInfo *info)
{
- g_assert (0);
+ DWORD id = mono_thread_info_get_tid (info);
+ HANDLE handle;
+
+ handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
+ g_assert (handle);
+
+ QueueUserAPC ((PAPCFUNC)interrupt_apc, handle, (ULONG_PTR)NULL);
+
+ CloseHandle (handle);
}
void
gboolean
mono_threads_core_suspend (MonoThreadInfo *info)
{
- g_assert_not_reached ();
+ DWORD id = mono_thread_info_get_tid (info);
+ HANDLE handle;
+ DWORD result;
+ gboolean res;
+
+ g_assert (id != GetCurrentThreadId ());
+
+ handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
+ g_assert (handle);
+
+ result = SuspendThread (handle);
+ if (result == (DWORD)-1) {
+ fprintf (stderr, "could not suspend thread %x (handle %p): %d\n", id, handle, GetLastError ()); fflush (stderr);
+ CloseHandle (handle);
+ return FALSE;
+ }
+
+ CloseHandle (handle);
+
+ res = mono_threads_get_runtime_callbacks ()->thread_state_init_from_handle (&info->suspend_state, info);
+ g_assert (res);
+
+ return TRUE;
}
gboolean
mono_threads_core_resume (MonoThreadInfo *info)
{
- g_assert_not_reached ();
+ DWORD id = mono_thread_info_get_tid (info);
+ HANDLE handle;
+ DWORD result;
+
+ handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
+ g_assert (handle);
+
+ if (info->async_target) {
+ MonoContext ctx;
+ CONTEXT context;
+ gboolean res;
+
+ ctx = info->suspend_state.ctx;
+ mono_threads_get_runtime_callbacks ()->setup_async_callback (&ctx, info->async_target, info->user_data);
+ info->async_target = info->user_data = NULL;
+
+ context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
+
+ if (!GetThreadContext (handle, &context)) {
+ CloseHandle (handle);
+ return FALSE;
+ }
+
+ g_assert (context.ContextFlags & CONTEXT_INTEGER);
+ g_assert (context.ContextFlags & CONTEXT_CONTROL);
+
+ mono_monoctx_to_sigctx (&ctx, &context);
+
+ context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
+ res = SetThreadContext (handle, &context);
+ g_assert (res);
+ }
+
+ result = ResumeThread (handle);
+ g_assert (result != (DWORD)-1);
+
+ CloseHandle (handle);
+
+ return result != (DWORD)-1;
}
void
}
#if HAVE_DECL___READFSDWORD==0
-static __inline__ __attribute__((always_inline))
-unsigned long long
+static MONO_ALWAYS_INLINE unsigned long long
__readfsdword (unsigned long offset)
{
unsigned long value;
return OpenThread (THREAD_ALL_ACCESS, TRUE, tid);
}
+#if !defined(__GNUC__)
+const DWORD MS_VC_EXCEPTION=0x406D1388;
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+#endif
+
void
mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
{
+#if !defined(__GNUC__)
+ /* http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx */
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = name;
+ info.dwThreadID = tid;
+ info.dwFlags = 0;
+
+ __try {
+ RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER) {
+ }
+#endif
+}
+
+
+gpointer
+mono_threads_core_prepare_interrupt (HANDLE thread_handle)
+{
+ return NULL;
+}
+
+void
+mono_threads_core_finish_interrupt (gpointer wait_handle)
+{
+}
+
+void
+mono_threads_core_self_interrupt (void)
+{
+}
+
+void
+mono_threads_core_clear_interruption (void)
+{
}
#endif
#if defined (HAVE_BOEHM_GC) && !defined (USE_INCLUDED_LIBGC)
return FALSE;
#endif
- /*port not done*/
#if defined(HOST_WIN32)
- return FALSE;
+ return !disable_new_interrupt;
#endif
#if defined (__i386__)
return !disable_new_interrupt;
+#endif
+#if defined(__arm__) && !defined(__APPLE__)
+ return !disable_new_interrupt;
#endif
return FALSE;
}
}
/*
- * mono_thread_info_open_handle:
+ * mono_threads_open_thread_handle:
*
* Return a io-layer/win32 handle for the thread identified by HANDLE/TID.
* The handle need to be closed by calling CloseHandle () when it is no
{
mono_threads_core_set_name (tid, name);
}
+
+/*
+ * mono_thread_info_prepare_interrupt:
+ *
+ * See wapi_prepare_interrupt ().
+ */
+gpointer
+mono_thread_info_prepare_interrupt (HANDLE thread_handle)
+{
+ return mono_threads_core_prepare_interrupt (thread_handle);
+}
+
+void
+mono_thread_info_finish_interrupt (gpointer wait_handle)
+{
+ mono_threads_core_finish_interrupt (wait_handle);
+}
+
+void
+mono_thread_info_interrupt (HANDLE thread_handle)
+{
+ gpointer wait_handle;
+
+ wait_handle = mono_thread_info_prepare_interrupt (thread_handle);
+ mono_thread_info_finish_interrupt (wait_handle);
+}
+
+void
+mono_thread_info_self_interrupt (void)
+{
+ mono_threads_core_self_interrupt ();
+}
+
+void
+mono_thread_info_clear_interruption (void)
+{
+ mono_threads_core_clear_interruption ();
+}
HANDLE
mono_thread_info_open_handle (void);
+gpointer
+mono_thread_info_prepare_interrupt (HANDLE thread_handle);
+
+void
+mono_thread_info_finish_interrupt (gpointer wait_handle);
+
+void
+mono_thread_info_interrupt (HANDLE thread_handle);
+
+void
+mono_thread_info_self_interrupt (void);
+
+void
+mono_thread_info_clear_interruption (void);
+
HANDLE
mono_threads_create_thread (LPTHREAD_START_ROUTINE start, gpointer arg, guint32 stack_size, guint32 creation_flags, MonoNativeThreadId *out_tid);
HANDLE mono_threads_core_open_handle (void) MONO_INTERNAL;
HANDLE mono_threads_core_open_thread_handle (HANDLE handle, MonoNativeThreadId tid) MONO_INTERNAL;
void mono_threads_core_set_name (MonoNativeThreadId tid, const char *name) MONO_INTERNAL;
+gpointer mono_threads_core_prepare_interrupt (HANDLE thread_handle);
+void mono_threads_core_finish_interrupt (gpointer wait_handle);
+void mono_threads_core_self_interrupt (void);
+void mono_threads_core_clear_interruption (void);
MonoNativeThreadId mono_native_thread_id_get (void) MONO_INTERNAL;
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>__default_codegen__;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;GC_NOT_DLL;WIN32_THREADS;WINVER=0x0500;_WIN32_WINNT=0x0500;_WIN32_IE=0x0501;_UNICODE;UNICODE;WIN32_THREADS;FD_SETSIZE=1024;$(PreprocessorDefinitions);_WINSOCKAPI_</PreprocessorDefinitions>
+ <DisableSpecificWarnings>4273;4005</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>Mswsock.lib;ws2_32.lib;ole32.lib;oleaut32.lib;psapi.lib;version.lib;advapi32.lib;winmm.lib;kernel32.lib;$(AdditionalDependencies)</AdditionalDependencies>
prj2make$(SCRIPT_SUFFIX) \
soapsuds$(SCRIPT_SUFFIX) \
caspol$(SCRIPT_SUFFIX) \
+ cert-sync$(SCRIPT_SUFFIX) \
cert2spc$(SCRIPT_SUFFIX) \
certmgr$(SCRIPT_SUFFIX) \
chktrust$(SCRIPT_SUFFIX) \
// Apply global rule first <alias source="locale" path="../dayPeriodWidth[@type='wide']"/>
el = node.SelectSingleNode ("dayPeriods/dayPeriodContext/dayPeriodWidth[@type='wide']/dayPeriod[@type='am']");
+ // Manual edits for exact .net compatiblity
switch (ci.Name) {
case "en-AU":
df.AMDesignator = "AM";
break;
+ case "en-NZ":
+ df.AMDesignator = "a.m.";
+ break;
default:
if (el != null)
df.AMDesignator = el.InnerText;
case "en-AU":
df.PMDesignator = "PM";
break;
+ case "en-NZ":
+ df.PMDesignator = "p.m.";
+ break;
default:
if (el != null)
df.PMDesignator = el.InnerText;