From db4299a19202b33011e8a3e88ae373eed1726ebd Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Tue, 14 Dec 2010 14:30:38 -0200 Subject: [PATCH 01/93] Fix marshaling of chars on structs. * marshal.c (emit_struct_conv): Take the native type of the field to decide what kind of conv to use if field is of type char. * marshal.c (mono_pinvoke_is_unicode): Unify auto and default. * marshal.c (emit_struct_conv_full): Kill this variant that doesn't make any sense as structures are marshaled in the same way regardless of the charset of the method. * metadata.c (mono_type_to_unmanaged): Handle marshalspec for char. Fixes the regression on MD caused by 1f3cfba. --- mono/metadata/marshal.c | 17 +++++------------ mono/metadata/metadata.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 849e475b16f3..356af5b4af58 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -1756,7 +1756,7 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv } static void -emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object, gboolean unicode) +emit_struct_conv (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object) { MonoMarshalType *info; int i; @@ -1859,7 +1859,7 @@ emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_obje case MONO_TYPE_R8: mono_mb_emit_ldloc (mb, 1); mono_mb_emit_ldloc (mb, 0); - if (ftype->type == MONO_TYPE_CHAR && !unicode) { + if (ntype == MONO_NATIVE_U1) { if (to_object) { mono_mb_emit_byte (mb, CEE_LDIND_U1); mono_mb_emit_byte (mb, CEE_STIND_I2); @@ -1975,12 +1975,6 @@ emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_obje } } -static void -emit_struct_conv (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object) -{ - emit_struct_conv_full (mb, klass, to_object, TRUE); -} - static void emit_struct_free (MonoMethodBuilder *mb, MonoClass *klass, int struct_var) { @@ -6940,13 +6934,12 @@ mono_pinvoke_is_unicode (MonoMethodPInvoke *piinfo) case PINVOKE_ATTRIBUTE_CHAR_SET_UNICODE: return TRUE; case PINVOKE_ATTRIBUTE_CHAR_SET_AUTO: + default: #ifdef TARGET_WIN32 return TRUE; #else return FALSE; #endif - default: - return FALSE; } } @@ -7074,7 +7067,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t, mono_mb_emit_stloc (mb, 1); /* emit valuetype conversion code */ - emit_struct_conv_full (mb, eklass, FALSE, mono_pinvoke_is_unicode (m->piinfo)); + emit_struct_conv (mb, eklass, FALSE); } mono_mb_emit_add_to_local (mb, index_var, 1); @@ -7192,7 +7185,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t, mono_mb_emit_stloc (mb, 1); /* emit valuetype conversion code */ - emit_struct_conv_full (mb, eklass, TRUE, mono_pinvoke_is_unicode (m->piinfo)); + emit_struct_conv (mb, eklass, TRUE); } if (need_free) { diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 8dfcd793e659..2e4dcd87d069 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -5413,7 +5413,17 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel } *conv = MONO_MARSHAL_CONV_BOOL_I4; return MONO_NATIVE_BOOLEAN; - case MONO_TYPE_CHAR: return unicode ? MONO_NATIVE_U2 : MONO_NATIVE_U1; + case MONO_TYPE_CHAR: + if (mspec) { + switch (mspec->native) { + case MONO_NATIVE_U2: + case MONO_NATIVE_U1: + return mspec->native; + default: + g_error ("cant marshal char to native type %02x", mspec->native); + } + } + return unicode ? MONO_NATIVE_U2 : MONO_NATIVE_U1; case MONO_TYPE_I1: return MONO_NATIVE_I1; case MONO_TYPE_U1: return MONO_NATIVE_U1; case MONO_TYPE_I2: return MONO_NATIVE_I2; From e400d3bc2325d693271d0ed2ad1252e08d9b0a6d Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Tue, 14 Dec 2010 14:34:26 -0200 Subject: [PATCH 02/93] Add one more test for marshaling of char arrays --- mono/tests/libtest.c | 21 +++++++++++++++++++++ mono/tests/pinvoke2.cs | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c index e51992917979..79a0b51c7115 100644 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@ -352,6 +352,27 @@ mono_test_marshal_ansi_char_array (char *s) return 0; } +LIBTEST_API int STDCALL +mono_test_marshal_unicode_char_array (gunichar2 *s) +{ + const char m[] = "abcdef"; + const char expected[] = "qwer"; + gunichar2 *s1, *s2; + glong len1, len2; + + s1 = g_utf8_to_utf16 (m, -1, NULL, &len1, NULL); + s2 = g_utf8_to_utf16 (expected, -1, NULL, &len2, NULL); + len1 = (len1 * 2); + len2 = (len2 * 2); + + if (memcmp (s, s2, len2)) + return 1; + + memcpy (s, s1, len1); + return 0; +} + + LIBTEST_API int STDCALL mono_test_empty_pinvoke (int i) { diff --git a/mono/tests/pinvoke2.cs b/mono/tests/pinvoke2.cs index e926f6bc6ad7..4c19f359f30d 100644 --- a/mono/tests/pinvoke2.cs +++ b/mono/tests/pinvoke2.cs @@ -1619,5 +1619,25 @@ public static int test_0_marshal_ansi_char_array () { return 2; } + /*char array marshaling */ + [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_char_array", CharSet=CharSet.Unicode)] + public static extern int mono_test_marshal_unicode_char_array (char[] a1); + + public static int test_0_marshal_unicode_char_array () { + char[] buf = new char [32]; + buf [0] = 'q'; + buf [1] = 'w'; + buf [2] = 'e'; + buf [3] = 'r'; + + if (mono_test_marshal_unicode_char_array (buf) != 0) + return 1; + + string s = new string (buf); + if (s.StartsWith ("abcdef")) + return 0; + else + return 2; + } } From 002317f5d4e3fcf9bc8684a6e2d5ee64a96bff3c Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Tue, 14 Dec 2010 18:37:14 -0200 Subject: [PATCH 03/93] Release per-appdomain binding information. * appdomain.c (unload_thread_main): Call function bindings cleanup. * assembly.c (mono_assembly_apply_binding): Dupe the content of per-domain bindings. Assign a domain_id on such entries to be possible to track them later. * assembly.c (mono_assembly_cleanup_domain_bindings): New function that removes per-domain bindings on unload. * metadata-internals.h (MonoAssemblyBindingInfo): Add domain_id field so it's possible to track if an entry is appdomain bound. --- mono/metadata/appdomain.c | 3 +++ mono/metadata/assembly.c | 31 +++++++++++++++++++++++++++++- mono/metadata/domain-internals.h | 2 ++ mono/metadata/metadata-internals.h | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 244cf85f2856..ab1fc103a1a9 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2292,6 +2292,9 @@ unload_thread_main (void *arg) for (i = 0; i < domain->class_vtable_array->len; ++i) clear_cached_vtable (g_ptr_array_index (domain->class_vtable_array, i)); deregister_reflection_info_roots (domain); + + mono_assembly_cleanup_domain_bindings (domain->domain_id); + mono_domain_unlock (domain); mono_loader_unlock (); diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 08782df6951d..9474f0d0f1b2 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -2445,7 +2445,15 @@ mono_assembly_apply_binding (MonoAssemblyName *aname, MonoAssemblyName *dest_nam mono_loader_lock (); mono_domain_lock (domain); - info = get_per_domain_assembly_binding_info (domain, aname); + info2 = get_per_domain_assembly_binding_info (domain, aname); + + if (info2) { + info = g_memdup (info2, sizeof (MonoAssemblyBindingInfo)); + info->name = g_strdup (info2->name); + info->culture = g_strdup (info2->culture); + info->domain_id = domain->domain_id; + } + mono_domain_unlock (domain); mono_loader_unlock (); } @@ -2897,6 +2905,27 @@ mono_assemblies_cleanup (void) free_assembly_preload_hooks (); } +/*LOCKING assumes loader lock is held*/ +void +mono_assembly_cleanup_domain_bindings (guint32 domain_id) +{ + GSList **iter = &loaded_assembly_bindings; + + while (*iter) { + GSList *l = *iter; + MonoAssemblyBindingInfo *info = l->data; + + if (info->domain_id == domain_id) { + *iter = l->next; + mono_assembly_binding_info_free (info); + g_free (info); + g_slist_free_1 (l); + } else { + iter = &l->next; + } + } +} + /* * Holds the assembly of the application, for * System.Diagnostics.Process::MainModule diff --git a/mono/metadata/domain-internals.h b/mono/metadata/domain-internals.h index 4867b72c052f..bca936805be2 100644 --- a/mono/metadata/domain-internals.h +++ b/mono/metadata/domain-internals.h @@ -566,4 +566,6 @@ int mono_framework_version (void) MONO_INTERNAL; void mono_reflection_cleanup_domain (MonoDomain *domain) MONO_INTERNAL; +void mono_assembly_cleanup_domain_bindings (guint32 domain_id) MONO_INTERNAL;; + #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */ diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h index ee6fb20ff1f9..fd98455b8ae8 100644 --- a/mono/metadata/metadata-internals.h +++ b/mono/metadata/metadata-internals.h @@ -444,6 +444,7 @@ typedef struct _MonoAssemblyBindingInfo { guint has_old_version_top : 1; guint has_new_version : 1; guint is_valid : 1; + gint32 domain_id; /*Needed to unload per-domain binding*/ } MonoAssemblyBindingInfo; struct _MonoMethodHeader { From 2b83ff4fd69b8f43d71da203ddde399760967f9e Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 14 Dec 2010 21:32:04 +0100 Subject: [PATCH 04/93] Add support for an additional TType encoding. --- mono/mini/unwind.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mono/mini/unwind.c b/mono/mini/unwind.c index d75ae49ffabd..2f1302065a8a 100644 --- a/mono/mini/unwind.c +++ b/mono/mini/unwind.c @@ -770,6 +770,10 @@ decode_lsda (guint8 *lsda, guint8 *code, MonoJitExceptionInfo **ex_info, guint32 gint32 offset = *(gint32*)ttype_entry; guint8 *stub = ttype_entry + offset; tinfo = *(gpointer*)stub; + } else if (ttype_encoding == (DW_EH_PE_pcrel | DW_EH_PE_sdata4)) { + guint8 *ttype_entry = (ttype - (type_offset * 4)); + gint32 offset = *(gint32*)ttype_entry; + tinfo = ttype_entry + offset; } else { g_assert_not_reached (); } From fbd6a1b09a084939dea427a6cf312ce610ee8b6c Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 14 Dec 2010 21:34:33 +0100 Subject: [PATCH 05/93] Put llvm type infos into the .text section. --- mono/mini/mini-llvm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 46555e2eb048..1df09e826bc7 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -2065,6 +2065,12 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMSetLinkage (type_info, LLVMPrivateLinkage); LLVMSetVisibility (type_info, LLVMHiddenVisibility); + /* + * Put this into the .text section so it needs less relocations/stubs, if + * the LSDA is in the .text section too. + */ + LLVMSetSection (type_info, "text"); + /* * Enabling this causes llc to crash: * http://llvm.org/bugs/show_bug.cgi?id=6102 From ee5160d55de0017351a2fb6c7433d3043a8a72d6 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 14 Dec 2010 16:20:35 -0500 Subject: [PATCH 06/93] Fixed AesManaged parameter names to make gui-compare happy --- .../System.Security.Cryptography/AesManaged.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.Core/System.Security.Cryptography/AesManaged.cs b/mcs/class/System.Core/System.Security.Cryptography/AesManaged.cs index 817053be5b88..8a9c56176f61 100644 --- a/mcs/class/System.Core/System.Security.Cryptography/AesManaged.cs +++ b/mcs/class/System.Core/System.Security.Cryptography/AesManaged.cs @@ -60,14 +60,14 @@ public override void GenerateKey () KeyValue = KeyBuilder.Key (KeySizeValue >> 3); } - public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) + public override ICryptoTransform CreateDecryptor (byte[] key, byte[] iv) { - return new AesTransform (this, false, rgbKey, rgbIV); + return new AesTransform (this, false, key, iv); } - public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) + public override ICryptoTransform CreateEncryptor (byte[] key, byte[] iv) { - return new AesTransform (this, true, rgbKey, rgbIV); + return new AesTransform (this, true, key, iv); } // I suppose some attributes differs ?!? because this does not look required From 6a8e4e51fc1181ac835645ff79ae454e5e097629 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 14 Dec 2010 22:38:44 +0100 Subject: [PATCH 07/93] Add llvm_label_prefix to a few symbols. --- mono/mini/aot-compiler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 903cad6797bc..8fe73c81e27b 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -6361,8 +6361,8 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) #endif acfg->num_trampolines [MONO_AOT_TRAMP_IMT_THUNK] = acfg->aot_opts.full_aot ? acfg->aot_opts.nimt_trampolines : 0; - acfg->got_symbol_base = g_strdup_printf ("mono_aot_%s_got", acfg->image->assembly->aname.name); - acfg->plt_symbol = g_strdup_printf ("mono_aot_%s_plt", acfg->image->assembly->aname.name); + acfg->got_symbol_base = g_strdup_printf ("%smono_aot_%s_got", acfg->llvm_label_prefix, acfg->image->assembly->aname.name); + acfg->plt_symbol = g_strdup_printf ("%smono_aot_%s_plt", acfg->llvm_label_prefix, acfg->image->assembly->aname.name); /* Get rid of characters which cannot occur in symbols */ for (p = acfg->got_symbol_base; *p; ++p) { From 4384daff772f537e8fb15bd85dba2f86a0352d55 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 10:03:51 +0000 Subject: [PATCH 08/93] Recover from invalid linq block syntax --- mcs/mcs/cs-parser.jay | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 2313675262ae..06f6ceccf07c 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -5568,6 +5568,11 @@ query_body $$ = head; } | opt_query_body_clauses COMPLETE_COMPLETION + | error + { + Error_SyntaxError (yyToken); + $$ = null; + } ; select_or_group_clause From d61516587945cc363fa6fcc5fb8035099e65849a Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 10:43:06 +0000 Subject: [PATCH 09/93] Emit delegate constructor parameter names --- mcs/mcs/delegate.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs index 0a7eb732e702..b6a461f9b4a9 100644 --- a/mcs/mcs/delegate.cs +++ b/mcs/mcs/delegate.cs @@ -298,9 +298,10 @@ public override void EmitType () } } - parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder); - + Constructor.ParameterInfo.ApplyAttributes (this, Constructor.ConstructorBuilder); Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime); + + parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder); InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime); if (BeginInvokeBuilder != null) { From bd05c6c83699e742e93eec754bf771ee111ff3b1 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 11:11:08 +0000 Subject: [PATCH 10/93] Some .net 4.0 api compatibility fixes --- .../System.Collections.Generic/HashSet.cs | 31 +++++++--------- .../MemoryMappedFileRights.cs | 4 +-- .../MemoryMappedFileSecurity.cs | 35 +++++++++++++++++-- .../System.Core/System.Linq/Enumerable.cs | 24 ++++++------- .../System.Linq/EnumerableQuery_T.cs | 23 +++++------- .../System.Linq/IOrderedEnumerable_T.cs | 5 +-- mcs/class/System.Core/System.Linq/Lookup.cs | 6 ++-- .../System/TimeZoneInfo.TransitionTime.cs | 6 ++-- .../System.Numerics/Complex.cs | 14 ++++---- .../Microsoft.Win32/RegistryValueKind.cs | 2 +- .../ConcurrentDictionary.cs | 3 ++ .../IsolatedStorageSecurityOptions.cs | 5 +-- .../corlib/System.Reflection/Assembly.cs | 18 +++------- .../System.Resources/ResourceManager.cs | 2 -- .../TypeLibImporterFlags.cs | 3 ++ .../ObjectSecurity_T.cs | 33 +++++++++++++++-- .../SecurityAction.cs | 12 +++++++ mcs/class/corlib/System/AggregateException.cs | 19 +++++----- mcs/class/corlib/System/AppDomain.cs | 4 +-- mcs/class/corlib/System/Decimal.cs | 10 ++++++ .../corlib/System/InvalidTimeZoneException.cs | 4 +-- mcs/class/corlib/System/String.cs | 4 +++ .../System/TimeZoneNotFoundException.cs | 4 +-- 23 files changed, 172 insertions(+), 99 deletions(-) diff --git a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs index 3fc9b1e3bfa1..579a1540d20b 100644 --- a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs +++ b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs @@ -176,26 +176,26 @@ public void CopyTo (T [] array) { CopyTo (array, 0, count); } - - public void CopyTo (T [] array, int index) + + public void CopyTo (T [] array, int arrayIndex) { - CopyTo (array, index, count); + CopyTo (array, arrayIndex, count); } - public void CopyTo (T [] array, int index, int count) + public void CopyTo (T [] array, int arrayIndex, int count) { if (array == null) throw new ArgumentNullException ("array"); - if (index < 0) - throw new ArgumentOutOfRangeException ("index"); - if (index > array.Length) + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException ("arrayIndex"); + if (arrayIndex > array.Length) throw new ArgumentException ("index larger than largest valid index of array"); - if (array.Length - index < count) + if (array.Length - arrayIndex < count) throw new ArgumentException ("Destination array cannot hold the requested elements!"); for (int i = 0, items = 0; i < touched && items < count; i++) { if (GetLinkHashCode (i) != 0) - array [index++] = slots [i]; + array [arrayIndex++] = slots [i]; } } @@ -352,15 +352,15 @@ public bool Remove (T item) return true; } - public int RemoveWhere (Predicate predicate) + public int RemoveWhere (Predicate match) { - if (predicate == null) - throw new ArgumentNullException ("predicate"); + if (match == null) + throw new ArgumentNullException ("match"); var candidates = new List (); foreach (var item in this) - if (predicate (item)) + if (match (item)) candidates.Add (item); foreach (var item in candidates) @@ -597,11 +597,6 @@ bool ICollection.IsReadOnly { get { return false; } } - void ICollection.CopyTo (T [] array, int index) - { - CopyTo (array, index); - } - void ICollection.Add (T item) { Add (item); diff --git a/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs b/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs index d6348604d09a..517ed6cbf80e 100644 --- a/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs +++ b/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs @@ -35,7 +35,6 @@ namespace System.IO.MemoryMappedFiles { [Flags] public enum MemoryMappedFileRights { - None = 0, CopyOnWrite = 1, Write = 2, Read = 4, @@ -48,8 +47,7 @@ public enum MemoryMappedFileRights { ChangePermissions = 0x40000, TakeOwnership = 0x80000, FullControl = 0xf000f, - AccessSystemSecurity = 0x1000000, - DelayAllocatePages = 0x4000000 + AccessSystemSecurity = 0x1000000 } } diff --git a/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs b/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs index 961e2c8164ea..47299e2a65ae 100644 --- a/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs +++ b/mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs @@ -1,8 +1,39 @@ +// +// MemoryMappedFileSecurity.cs +// +// Authors: +// Marek Safar (marek.safar@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.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. +// + #if NET_4_0 -namespace System.IO.MemoryMappedFiles { +using System.Security.AccessControl; - public class MemoryMappedFileSecurity { +namespace System.IO.MemoryMappedFiles +{ + public class MemoryMappedFileSecurity : ObjectSecurity + { } } diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs index 5d8e892a335d..d0a4c77a7324 100644 --- a/mcs/class/System.Core/System.Linq/Enumerable.cs +++ b/mcs/class/System.Core/System.Linq/Enumerable.cs @@ -642,13 +642,13 @@ public static int Count (this IEnumerable source) return counter; } - public static int Count (this IEnumerable source, Func selector) + public static int Count (this IEnumerable source, Func predicate) { - Check.SourceAndSelector (source, selector); + Check.SourceAndSelector (source, predicate); int counter = 0; foreach (var element in source) - if (selector (element)) + if (predicate (element)) counter++; return counter; @@ -1262,13 +1262,13 @@ public static long LongCount (this IEnumerable source) return counter; } - public static long LongCount (this IEnumerable source, Func selector) + public static long LongCount (this IEnumerable source, Func predicate) { - Check.SourceAndSelector (source, selector); + Check.SourceAndSelector (source, predicate); long counter = 0; foreach (TSource element in source) - if (selector (element)) + if (predicate (element)) counter++; return counter; @@ -2285,11 +2285,11 @@ static IEnumerable CreateSelectManyIterator (IEnumera } public static IEnumerable SelectMany (this IEnumerable source, - Func> collectionSelector, Func selector) + Func> collectionSelector, Func resultSelector) { - Check.SourceAndCollectionSelectors (source, collectionSelector, selector); + Check.SourceAndCollectionSelectors (source, collectionSelector, resultSelector); - return CreateSelectManyIterator (source, collectionSelector, selector); + return CreateSelectManyIterator (source, collectionSelector, resultSelector); } static IEnumerable CreateSelectManyIterator (IEnumerable source, @@ -2301,11 +2301,11 @@ static IEnumerable CreateSelectManyIterator SelectMany (this IEnumerable source, - Func> collectionSelector, Func selector) + Func> collectionSelector, Func resultSelector) { - Check.SourceAndCollectionSelectors (source, collectionSelector, selector); + Check.SourceAndCollectionSelectors (source, collectionSelector, resultSelector); - return CreateSelectManyIterator (source, collectionSelector, selector); + return CreateSelectManyIterator (source, collectionSelector, resultSelector); } static IEnumerable CreateSelectManyIterator (IEnumerable source, diff --git a/mcs/class/System.Core/System.Linq/EnumerableQuery_T.cs b/mcs/class/System.Core/System.Linq/EnumerableQuery_T.cs index 1a97dada760e..77562b4ebd16 100644 --- a/mcs/class/System.Core/System.Linq/EnumerableQuery_T.cs +++ b/mcs/class/System.Core/System.Linq/EnumerableQuery_T.cs @@ -37,17 +37,17 @@ namespace System.Linq { public class EnumerableQuery : EnumerableQuery, IOrderedQueryable, IQueryable, IQueryProvider { - QueryableEnumerable queryable; + readonly QueryableEnumerable queryable; - public Type ElementType { + Type IQueryable.ElementType { get { return queryable.ElementType; } } - public Expression Expression { + Expression IQueryable.Expression { get { return queryable.Expression; } } - public IQueryProvider Provider { + IQueryProvider IQueryable.Provider { get { return queryable; } } @@ -61,37 +61,32 @@ public EnumerableQuery (IEnumerable enumerable) queryable = new QueryableEnumerable (enumerable); } - public IEnumerable GetEnumerable () - { - return queryable.GetEnumerable (); - } - IEnumerator IEnumerable.GetEnumerator () { return queryable.GetEnumerator (); } - public IEnumerator GetEnumerator () + IEnumerator IEnumerable.GetEnumerator () { return queryable.GetEnumerator (); } - public IQueryable CreateQuery (Expression expression) + IQueryable IQueryProvider.CreateQuery (Expression expression) { return queryable.CreateQuery (expression); } - public object Execute (Expression expression) + object IQueryProvider.Execute (Expression expression) { return queryable.Execute (expression); } - public IQueryable CreateQuery (Expression expression) + IQueryable IQueryProvider.CreateQuery (Expression expression) { return new EnumerableQuery (expression); } - public TResult Execute (Expression expression) + TResult IQueryProvider.Execute (Expression expression) { return queryable.Execute (expression); } diff --git a/mcs/class/System.Core/System.Linq/IOrderedEnumerable_T.cs b/mcs/class/System.Core/System.Linq/IOrderedEnumerable_T.cs index d87417072c7c..6d9d2294a873 100644 --- a/mcs/class/System.Core/System.Linq/IOrderedEnumerable_T.cs +++ b/mcs/class/System.Core/System.Linq/IOrderedEnumerable_T.cs @@ -30,7 +30,8 @@ namespace System.Linq { - public interface IOrderedEnumerable : IEnumerable { - IOrderedEnumerable CreateOrderedEnumerable (Func selector, IComparer comparer, bool descending); + public interface IOrderedEnumerable : IEnumerable + { + IOrderedEnumerable CreateOrderedEnumerable (Func keySelector, IComparer comparer, bool descending); } } diff --git a/mcs/class/System.Core/System.Linq/Lookup.cs b/mcs/class/System.Core/System.Linq/Lookup.cs index 116814feb724..0191a6b6ff31 100644 --- a/mcs/class/System.Core/System.Linq/Lookup.cs +++ b/mcs/class/System.Core/System.Linq/Lookup.cs @@ -69,13 +69,13 @@ internal Lookup (Dictionary> lookup, IEnumerable nullGrouping = new Grouping (default (TKey), nullKeyElements); } - public IEnumerable ApplyResultSelector (Func, TResult> selector) + public IEnumerable ApplyResultSelector (Func, TResult> resultSelector) { if (nullGrouping != null) - yield return selector (nullGrouping.Key, nullGrouping); + yield return resultSelector (nullGrouping.Key, nullGrouping); foreach (var group in groups.Values) - yield return selector (group.Key, group); + yield return resultSelector (group.Key, group); } public bool Contains (TKey key) diff --git a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs index 7aa1bffe3b18..552c34695408 100644 --- a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs +++ b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs @@ -193,10 +193,10 @@ public void GetObjectData (SerializationInfo info, StreamingContext context) throw new NotImplementedException (); } - public override bool Equals (object other) + public override bool Equals (object obj) { - if (other is TransitionTime) - return this == (TransitionTime) other; + if (obj is TransitionTime) + return this == (TransitionTime) obj; return false; } diff --git a/mcs/class/System.Numerics/System.Numerics/Complex.cs b/mcs/class/System.Numerics/System.Numerics/Complex.cs index 7762ae00b8d4..7f870fce6601 100644 --- a/mcs/class/System.Numerics/System.Numerics/Complex.cs +++ b/mcs/class/System.Numerics/System.Numerics/Complex.cs @@ -110,13 +110,13 @@ public static Complex Multiply (Complex left, Complex right) (left.imaginary * right.real - left.real * right.imaginary) / rsri); } - public static Complex Divide (Complex left, Complex right) + public static Complex Divide (Complex dividend, Complex divisor) { - double rsri = right.real * right.real + right.imaginary * right.imaginary; + double rsri = divisor.real * divisor.real + divisor.imaginary * divisor.imaginary; return new Complex ( - (left.real * right.real + left.imaginary * right.imaginary) / rsri, + (dividend.real * divisor.real + dividend.imaginary * divisor.imaginary) / rsri, - (left.imaginary * right.real - left.real * right.imaginary) / rsri); + (dividend.imaginary * divisor.real - dividend.real * divisor.imaginary) / rsri); } public static bool operator == (Complex left, Complex right) @@ -129,12 +129,12 @@ public bool Equals (Complex value) return real == value.real && imaginary == value.imaginary; } - public override bool Equals (object value) + public override bool Equals (object obj) { - if (value == null || !(value is Complex)) + if (obj == null || !(obj is Complex)) return false; - Complex r = (Complex) value; + Complex r = (Complex) obj; return real == r.real && imaginary == r.imaginary; } diff --git a/mcs/class/corlib/Microsoft.Win32/RegistryValueKind.cs b/mcs/class/corlib/Microsoft.Win32/RegistryValueKind.cs index ff0c7255b30d..e94e1f210334 100644 --- a/mcs/class/corlib/Microsoft.Win32/RegistryValueKind.cs +++ b/mcs/class/corlib/Microsoft.Win32/RegistryValueKind.cs @@ -41,7 +41,7 @@ public enum RegistryValueKind { MultiString = 7, QWord = 11, #if NET_4_0 - None = 12 + None = -1 #endif } } diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs index f4dc19b82a06..6e78662d0139 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs @@ -29,9 +29,12 @@ using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; +using System.Diagnostics; namespace System.Collections.Concurrent { + [DebuggerDisplay ("Count={Count}")] + [DebuggerTypeProxy (typeof (CollectionDebuggerView<,>))] public class ConcurrentDictionary : IDictionary, ICollection>, IEnumerable>, IDictionary, ICollection, IEnumerable diff --git a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageSecurityOptions.cs b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageSecurityOptions.cs index 112a1035695e..0d3b391fbc66 100644 --- a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageSecurityOptions.cs +++ b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageSecurityOptions.cs @@ -29,8 +29,9 @@ #if NET_4_0 namespace System.IO.IsolatedStorage { - public enum IsolatedStorageSecurityOptions { - IncreaseQuotaForApplication + public enum IsolatedStorageSecurityOptions + { + IncreaseQuotaForApplication = 4 } } diff --git a/mcs/class/corlib/System.Reflection/Assembly.cs b/mcs/class/corlib/System.Reflection/Assembly.cs index 030fc96fa133..4f634d2c92eb 100644 --- a/mcs/class/corlib/System.Reflection/Assembly.cs +++ b/mcs/class/corlib/System.Reflection/Assembly.cs @@ -45,8 +45,6 @@ namespace System.Reflection { -#pragma warning disable 659 // overrides Equals but not GetHashCode - [ComVisible (true)] [ComDefaultInterfaceAttribute (typeof (_Assembly))] [Serializable] @@ -597,9 +595,7 @@ public static Assembly ReflectionOnlyLoadFrom (string assemblyFile) return LoadFrom (assemblyFile, true); } -#if NET_4_0 [Obsolete] -#endif public static Assembly LoadWithPartialName (string partialName) { return LoadWithPartialName (partialName, null); @@ -624,9 +620,7 @@ Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore) [MethodImplAttribute (MethodImplOptions.InternalCall)] private static extern Assembly load_with_partial_name (string name, Evidence e); -#if NET_4_0 [Obsolete] -#endif public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence) { return LoadWithPartialName (partialName, securityEvidence, true); @@ -780,6 +774,11 @@ public virtual extern bool ReflectionOnly { [MethodImplAttribute (MethodImplOptions.InternalCall)] get; } + + public override int GetHashCode () + { + return base.GetHashCode (); + } public override bool Equals (object o) { @@ -946,11 +945,6 @@ public virtual bool IsDynamic { get { return false; } } - public override int GetHashCode () - { - return base.GetHashCode (); - } - public static bool operator == (Assembly left, Assembly right) { if ((object)left == (object)right) @@ -971,5 +965,3 @@ public override int GetHashCode () #endif } } - -#pragma warning restore 659 diff --git a/mcs/class/corlib/System.Resources/ResourceManager.cs b/mcs/class/corlib/System.Resources/ResourceManager.cs index 0179475252c8..5b8f3d53b8be 100644 --- a/mcs/class/corlib/System.Resources/ResourceManager.cs +++ b/mcs/class/corlib/System.Resources/ResourceManager.cs @@ -302,14 +302,12 @@ Stream GetManifestResourceStreamNoCase (Assembly ass, string fn) return null; } - [CLSCompliant (false)] [ComVisible (false)] public UnmanagedMemoryStream GetStream (string name) { return GetStream (name, (CultureInfo) null); } - [CLSCompliant (false)] [ComVisible (false)] public UnmanagedMemoryStream GetStream (string name, CultureInfo culture) { diff --git a/mcs/class/corlib/System.Runtime.InteropServices/TypeLibImporterFlags.cs b/mcs/class/corlib/System.Runtime.InteropServices/TypeLibImporterFlags.cs index 20c59b0948f2..fc611887c4a6 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/TypeLibImporterFlags.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/TypeLibImporterFlags.cs @@ -48,5 +48,8 @@ public enum TypeLibImporterFlags ImportAsX86 = 256, ReflectionOnlyLoading = 4096, SerializableValueClasses = 32, +#if NET_4_0 + NoDefineVersionResource = 8192 +#endif } } diff --git a/mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs b/mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs index 40c43e109397..afe435a239ee 100644 --- a/mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs +++ b/mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs @@ -23,12 +23,41 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_4_0 +#if NET_4_0 || BOOTSTRAP_NET_4_0 + +using System.Security.Principal; namespace System.Security.AccessControl { - public abstract class ObjectSecurity : NativeObjectSecurity + public abstract class ObjectSecurity : NativeObjectSecurity where T : struct { + public override Type AccessRightType { + get { + return null; + } + } + + public override Type AccessRuleType { + get { + return null; + } + } + + public override Type AuditRuleType { + get { + return null; + } + } + + public override AccessRule AccessRuleFactory(IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type) + { + return null; + } + + public override AuditRule AuditRuleFactory(IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags) + { + return null; + } } } diff --git a/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs b/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs index e33753f11b88..b35b957d4f29 100644 --- a/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs +++ b/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs @@ -43,12 +43,24 @@ namespace System.Security.Permissions { public enum SecurityAction { Demand = 2, Assert = 3, +#if NET_4_0 + [Obsolete] +#endif Deny = 4, PermitOnly = 5, LinkDemand = 6, InheritanceDemand = 7, +#if NET_4_0 + [Obsolete] +#endif RequestMinimum = 8, +#if NET_4_0 + [Obsolete] +#endif RequestOptional = 9, +#if NET_4_0 + [Obsolete] +#endif RequestRefuse = 10, } } diff --git a/mcs/class/corlib/System/AggregateException.cs b/mcs/class/corlib/System/AggregateException.cs index a4db6e599824..df5cefbd2a08 100644 --- a/mcs/class/corlib/System/AggregateException.cs +++ b/mcs/class/corlib/System/AggregateException.cs @@ -43,12 +43,12 @@ public AggregateException (string message): base (message, null) { } - public AggregateException (string message, Exception e): base (message, e) + public AggregateException (string message, Exception innerException): base (message, innerException) { } - protected AggregateException (SerializationInfo info, StreamingContext ctx) - : base (info, ctx) + protected AggregateException (SerializationInfo info, StreamingContext context) + : base (info, context) { } @@ -67,10 +67,10 @@ public AggregateException (IEnumerable innerExceptions) { } - public AggregateException (string message, IEnumerable inner) - : base(GetFormattedMessage(message, inner)) + public AggregateException (string message, IEnumerable innerExceptions) + : base(GetFormattedMessage(message, innerExceptions)) { - this.innerExceptions = new List (inner); + this.innerExceptions = new List (innerExceptions); } public AggregateException Flatten () @@ -89,12 +89,12 @@ public AggregateException Flatten () return new AggregateException (inner); } - public void Handle (Func handler) + public void Handle (Func predicate) { List failed = new List (); foreach (var e in innerExceptions) { try { - if (!handler (e)) + if (!predicate (e)) failed.Add (e); } catch { throw new AggregateException (failed); @@ -115,9 +115,10 @@ public override string ToString () return this.Message; } - const string baseMessage = "Exception(s) occurred : {0}."; static string GetFormattedMessage (string customMessage, IEnumerable inner) { + const string baseMessage = "Exception(s) occurred : {0}."; + System.Text.StringBuilder finalMessage = new System.Text.StringBuilder (string.Format (baseMessage, customMessage)); foreach (Exception e in inner) { diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index c522ce54078c..881b64d99a9b 100644 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -390,11 +390,11 @@ public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bo culture, activationAttributes, null); } - public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase, + public object CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) { - ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, ignoreCase, bindingAttr, binder, args, + ObjectHandle oh = CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes); return (oh != null) ? oh.Unwrap () : null; diff --git a/mcs/class/corlib/System/Decimal.cs b/mcs/class/corlib/System/Decimal.cs index ed7eaa252f7d..1ba3b80dcc3d 100644 --- a/mcs/class/corlib/System/Decimal.cs +++ b/mcs/class/corlib/System/Decimal.cs @@ -38,6 +38,7 @@ using System.Text; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; +using System.Runtime.Serialization; #if MSTEST using System.Runtime.InteropServices; @@ -53,6 +54,9 @@ namespace System [Serializable] [System.Runtime.InteropServices.ComVisible (true)] public struct Decimal: IFormattable, IConvertible, IComparable, IComparable, IEquatable +#if NET_4_0 + , IDeserializationCallback +#endif { public const decimal MinValue = -79228162514264337593543950335m; public const decimal MaxValue = 79228162514264337593543950335m; @@ -1336,6 +1340,12 @@ public string ToString (IFormatProvider provider) { return ToString ("G", provider); } + +#if NET_4_0 + void IDeserializationCallback.OnDeserialization(object sender) + { + } +#endif #if !MSTEST [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/mcs/class/corlib/System/InvalidTimeZoneException.cs b/mcs/class/corlib/System/InvalidTimeZoneException.cs index d53141adff94..5f52ac28915c 100644 --- a/mcs/class/corlib/System/InvalidTimeZoneException.cs +++ b/mcs/class/corlib/System/InvalidTimeZoneException.cs @@ -44,10 +44,10 @@ public InvalidTimeZoneException () : base () public InvalidTimeZoneException (string message) : base (message) {} - public InvalidTimeZoneException (string message, Exception e) : base (message, e) + public InvalidTimeZoneException (string message, Exception innerException) : base (message, innerException) {} - protected InvalidTimeZoneException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc) + protected InvalidTimeZoneException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext context) : base (info, context) {} } } diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs index 0d7a20f869b3..37e4e7ece000 100644 --- a/mcs/class/corlib/System/String.cs +++ b/mcs/class/corlib/System/String.cs @@ -2217,7 +2217,11 @@ public static string IsInterned (string str) return InternalIsInterned (str); } +#if NET_4_0 public static string Join (string separator, params string [] value) +#else + public static string Join (string separator, string [] value) +#endif { if (value == null) throw new ArgumentNullException ("value"); diff --git a/mcs/class/corlib/System/TimeZoneNotFoundException.cs b/mcs/class/corlib/System/TimeZoneNotFoundException.cs index 3dd922f035d8..e550e78306b5 100644 --- a/mcs/class/corlib/System/TimeZoneNotFoundException.cs +++ b/mcs/class/corlib/System/TimeZoneNotFoundException.cs @@ -44,10 +44,10 @@ public TimeZoneNotFoundException () : base () public TimeZoneNotFoundException (string message) : base (message) {} - public TimeZoneNotFoundException (string message, Exception e) : base (message, e) + public TimeZoneNotFoundException (string message, Exception innerException) : base (message, innerException) {} - protected TimeZoneNotFoundException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc) + protected TimeZoneNotFoundException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext context) : base (info, context) {} } } From 754b331640830f9a7ec073b39ce646d71979a9de Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 11:35:22 +0000 Subject: [PATCH 11/93] Switch to resizeable array when adding second item to base member cache --- mcs/mcs/membercache.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mcs/mcs/membercache.cs b/mcs/mcs/membercache.cs index 6561b28a89ef..2392dfa5b289 100644 --- a/mcs/mcs/membercache.cs +++ b/mcs/mcs/membercache.cs @@ -231,6 +231,11 @@ public void AddBaseType (TypeSpec baseType) if (list.Contains (ce)) continue; + if (list is MemberSpec[]) { + list = new List () { list [0] }; + member_hash[entry.Key] = list; + } + list.Add (ce); } } From 63919259276bf6164d42d3da584ad18026334a3d Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 11:36:24 +0000 Subject: [PATCH 12/93] Keep only single Dispose implementation in ResourceReader --- mcs/class/corlib/System.Resources/ResourceReader.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mcs/class/corlib/System.Resources/ResourceReader.cs b/mcs/class/corlib/System.Resources/ResourceReader.cs index 367929b07097..ae5f679ff289 100644 --- a/mcs/class/corlib/System.Resources/ResourceReader.cs +++ b/mcs/class/corlib/System.Resources/ResourceReader.cs @@ -479,10 +479,12 @@ public void Close () #if NET_4_0 public void Dispose () +#else + void IDisposable.Dispose () +#endif { Dispose(true); } -#endif public IDictionaryEnumerator GetEnumerator () { if (reader == null){ @@ -547,11 +549,6 @@ private void GetResourceDataAt (int index, out string resourceType, out byte [] } } - void IDisposable.Dispose () - { - Dispose(true); - } - private void Dispose (bool disposing) { if(disposing) { From 25b26705a4465b56e036d0f81746f8cf4bc2976a Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 11:40:59 +0000 Subject: [PATCH 13/93] Add existing class to System.Net build --- mcs/class/System.Net/System.Net.dll.sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/System.Net/System.Net.dll.sources b/mcs/class/System.Net/System.Net.dll.sources index 5af78ba50547..ce0df60dd4d9 100644 --- a/mcs/class/System.Net/System.Net.dll.sources +++ b/mcs/class/System.Net/System.Net.dll.sources @@ -1,4 +1,4 @@ Assembly/AssemblyInfo.cs ../../build/common/Consts.cs ../../build/common/MonoTODOAttribute.cs - +System.Net/IPEndPointCollection.cs From 2fad7a53fae93c7b1e5334e20d9364169045f4d5 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 12:06:10 +0000 Subject: [PATCH 14/93] Workaround problem when compiling many resource files references --- mcs/mcs/assembly.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index be7cb032001a..1184623b921b 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -721,6 +721,7 @@ public void EmbedResources () if (RootContext.Target == Target.Module) { Report.Error (1507, "Cannot link resource file when building a module"); } else { + int counter = 0; foreach (var res in RootContext.Resources) { if (!File.Exists (res.FileName)) { Report.Error (1566, "Error reading resource file `{0}'", res.FileName); @@ -728,7 +729,16 @@ public void EmbedResources () } if (res.IsEmbeded) { - var stream = File.OpenRead (res.FileName); + Stream stream; + if (counter++ < 10) { + stream = File.OpenRead (res.FileName); + } else { + // TODO: SRE API requires resouce stream to be available during AssemblyBuilder::Save + // we workaround it by reading everything into memory to compile projects with + // many embedded resources (over 3500) references + stream = new MemoryStream (File.ReadAllBytes (res.FileName)); + } + module.Builder.DefineManifestResource (res.Name, stream, res.Attributes); } else { Builder.AddResourceFile (res.Name, Path.GetFileName (res.FileName), res.Attributes); From 073a0e3051eb59b5b0f845c1e2b9c9c3a0c9fee8 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 12:18:08 +0000 Subject: [PATCH 15/93] Fix comment typo --- mcs/mcs/assembly.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index 1184623b921b..fb21b000c222 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -733,9 +733,9 @@ public void EmbedResources () if (counter++ < 10) { stream = File.OpenRead (res.FileName); } else { - // TODO: SRE API requires resouce stream to be available during AssemblyBuilder::Save + // TODO: SRE API requires resource stream to be available during AssemblyBuilder::Save // we workaround it by reading everything into memory to compile projects with - // many embedded resources (over 3500) references + // many embedded resource (over 3500) references stream = new MemoryStream (File.ReadAllBytes (res.FileName)); } From 0a0e04ba13a1e790ab51600dcff816857f8728b6 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 13:26:20 +0000 Subject: [PATCH 16/93] [656150] Fix repl recovery after invalid expression. --- mcs/mcs/eval.cs | 2 ++ mcs/mcs/report.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/mcs/mcs/eval.cs b/mcs/mcs/eval.cs index 81301521a10e..eeed915e265d 100644 --- a/mcs/mcs/eval.cs +++ b/mcs/mcs/eval.cs @@ -243,6 +243,8 @@ static public string Compile (string input, out CompiledMethod compiled) lock (evaluator_lock){ if (!inited) Init (); + else + ctx.Report.Printer.Reset (); // RootContext.ToplevelTypes = new ModuleContainer (ctx); diff --git a/mcs/mcs/report.cs b/mcs/mcs/report.cs index fa9b9d9a6df9..f3512d9f789b 100644 --- a/mcs/mcs/report.cs +++ b/mcs/mcs/report.cs @@ -657,6 +657,12 @@ protected void Print (AbstractMessage msg, TextWriter output) output.WriteLine (s + msg.MessageType + ")"); } } + + public void Reset () + { + // Temporary hack for broken repl flow + errors = warnings = 0; + } } // From 80502502e135a5450e9c2af7ad811d7ad4f13205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 14:13:08 +0000 Subject: [PATCH 17/93] Update Task parameter names --- .../corlib/System.Threading.Tasks/Task.cs | 130 +++++++++--------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/mcs/class/corlib/System.Threading.Tasks/Task.cs b/mcs/class/corlib/System.Threading.Tasks/Task.cs index f17d762537b7..6c6a6899bccb 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Task.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Task.cs @@ -30,9 +30,11 @@ namespace System.Threading.Tasks { + [System.Diagnostics.DebuggerDisplay ("Id = {Id}, Status = {Status}, Method = {DebuggerDisplayMethodDescription}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.SystemThreadingTasks_TaskDebugView")] public class Task : IDisposable, IAsyncResult { - // With this attribute each thread has its own value so that it's correct for our Schedule code + // With this attribute each thread has itimeout own value so that it's correct for our Schedule code // and for Parent property. [System.ThreadStatic] static Task current; @@ -64,25 +66,25 @@ public class Task : IDisposable, IAsyncResult ConcurrentQueue completed = new ConcurrentQueue (); - CancellationToken token; - + CancellationToken token; + public Task (Action action) : this (action, TaskCreationOptions.None) { } - public Task (Action action, TaskCreationOptions options) : this (action, CancellationToken.None, options) + public Task (Action action, TaskCreationOptions creationOptions) : this (action, CancellationToken.None, creationOptions) { } - public Task (Action action, CancellationToken token) : this (action, token, TaskCreationOptions.None) + public Task (Action action, CancellationToken cancellationToken) : this (action, cancellationToken, TaskCreationOptions.None) { } - public Task (Action action, CancellationToken token, TaskCreationOptions options) - : this ((o) => { if (action != null) action (); }, null, token, options) + public Task (Action action, CancellationToken cancellationToken, TaskCreationOptions creationOptions) + : this ((o) => { if (action != null) action (); }, null, cancellationToken, creationOptions) { } @@ -90,24 +92,24 @@ public Task (Action action, object state) : this (action, state, TaskCre { } - public Task (Action action, object state, TaskCreationOptions options) - : this (action, state, CancellationToken.None, options) + public Task (Action action, object state, TaskCreationOptions creationOptions) + : this (action, state, CancellationToken.None, creationOptions) { } - public Task (Action action, object state, CancellationToken token) - : this (action, state, token, TaskCreationOptions.None) + public Task (Action action, object state, CancellationToken cancellationToken) + : this (action, state, cancellationToken, TaskCreationOptions.None) { } - public Task (Action action, object state, CancellationToken token, TaskCreationOptions options) + public Task (Action action, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions) { - this.taskCreationOptions = options; + this.taskCreationOptions = creationOptions; this.action = action == null ? EmptyFunc : action; this.state = state; this.taskId = Interlocked.Increment (ref id); this.status = TaskStatus.Created; - this.token = token; + this.token = cancellationToken; // Process taskCreationOptions if (CheckTaskOptions (taskCreationOptions, TaskCreationOptions.AttachedToParent)) { @@ -138,9 +140,9 @@ public void Start () Start (TaskScheduler.Current); } - public void Start (TaskScheduler tscheduler) + public void Start (TaskScheduler scheduler) { - Start (ProxifyScheduler (tscheduler)); + Start (ProxifyScheduler (scheduler)); } void Start (IScheduler scheduler) @@ -172,7 +174,7 @@ public void RunSynchronously () RunSynchronously (TaskScheduler.Current); } - public void RunSynchronously (TaskScheduler tscheduler) + public void RunSynchronously (TaskScheduler scheduler) { // TODO // Adopt this scheme for the moment @@ -181,66 +183,66 @@ public void RunSynchronously (TaskScheduler tscheduler) #endregion #region ContinueWith - public Task ContinueWith (Action a) + public Task ContinueWith (Action continuationAction) { - return ContinueWith (a, TaskContinuationOptions.None); + return ContinueWith (continuationAction, TaskContinuationOptions.None); } - public Task ContinueWith (Action a, TaskContinuationOptions kind) + public Task ContinueWith (Action continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWith (a, CancellationToken.None, kind, TaskScheduler.Current); + return ContinueWith (continuationAction, CancellationToken.None, continuationOptions, TaskScheduler.Current); } - public Task ContinueWith (Action a, CancellationToken token) + public Task ContinueWith (Action continuationAction, CancellationToken cancellationToken) { - return ContinueWith (a, token, TaskContinuationOptions.None, TaskScheduler.Current); + return ContinueWith (continuationAction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current); } - public Task ContinueWith (Action a, TaskScheduler scheduler) + public Task ContinueWith (Action continuationAction, TaskScheduler scheduler) { - return ContinueWith (a, CancellationToken.None, TaskContinuationOptions.None, scheduler); + return ContinueWith (continuationAction, CancellationToken.None, TaskContinuationOptions.None, scheduler); } - public Task ContinueWith (Action a, CancellationToken token, TaskContinuationOptions kind, TaskScheduler scheduler) + public Task ContinueWith (Action continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - Task continuation = new Task ((o) => a ((Task)o), this, token, GetCreationOptions (kind)); - ContinueWithCore (continuation, kind, scheduler); + Task continuation = new Task ((o) => continuationAction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions)); + ContinueWithCore (continuation, continuationOptions, scheduler); return continuation; } - public Task ContinueWith (Func a) + public Task ContinueWith (Func continuationFunction) { - return ContinueWith (a, TaskContinuationOptions.None); + return ContinueWith (continuationFunction, TaskContinuationOptions.None); } - public Task ContinueWith (Func a, TaskContinuationOptions options) + public Task ContinueWith (Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWith (a, CancellationToken.None, options, TaskScheduler.Current); + return ContinueWith (continuationFunction, CancellationToken.None, continuationOptions, TaskScheduler.Current); } - public Task ContinueWith (Func a, CancellationToken token) + public Task ContinueWith (Func continuationFunction, CancellationToken cancellationToken) { - return ContinueWith (a, token, TaskContinuationOptions.None, TaskScheduler.Current); + return ContinueWith (continuationFunction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current); } - public Task ContinueWith (Func a, TaskScheduler scheduler) + public Task ContinueWith (Func continuationFunction, TaskScheduler scheduler) { - return ContinueWith (a, CancellationToken.None, TaskContinuationOptions.None, scheduler); + return ContinueWith (continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler); } - public Task ContinueWith (Func a, CancellationToken token, - TaskContinuationOptions kind, TaskScheduler scheduler) + public Task ContinueWith (Func continuationFunction, CancellationToken cancellationToken, + TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - Task t = new Task ((o) => a ((Task)o), this, token, GetCreationOptions (kind)); + Task t = new Task ((o) => continuationFunction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions)); - ContinueWithCore (t, kind, scheduler); + ContinueWithCore (t, continuationOptions, scheduler); return t; } - internal void ContinueWithCore (Task continuation, TaskContinuationOptions kind, TaskScheduler scheduler) + internal void ContinueWithCore (Task continuation, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - ContinueWithCore (continuation, kind, scheduler, () => true); + ContinueWithCore (continuation, continuationOptions, scheduler, () => true); } internal void ContinueWithCore (Task continuation, TaskContinuationOptions kind, @@ -483,14 +485,14 @@ public void Wait () throw new AggregateException (new TaskCanceledException (this)); } - public void Wait (CancellationToken token) + public void Wait (CancellationToken cancellationToken) { - Wait (-1, token); + Wait (-1, cancellationToken); } - public bool Wait (TimeSpan ts) + public bool Wait (TimeSpan timeout) { - return Wait (CheckTimeout (ts), CancellationToken.None); + return Wait (CheckTimeout (timeout), CancellationToken.None); } public bool Wait (int millisecondsTimeout) @@ -498,7 +500,7 @@ public bool Wait (int millisecondsTimeout) return Wait (millisecondsTimeout, CancellationToken.None); } - public bool Wait (int millisecondsTimeout, CancellationToken token) + public bool Wait (int millisecondsTimeout, CancellationToken cancellationToken) { if (millisecondsTimeout < -1) throw new ArgumentOutOfRangeException ("millisecondsTimeout"); @@ -511,12 +513,12 @@ public bool Wait (int millisecondsTimeout, CancellationToken token) Watch watch = Watch.StartNew (); if (scheduler == null) { - schedWait.Wait (millisecondsTimeout, token); + schedWait.Wait (millisecondsTimeout, cancellationToken); millisecondsTimeout = ComputeTimeout (millisecondsTimeout, watch); } Func stopFunc - = delegate { token.ThrowIfCancellationRequested (); return watch.ElapsedMilliseconds > millisecondsTimeout; }; + = delegate { cancellationToken.ThrowIfCancellationRequested (); return watch.ElapsedMilliseconds > millisecondsTimeout; }; bool result = scheduler.ParticipateUntil (this, stopFunc); if (exception != null) @@ -538,7 +540,7 @@ public static void WaitAll (params Task[] tasks) t.Wait (); } - public static void WaitAll (Task[] tasks, CancellationToken token) + public static void WaitAll (Task[] tasks, CancellationToken cancellationToken) { if (tasks == null) throw new ArgumentNullException ("tasks"); @@ -546,10 +548,10 @@ public static void WaitAll (Task[] tasks, CancellationToken token) throw new ArgumentException ("tasks is empty", "tasks"); foreach (var t in tasks) - t.Wait (token); + t.Wait (cancellationToken); } - public static bool WaitAll (Task[] tasks, TimeSpan ts) + public static bool WaitAll (Task[] tasks, TimeSpan timeout) { if (tasks == null) throw new ArgumentNullException ("tasks"); @@ -558,7 +560,7 @@ public static bool WaitAll (Task[] tasks, TimeSpan ts) bool result = true; foreach (var t in tasks) - result &= t.Wait (ts); + result &= t.Wait (timeout); return result; } @@ -575,7 +577,7 @@ public static bool WaitAll (Task[] tasks, int millisecondsTimeout) return result; } - public static bool WaitAll (Task[] tasks, int millisecondsTimeout, CancellationToken token) + public static bool WaitAll (Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) { if (tasks == null) throw new ArgumentNullException ("tasks"); @@ -584,7 +586,7 @@ public static bool WaitAll (Task[] tasks, int millisecondsTimeout, CancellationT bool result = true; foreach (var t in tasks) - result &= t.Wait (millisecondsTimeout, token); + result &= t.Wait (millisecondsTimeout, cancellationToken); return result; } @@ -593,9 +595,9 @@ public static int WaitAny (params Task[] tasks) return WaitAny (tasks, -1, CancellationToken.None); } - public static int WaitAny (Task[] tasks, TimeSpan ts) + public static int WaitAny (Task[] tasks, TimeSpan timeout) { - return WaitAny (tasks, CheckTimeout (ts)); + return WaitAny (tasks, CheckTimeout (timeout)); } public static int WaitAny (Task[] tasks, int millisecondsTimeout) @@ -609,19 +611,19 @@ public static int WaitAny (Task[] tasks, int millisecondsTimeout) return WaitAny (tasks, millisecondsTimeout, CancellationToken.None); } - public static int WaitAny (Task[] tasks, CancellationToken token) + public static int WaitAny (Task[] tasks, CancellationToken cancellationToken) { - return WaitAny (tasks, -1, token); + return WaitAny (tasks, -1, cancellationToken); } - public static int WaitAny (Task[] tasks, int millisecondsTimeout, CancellationToken token) + public static int WaitAny (Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) { if (tasks == null) throw new ArgumentNullException ("tasks"); if (tasks.Length == 0) throw new ArgumentException ("tasks is empty", "tasks"); if (tasks.Length == 1) { - tasks[0].Wait (millisecondsTimeout, token); + tasks[0].Wait (millisecondsTimeout, cancellationToken); return 0; } @@ -666,7 +668,7 @@ public static int WaitAny (Task[] tasks, int millisecondsTimeout, CancellationTo if (millisecondsTimeout != -1 && watch.ElapsedMilliseconds > millisecondsTimeout) return true; - token.ThrowIfCancellationRequested (); + cancellationToken.ThrowIfCancellationRequested (); return numFinished >= 1; }); @@ -703,11 +705,11 @@ public void Dispose () Dispose (true); } - protected virtual void Dispose (bool disposeManagedRes) + protected virtual void Dispose (bool disposing) { // Set action to null so that the GC can collect the delegate and thus // any big object references that the user might have captured in a anonymous method - if (disposeManagedRes) { + if (disposing) { action = null; completed.Clear (); state = null; From ba688ff8b9bc72adfc54f4f00363b13698ebc59b Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 25 Nov 2010 17:01:56 -0500 Subject: [PATCH 18/93] Test case for security issue --- .../Test/System.Reflection/MethodBaseTest.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs b/mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs index 67c4d1e91ab6..fcefa0403d70 100644 --- a/mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs @@ -326,5 +326,28 @@ public void GetMethodFromHandle_Handle_Method_On_Generic_Class () } catch (ArgumentException) { } } + + // test case adapted from http://www.chrishowie.com/2010/11/24/mutable-strings-in-mono/ + public class FakeString { + public int length; + public char start_char; + } + + private static FakeString UnsafeConversion (T thing) where T : FakeString + { + return thing; + } + + [Test] + public void MutableString () + { + var m = typeof (MethodBaseTest).GetMethod ("UnsafeConversion", BindingFlags.NonPublic | BindingFlags.Static); + try { + var m2 = m.MakeGenericMethod (typeof (string)); + Assert.Fail ("MakeGenericMethod"); + } + catch (ArgumentException) { + } + } } } From c3e7a90fa5206c9f4f13af467846acde089f438b Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Wed, 15 Dec 2010 11:36:29 -0500 Subject: [PATCH 19/93] [moon] Return true for IsolatedStorageFile.IsEnabled * MoonIsolatedStorageFile.cs: Return true, instead of throwing a NIE, for IsEnabled since this is the behavior for Silverlight 3 (i.e. always enabled) even if the call is new in SL4 (but part of ML3 ;-) --- .../System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs b/mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs index 68f5359f81bd..f61550e2ec5f 100644 --- a/mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs +++ b/mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs @@ -99,11 +99,11 @@ internal string Verify (string path) } throw new IsolatedStorageException (); } - + + [MonoTODO ("always return true since this was the only behavior in Silverlight 3")] public static bool IsEnabled { get { - Console.WriteLine ("NIEX: System.IO.IsolatedStorage.IsolatedStorageFile:get_IsEnabled"); - throw new NotImplementedException (); + return true; } } From ed404a7b7434f83c163e28ac1fdedf0cb4d170c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 16:35:47 +0000 Subject: [PATCH 20/93] More parameter renaming --- .../corlib/System.Threading.Tasks/Future.cs | 85 +++-- .../corlib/System.Threading.Tasks/Parallel.cs | 158 ++++---- .../ParallelLoopState.cs | 1 + .../corlib/System.Threading.Tasks/Task.cs | 7 +- .../TaskCanceledException.cs | 2 +- .../TaskCompletionSource.cs | 24 +- .../System.Threading.Tasks/TaskFactory.cs | 338 +++++++++--------- .../System.Threading.Tasks/TaskScheduler.cs | 2 + .../System.Threading/CancellationToken.cs | 12 +- .../CancellationTokenRegistration.cs | 8 +- .../CancellationTokenSource.cs | 6 +- .../corlib/System.Threading/CountdownEvent.cs | 70 ++-- .../System.Threading/LazyInitializer.cs | 14 +- .../LockRecursionException.cs | 8 +- .../System.Threading/ManualResetEventSlim.cs | 34 +- .../corlib/System.Threading/SemaphoreSlim.cs | 38 +- mcs/class/corlib/System.Threading/SpinLock.cs | 19 +- mcs/class/corlib/System.Threading/SpinWait.cs | 14 +- .../corlib/System.Threading/ThreadLocal.cs | 19 +- 19 files changed, 441 insertions(+), 418 deletions(-) diff --git a/mcs/class/corlib/System.Threading.Tasks/Future.cs b/mcs/class/corlib/System.Threading.Tasks/Future.cs index 295354fd609e..6075cdc0f70a 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Future.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Future.cs @@ -27,7 +27,8 @@ namespace System.Threading.Tasks { - + [System.Diagnostics.DebuggerDisplay ("Id = {Id}, Status = {Status}, Method = {DebuggerDisplayMethodDescription}, Result = {DebuggerDisplayResultDescription}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.SystemThreadingTasks_FutureDebugView`1")] public class Task: Task { TResult value; @@ -36,6 +37,7 @@ public class Task: Task Func function; object state; + [System.Diagnostics.DebuggerBrowsable (System.Diagnostics.DebuggerBrowsableState.Never)] public TResult Result { get { if (function != null) @@ -58,20 +60,20 @@ public Task (Func function) : this (function, TaskCreationOptions.None) } - public Task (Func function, CancellationToken token) - : this ((o) => function (), null, token, TaskCreationOptions.None) + public Task (Func function, CancellationToken cancellationToken) + : this ((o) => function (), null, cancellationToken, TaskCreationOptions.None) { } - public Task (Func function, TaskCreationOptions options) - : this ((o) => function (), null, CancellationToken.None, options) + public Task (Func function, TaskCreationOptions creationOptions) + : this ((o) => function (), null, CancellationToken.None, creationOptions) { } - public Task (Func function, CancellationToken token, TaskCreationOptions options) - : this ((o) => function (), null, token, options) + public Task (Func function, CancellationToken cancellationToken, TaskCreationOptions creationOptions) + : this ((o) => function (), null, cancellationToken, creationOptions) { } @@ -81,20 +83,20 @@ public Task (Func function, object state) : this (function, sta } - public Task (Func function, object state, CancellationToken token) - : this (function, state, token, TaskCreationOptions.None) + public Task (Func function, object state, CancellationToken cancellationToken) + : this (function, state, cancellationToken, TaskCreationOptions.None) { } - public Task (Func function, object state, TaskCreationOptions options) - : this (function, state, CancellationToken.None, options) + public Task (Func function, object state, TaskCreationOptions creationOptions) + : this (function, state, CancellationToken.None, creationOptions) { } - public Task (Func function, object state, CancellationToken token, TaskCreationOptions options) - : base (null, state, token, options) + public Task (Func function, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions) + : base (null, state, cancellationToken, creationOptions) { this.function = function; this.state = state; @@ -109,61 +111,70 @@ internal override void InnerInvoke () state = null; } - public Task ContinueWith (Action> a) + public Task ContinueWith (Action> continuationAction) { - return ContinueWith (a, TaskContinuationOptions.None); + return ContinueWith (continuationAction, TaskContinuationOptions.None); } - public Task ContinueWith (Action> a, TaskContinuationOptions options) + public Task ContinueWith (Action> continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWith (a, CancellationToken.None, options, TaskScheduler.Current); + return ContinueWith (continuationAction, CancellationToken.None, continuationOptions, TaskScheduler.Current); } - public Task ContinueWith (Action> a, CancellationToken token) + public Task ContinueWith (Action> continuationAction, CancellationToken cancellationToken) { - return ContinueWith (a, token, TaskContinuationOptions.None, TaskScheduler.Current); + return ContinueWith (continuationAction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current); } - public Task ContinueWith (Action> a, TaskScheduler scheduler) + public Task ContinueWith (Action> continuationAction, TaskScheduler scheduler) { - return ContinueWith (a, CancellationToken.None, TaskContinuationOptions.None, scheduler); + return ContinueWith (continuationAction, CancellationToken.None, TaskContinuationOptions.None, scheduler); } - public Task ContinueWith (Action> a, CancellationToken token, - TaskContinuationOptions options, TaskScheduler scheduler) + public Task ContinueWith (Action> continuationAction, CancellationToken cancellationToken, + TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - Task t = new Task ((o) => a ((Task)o), this, token, GetCreationOptions (options)); - ContinueWithCore (t, options, scheduler); + if (continuationAction == null) + throw new ArgumentNullException ("continuationFunction"); + if (scheduler == null) + throw new ArgumentNullException ("scheduler"); + + Task t = new Task ((o) => continuationAction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions)); + ContinueWithCore (t, continuationOptions, scheduler); return t; } - public Task ContinueWith (Func, TNewResult> a) + public Task ContinueWith (Func, TNewResult> continuationFunction) { - return ContinueWith (a, TaskContinuationOptions.None); + return ContinueWith (continuationFunction, TaskContinuationOptions.None); } - public Task ContinueWith (Func, TNewResult> a, CancellationToken token) + public Task ContinueWith (Func, TNewResult> continuationFunction, CancellationToken cancellationToken) { - return ContinueWith (a, token, TaskContinuationOptions.None, TaskScheduler.Current); + return ContinueWith (continuationFunction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current); } - public Task ContinueWith (Func, TNewResult> a, TaskContinuationOptions options) + public Task ContinueWith (Func, TNewResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWith (a, CancellationToken.None, options, TaskScheduler.Current); + return ContinueWith (continuationFunction, CancellationToken.None, continuationOptions, TaskScheduler.Current); } - public Task ContinueWith (Func, TNewResult> a, TaskScheduler scheduler) + public Task ContinueWith (Func, TNewResult> continuationFunction, TaskScheduler scheduler) { - return ContinueWith (a, CancellationToken.None, TaskContinuationOptions.None, scheduler); + return ContinueWith (continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler); } - public Task ContinueWith (Func, TNewResult> a, CancellationToken token, - TaskContinuationOptions options, + public Task ContinueWith (Func, TNewResult> continuationFunction, + CancellationToken cancellationToken, + TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - Task t = new Task ((o) => a ((Task)o), this, token, GetCreationOptions (options)); - ContinueWithCore (t, options, scheduler); + Task t = new Task ((o) => continuationFunction ((Task)o), + this, + cancellationToken, + GetCreationOptions (continuationOptions)); + ContinueWithCore (t, continuationOptions, scheduler); return t; } diff --git a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs index 1891be5b9095..ca47d658be89 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs @@ -92,62 +92,62 @@ static void InitTasks (Task[] tasks, int count, Action action, ParallelOptions o #region For - public static ParallelLoopResult For (int from, int to, Action action) + public static ParallelLoopResult For (int fromInclusive, int toExclusive, Action body) { - return For (from, to, ParallelOptions.Default, action); + return For (fromInclusive, toExclusive, ParallelOptions.Default, body); } - public static ParallelLoopResult For (int from, int to, Action action) + public static ParallelLoopResult For (int fromInclusive, int toExclusive, Action body) { - return For (from, to, ParallelOptions.Default, action); + return For (fromInclusive, toExclusive, ParallelOptions.Default, body); } - public static ParallelLoopResult For (int from, int to, ParallelOptions options, Action action) + public static ParallelLoopResult For (int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action body) { - return For (from, to, options, (index, state) => action (index)); + return For (fromInclusive, toExclusive, parallelOptions, (index, state) => body (index)); } - public static ParallelLoopResult For (int from, int to, ParallelOptions options, Action action) + public static ParallelLoopResult For (int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action body) { - return For (from, to, options, () => null, (i, s, l) => { action (i, s); return null; }, _ => {}); + return For (fromInclusive, toExclusive, parallelOptions, () => null, (i, s, l) => { body (i, s); return null; }, _ => {}); } - public static ParallelLoopResult For (int from, - int to, - Func init, - Func action, - Action destruct) + public static ParallelLoopResult For (int fromInclusive, + int toExclusive, + Func localInit, + Func body, + Action localFinally) { - return For (from, to, ParallelOptions.Default, init, action, destruct); + return For (fromInclusive, toExclusive, ParallelOptions.Default, localInit, body, localFinally); } - public static ParallelLoopResult For (int from, - int to, - ParallelOptions options, - Func init, - Func action, - Action destruct) + public static ParallelLoopResult For (int fromInclusive, + int toExclusive, + ParallelOptions parallelOptions, + Func localInit, + Func body, + Action localFinally) { - if (action == null) - throw new ArgumentNullException ("action"); - if (init == null) + if (body == null) + throw new ArgumentNullException ("body"); + if (localInit == null) throw new ArgumentNullException ("localInit"); - if (destruct == null) + if (localFinally == null) throw new ArgumentNullException ("localFinally"); - if (options == null) + if (parallelOptions == null) throw new ArgumentNullException ("options"); - if (from >= to) + if (fromInclusive >= toExclusive) return new ParallelLoopResult (null, true); - // Number of task to be launched (normally == Env.ProcessorCount) + // Number of task toExclusive be launched (normally == Env.ProcessorCount) int step; - int num = GetBestWorkerNumber (from, to, options, out step); + int num = GetBestWorkerNumber (fromInclusive, toExclusive, parallelOptions, out step); Task[] tasks = new Task [num]; StealRange[] ranges = new StealRange[num]; for (int i = 0; i < num; i++) - ranges[i] = new StealRange (from, i, step); + ranges[i] = new StealRange (fromInclusive, i, step); ParallelLoopState.ExternalInfos infos = new ParallelLoopState.ExternalInfos (); @@ -157,11 +157,11 @@ public static ParallelLoopResult For (int from, int localWorker = Interlocked.Increment (ref currentIndex); StealRange range = ranges[localWorker]; int index = range.Actual; - int stopIndex = localWorker + 1 == num ? to : Math.Min (to, index + step); - TLocal local = init (); + int stopIndex = localWorker + 1 == num ? toExclusive : Math.Min (toExclusive, index + step); + TLocal local = localInit (); ParallelLoopState state = new ParallelLoopState (infos); - CancellationToken token = options.CancellationToken; + CancellationToken token = parallelOptions.CancellationToken; try { for (int i = index; i < stopIndex; range.Actual = ++i) { @@ -174,18 +174,18 @@ public static ParallelLoopResult For (int from, return; state.CurrentIteration = i; - local = action (i, state, local); + local = body (i, state, local); if (i >= stopIndex - range.Stolen) break; } - // Try to steal from our right neighbor (cyclic) + // Try toExclusive steal fromInclusive our right neighbor (cyclic) int len = num + localWorker; for (int sIndex = localWorker + 1; sIndex < len; ++sIndex) { int extWorker = sIndex % num; range = ranges[extWorker]; - stopIndex = extWorker + 1 == num ? to : Math.Min (to, from + (extWorker + 1) * step); + stopIndex = extWorker + 1 == num ? toExclusive : Math.Min (toExclusive, fromInclusive + (extWorker + 1) * step); int stolen; do { @@ -197,17 +197,17 @@ public static ParallelLoopResult For (int from, stolen = stopIndex - stolen - 1; if (stolen > range.Actual) - local = action (stolen, state, local); + local = body (stolen, state, local); next: continue; } } finally { - destruct (local); + localFinally (local); } }; - InitTasks (tasks, num, workerMethod, options); + InitTasks (tasks, num, workerMethod, parallelOptions); try { Task.WaitAll (tasks); @@ -223,9 +223,9 @@ class StealRange public int Stolen; public int Actual; - public StealRange (int from, int i, int step) + public StealRange (int fromInclusive, int i, int step) { - Actual = from + i * step; + Actual = fromInclusive + i * step; } } @@ -316,47 +316,47 @@ static ParallelLoopResult ForEach (Func (IEnumerable enumerable, Action action) + public static ParallelLoopResult ForEach (IEnumerable source, Action body) { - if (enumerable == null) + if (source == null) throw new ArgumentNullException ("source"); - if (action == null) - throw new ArgumentNullException ("action"); + if (body == null) + throw new ArgumentNullException ("body"); - return ForEach (Partitioner.Create (enumerable), + return ForEach (Partitioner.Create (source), ParallelOptions.Default, () => null, - (e, s, l) => { action (e); return null; }, + (e, s, l) => { body (e); return null; }, _ => {}); } - public static ParallelLoopResult ForEach (IEnumerable enumerable, Action action) + public static ParallelLoopResult ForEach (IEnumerable source, Action body) { - if (enumerable == null) + if (source == null) throw new ArgumentNullException ("source"); - if (action == null) - throw new ArgumentNullException ("action"); + if (body == null) + throw new ArgumentNullException ("body"); - return ForEach (Partitioner.Create (enumerable), + return ForEach (Partitioner.Create (source), ParallelOptions.Default, () => null, - (e, s, l) => { action (e, s); return null; }, + (e, s, l) => { body (e, s); return null; }, _ => {}); } - public static ParallelLoopResult ForEach (IEnumerable enumerable, - Action action) + public static ParallelLoopResult ForEach (IEnumerable source, + Action body) { - if (enumerable == null) + if (source == null) throw new ArgumentNullException ("source"); - if (action == null) - throw new ArgumentNullException ("action"); + if (body == null) + throw new ArgumentNullException ("body"); - return ForEach (Partitioner.Create (enumerable), + return ForEach (Partitioner.Create (source), ParallelOptions.Default, () => null, - (e, s, l) => { action (e, s, -1); return null; }, + (e, s, l) => { body (e, s, -1); return null; }, _ => {}); } @@ -545,34 +545,34 @@ public static ParallelLoopResult ForEach (IEnumerable return ForEach (Partitioner.Create (source), parallelOptions, localInit, body, localFinally); } - public static ParallelLoopResult ForEach (Partitioner enumerable, ParallelOptions options, - Func init, - Func action, - Action destruct) + public static ParallelLoopResult ForEach (Partitioner source, ParallelOptions parallelOptions, + Func localInit, + Func body, + Action localFinally) { - if (enumerable == null) + if (source == null) throw new ArgumentNullException ("source"); - if (action == null) - throw new ArgumentNullException ("action"); + if (body == null) + throw new ArgumentNullException ("body"); - return ForEach (enumerable.GetPartitions, options, init, action, destruct); + return ForEach (source.GetPartitions, parallelOptions, localInit, body, localFinally); } - public static ParallelLoopResult ForEach (OrderablePartitioner enumerable, ParallelOptions options, - Func init, - Func action, - Action destruct) + public static ParallelLoopResult ForEach (OrderablePartitioner source, ParallelOptions parallelOptions, + Func localInit, + Func body, + Action localFinally) { - if (enumerable == null) + if (source == null) throw new ArgumentNullException ("source"); - if (action == null) - throw new ArgumentNullException ("action"); + if (body == null) + throw new ArgumentNullException ("body"); - return ForEach, TLocal> (enumerable.GetOrderablePartitions, - options, - init, - (e, s, l) => action (e.Value, s, e.Key, l), - destruct); + return ForEach, TLocal> (source.GetOrderablePartitions, + parallelOptions, + localInit, + (e, s, l) => body (e.Value, s, e.Key, l), + localFinally); } #endregion diff --git a/mcs/class/corlib/System.Threading.Tasks/ParallelLoopState.cs b/mcs/class/corlib/System.Threading.Tasks/ParallelLoopState.cs index adaa7f97a54d..e5606d5f1157 100644 --- a/mcs/class/corlib/System.Threading.Tasks/ParallelLoopState.cs +++ b/mcs/class/corlib/System.Threading.Tasks/ParallelLoopState.cs @@ -28,6 +28,7 @@ namespace System.Threading.Tasks { + [System.Diagnostics.DebuggerDisplayAttribute ("ShouldExitCurrentIteration = {ShouldExitCurrentIteration}")] public class ParallelLoopState { internal class ExternalInfos diff --git a/mcs/class/corlib/System.Threading.Tasks/Task.cs b/mcs/class/corlib/System.Threading.Tasks/Task.cs index 6c6a6899bccb..abb7c64b99eb 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Task.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Task.cs @@ -34,7 +34,7 @@ namespace System.Threading.Tasks [System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.SystemThreadingTasks_TaskDebugView")] public class Task : IDisposable, IAsyncResult { - // With this attribute each thread has itimeout own value so that it's correct for our Schedule code + // With this attribute each thread has its own value so that it's correct for our Schedule code // and for Parent property. [System.ThreadStatic] static Task current; @@ -233,6 +233,11 @@ public Task ContinueWith (Func continuationFunc public Task ContinueWith (Func continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { + if (continuationFunction == null) + throw new ArgumentNullException ("continuationFunction"); + if (scheduler == null) + throw new ArgumentNullException ("scheduler"); + Task t = new Task ((o) => continuationFunction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions)); ContinueWithCore (t, continuationOptions, scheduler); diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskCanceledException.cs b/mcs/class/corlib/System.Threading.Tasks/TaskCanceledException.cs index 80c2c4055e45..7f80dfc35562 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskCanceledException.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskCanceledException.cs @@ -41,7 +41,7 @@ public TaskCanceledException (string message): base (message) { } - public TaskCanceledException (string message, Exception inner): base (message, inner) + public TaskCanceledException (string message, Exception innerException): base (message, innerException) { } diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs b/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs index 25a896baa633..bfb4ba7ea0d9 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs @@ -46,15 +46,15 @@ public TaskCompletionSource (object state) source.SetupScheduler (TaskScheduler.Current); } - public TaskCompletionSource (TaskCreationOptions options) + public TaskCompletionSource (TaskCreationOptions creationOptions) { - source = new Task (null, options); + source = new Task (null, creationOptions); source.SetupScheduler (TaskScheduler.Current); } - public TaskCompletionSource (object state, TaskCreationOptions options) + public TaskCompletionSource (object state, TaskCreationOptions creationOptions) { - source = new Task (null, state, options); + source = new Task (null, state, creationOptions); source.SetupScheduler (TaskScheduler.Current); } @@ -64,14 +64,14 @@ public void SetCanceled () ThrowInvalidException (); } - public void SetException (Exception e) + public void SetException (Exception exception) { - SetException (new Exception[] { e }); + SetException (new Exception[] { exception }); } - public void SetException (IEnumerable e) + public void SetException (IEnumerable exceptions) { - if (!ApplyOperation (() => source.HandleGenericException (new AggregateException (e)))) + if (!ApplyOperation (() => source.HandleGenericException (new AggregateException (exceptions)))) ThrowInvalidException (); } @@ -91,14 +91,14 @@ public bool TrySetCanceled () return ApplyOperation (source.CancelReal); } - public bool TrySetException (Exception e) + public bool TrySetException (Exception exception) { - return TrySetException (new Exception[] { e }); + return TrySetException (new Exception[] { exception }); } - public bool TrySetException (IEnumerable e) + public bool TrySetException (IEnumerable exceptions) { - return ApplyOperation (() => source.HandleGenericException (new AggregateException (e))); + return ApplyOperation (() => source.HandleGenericException (new AggregateException (exceptions))); } public bool TrySetResult (TResult result) diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs b/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs index 4e5a2b68620a..eeefc6dc4d45 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs @@ -34,9 +34,9 @@ namespace System.Threading.Tasks public class TaskFactory { TaskScheduler scheduler; - TaskCreationOptions options; - TaskContinuationOptions contOptions; - CancellationToken token; + TaskCreationOptions creationOptions; + TaskContinuationOptions continuationOptions; + CancellationToken cancellationToken; #region ctors public TaskFactory () @@ -44,8 +44,8 @@ public TaskFactory () { } - public TaskFactory (CancellationToken token) - : this (token, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Current) + public TaskFactory (CancellationToken cancellationToken) + : this (cancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Current) { } @@ -54,61 +54,61 @@ public TaskFactory (TaskScheduler scheduler) { } - public TaskFactory (TaskCreationOptions options, TaskContinuationOptions contOptions) - : this (CancellationToken.None, options, contOptions, TaskScheduler.Current) + public TaskFactory (TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions) + : this (CancellationToken.None, creationOptions, continuationOptions, TaskScheduler.Current) { } - public TaskFactory (CancellationToken token, TaskCreationOptions options, TaskContinuationOptions contOptions, + public TaskFactory (CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - this.token = token; + this.cancellationToken = cancellationToken; this.scheduler = scheduler; - this.options = options; - this.contOptions = contOptions; + this.creationOptions = creationOptions; + this.continuationOptions = continuationOptions; } #endregion #region StartNew for Task public Task StartNew (Action action) { - return StartNew (action, token, options, scheduler); + return StartNew (action, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, CancellationToken token) + public Task StartNew (Action action, CancellationToken cancellationToken) { - return StartNew (action, token, options, scheduler); + return StartNew (action, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, TaskCreationOptions options) + public Task StartNew (Action action, TaskCreationOptions creationOptions) { - return StartNew (action, token, options, scheduler); + return StartNew (action, cancellationToken, creationOptions, scheduler); } public Task StartNew (Action action, object state) { - return StartNew (action, state, token, options, scheduler); + return StartNew (action, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, object state, CancellationToken token) + public Task StartNew (Action action, object state, CancellationToken cancellationToken) { - return StartNew (action, state, token, options, scheduler); + return StartNew (action, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, object state, TaskCreationOptions options) + public Task StartNew (Action action, object state, TaskCreationOptions creationOptions) { - return StartNew (action, state, token, options, scheduler); + return StartNew (action, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, CancellationToken token, TaskCreationOptions options, TaskScheduler scheduler) + public Task StartNew (Action action, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) { - return StartNew ((o) => action (), null, token, options, scheduler); + return StartNew ((o) => action (), null, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Action action, object state, CancellationToken token, TaskCreationOptions options, + public Task StartNew (Action action, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) { - Task t = new Task (action, state, token, options); + Task t = new Task (action, state, cancellationToken, creationOptions); t.Start (scheduler); return t; @@ -118,49 +118,49 @@ public Task StartNew (Action action, object state, CancellationToken tok #region StartNew for Task public Task StartNew (Func function) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, TaskCreationOptions options) + public Task StartNew (Func function, TaskCreationOptions creationOptions) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, CancellationToken token) + public Task StartNew (Func function, CancellationToken cancellationToken) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, - CancellationToken token, - TaskCreationOptions options, + CancellationToken cancellationToken, + TaskCreationOptions creationOptions, TaskScheduler scheduler) { - return StartNew ((o) => function (), null, token, options, scheduler); + return StartNew ((o) => function (), null, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, object state) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, object state, CancellationToken token) + public Task StartNew (Func function, object state, CancellationToken cancellationToken) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, object state, TaskCreationOptions options) + public Task StartNew (Func function, object state, TaskCreationOptions creationOptions) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, object state, - CancellationToken token, - TaskCreationOptions options, + CancellationToken cancellationToken, + TaskCreationOptions creationOptions, TaskScheduler scheduler) { - Task t = new Task (function, state, token, options); + Task t = new Task (function, state, cancellationToken, creationOptions); t.Start (scheduler); return t; @@ -171,20 +171,20 @@ public Task StartNew (Func function, object s public Task ContinueWhenAny (Task[] tasks, Action continuationAction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action continuationAction, CancellationToken token) + public Task ContinueWhenAny (Task[] tasks, Action continuationAction, CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAny (Task[] tasks, Action continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action continuationAction, CancellationToken token, + public Task ContinueWhenAny (Task[] tasks, Action continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); @@ -192,7 +192,7 @@ public Task ContinueWhenAny (Task[] tasks, Action continuationAction, Canc Task commonContinuation = new Task (null); foreach (Task t in ourTasks) { - Task cont = new Task ((o) => { continuationAction ((Task)o); }, t, token, options); + Task cont = new Task ((o) => { continuationAction ((Task)o); }, t, cancellationToken, creationOptions); t.ContinueWithCore (cont, continuationOptions, scheduler, trigger.TrySet); cont.ContinueWithCore (commonContinuation, TaskContinuationOptions.None, scheduler); } @@ -202,52 +202,52 @@ public Task ContinueWhenAny (Task[] tasks, Action continuationAction, Canc public Task ContinueWhenAny (Task[] tasks, Action> continuationAction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, - CancellationToken token) + CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, - CancellationToken token, TaskContinuationOptions continuationOptions, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWhenAny ((Task[]) tasks, (o) => continuationAction ((Task)o), - token, continuationOptions, scheduler); + cancellationToken, continuationOptions, scheduler); } [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationAction) + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationAction, - CancellationToken token) + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, + CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationAction, + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationAction, - CancellationToken token, + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { @@ -256,59 +256,59 @@ public Task ContinueWhenAny (Task[] tasks, Func [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction) + Func, TResult> continuationFunction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, - CancellationToken token) + Func, TResult> continuationFunction, + CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, + Func, TResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, - CancellationToken token, + Func, TResult> continuationFunction, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - return ContinueWhenAny ((Task[])tasks, (t) => continuationAction((Task)t), token, continuationOptions, scheduler); + return ContinueWhenAny ((Task[])tasks, (t) => continuationFunction((Task)t), cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAll (Task[] tasks, Action continuationFunction) + public Task ContinueWhenAll (Task[] tasks, Action continuationAction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAll (Task[] tasks, Action continuationFunction, CancellationToken token) + public Task ContinueWhenAll (Task[] tasks, Action continuationAction, CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAll (Task[] tasks, Action continuationFunction, + public Task ContinueWhenAll (Task[] tasks, Action continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAll (Task[] tasks, Action continuationFunction, CancellationToken token, + public Task ContinueWhenAll (Task[] tasks, Action continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction ((Task[])o), ourTasks, token, options); + Task cont = new Task ((o) => continuationAction ((Task[])o), ourTasks, cancellationToken, creationOptions); foreach (Task t in ourTasks) t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); @@ -317,56 +317,56 @@ public Task ContinueWhenAll (Task[] tasks, Action continuationFunction, } public Task ContinueWhenAll (Task[] tasks, - Action[]> continuationFunction) + Action[]> continuationAction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, - Action[]> continuationFunction, CancellationToken token) + Action[]> continuationAction, CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAll (Task[] tasks, Action[]> continuationFunction, + public Task ContinueWhenAll (Task[] tasks, Action[]> continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, - Action[]> continuationFunction, - CancellationToken token, TaskContinuationOptions continuationOptions, + Action[]> continuationAction, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - return ContinueWhenAll ((Task[]) tasks, (o) => continuationFunction (tasks), token, + return ContinueWhenAll ((Task[]) tasks, (o) => continuationAction (tasks), cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, - CancellationToken token) + CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, - CancellationToken token, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction ((Task[])o), ourTasks, token, options); + Task cont = new Task ((o) => continuationFunction ((Task[])o), ourTasks, cancellationToken, creationOptions); foreach (Task t in ourTasks) t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); @@ -377,32 +377,32 @@ public Task ContinueWhenAll (Task[] tasks, Func ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, - CancellationToken token) + CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, - CancellationToken token, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWhenAll ((Task[]) tasks, (o) => continuationFunction (tasks), - token, + cancellationToken, continuationOptions, scheduler); } @@ -419,7 +419,7 @@ public Task ContinueWhenAll (Task endMethod) { - return FromAsync (asyncResult, endMethod, options); + return FromAsync (asyncResult, endMethod, creationOptions); } [MonoLimitation(errorMsg)] @@ -439,7 +439,7 @@ public Task FromAsync (IAsyncResult asyncResult, Action endMethod, [MonoLimitation(errorMsg)] public Task FromAsync (IAsyncResult asyncResult, Func endMethod) { - return FromAsync (asyncResult, endMethod, options); + return FromAsync (asyncResult, endMethod, creationOptions); } [MonoLimitation(errorMsg)] @@ -461,7 +461,7 @@ public Task FromAsync (IAsyncResult asyncResult, Func beginMethod, Action endMethod, object state) { - return FromAsync ((a, c, o) => beginMethod (c, o), endMethod, state, options); + return FromAsync ((a, c, o) => beginMethod (c, o), endMethod, state, creationOptions); } [MonoLimitation(errorMsg)] @@ -587,19 +587,19 @@ public TaskScheduler Scheduler { public TaskContinuationOptions ContinuationOptions { get { - return contOptions; + return continuationOptions; } } public TaskCreationOptions CreationOptions { get { - return options; + return creationOptions; } } public CancellationToken CancellationToken { get { - return token; + return cancellationToken; } } } @@ -607,9 +607,9 @@ public CancellationToken CancellationToken { public class TaskFactory { TaskScheduler scheduler; - TaskCreationOptions options; - TaskContinuationOptions contOptions; - CancellationToken token; + TaskCreationOptions creationOptions; + TaskContinuationOptions continuationOptions; + CancellationToken cancellationToken; TaskFactory parent; @@ -624,25 +624,25 @@ public TaskFactory (TaskScheduler scheduler) { } - public TaskFactory (CancellationToken token) - : this (token, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Current) + public TaskFactory (CancellationToken cancellationToken) + : this (cancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Current) { } - public TaskFactory (TaskCreationOptions options, TaskContinuationOptions contOptions) - : this (CancellationToken.None, options, contOptions, TaskScheduler.Current) + public TaskFactory (TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions) + : this (CancellationToken.None, creationOptions, continuationOptions, TaskScheduler.Current) { } - public TaskFactory (CancellationToken token, TaskCreationOptions options, TaskContinuationOptions contOptions, + public TaskFactory (CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - this.token = token; + this.cancellationToken = cancellationToken; this.scheduler = scheduler; - this.options = options; - this.contOptions = contOptions; + this.creationOptions = creationOptions; + this.continuationOptions = continuationOptions; - this.parent = new TaskFactory (token, options, contOptions, scheduler); + this.parent = new TaskFactory (cancellationToken, creationOptions, continuationOptions, scheduler); } #endregion @@ -650,48 +650,48 @@ public TaskFactory (CancellationToken token, TaskCreationOptions options, TaskCo #region StartNew for Task public Task StartNew (Func function) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, TaskCreationOptions options) + public Task StartNew (Func function, TaskCreationOptions creationOptions) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, CancellationToken token) + public Task StartNew (Func function, CancellationToken cancellationToken) { - return StartNew (function, token, options, scheduler); + return StartNew (function, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, - CancellationToken token, - TaskCreationOptions options, + CancellationToken cancellationToken, + TaskCreationOptions creationOptions, TaskScheduler scheduler) { - return StartNew ((o) => function (), null, token, options, scheduler); + return StartNew ((o) => function (), null, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, object state) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, object state, TaskCreationOptions options) + public Task StartNew (Func function, object state, TaskCreationOptions creationOptions) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } - public Task StartNew (Func function, object state, CancellationToken token) + public Task StartNew (Func function, object state, CancellationToken cancellationToken) { - return StartNew (function, state, token, options, scheduler); + return StartNew (function, state, cancellationToken, creationOptions, scheduler); } public Task StartNew (Func function, object state, - CancellationToken token, - TaskCreationOptions options, + CancellationToken cancellationToken, + TaskCreationOptions creationOptions, TaskScheduler scheduler) { - return parent.StartNew (function, state, token, options, scheduler); + return parent.StartNew (function, state, cancellationToken, creationOptions, scheduler); } #endregion @@ -699,31 +699,31 @@ public Task StartNew (Func function, object state, [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func continuationAction) + Func continuationFunction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func continuationAction, - CancellationToken token) + Func continuationFunction, + CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func continuationAction, + Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func continuationAction, - CancellationToken token, + Func continuationFunction, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { @@ -732,31 +732,31 @@ public Task ContinueWhenAny (Task[] tasks, [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction) + Func, TResult> continuationFunction) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, - CancellationToken token) + Func, TResult> continuationFunction, + CancellationToken cancellationToken) { - return ContinueWhenAny (tasks, continuationAction, token, contOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, + Func, TResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAny (tasks, continuationAction, token, continuationOptions, scheduler); + return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } [MonoTODO] public Task ContinueWhenAny (Task[] tasks, - Func, TResult> continuationAction, - CancellationToken token, + Func, TResult> continuationFunction, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { @@ -766,31 +766,31 @@ public Task ContinueWhenAny (Task public Task ContinueWhenAll (Task[] tasks, Func continuationFunction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, - CancellationToken token) + CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func continuationFunction, - CancellationToken token, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, token, options); + Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, cancellationToken, creationOptions); foreach (Task t in ourTasks) t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); @@ -801,31 +801,31 @@ public Task ContinueWhenAll (Task[] tasks, public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWhenAll (tasks, continuationFunction, token, continuationOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, - CancellationToken token) + CancellationToken cancellationToken) { - return ContinueWhenAll (tasks, continuationFunction, token, contOptions, scheduler); + return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, Func[], TResult> continuationFunction, - CancellationToken token, + CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, token, options); + Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, cancellationToken, creationOptions); foreach (Task t in ourTasks) t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); @@ -841,7 +841,7 @@ public Task ContinueWhenAll (Task [MonoLimitation(errorMsg)] public Task FromAsync (IAsyncResult asyncResult, Func endMethod) { - return FromAsync (asyncResult, endMethod, options); + return FromAsync (asyncResult, endMethod, creationOptions); } [MonoLimitation(errorMsg)] @@ -932,19 +932,19 @@ public TaskScheduler Scheduler { public TaskContinuationOptions ContinuationOptions { get { - return contOptions; + return continuationOptions; } } public TaskCreationOptions CreationOptions { get { - return options; + return creationOptions; } } public CancellationToken CancellationToken { get { - return token; + return cancellationToken; } } } diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs b/mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs index 1084dbe254c8..64f596af698b 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs @@ -31,6 +31,8 @@ namespace System.Threading.Tasks { + [System.Diagnostics.DebuggerDisplay ("Id={Id}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.TaskScheduler+SystemThreadingTasks_TaskSchedulerDebugView")] public abstract class TaskScheduler { static TaskScheduler defaultScheduler = new Scheduler (); diff --git a/mcs/class/corlib/System.Threading/CancellationToken.cs b/mcs/class/corlib/System.Threading/CancellationToken.cs index f541e770b546..e97047fd138e 100644 --- a/mcs/class/corlib/System.Threading/CancellationToken.cs +++ b/mcs/class/corlib/System.Threading/CancellationToken.cs @@ -82,9 +82,9 @@ public bool Equals (CancellationToken other) return this.Source == other.Source; } - public override bool Equals (object obj) + public override bool Equals (object other) { - return (obj is CancellationToken) ? Equals ((CancellationToken)obj) : false; + return (other is CancellationToken) ? Equals ((CancellationToken)other) : false; } public override int GetHashCode () @@ -92,14 +92,14 @@ public override int GetHashCode () return Source.GetHashCode (); } - public static bool operator == (CancellationToken lhs, CancellationToken rhs) + public static bool operator == (CancellationToken left, CancellationToken right) { - return lhs.Equals (rhs); + return left.Equals (right); } - public static bool operator != (CancellationToken lhs, CancellationToken rhs) + public static bool operator != (CancellationToken left, CancellationToken right) { - return !lhs.Equals (rhs); + return !left.Equals (right); } public bool CanBeCanceled { diff --git a/mcs/class/corlib/System.Threading/CancellationTokenRegistration.cs b/mcs/class/corlib/System.Threading/CancellationTokenRegistration.cs index 1e4e0b69efd9..6560b351388c 100644 --- a/mcs/class/corlib/System.Threading/CancellationTokenRegistration.cs +++ b/mcs/class/corlib/System.Threading/CancellationTokenRegistration.cs @@ -56,14 +56,14 @@ public bool Equals (CancellationTokenRegistration other) return this.id == other.id && this.source == other.source; } - public static bool operator== (CancellationTokenRegistration lhs, CancellationTokenRegistration rhs) + public static bool operator== (CancellationTokenRegistration left, CancellationTokenRegistration right) { - return lhs.Equals (rhs); + return left.Equals (right); } - public static bool operator!= (CancellationTokenRegistration lhs, CancellationTokenRegistration rhs) + public static bool operator!= (CancellationTokenRegistration left, CancellationTokenRegistration right) { - return !lhs.Equals (rhs); + return !left.Equals (right); } #endregion diff --git a/mcs/class/corlib/System.Threading/CancellationTokenSource.cs b/mcs/class/corlib/System.Threading/CancellationTokenSource.cs index 05ca53a182f1..54a61b29b7a8 100644 --- a/mcs/class/corlib/System.Threading/CancellationTokenSource.cs +++ b/mcs/class/corlib/System.Threading/CancellationTokenSource.cs @@ -53,18 +53,18 @@ public void Cancel () } // If parameter is true we throw exception as soon as they appear otherwise we aggregate them - public void Cancel (bool throwOnFirst) + public void Cancel (bool throwOnFirstException) { canceled = true; handle.Set (); List exceptions = null; - if (!throwOnFirst) + if (!throwOnFirstException) exceptions = new List (); lock (callbacks) { foreach (KeyValuePair item in callbacks) { - if (throwOnFirst) { + if (throwOnFirstException) { item.Value (); } else { try { diff --git a/mcs/class/corlib/System.Threading/CountdownEvent.cs b/mcs/class/corlib/System.Threading/CountdownEvent.cs index fd31339fd358..504ca68515af 100644 --- a/mcs/class/corlib/System.Threading/CountdownEvent.cs +++ b/mcs/class/corlib/System.Threading/CountdownEvent.cs @@ -30,15 +30,15 @@ namespace System.Threading { public class CountdownEvent : IDisposable { - int count; + int initialCount; int initial; ManualResetEventSlim evt = new ManualResetEventSlim (false); - public CountdownEvent (int count) + public CountdownEvent (int initialCount) { - if (count < 0) - throw new ArgumentOutOfRangeException ("count is negative"); - this.initial = this.count = count; + if (initialCount < 0) + throw new ArgumentOutOfRangeException ("initialCount is negative"); + this.initial = this.initialCount = initialCount; } public bool Signal () @@ -46,18 +46,18 @@ public bool Signal () return Signal (1); } - public bool Signal (int num) + public bool Signal (int signalCount) { - if (num <= 0) - throw new ArgumentOutOfRangeException ("num"); + if (signalCount <= 0) + throw new ArgumentOutOfRangeException ("signalCount"); Action check = delegate (int value) { if (value < 0) - throw new InvalidOperationException ("the specified count is larger that CurrentCount"); + throw new InvalidOperationException ("the specified initialCount is larger that CurrentCount"); }; int newValue; - if (!ApplyOperation (-num, check, out newValue)) + if (!ApplyOperation (-signalCount, check, out newValue)) throw new InvalidOperationException ("The event is already set"); if (newValue == 0) { @@ -73,12 +73,12 @@ public void AddCount () AddCount (1); } - public void AddCount (int num) + public void AddCount (int signalCount) { - if (num < 0) - throw new ArgumentOutOfRangeException ("num"); + if (signalCount < 0) + throw new ArgumentOutOfRangeException ("signalCount"); - if (!TryAddCount (num)) + if (!TryAddCount (signalCount)) throw new InvalidOperationException ("The event is already set"); } @@ -87,12 +87,12 @@ public bool TryAddCount () return TryAddCount (1); } - public bool TryAddCount (int num) + public bool TryAddCount (int signalCount) { - if (num < 0) - throw new ArgumentOutOfRangeException ("num"); + if (signalCount < 0) + throw new ArgumentOutOfRangeException ("signalCount"); - return ApplyOperation (num, null); + return ApplyOperation (signalCount, null); } bool ApplyOperation (int num, Action doCheck) @@ -107,7 +107,7 @@ bool ApplyOperation (int num, Action doCheck, out int newValue) newValue = 0; do { - oldCount = count; + oldCount = initialCount; if (oldCount == 0) return false; @@ -115,7 +115,7 @@ bool ApplyOperation (int num, Action doCheck, out int newValue) if (doCheck != null) doCheck (newValue); - } while (Interlocked.CompareExchange (ref count, newValue, oldCount) != oldCount); + } while (Interlocked.CompareExchange (ref initialCount, newValue, oldCount) != oldCount); return true; } @@ -125,29 +125,29 @@ public void Wait () evt.Wait (); } - public void Wait (CancellationToken token) + public void Wait (CancellationToken cancellationToken) { - evt.Wait (token); + evt.Wait (cancellationToken); } - public bool Wait (int timeoutMilli) + public bool Wait (int millisecondsTimeout) { - return evt.Wait (timeoutMilli); + return evt.Wait (millisecondsTimeout); } - public bool Wait(TimeSpan span) + public bool Wait(TimeSpan timeout) { - return evt.Wait (span); + return evt.Wait (timeout); } - public bool Wait (int timeoutMilli, CancellationToken token) + public bool Wait (int millisecondsTimeout, CancellationToken cancellationToken) { - return evt.Wait (timeoutMilli, token); + return evt.Wait (millisecondsTimeout, cancellationToken); } - public bool Wait(TimeSpan span, CancellationToken token) + public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { - return evt.Wait (span, token); + return evt.Wait (timeout, cancellationToken); } public void Reset () @@ -155,15 +155,15 @@ public void Reset () Reset (initial); } - public void Reset (int value) + public void Reset (int count) { evt.Reset (); - count = initial = value; + initialCount = initial = count; } public int CurrentCount { get { - return count; + return initialCount; } } @@ -175,7 +175,7 @@ public int InitialCount { public bool IsSet { get { - return count == 0; + return initialCount == 0; } } @@ -192,7 +192,7 @@ public void Dispose () } - protected virtual void Dispose (bool managedRes) + protected virtual void Dispose (bool disposing) { } diff --git a/mcs/class/corlib/System.Threading/LazyInitializer.cs b/mcs/class/corlib/System.Threading/LazyInitializer.cs index 9b4ada957ac2..a96204085c7a 100644 --- a/mcs/class/corlib/System.Threading/LazyInitializer.cs +++ b/mcs/class/corlib/System.Threading/LazyInitializer.cs @@ -37,27 +37,27 @@ public static T EnsureInitialized (ref T target) where T : class return EnsureInitialized (ref target, GetDefaultCtorValue); } - public static T EnsureInitialized (ref T target, Func initFunc) where T : class + public static T EnsureInitialized (ref T target, Func valueFactory) where T : class { if (target == null) - Interlocked.CompareExchange (ref target, initFunc (), null); + Interlocked.CompareExchange (ref target, valueFactory (), null); return target; } - public static T EnsureInitialized (ref T target, ref bool initialized, ref object syncRoot) + public static T EnsureInitialized (ref T target, ref bool initialized, ref object syncLock) { - return EnsureInitialized (ref target, ref initialized, ref syncRoot, GetDefaultCtorValue); + return EnsureInitialized (ref target, ref initialized, ref syncLock, GetDefaultCtorValue); } - public static T EnsureInitialized (ref T target, ref bool initialized, ref object syncRoot, Func initFunc) + public static T EnsureInitialized (ref T target, ref bool initialized, ref object syncLock, Func valueFactory) { - lock (syncRoot) { + lock (syncLock) { if (initialized) return target; initialized = true; - return target = initFunc (); + return target = valueFactory (); } } diff --git a/mcs/class/corlib/System.Threading/LockRecursionException.cs b/mcs/class/corlib/System.Threading/LockRecursionException.cs index d70d24c70e4a..1a8f7a8e25f9 100644 --- a/mcs/class/corlib/System.Threading/LockRecursionException.cs +++ b/mcs/class/corlib/System.Threading/LockRecursionException.cs @@ -47,13 +47,13 @@ public LockRecursionException (string message) { } - public LockRecursionException (string message, Exception e) - : base (message, e) + public LockRecursionException (string message, Exception innerException) + : base (message, innerException) { } - protected LockRecursionException (SerializationInfo info, StreamingContext sc) - : base (info, sc) + protected LockRecursionException (SerializationInfo info, StreamingContext context) + : base (info, context) { } } diff --git a/mcs/class/corlib/System.Threading/ManualResetEventSlim.cs b/mcs/class/corlib/System.Threading/ManualResetEventSlim.cs index 46a814d58bb9..69841e581171 100644 --- a/mcs/class/corlib/System.Threading/ManualResetEventSlim.cs +++ b/mcs/class/corlib/System.Threading/ManualResetEventSlim.cs @@ -45,16 +45,16 @@ public ManualResetEventSlim () : this (false, defaultSpinCount) { } - public ManualResetEventSlim (bool initState) : this (initState, defaultSpinCount) + public ManualResetEventSlim (bool initialState) : this (initialState, defaultSpinCount) { } - public ManualResetEventSlim (bool initState, int spinCount) + public ManualResetEventSlim (bool initialState, int spinCount) { if (spinCount < 0) throw new ArgumentOutOfRangeException ("spinCount is less than 0", "spinCount"); - this.state = initState ? isSet : isNotSet; + this.state = initialState ? isSet : isNotSet; this.spinCount = spinCount; } @@ -94,39 +94,39 @@ public bool Wait (int millisecondsTimeout) return Wait (millisecondsTimeout, CancellationToken.None); } - public bool Wait (TimeSpan ts) + public bool Wait (TimeSpan timeout) { - return Wait ((int)ts.TotalMilliseconds, CancellationToken.None); + return Wait ((int)timeout.TotalMilliseconds, CancellationToken.None); } - public void Wait (CancellationToken token) + public void Wait (CancellationToken cancellationToken) { - Wait (-1, token); + Wait (-1, cancellationToken); } - public bool Wait (int ms, CancellationToken token) + public bool Wait (int millisecondsTimeout, CancellationToken cancellationToken) { - if (ms < -1) + if (millisecondsTimeout < -1) throw new ArgumentOutOfRangeException ("millisecondsTimeout", "millisecondsTimeout is a negative number other than -1"); - long start = ms == -1 ? 0 : sw.ElapsedMilliseconds; + long start = millisecondsTimeout == -1 ? 0 : sw.ElapsedMilliseconds; SpinWait wait = new SpinWait (); while (state == isNotSet) { - token.ThrowIfCancellationRequested (); + cancellationToken.ThrowIfCancellationRequested (); - if (ms > -1 && (sw.ElapsedMilliseconds - start) > ms) + if (millisecondsTimeout > -1 && (sw.ElapsedMilliseconds - start) > millisecondsTimeout) return false; if (wait.Count < spinCount) { wait.SpinOnce (); } else { - int waitTime = ms == -1 ? -1 : Math.Max (ms - (int)(sw.ElapsedMilliseconds - start) , 1); + int waitTime = millisecondsTimeout == -1 ? -1 : Math.Max (millisecondsTimeout - (int)(sw.ElapsedMilliseconds - start) , 1); WaitHandle handle = WaitHandle; if (state == isSet) return true; - if (WaitHandle.WaitAny (new[] { handle, token.WaitHandle }, waitTime, false) == 0) + if (WaitHandle.WaitAny (new[] { handle, cancellationToken.WaitHandle }, waitTime, false) == 0) return true; } } @@ -134,9 +134,9 @@ public bool Wait (int ms, CancellationToken token) return true; } - public bool Wait (TimeSpan ts, CancellationToken token) + public bool Wait (TimeSpan timeout, CancellationToken cancellationToken) { - return Wait ((int)ts.TotalMilliseconds, token); + return Wait ((int)timeout.TotalMilliseconds, cancellationToken); } public WaitHandle WaitHandle { @@ -154,7 +154,7 @@ public void Dispose () Dispose(true); } - protected virtual void Dispose(bool managedRes) + protected virtual void Dispose (bool disposing) { } diff --git a/mcs/class/corlib/System.Threading/SemaphoreSlim.cs b/mcs/class/corlib/System.Threading/SemaphoreSlim.cs index 340d95057c0a..455951ad78d7 100644 --- a/mcs/class/corlib/System.Threading/SemaphoreSlim.cs +++ b/mcs/class/corlib/System.Threading/SemaphoreSlim.cs @@ -33,24 +33,24 @@ public class SemaphoreSlim : IDisposable const int spinCount = 10; const int deepSleepTime = 20; - readonly int max; + readonly int maxCount; int currCount; bool isDisposed; EventWaitHandle handle; - public SemaphoreSlim (int initial) : this (initial, int.MaxValue) + public SemaphoreSlim (int initialCount) : this (initialCount, int.MaxValue) { } - public SemaphoreSlim (int initial, int max) + public SemaphoreSlim (int initialCount, int maxCount) { - if (initial < 0 || initial > max || max < 0) - throw new ArgumentOutOfRangeException ("The initial argument is negative, initial is greater than max, or max is not positive."); + if (initialCount < 0 || initialCount > maxCount || maxCount < 0) + throw new ArgumentOutOfRangeException ("The initialCount argument is negative, initialCount is greater than maxCount, or maxCount is not positive."); - this.max = max; - this.currCount = initial; - this.handle = new ManualResetEvent (initial == 0); + this.maxCount = maxCount; + this.currCount = initialCount; + this.handle = new ManualResetEvent (initialCount == 0); } ~SemaphoreSlim () @@ -63,7 +63,7 @@ public void Dispose () Dispose(true); } - protected virtual void Dispose (bool managedRes) + protected virtual void Dispose (bool disposing) { isDisposed = true; } @@ -96,7 +96,7 @@ public int Release (int releaseCount) do { oldValue = currCount; newValue = (currCount + releaseCount); - newValue = newValue > max ? max : newValue; + newValue = newValue > maxCount ? maxCount : newValue; } while (Interlocked.CompareExchange (ref currCount, newValue, oldValue) != oldValue); handle.Set (); @@ -109,9 +109,9 @@ public void Wait () Wait (CancellationToken.None); } - public bool Wait (TimeSpan ts) + public bool Wait (TimeSpan timeout) { - return Wait ((int)ts.TotalMilliseconds, CancellationToken.None); + return Wait ((int)timeout.TotalMilliseconds, CancellationToken.None); } public bool Wait (int millisecondsTimeout) @@ -119,18 +119,18 @@ public bool Wait (int millisecondsTimeout) return Wait (millisecondsTimeout, CancellationToken.None); } - public void Wait (CancellationToken token) + public void Wait (CancellationToken cancellationToken) { - Wait (-1, token); + Wait (-1, cancellationToken); } - public bool Wait (TimeSpan ts, CancellationToken token) + public bool Wait (TimeSpan timeout, CancellationToken cancellationToken) { CheckState(); - return Wait ((int)ts.TotalMilliseconds, token); + return Wait ((int)timeout.TotalMilliseconds, cancellationToken); } - public bool Wait (int millisecondsTimeout, CancellationToken token) + public bool Wait (int millisecondsTimeout, CancellationToken cancellationToken) { CheckState (); if (millisecondsTimeout < -1) @@ -146,7 +146,7 @@ public bool Wait (int millisecondsTimeout, CancellationToken token) int result; do { - token.ThrowIfCancellationRequested (); + cancellationToken.ThrowIfCancellationRequested (); if (stopCondition ()) return false; @@ -168,7 +168,7 @@ public bool Wait (int millisecondsTimeout, CancellationToken token) SpinWait wait = new SpinWait (); while (Thread.VolatileRead (ref currCount) <= 0) { - token.ThrowIfCancellationRequested (); + cancellationToken.ThrowIfCancellationRequested (); if (stopCondition ()) return false; diff --git a/mcs/class/corlib/System.Threading/SpinLock.cs b/mcs/class/corlib/System.Threading/SpinLock.cs index 055b7fcefbe3..122a3f094b2d 100644 --- a/mcs/class/corlib/System.Threading/SpinLock.cs +++ b/mcs/class/corlib/System.Threading/SpinLock.cs @@ -44,6 +44,8 @@ internal struct TicketType { // Implement the ticket SpinLock algorithm described on http://locklessinc.com/articles/locks/ // This lock is usable on both endianness // TODO: some 32 bits platform apparently doesn't support CAS with 64 bits value + [System.Diagnostics.DebuggerDisplay ("IsHeld = {IsHeld}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Threading.SpinLock+SystemThreading_SpinLockDebugView")] public struct SpinLock { TicketType ticket; @@ -76,9 +78,9 @@ public bool IsHeldByCurrentThread { } } - public SpinLock (bool trackId) + public SpinLock (bool enableThreadOwnerTracking) { - this.isThreadOwnerTrackingEnabled = trackId; + this.isThreadOwnerTrackingEnabled = enableThreadOwnerTracking; this.threadWhoTookLock = 0; this.ticket = new TicketType (); } @@ -118,16 +120,16 @@ public void TryEnter (TimeSpan timeout, ref bool lockTaken) TryEnter ((int)timeout.TotalMilliseconds, ref lockTaken); } - public void TryEnter (int milliSeconds, ref bool lockTaken) + public void TryEnter (int millisecondsTimeout, ref bool lockTaken) { - if (milliSeconds < -1) + if (millisecondsTimeout < -1) throw new ArgumentOutOfRangeException ("milliSeconds", "millisecondsTimeout is a negative number other than -1"); if (lockTaken) throw new ArgumentException ("lockTaken", "lockTaken must be initialized to false"); if (isThreadOwnerTrackingEnabled && IsHeldByCurrentThread) throw new LockRecursionException (); - long start = milliSeconds == -1 ? 0 : sw.ElapsedMilliseconds; + long start = millisecondsTimeout == -1 ? 0 : sw.ElapsedMilliseconds; bool stop = false; do { @@ -146,7 +148,7 @@ long newTotalValue stop = true; } } - } while (!stop && (milliSeconds == -1 || (sw.ElapsedMilliseconds - start) < milliSeconds)); + } while (!stop && (millisecondsTimeout == -1 || (sw.ElapsedMilliseconds - start) < millisecondsTimeout)); } public void Exit () @@ -154,7 +156,8 @@ public void Exit () Exit (false); } - public void Exit (bool flushReleaseWrites) + [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)] + public void Exit (bool useMemoryBarrier) { RuntimeHelpers.PrepareConstrainedRegions (); try {} @@ -164,7 +167,7 @@ public void Exit (bool flushReleaseWrites) threadWhoTookLock = int.MinValue; // Fast path - if (flushReleaseWrites) + if (useMemoryBarrier) Interlocked.Increment (ref ticket.Value); else ticket.Value++; diff --git a/mcs/class/corlib/System.Threading/SpinWait.cs b/mcs/class/corlib/System.Threading/SpinWait.cs index 435ed4dabc59..67f67afd071a 100644 --- a/mcs/class/corlib/System.Threading/SpinWait.cs +++ b/mcs/class/corlib/System.Threading/SpinWait.cs @@ -52,25 +52,25 @@ public void SpinOnce () } } - public static void SpinUntil (Func predicate) + public static void SpinUntil (Func condition) { SpinWait sw = new SpinWait (); - while (!predicate ()) + while (!condition ()) sw.SpinOnce (); } - public static bool SpinUntil (Func predicate, TimeSpan ts) + public static bool SpinUntil (Func condition, TimeSpan timeout) { - return SpinUntil (predicate, (int)ts.TotalMilliseconds); + return SpinUntil (condition, (int)timeout.TotalMilliseconds); } - public static bool SpinUntil (Func predicate, int milliseconds) + public static bool SpinUntil (Func condition, int millisecondsTimeout) { SpinWait sw = new SpinWait (); Watch watch = Watch.StartNew (); - while (!predicate ()) { - if (watch.ElapsedMilliseconds > milliseconds) + while (!condition ()) { + if (watch.ElapsedMilliseconds > millisecondsTimeout) return false; sw.SpinOnce (); } diff --git a/mcs/class/corlib/System.Threading/ThreadLocal.cs b/mcs/class/corlib/System.Threading/ThreadLocal.cs index 9fb6bc7bf3e1..313615f10ae4 100644 --- a/mcs/class/corlib/System.Threading/ThreadLocal.cs +++ b/mcs/class/corlib/System.Threading/ThreadLocal.cs @@ -32,11 +32,12 @@ namespace System.Threading { - [HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, - ExternalThreading = true)] + [HostProtection (SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)] + [System.Diagnostics.DebuggerDisplay ("IsValueCreated={IsValueCreated}, Value={ValueForDebugDisplay}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Threading.SystemThreading_ThreadLocalDebugView`1")] public class ThreadLocal : IDisposable { - readonly Func initializer; + readonly Func valueFactory; LocalDataStoreSlot localStore; Exception cachedException; @@ -51,13 +52,13 @@ public ThreadLocal () : this (LazyInitializer.GetDefaultCtorValue) { } - public ThreadLocal (Func initializer) + public ThreadLocal (Func valueFactory) { - if (initializer == null) - throw new ArgumentNullException ("initializer"); + if (valueFactory == null) + throw new ArgumentNullException ("valueFactory"); localStore = Thread.AllocateDataSlot (); - this.initializer = initializer; + this.valueFactory = valueFactory; } public void Dispose () @@ -65,7 +66,7 @@ public void Dispose () Dispose (true); } - protected virtual void Dispose (bool dispManagedRes) + protected virtual void Dispose (bool disposing) { } @@ -133,7 +134,7 @@ void ThrowIfNeeded () DataSlotWrapper DataSlotCreator () { DataSlotWrapper wrapper = new DataSlotWrapper (); - Func valSelector = initializer; + Func valSelector = valueFactory; wrapper.Getter = delegate { wrapper.Creating = true; From 89fecf7d97e6644a94dce23dcc7a5db7a6af1d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 17:09:19 +0000 Subject: [PATCH 21/93] Yet more parameter manual fixup --- .../ConcurrentDictionary.cs | 18 ++++---- .../ConcurrentQueue.cs | 26 +++++------ .../ConcurrentStack.cs | 43 ++++++++++--------- .../Partitioner.cs | 8 ++-- 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs index 6e78662d0139..957b7df739e0 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs @@ -47,10 +47,10 @@ public ConcurrentDictionary () : this (EqualityComparer.Default) { } - public ConcurrentDictionary (IEnumerable> values) - : this (values, EqualityComparer.Default) + public ConcurrentDictionary (IEnumerable> collection) + : this (collection, EqualityComparer.Default) { - foreach (KeyValuePair pair in values) + foreach (KeyValuePair pair in collection) Add (pair.Key, pair.Value); } @@ -59,10 +59,10 @@ public ConcurrentDictionary (IEqualityComparer comparer) this.comparer = comparer; } - public ConcurrentDictionary (IEnumerable> values, IEqualityComparer comparer) + public ConcurrentDictionary (IEnumerable> collection, IEqualityComparer comparer) : this (comparer) { - foreach (KeyValuePair pair in values) + foreach (KeyValuePair pair in collection) Add (pair.Key, pair.Value); } @@ -74,9 +74,9 @@ public ConcurrentDictionary (int concurrencyLevel, int capacity) } public ConcurrentDictionary (int concurrencyLevel, - IEnumerable> values, + IEnumerable> collection, IEqualityComparer comparer) - : this (values, comparer) + : this (collection, comparer) { } @@ -145,9 +145,9 @@ public bool TryGetValue (TKey key, out TValue value) return result; } - public bool TryUpdate (TKey key, TValue newValue, TValue comparand) + public bool TryUpdate (TKey key, TValue newValue, TValue comparisonValue) { - return internalDictionary.CompareExchange (Hash (key), Make (key, newValue), (e) => e.Value.Equals (comparand)); + return internalDictionary.CompareExchange (Hash (key), Make (key, newValue), (e) => e.Value.Equals (comparisonValue)); } public TValue this[TKey key] { diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs index 5c4f1923ae7d..1b2622410a70 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs @@ -32,7 +32,9 @@ namespace System.Collections.Concurrent { - + + [System.Diagnostics.DebuggerDisplay ("Count = {Count}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Collections.Concurrent.SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView`1")] public class ConcurrentQueue : IProducerConsumerCollection, IEnumerable, ICollection, IEnumerable { @@ -51,9 +53,9 @@ public ConcurrentQueue () tail = head; } - public ConcurrentQueue (IEnumerable enumerable): this() + public ConcurrentQueue (IEnumerable collection): this() { - foreach (T item in enumerable) + foreach (T item in collection) Enqueue (item); } @@ -93,9 +95,9 @@ bool IProducerConsumerCollection.TryAdd (T item) return true; } - public bool TryDequeue (out T value) + public bool TryDequeue (out T result) { - value = default (T); + result = default (T); bool advanced = false; while (!advanced) { @@ -111,10 +113,10 @@ public bool TryDequeue (out T value) // If not then the linked list is mal formed, update tail Interlocked.CompareExchange (ref tail, oldNext, oldTail); } - value = default (T); + result = default (T); return false; } else { - value = oldNext.Value; + result = oldNext.Value; advanced = Interlocked.CompareExchange (ref head, oldNext, oldHead) == oldHead; } } @@ -125,15 +127,15 @@ public bool TryDequeue (out T value) return true; } - public bool TryPeek (out T value) + public bool TryPeek (out T result) { if (IsEmpty) { - value = default (T); + result = default (T); return false; } Node first = head.Next; - value = first.Value; + result = first.Value; return true; } @@ -169,12 +171,12 @@ void ICollection.CopyTo (Array array, int index) CopyTo (dest, index); } - public void CopyTo (T[] dest, int index) + public void CopyTo (T[] array, int index) { IEnumerator e = InternalGetEnumerator (); int i = index; while (e.MoveNext ()) { - dest [i++] = e.Current; + array [i++] = e.Current; } } diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs index edc3c5c1f6a7..7a2df80b6878 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs @@ -33,7 +33,8 @@ namespace System.Collections.Concurrent { - + [System.Diagnostics.DebuggerDisplay ("Count = {Count}")] + [System.Diagnostics.DebuggerTypeProxy ("System.Collections.Concurrent.SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView`1")] public class ConcurrentStack : IProducerConsumerCollection, IEnumerable, ICollection, IEnumerable { @@ -51,9 +52,9 @@ public ConcurrentStack () { } - public ConcurrentStack (IEnumerable enumerable) + public ConcurrentStack (IEnumerable collection) { - foreach (T item in enumerable) + foreach (T item in collection) Push (item); } @@ -63,10 +64,10 @@ bool IProducerConsumerCollection.TryAdd (T elem) return true; } - public void Push (T element) + public void Push (T item) { Node temp = new Node (); - temp.Value = element; + temp.Value = item; do { temp.Next = head; } while (Interlocked.CompareExchange (ref head, temp, temp.Next) != temp.Next); @@ -74,19 +75,19 @@ public void Push (T element) Interlocked.Increment (ref count); } - public void PushRange (T[] values) + public void PushRange (T[] items) { - PushRange (values, 0, values.Length); + PushRange (items, 0, items.Length); } - public void PushRange (T[] values, int start, int length) + public void PushRange (T[] items, int start, int length) { Node insert = null; Node first = null; for (int i = start; i < length; i++) { Node temp = new Node (); - temp.Value = values[i]; + temp.Value = items[i]; temp.Next = insert; insert = temp; @@ -101,30 +102,30 @@ public void PushRange (T[] values, int start, int length) Interlocked.Add (ref count, length); } - public bool TryPop (out T value) + public bool TryPop (out T result) { Node temp; do { temp = head; // The stak is empty if (temp == null) { - value = default (T); + result = default (T); return false; } } while (Interlocked.CompareExchange (ref head, temp.Next, temp) != temp); Interlocked.Decrement (ref count); - value = temp.Value; + result = temp.Value; return true; } - public int TryPopRange (T[] values) + public int TryPopRange (T[] items) { - return TryPopRange (values, 0, values.Length); + return TryPopRange (items, 0, items.Length); } - public int TryPopRange (T[] values, int startIndex, int count) + public int TryPopRange (T[] items, int startIndex, int count) { Node temp; Node end; @@ -143,21 +144,21 @@ public int TryPopRange (T[] values, int startIndex, int count) int i; for (i = startIndex; i < count && temp != null; i++) { - values[i] = temp.Value; + items[i] = temp.Value; temp = temp.Next; } return i - 1; } - public bool TryPeek (out T value) + public bool TryPeek (out T result) { Node myHead = head; if (myHead == null) { - value = default (T); + result = default (T); return false; } - value = myHead.Value; + result = myHead.Value; return true; } @@ -198,12 +199,12 @@ void ICollection.CopyTo (Array array, int index) CopyTo (dest, index); } - public void CopyTo (T[] dest, int index) + public void CopyTo (T[] array, int index) { IEnumerator e = InternalGetEnumerator (); int i = index; while (e.MoveNext ()) { - dest[i++] = e.Current; + array[i++] = e.Current; } } diff --git a/mcs/class/corlib/System.Collections.Concurrent/Partitioner.cs b/mcs/class/corlib/System.Collections.Concurrent/Partitioner.cs index 3521622f3636..194e7734a3f6 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/Partitioner.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/Partitioner.cs @@ -44,14 +44,14 @@ public static OrderablePartitioner Create (IEnumerable (source); } - public static OrderablePartitioner Create (TSource[] source, bool loadBalance) + public static OrderablePartitioner Create (TSource[] array, bool loadBalance) { - return Create ((IList)source, loadBalance); + return Create ((IList)array, loadBalance); } - public static OrderablePartitioner Create (IList source, bool loadBalance) + public static OrderablePartitioner Create (IList list, bool loadBalance) { - return new ListPartitioner (source); + return new ListPartitioner (list); } public static OrderablePartitioner> Create (int fromInclusive, From 1a29dfd26056cbdaedb28e0d585a3c975ee3c7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 17:09:47 +0000 Subject: [PATCH 22/93] Add prototype for Parallel.For long overloads --- .../corlib/System.Threading.Tasks/Parallel.cs | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs index ca47d658be89..0d7ebc109ea8 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs @@ -90,7 +90,7 @@ static void InitTasks (Task[] tasks, int count, Action action, ParallelOptions o } } - #region For +#region For public static ParallelLoopResult For (int fromInclusive, int toExclusive, Action body) { @@ -229,9 +229,69 @@ public StealRange (int fromInclusive, int i, int step) } } - #endregion +#endregion + +#region For (long) + + [MonoTODO] + public static ParallelLoopResult For (long fromInclusive, long toExclusive, Action body) + { + return For (fromInclusive, toExclusive, ParallelOptions.Default, body); + } + + [MonoTODO] + public static ParallelLoopResult For (long fromInclusive, long toExclusive, Action body) + { + return For (fromInclusive, toExclusive, ParallelOptions.Default, body); + } + + [MonoTODO] + public static ParallelLoopResult For (long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action body) + { + return For (fromInclusive, toExclusive, parallelOptions, (index, state) => body (index)); + } - #region Foreach + [MonoTODO] + public static ParallelLoopResult For (long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action body) + { + return For (fromInclusive, toExclusive, parallelOptions, () => null, (i, s, l) => { body (i, s); return null; }, _ => {}); + } + + [MonoTODO] + public static ParallelLoopResult For (long fromInclusive, + long toExclusive, + Func localInit, + Func body, + Action localFinally) + { + return For (fromInclusive, toExclusive, ParallelOptions.Default, localInit, body, localFinally); + } + + [MonoTODO ("See how this can be refactored with the above For implementation")] + public static ParallelLoopResult For (long fromInclusive, + long toExclusive, + ParallelOptions parallelOptions, + Func localInit, + Func body, + Action localFinally) + { + if (body == null) + throw new ArgumentNullException ("body"); + if (localInit == null) + throw new ArgumentNullException ("localInit"); + if (localFinally == null) + throw new ArgumentNullException ("localFinally"); + if (parallelOptions == null) + throw new ArgumentNullException ("options"); + if (fromInclusive >= toExclusive) + return new ParallelLoopResult (null, true); + + throw new NotImplementedException (); + } + +#endregion + +#region Foreach static ParallelLoopResult ForEach (Func>> enumerable, ParallelOptions options, Func init, Func action, Action destruct) @@ -660,7 +720,7 @@ internal static Task[] SpawnBestNumber (Action action, int dop, bool wait, Actio return tasks; } - #endregion +#endregion } } #endif From edef0d70bcbd43d7db15b8ac7569e4683c0645eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 17:10:17 +0000 Subject: [PATCH 23/93] Add missing members in AggregateException --- mcs/class/corlib/System/AggregateException.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mcs/class/corlib/System/AggregateException.cs b/mcs/class/corlib/System/AggregateException.cs index df5cefbd2a08..0a4b105af355 100644 --- a/mcs/class/corlib/System/AggregateException.cs +++ b/mcs/class/corlib/System/AggregateException.cs @@ -30,7 +30,9 @@ namespace System { + [System.SerializableAttribute] + [System.Diagnostics.DebuggerDisplay ("Count = {InnerExceptions.Count}")] public class AggregateException : Exception { List innerExceptions; @@ -114,6 +116,16 @@ public override string ToString () { return this.Message; } + + public override Exception GetBaseException () + { + return this; + } + + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + throw new NotImplementedException (); + } static string GetFormattedMessage (string customMessage, IEnumerable inner) { From 1b5c2e4dd9ce2187ef2ff0a4382d0dd2f8ac6a0b Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 15:48:14 +0000 Subject: [PATCH 24/93] [659528] Fixed cloning of switch sections --- mcs/mcs/statement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index 646ad2d4c64c..e09dde738313 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -3108,7 +3108,7 @@ public SwitchSection Clone (CloneContext clonectx) { var cloned_labels = new List (); - foreach (SwitchLabel sl in cloned_labels) + foreach (SwitchLabel sl in Labels) cloned_labels.Add (sl.Clone (clonectx)); return new SwitchSection (cloned_labels, clonectx.LookupBlock (Block)); From 7b27c2f3f3a88c92fbd011a33af015369e93fc42 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 17:08:10 +0000 Subject: [PATCH 25/93] [659536] Don't re-create array expressions when infering implicit array type --- mcs/mcs/expression.cs | 37 ++++++++++++++++++++++++++++++++++--- mcs/mcs/generic.cs | 25 +++++++++++++++---------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs index 9289f179c51e..18c77b06aa12 100644 --- a/mcs/mcs/expression.cs +++ b/mcs/mcs/expression.cs @@ -6653,7 +6653,38 @@ protected override void CloneTo (CloneContext clonectx, Expression t) // class ImplicitlyTypedArrayCreation : ArrayCreation { - TypeInferenceContext best_type_inference; + sealed class InferenceContext : TypeInferenceContext + { + class ExpressionBoundInfo : BoundInfo + { + readonly Expression expr; + + public ExpressionBoundInfo (Expression expr) + : base (expr.Type, BoundKind.Lower) + { + this.expr = expr; + } + + public override bool Equals (BoundInfo other) + { + // We are using expression not type for conversion check + // no optimization based on types is possible + return false; + } + + public override Expression GetTypeExpression () + { + return expr; + } + } + + public void AddExpression (Expression expr) + { + AddToBounds (new ExpressionBoundInfo (expr), 0); + } + } + + InferenceContext best_type_inference; public ImplicitlyTypedArrayCreation (ComposedTypeSpecifier rank, ArrayInitializer initializers, Location loc) : base (null, rank, initializers, loc) @@ -6672,7 +6703,7 @@ protected override Expression DoResolve (ResolveContext ec) dimensions = rank.Dimension; - best_type_inference = new TypeInferenceContext (); + best_type_inference = new InferenceContext (); if (!ResolveInitializers (ec)) return null; @@ -6716,7 +6747,7 @@ protected override Expression ResolveArrayElement (ResolveContext ec, Expression { element = element.Resolve (ec); if (element != null) - best_type_inference.AddCommonTypeBound (element.Type); + best_type_inference.AddExpression (element); return element; } diff --git a/mcs/mcs/generic.cs b/mcs/mcs/generic.cs index 902b3b5befaa..23b4cf19b3a4 100644 --- a/mcs/mcs/generic.cs +++ b/mcs/mcs/generic.cs @@ -2473,14 +2473,14 @@ bool DoSecondPhase (ResolveContext ec, TypeInferenceContext tic, TypeSpec[] meth public class TypeInferenceContext { - enum BoundKind + protected enum BoundKind { Exact = 0, Lower = 1, Upper = 2 } - class BoundInfo : IEquatable + protected class BoundInfo : IEquatable { public readonly TypeSpec Type; public readonly BoundKind Kind; @@ -2496,9 +2496,14 @@ public override int GetHashCode () return Type.GetHashCode (); } + public virtual Expression GetTypeExpression () + { + return new TypeExpression (Type, Location.Null); + } + #region IEquatable Members - public bool Equals (BoundInfo other) + public virtual bool Equals (BoundInfo other) { return Type == other.Type && Kind == other.Kind; } @@ -2554,7 +2559,7 @@ public void AddCommonTypeBound (TypeSpec type) AddToBounds (new BoundInfo (type, BoundKind.Lower), 0); } - void AddToBounds (BoundInfo bound, int index) + protected void AddToBounds (BoundInfo bound, int index) { // // Some types cannot be used as type arguments @@ -2760,14 +2765,14 @@ public bool FixType (ResolveContext ec, int i) if (bound.Kind == BoundKind.Exact || cbound.Kind == BoundKind.Exact) { if (cbound.Kind == BoundKind.Lower) { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (cbound.Type, Location.Null), bound.Type)) { + if (!Convert.ImplicitConversionExists (ec, cbound.GetTypeExpression (), bound.Type)) { break; } continue; } if (cbound.Kind == BoundKind.Upper) { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (bound.Type, Location.Null), cbound.Type)) { + if (!Convert.ImplicitConversionExists (ec, bound.GetTypeExpression (), cbound.Type)) { break; } @@ -2775,7 +2780,7 @@ public bool FixType (ResolveContext ec, int i) } if (bound.Kind != BoundKind.Exact) { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (bound.Type, Location.Null), cbound.Type)) { + if (!Convert.ImplicitConversionExists (ec, bound.GetTypeExpression (), cbound.Type)) { break; } @@ -2788,11 +2793,11 @@ public bool FixType (ResolveContext ec, int i) if (bound.Kind == BoundKind.Lower) { if (cbound.Kind == BoundKind.Lower) { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (cbound.Type, Location.Null), bound.Type)) { + if (!Convert.ImplicitConversionExists (ec, cbound.GetTypeExpression (), bound.Type)) { break; } } else { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (bound.Type, Location.Null), cbound.Type)) { + if (!Convert.ImplicitConversionExists (ec, bound.GetTypeExpression (), cbound.Type)) { break; } @@ -2803,7 +2808,7 @@ public bool FixType (ResolveContext ec, int i) } if (bound.Kind == BoundKind.Upper) { - if (!Convert.ImplicitConversionExists (ec, new TypeExpression (bound.Type, Location.Null), cbound.Type)) { + if (!Convert.ImplicitConversionExists (ec, bound.GetTypeExpression (), cbound.Type)) { break; } } else { From 78d78bc4666dd2fd8bf19af4636bb2b5eb77cde1 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 17:09:43 +0000 Subject: [PATCH 26/93] New tests. --- mcs/tests/gtest-anon-23.cs | 20 +++++++++++ mcs/tests/gtest-implicitarray-03.cs | 18 ++++++++++ mcs/tests/ver-il-gmcs.xml | 52 ++++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 mcs/tests/gtest-implicitarray-03.cs diff --git a/mcs/tests/gtest-anon-23.cs b/mcs/tests/gtest-anon-23.cs index 6ff5738983e8..6358a2a2418f 100644 --- a/mcs/tests/gtest-anon-23.cs +++ b/mcs/tests/gtest-anon-23.cs @@ -20,6 +20,12 @@ public int? MyTypeProperty { } } +enum E +{ + E1, + E2 +} + public class B { protected virtual void BaseM () @@ -35,6 +41,11 @@ static void Test (D d) { } + static void Test (Action func) + { + func (E.E1); + } + void InstanceTests () { Test (() => base.BaseM ()); @@ -82,6 +93,15 @@ public static void Main () }; }); + Test (x => { + switch (x) { + case E.E1: + goto case E.E2; + case E.E2: + break; + } + }); + var c = new C (); c.InstanceTests (); } diff --git a/mcs/tests/gtest-implicitarray-03.cs b/mcs/tests/gtest-implicitarray-03.cs new file mode 100644 index 000000000000..97ab1ba3370d --- /dev/null +++ b/mcs/tests/gtest-implicitarray-03.cs @@ -0,0 +1,18 @@ +using System; +using System.Linq.Expressions; + +public static class InferArrayType +{ + public static void foo (Func[] args) + { + } + + public static void bar (Action seq, Func action) + { + foo (new[] { p => { seq (p); return true; }, action }); + } + + public static void Main () + { + } +} diff --git a/mcs/tests/ver-il-gmcs.xml b/mcs/tests/ver-il-gmcs.xml index d8ea2e4e4478..13f778ae5908 100644 --- a/mcs/tests/ver-il-gmcs.xml +++ b/mcs/tests/ver-il-gmcs.xml @@ -11034,6 +11034,29 @@ + + + + 7 + + + + + 17 + + + 7 + + + + + 26 + + + 7 + + + @@ -14543,7 +14566,7 @@ 1 - 212 + 246 @@ -14612,6 +14635,12 @@ 7 + + 8 + + + 31 + @@ -20189,6 +20218,27 @@ + + + + 1 + + + 44 + + + 1 + + + + + 14 + + + 7 + + + From a24ada6a4e6d979c7768ae249bd37268546d4a0c Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 17:24:16 +0000 Subject: [PATCH 27/93] Fixed cloning of default switch case --- mcs/mcs/statement.cs | 3 +++ mcs/tests/gtest-anon-23.cs | 5 ++++- mcs/tests/ver-il-gmcs.xml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index e09dde738313..2700144ddd07 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -3090,6 +3090,9 @@ public void Error_AlreadyOccurs (ResolveContext ec, TypeSpec switch_type, Switch public SwitchLabel Clone (CloneContext clonectx) { + if (label == null) + return this; + return new SwitchLabel (label.Clone (clonectx), loc); } } diff --git a/mcs/tests/gtest-anon-23.cs b/mcs/tests/gtest-anon-23.cs index 6358a2a2418f..91c72b45afe6 100644 --- a/mcs/tests/gtest-anon-23.cs +++ b/mcs/tests/gtest-anon-23.cs @@ -23,7 +23,8 @@ public int? MyTypeProperty { enum E { E1, - E2 + E2, + E3 } public class B @@ -99,6 +100,8 @@ public static void Main () goto case E.E2; case E.E2: break; + default: + break; } }); diff --git a/mcs/tests/ver-il-gmcs.xml b/mcs/tests/ver-il-gmcs.xml index 13f778ae5908..439de26d894d 100644 --- a/mcs/tests/ver-il-gmcs.xml +++ b/mcs/tests/ver-il-gmcs.xml @@ -14639,7 +14639,7 @@ 8 - 31 + 36 From c0b19d1afc89d37d8b68e2ddd443269a2cde5a33 Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Wed, 15 Dec 2010 18:35:18 +0100 Subject: [PATCH 28/93] Make sure AppdDomain.PermissionSet doesn't return null --- mcs/class/corlib/System/AppDomain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index 881b64d99a9b..b73252f49c02 100644 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -226,7 +226,7 @@ internal PermissionSet GrantedPermissionSet { #if NET_4_0 public PermissionSet PermissionSet { - get { return this.GrantedPermissionSet; } + get { return _granted ?? (_granted = new PermissionSet (PermissionState.Unrestricted)); } } #endif From 5976833aee14743ed116e6a86130fb91994efcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 15 Dec 2010 17:43:11 +0000 Subject: [PATCH 29/93] Sys.Core parameters fixup --- .../System.Linq/ParallelEnumerable.cs | 356 +++++++++--------- .../System.Threading.Tasks/TaskExtensions.cs | 16 +- 2 files changed, 186 insertions(+), 186 deletions(-) diff --git a/mcs/class/System.Core/System.Linq/ParallelEnumerable.cs b/mcs/class/System.Core/System.Linq/ParallelEnumerable.cs index 9b4d15fc1232..ae1845bb9c2e 100644 --- a/mcs/class/System.Core/System.Linq/ParallelEnumerable.cs +++ b/mcs/class/System.Core/System.Linq/ParallelEnumerable.cs @@ -48,12 +48,12 @@ public static ParallelQuery Range (int start, int count) return (new RangeList (start, count)).AsParallel (); } - public static ParallelQuery Repeat (TResult obj, int count) + public static ParallelQuery Repeat (TResult element, int count) { if (count < 0) throw new ArgumentOutOfRangeException ("count", "count is less than 0"); - return (new RepeatList (obj, count)).AsParallel (); + return (new RepeatList (element, count)).AsParallel (); } #endregion @@ -176,14 +176,14 @@ public static ParallelQuery WithMergeOptions (this ParallelQue } public static ParallelQuery WithDegreeOfParallelism (this ParallelQuery source, - int degreeParallelism) + int degreeOfParallelism) { - if (degreeParallelism < 1 || degreeParallelism > 63) - throw new ArgumentException ("degreeOfParallelism is less than 1 or greater than 63", "degreeParallelism"); + if (degreeOfParallelism < 1 || degreeOfParallelism > 63) + throw new ArgumentException ("degreeOfParallelism is less than 1 or greater than 63", "degreeOfParallelism"); if (source == null) throw new ArgumentNullException ("source"); - return new ParallelQuery (new DegreeOfParallelismNode (degreeParallelism, source.Node)); + return new ParallelQuery (new DegreeOfParallelismNode (degreeOfParallelism, source.Node)); } internal static ParallelQuery WithImplementerToken (this ParallelQuery source, @@ -334,15 +334,15 @@ public static TResult Aggregate (this ParallelQue } public static TResult Aggregate (this ParallelQuery source, - Func seedFunc, + Func seedFactory, Func updateAccumulatorFunc, Func combineAccumulatorsFunc, Func resultSelector) { if (source == null) throw new ArgumentNullException ("source"); - if (seedFunc == null) - throw new ArgumentNullException ("seedFunc"); + if (seedFactory == null) + throw new ArgumentNullException ("seedFactory"); if (updateAccumulatorFunc == null) throw new ArgumentNullException ("updateAccumulatorFunc"); if (combineAccumulatorsFunc == null) @@ -352,7 +352,7 @@ public static TResult Aggregate (this ParallelQue TAccumulate accumulator = default (TAccumulate); - ParallelExecuter.ProcessAndAggregate (source.Node, seedFunc, updateAccumulatorFunc, (list) => { + ParallelExecuter.ProcessAndAggregate (source.Node, seedFactory, updateAccumulatorFunc, (list) => { accumulator = list [0]; for (int i = 1; i < list.Count; i++) accumulator = combineAccumulatorsFunc (accumulator, list[i]); @@ -1215,104 +1215,104 @@ public static float Average (this ParallelQuery source) return source.Select ((e) => e.HasValue ? e.Value : 0).Average (); } - public static double Average (this ParallelQuery source, Func func) + public static double Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static double Average (this ParallelQuery source, Func func) + public static double Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static float Average (this ParallelQuery source, Func func) + public static float Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static double Average (this ParallelQuery source, Func func) + public static double Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static decimal Average (this ParallelQuery source, Func func) + public static decimal Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static double? Average (this ParallelQuery source, Func func) + public static double? Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static double? Average (this ParallelQuery source, Func func) + public static double? Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static float? Average (this ParallelQuery source, Func func) + public static float? Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static double? Average (this ParallelQuery source, Func func) + public static double? Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } - public static decimal? Average (this ParallelQuery source, Func func) + public static decimal? Average (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Average (); + return source.Select (selector).Average (); } #endregion @@ -1394,104 +1394,104 @@ public static decimal Sum (this ParallelQuery source) return source.Select ((e) => e.HasValue ? e.Value : 0).Sum (); } - public static int Sum (this ParallelQuery source, Func func) + public static int Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static long Sum (this ParallelQuery source, Func func) + public static long Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static decimal Sum (this ParallelQuery source, Func func) + public static decimal Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static float Sum (this ParallelQuery source, Func func) + public static float Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static double Sum (this ParallelQuery source, Func func) + public static double Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static int? Sum (this ParallelQuery source, Func func) + public static int? Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static long? Sum (this ParallelQuery source, Func func) + public static long? Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static decimal? Sum (this ParallelQuery source, Func func) + public static decimal? Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static float? Sum (this ParallelQuery source, Func func) + public static float? Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } - public static double? Sum (this ParallelQuery source, Func func) + public static double? Sum (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Sum (); + return source.Select (selector).Sum (); } #endregion @@ -1542,14 +1542,14 @@ public static TSource Min (this ParallelQuery source) return BestOrder (source, (first, second) => comparer.Compare (first, second) < 0, default (TSource)); } - public static TResult Min (this ParallelQuery source, Func func) + public static TResult Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } public static int? Min (this ParallelQuery source) @@ -1592,104 +1592,104 @@ public static TResult Min (this ParallelQuery source, return source.Select ((e) => e.HasValue ? e.Value : decimal.MaxValue).Min (); } - public static int Min (this ParallelQuery source, Func func) + public static int Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static long Min (this ParallelQuery source, Func func) + public static long Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static float Min (this ParallelQuery source, Func func) + public static float Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static double Min (this ParallelQuery source, Func func) + public static double Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static decimal Min (this ParallelQuery source, Func func) + public static decimal Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static int? Min (this ParallelQuery source, Func func) + public static int? Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static long? Min (this ParallelQuery source, Func func) + public static long? Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static float? Min (this ParallelQuery source, Func func) + public static float? Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static double? Min (this ParallelQuery source, Func func) + public static double? Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } - public static decimal? Min (this ParallelQuery source, Func func) + public static decimal? Min (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Min (); + return source.Select (selector).Min (); } public static int Max (this ParallelQuery source) @@ -1724,14 +1724,14 @@ public static TSource Max (this ParallelQuery source) return BestOrder (source, (first, second) => comparer.Compare (first, second) > 0, default (TSource)); } - public static TResult Max (this ParallelQuery source, Func func) + public static TResult Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } public static int? Max (this ParallelQuery source) @@ -1774,104 +1774,104 @@ public static TResult Max (this ParallelQuery source, return source.Select ((e) => e.HasValue ? e.Value : decimal.MinValue).Max (); } - public static int Max (this ParallelQuery source, Func func) + public static int Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static long Max (this ParallelQuery source, Func func) + public static long Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static float Max (this ParallelQuery source, Func func) + public static float Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static double Max (this ParallelQuery source, Func func) + public static double Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static decimal Max (this ParallelQuery source, Func func) + public static decimal Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static int? Max (this ParallelQuery source, Func func) + public static int? Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static long? Max (this ParallelQuery source, Func func) + public static long? Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static float? Max (this ParallelQuery source, Func func) + public static float? Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static double? Max (this ParallelQuery source, Func func) + public static double? Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } - public static decimal? Max (this ParallelQuery source, Func func) + public static decimal? Max (this ParallelQuery source, Func selector) { if (source == null) throw new ArgumentNullException ("source"); - if (func == null) - throw new ArgumentNullException ("func"); + if (selector == null) + throw new ArgumentNullException ("selector"); - return source.Select (func).Max (); + return source.Select (selector).Max (); } #endregion diff --git a/mcs/class/System.Core/System.Threading.Tasks/TaskExtensions.cs b/mcs/class/System.Core/System.Threading.Tasks/TaskExtensions.cs index fec880656c1f..0eecf7e5bda2 100644 --- a/mcs/class/System.Core/System.Threading.Tasks/TaskExtensions.cs +++ b/mcs/class/System.Core/System.Threading.Tasks/TaskExtensions.cs @@ -37,26 +37,26 @@ public static class TaskExtensions { const TaskContinuationOptions opt = TaskContinuationOptions.ExecuteSynchronously; - public static Task Unwrap (this Task> outer) + public static Task Unwrap (this Task> task) { - if (outer == null) - throw new ArgumentNullException ("outer"); + if (task == null) + throw new ArgumentNullException ("task"); TaskCompletionSource src = new TaskCompletionSource (); - outer.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (t2.Result)), opt)), opt); + task.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (t2.Result)), opt)), opt); return src.Task; } - public static Task Unwrap (this Task outer) + public static Task Unwrap (this Task task) { - if (outer == null) - throw new ArgumentNullException ("outer"); + if (task == null) + throw new ArgumentNullException ("task"); TaskCompletionSource src = new TaskCompletionSource (); - outer.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (null)), opt)), opt); + task.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (null)), opt)), opt); return src.Task; } From 50278f2555e69d56f9b5d68373517c6f20755b07 Mon Sep 17 00:00:00 2001 From: Bojan Rajkovic Date: Wed, 15 Dec 2010 15:51:54 -0500 Subject: [PATCH 30/93] Correct LDFLAGS on the Darwin platform so the profiler will build. --- mono/profiler/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mono/profiler/Makefile.am b/mono/profiler/Makefile.am index ff3a90092dcc..f92e001b1853 100644 --- a/mono/profiler/Makefile.am +++ b/mono/profiler/Makefile.am @@ -14,6 +14,8 @@ if JIT_SUPPORTED if PLATFORM_LINUX bin_PROGRAMS = mprof-report lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la +else if PLATFORM_DARWIN +libmono_profiler_log_la_LDFLAGS = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace else bin_PROGRAMS = mprof-report lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la From 446ab2fafe3f35a50133e6e602777d67324bad18 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 16 Dec 2010 02:13:50 +0100 Subject: [PATCH 31/93] Modify the Mono EH Frame decoding so it handles the LSDA+type_info embedded into the FDE. --- mono/mini/aot-runtime.c | 12 +++++++----- mono/mini/unwind.c | 33 ++++++++++++++++----------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index 6912e3385f78..b4be90aa2e54 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include "mono/utils/mono-compiler.h" @@ -1595,14 +1596,15 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain, /* Count number of nested clauses */ nested_len = 0; for (i = 0; i < ei_len; ++i) { - gint32 cindex1 = *(gint32*)type_info [i]; + /* This might be unaligned */ + gint32 cindex1 = read32 (type_info [i]); GSList *l; for (l = nesting [cindex1]; l; l = l->next) { gint32 nesting_cindex = GPOINTER_TO_INT (l->data); for (j = 0; j < ei_len; ++j) { - gint32 cindex2 = *(gint32*)type_info [j]; + gint32 cindex2 = read32 (type_info [j]); if (cindex2 == nesting_cindex) nested_len ++; @@ -1632,7 +1634,7 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain, * compiler, we have to combine that with the information produced by LLVM */ /* The type_info entries contain IL clause indexes */ - int clause_index = *(gint32*)type_info [i]; + int clause_index = read32 (type_info [i]); MonoJitExceptionInfo *jei = &jinfo->clauses [i]; MonoJitExceptionInfo *orig_jei = &clauses [clause_index]; @@ -1648,14 +1650,14 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain, /* See exception_cb () in mini-llvm.c as to why this is needed */ nindex = ei_len; for (i = 0; i < ei_len; ++i) { - gint32 cindex1 = *(gint32*)type_info [i]; + gint32 cindex1 = read32 (type_info [i]); GSList *l; for (l = nesting [cindex1]; l; l = l->next) { gint32 nesting_cindex = GPOINTER_TO_INT (l->data); for (j = 0; j < ei_len; ++j) { - gint32 cindex2 = *(gint32*)type_info [j]; + gint32 cindex2 = read32 (type_info [j]); if (cindex2 == nesting_cindex) { /* diff --git a/mono/mini/unwind.c b/mono/mini/unwind.c index 2f1302065a8a..df3058114d47 100644 --- a/mono/mini/unwind.c +++ b/mono/mini/unwind.c @@ -774,6 +774,10 @@ decode_lsda (guint8 *lsda, guint8 *code, MonoJitExceptionInfo **ex_info, guint32 guint8 *ttype_entry = (ttype - (type_offset * 4)); gint32 offset = *(gint32*)ttype_entry; tinfo = ttype_entry + offset; + } else if (ttype_encoding == DW_EH_PE_udata4) { + /* Embedded directly */ + guint8 *ttype_entry = (ttype - (type_offset * 4)); + tinfo = ttype_entry; } else { g_assert_not_reached (); } @@ -976,7 +980,7 @@ void mono_unwind_decode_llvm_mono_fde (guint8 *fde, int fde_len, guint8 *cie, guint8 *code, MonoLLVMFDEInfo *res) { guint8 *p, *fde_aug, *cie_cfi, *fde_cfi, *buf; - int aug_len, cie_cfi_len, fde_cfi_len; + int has_aug, aug_len, cie_cfi_len, fde_cfi_len; gint32 code_align, data_align, return_reg, pers_encoding; memset (res, 0, sizeof (*res)); @@ -985,30 +989,25 @@ mono_unwind_decode_llvm_mono_fde (guint8 *fde, int fde_len, guint8 *cie, guint8 /* fde points to data emitted by LLVM in DwarfException::EmitMonoEHFrame () */ p = fde; - aug_len = *p; + has_aug = *p; p ++; + if (has_aug) { + aug_len = read32 (p); + p += 4; + } else { + aug_len = 0; + } fde_aug = p; p += aug_len; fde_cfi = p; - if (aug_len) { - gint32 lsda_offset; + if (has_aug) { guint8 *lsda; - /* LSDA pointer */ - - /* sdata|pcrel encoding */ - if (aug_len == 4) - lsda_offset = read32 (fde_aug); - else if (aug_len == 8) - lsda_offset = *(gint64*)fde_aug; - else - g_assert_not_reached (); - if (lsda_offset != 0) { - lsda = fde_aug + lsda_offset; + /* The LSDA is embedded directly into the FDE */ + lsda = fde_aug; - decode_lsda (lsda, code, &res->ex_info, &res->ex_info_len, &res->type_info, &res->this_reg, &res->this_offset); - } + decode_lsda (lsda, code, &res->ex_info, &res->ex_info_len, &res->type_info, &res->this_reg, &res->this_offset); } /* Decode CIE */ From ecd103fe4e147198cec81b28f178f00f89235c97 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 16 Dec 2010 07:17:08 +0100 Subject: [PATCH 32/93] Fix the build --- mono/profiler/Makefile.am | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mono/profiler/Makefile.am b/mono/profiler/Makefile.am index f92e001b1853..0eaecca28d80 100644 --- a/mono/profiler/Makefile.am +++ b/mono/profiler/Makefile.am @@ -11,14 +11,10 @@ INCLUDES = \ if !DISABLE_PROFILER if JIT_SUPPORTED -if PLATFORM_LINUX bin_PROGRAMS = mprof-report lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la -else if PLATFORM_DARWIN +if PLATFORM_DARWIN libmono_profiler_log_la_LDFLAGS = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace -else -bin_PROGRAMS = mprof-report -lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la endif endif endif From c84f6ede0d448aa3e500fc6e7e63abde50c0da0b Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Thu, 16 Dec 2010 16:27:19 +0900 Subject: [PATCH 33/93] For IXmlSerializable/XData, Instance property returns null (!) --- mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs | 3 ++- mcs/class/System.Xaml/Test/System.Xaml/XamlReaderTestBase.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs b/mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs index 704fb4c34b69..0a418cbc7f88 100644 --- a/mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs +++ b/mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs @@ -119,10 +119,11 @@ PrefixLookup PrefixLookup { // - For root Type it returns TypeExtension. // - For root Array it returns Array. // - For non-root Type it returns Type. + // - For IXmlSerializable, it does not either return the raw IXmlSerializable or interpreted XData (it just returns null). public virtual object Instance { get { var cur = NodeType == XamlNodeType.StartObject ? nodes.Current.Object.GetRawValue () : null; - return cur == root ? root_raw : cur; + return cur == root ? root_raw : cur is XData ? null : cur; } } diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlReaderTestBase.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlReaderTestBase.cs index 14af2475ddaa..b5f32acbd7ee 100644 --- a/mcs/class/System.Xaml/Test/System.Xaml/XamlReaderTestBase.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlReaderTestBase.cs @@ -2192,6 +2192,8 @@ protected void Read_XmlSerializableWrapper (XamlReader r, bool isObjectReader) Assert.IsTrue (r.Read (), "so#2-1"); Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#2-2"); Assert.AreEqual (XamlLanguage.XData, r.Type, "so#2-3"); + if (r is XamlObjectReader) + Assert.IsNull (((XamlObjectReader) r).Instance, "xdata-instance"); Assert.IsTrue (r.Read (), "sm2#1"); Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm2#2"); From 3f71818dcde960e98a55d79d501842339c7d4b68 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Thu, 16 Dec 2010 18:13:22 +0900 Subject: [PATCH 34/93] Implement XamlType.GetAllAttachableProperties() and family, except for events. --- mcs/class/System.Xaml/System.Xaml/XamlType.cs | 51 +++++++++++- .../Test/System.Xaml/TestedTypes.cs | 78 +++++++++++++++++++ .../Test/System.Xaml/XamlTypeTest.cs | 13 ++++ 3 files changed, 138 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.Xaml/System.Xaml/XamlType.cs b/mcs/class/System.Xaml/System.Xaml/XamlType.cs index 24c4fe4b91d1..d98839371373 100755 --- a/mcs/class/System.Xaml/System.Xaml/XamlType.cs +++ b/mcs/class/System.Xaml/System.Xaml/XamlType.cs @@ -376,13 +376,55 @@ protected virtual XamlMember LookupAliasedProperty (XamlDirective directive) protected virtual IEnumerable LookupAllAttachableMembers () { if (UnderlyingType == null) - return BaseType != null ? BaseType.GetAllAttachableMembers () : null; - return DoLookupAllAttachableMembers (); + return BaseType != null ? BaseType.GetAllAttachableMembers () : empty_array; + if (all_attachable_members_cache == null) { + all_attachable_members_cache = new List (DoLookupAllAttachableMembers ()); + all_attachable_members_cache.Sort (TypeExtensionMethods.CompareMembers); + } + return all_attachable_members_cache; } IEnumerable DoLookupAllAttachableMembers () { - yield break; // FIXME: what to return here? + // based on http://msdn.microsoft.com/en-us/library/ff184560.aspx + var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; + + var gl = new Dictionary (); + var sl = new Dictionary (); + var nl = new List (); + foreach (var mi in UnderlyingType.GetMethods (bf)) { + if (mi.Name.StartsWith ("Get", StringComparison.Ordinal)) { + if (mi.ReturnType == typeof (void)) + continue; + var args = mi.GetParameters (); + if (args.Length != 1) + continue; + var name = mi.Name.Substring (3); + gl.Add (name, mi); + if (!nl.Contains (name)) + nl.Add (name); + } else if (mi.Name.StartsWith ("Set", StringComparison.Ordinal)) { + // looks like the return type is *ignored* + //if (mi.ReturnType != typeof (void)) + // continue; + var args = mi.GetParameters (); + if (args.Length != 2) + continue; + var name = mi.Name.Substring (3); + sl.Add (name, mi); + if (!nl.Contains (name)) + nl.Add (name); + } + } + + foreach (var name in nl) { + MethodInfo m; + var g = gl.TryGetValue (name, out m) ? m : null; + var s = sl.TryGetValue (name, out m) ? m : null; + yield return new XamlMember (name, g, s, SchemaContext); + } + + // FIXME: attachable events? } static readonly XamlMember [] empty_array = new XamlMember [0]; @@ -399,6 +441,7 @@ protected virtual IEnumerable LookupAllMembers () } List all_members_cache; + List all_attachable_members_cache; IEnumerable DoLookupAllMembers () { @@ -447,7 +490,7 @@ protected virtual IList LookupAllowedContentTypes () protected virtual XamlMember LookupAttachableMember (string name) { - throw new NotImplementedException (); + return GetAllAttachableMembers ().FirstOrDefault (m => m.Name == name); } [MonoTODO] diff --git a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs index 5d6f8cfdf65e..a5412b614894 100755 --- a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs @@ -593,4 +593,82 @@ public XmlSchema GetSchema () return null; } } + + public class Attachable + { + static Dictionary dic = new Dictionary (); + + public static string GetFoo (object target) + { + string v; + return dic.TryGetValue (target, out v) ? v : null; + } + + public static void SetFoo (object target, string value) + { + dic [target] = value; + } + + public static string GetBar (object target, object signatureMismatch) + { + return null; + } + + public static void SetBar (object signatureMismatch) + { + } + + public static void GetBaz (object noReturnType) + { + } + + public static string SetBaz (object target, object extraReturnType) + { + return null; + } + + protected static string GetProtected (object target) + { + string v; + return dic.TryGetValue (target, out v) ? v : null; + } + + protected static void SetProtected (object target, string value) + { + dic [target] = value; + } + } + + public class AttachedPropertyStore : IAttachedPropertyStore + { + public AttachedPropertyStore () + { + } + + Dictionary props = new Dictionary (); + + public int PropertyCount { + get { return props.Count; } + } + + public void CopyPropertiesTo (KeyValuePair [] array, int index) + { + ((ICollection>) props).CopyTo (array, index); + } + + public bool RemoveProperty (AttachableMemberIdentifier attachableMemberIdentifier) + { + return props.Remove (attachableMemberIdentifier); + } + + public void SetProperty (AttachableMemberIdentifier attachableMemberIdentifier, object value) + { + props [attachableMemberIdentifier] = value; + } + + public bool TryGetProperty (AttachableMemberIdentifier attachableMemberIdentifier, out object value) + { + return props.TryGetValue (attachableMemberIdentifier, out value); + } + } } diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs index 716942fe2d43..5d1906e8ca5b 100755 --- a/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs @@ -759,6 +759,19 @@ public void XDataMembers () Assert.IsNotNull (XamlLanguage.XData.GetMember ("XmlReader"), "#2"); // it is returned, but ignored by XamlObjectReader. Assert.IsNotNull (XamlLanguage.XData.GetMember ("Text"), "#3"); } + + [Test] + public void AttachableProperty () + { + var xt = new XamlType (typeof (Attachable), sctx); + var apl = xt.GetAllAttachableMembers (); + Assert.IsTrue (apl.Any (ap => ap.Name == "Foo"), "#1"); + Assert.IsTrue (apl.Any (ap => ap.Name == "Protected"), "#2"); + // oh? SetBaz() has non-void return value, but it seems ignored. + Assert.IsTrue (apl.Any (ap => ap.Name == "Baz"), "#3"); + Assert.AreEqual (3, apl.Count, "#4"); + Assert.IsTrue (apl.All (ap => ap.IsAttachable), "#5"); + } } class MyXamlType : XamlType From 6c1d8710404e8438299edcaab0ab26a39a2a0bc2 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 15 Dec 2010 20:16:30 +0000 Subject: [PATCH 35/93] Add more attribute arguments checks --- mcs/mcs/attribute.cs | 118 ++++++------------------------------------- 1 file changed, 15 insertions(+), 103 deletions(-) diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index c7ab71f84af3..3b59a197d5c5 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -740,6 +740,7 @@ protected virtual bool IsSecurityActionValid (bool for_assembly) SecurityAction action = GetSecurityActionValue (); switch (action) { +#pragma warning disable 618 case SecurityAction.Demand: case SecurityAction.Assert: case SecurityAction.Deny: @@ -756,6 +757,7 @@ protected virtual bool IsSecurityActionValid (bool for_assembly) if (for_assembly) return true; break; +#pragma warning restore 618 default: Error_AttributeEmitError ("SecurityAction is out of range"); @@ -915,109 +917,6 @@ public Constant GetNamedValue (string name) return null; } - // - // Theoretically, we can get rid of this, since FieldBuilder.SetCustomAttribute() - // and ParameterBuilder.SetCustomAttribute() are supposed to handle this attribute. - // However, we can't, since it appears that the .NET 1.1 SRE hangs when given a MarshalAsAttribute. - // -#if false - public UnmanagedMarshal GetMarshal (Attributable attr) - { - UnmanagedType UnmanagedType; - if (!RootContext.StdLib || pos_values [0].GetType () != typeof (UnmanagedType)) - UnmanagedType = (UnmanagedType) System.Enum.ToObject (typeof (UnmanagedType), pos_values [0]); - else - UnmanagedType = (UnmanagedType) pos_values [0]; - - object value = GetFieldValue ("SizeParamIndex"); - if (value != null && UnmanagedType != UnmanagedType.LPArray) { - Error_AttributeEmitError ("SizeParamIndex field is not valid for the specified unmanaged type"); - return null; - } - - object o = GetFieldValue ("ArraySubType"); - UnmanagedType array_sub_type = o == null ? (UnmanagedType) 0x50 /* NATIVE_MAX */ : (UnmanagedType) o; - - switch (UnmanagedType) { - case UnmanagedType.CustomMarshaler: { - MethodInfo define_custom = typeof (UnmanagedMarshal).GetMethod ("DefineCustom", - BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - if (define_custom == null) { - Report.RuntimeMissingSupport (Location, "set marshal info"); - return null; - } - - object [] args = new object [4]; - args [0] = GetFieldValue ("MarshalTypeRef"); - args [1] = GetFieldValue ("MarshalCookie"); - args [2] = GetFieldValue ("MarshalType"); - args [3] = Guid.Empty; - return (UnmanagedMarshal) define_custom.Invoke (null, args); - } - case UnmanagedType.LPArray: { - object size_const = GetFieldValue ("SizeConst"); - object size_param_index = GetFieldValue ("SizeParamIndex"); - - if ((size_const != null) || (size_param_index != null)) { - MethodInfo define_array = typeof (UnmanagedMarshal).GetMethod ("DefineLPArrayInternal", - BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - if (define_array == null) { - Report.RuntimeMissingSupport (Location, "set marshal info"); - return null; - } - - object [] args = new object [3]; - args [0] = array_sub_type; - args [1] = size_const == null ? -1 : size_const; - args [2] = size_param_index == null ? -1 : size_param_index; - return (UnmanagedMarshal) define_array.Invoke (null, args); - } - else - return UnmanagedMarshal.DefineLPArray (array_sub_type); - } - case UnmanagedType.SafeArray: - return UnmanagedMarshal.DefineSafeArray (array_sub_type); - - case UnmanagedType.ByValArray: - FieldBase fm = attr as FieldBase; - if (fm == null) { - Error_AttributeEmitError ("Specified unmanaged type is only valid on fields"); - return null; - } - return UnmanagedMarshal.DefineByValArray ((int) GetFieldValue ("SizeConst")); - - case UnmanagedType.ByValTStr: - return UnmanagedMarshal.DefineByValTStr ((int) GetFieldValue ("SizeConst")); - - default: - return UnmanagedMarshal.DefineUnmanagedMarshal (UnmanagedType); - } - } - - object GetFieldValue (string name) - { - int i; - if (field_info_arr == null) - return null; - i = 0; - foreach (FieldInfo fi in field_info_arr) { - if (fi.Name == name) - return GetValue (field_values_arr [i]); - i++; - } - return null; - } - - static object GetValue (object value) - { - if (value is EnumConstant) - return ((EnumConstant) value).GetValue (); - else - return value; - } - -#endif - public CharSet GetCharSetValue () { return (CharSet)System.Enum.Parse (typeof (CharSet), ((Constant) PosArguments [0].Expr).GetValue ().ToString ()); @@ -1136,6 +1035,19 @@ public void Emit (Dictionary> allEmitted) context.Compiler.Report.Error (591, Location, "Invalid value for argument to `{0}' attribute", "System.AttributeUsage"); } + } else if (Type == predefined.MarshalAs) { + if (PosArguments.Count == 1) { + var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) PosArguments[0].Expr).GetValue ().ToString ()); + if (u_type == UnmanagedType.ByValArray && !(Owner is FieldBase)) { + Error_AttributeEmitError ("Specified unmanaged type is only valid on fields"); + } + } + } else if (Type == predefined.DllImport) { + if (PosArguments.Count == 1) { + var value = ((Constant) PosArguments[0].Expr).GetValue () as string; + if (string.IsNullOrEmpty (value)) + Error_AttributeEmitError ("DllName cannot be empty"); + } } else if (Type == predefined.MethodImpl && pt == TypeManager.short_type && !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) arg_expr).GetValue ().ToString ())) { Error_AttributeEmitError ("Incorrect argument value."); From 5eea47a4e1dabfc108218a5fac4fb26cb3f8dfc4 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 08:25:44 +0000 Subject: [PATCH 36/93] New test --- mcs/tests/test-anon-98.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 mcs/tests/test-anon-98.cs diff --git a/mcs/tests/test-anon-98.cs b/mcs/tests/test-anon-98.cs new file mode 100644 index 000000000000..7c9d32b3c775 --- /dev/null +++ b/mcs/tests/test-anon-98.cs @@ -0,0 +1,15 @@ +using System; + +class Foo +{ + ~Foo() + { + int x = 1; + Action a = () => Console.WriteLine("{0}", x); + } + + public static void Main () + { + new Foo (); + } +} From db16de152705ea141cd9af4ae6f76e51dc0ceaef Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 09:24:24 +0000 Subject: [PATCH 37/93] Cleanup references in static mode --- mcs/mcs/ikvm.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mcs/mcs/ikvm.cs b/mcs/mcs/ikvm.cs index cb2b6a0ba505..14ea40b52a86 100644 --- a/mcs/mcs/ikvm.cs +++ b/mcs/mcs/ikvm.cs @@ -181,6 +181,9 @@ public StaticLoader (StaticImporter importer, CompilerContext compiler) this.importer = importer; domain = new Universe (); domain.AssemblyResolve += AssemblyReferenceResolver; + + // TODO: profile specific + paths.Add (Path.GetDirectoryName (typeof (object).Assembly.Location)); } public Assembly Corlib { @@ -219,17 +222,10 @@ protected override string[] GetDefaultReferences () // For now the "default config" is harcoded into the compiler // we can move this outside later // - var default_references = new List (8); + var default_references = new List (4); default_references.Add ("System.dll"); default_references.Add ("System.Xml.dll"); -#if NET_2_1 - default_references.Add ("System.Net.dll"); - default_references.Add ("System.Windows.dll"); - default_references.Add ("System.Windows.Browser.dll"); -#endif - - // TODO: Will have to do it based on mscorlib version or something like that if (RootContext.Version > LanguageVersion.ISO_2) default_references.Add ("System.Core.dll"); From 695497314852d8a7d2462c73394afdf89c6d4fec Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 09:25:06 +0000 Subject: [PATCH 38/93] Some 4.0 API tweaks --- .../System.Collections.Concurrent/ConcurrentQueue.cs | 4 ++-- .../System.Collections.Concurrent/ConcurrentStack.cs | 8 ++++---- mcs/class/corlib/System.Threading/AsyncFlowControl.cs | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs index 1b2622410a70..528ed194e66a 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentQueue.cs @@ -33,8 +33,8 @@ namespace System.Collections.Concurrent { - [System.Diagnostics.DebuggerDisplay ("Count = {Count}")] - [System.Diagnostics.DebuggerTypeProxy ("System.Collections.Concurrent.SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView`1")] + [System.Diagnostics.DebuggerDisplay ("Count={Count}")] + [System.Diagnostics.DebuggerTypeProxy (typeof (CollectionDebuggerView<>))] public class ConcurrentQueue : IProducerConsumerCollection, IEnumerable, ICollection, IEnumerable { diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs index 7a2df80b6878..920435b017b9 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs @@ -34,7 +34,7 @@ namespace System.Collections.Concurrent { [System.Diagnostics.DebuggerDisplay ("Count = {Count}")] - [System.Diagnostics.DebuggerTypeProxy ("System.Collections.Concurrent.SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView`1")] + [System.Diagnostics.DebuggerTypeProxy (typeof (CollectionDebuggerView<>))] public class ConcurrentStack : IProducerConsumerCollection, IEnumerable, ICollection, IEnumerable { @@ -80,12 +80,12 @@ public void PushRange (T[] items) PushRange (items, 0, items.Length); } - public void PushRange (T[] items, int start, int length) + public void PushRange (T[] items, int startIndex, int count) { Node insert = null; Node first = null; - for (int i = start; i < length; i++) { + for (int i = startIndex; i < count; i++) { Node temp = new Node (); temp.Value = items[i]; temp.Next = insert; @@ -99,7 +99,7 @@ public void PushRange (T[] items, int start, int length) first.Next = head; } while (Interlocked.CompareExchange (ref head, insert, first.Next) != first.Next); - Interlocked.Add (ref count, length); + Interlocked.Add (ref count, count); } public bool TryPop (out T result) diff --git a/mcs/class/corlib/System.Threading/AsyncFlowControl.cs b/mcs/class/corlib/System.Threading/AsyncFlowControl.cs index a534b7de2367..cdd937359558 100644 --- a/mcs/class/corlib/System.Threading/AsyncFlowControl.cs +++ b/mcs/class/corlib/System.Threading/AsyncFlowControl.cs @@ -65,7 +65,11 @@ public void Undo () _t = null; } - void IDisposable.Dispose () +#if NET_4_0 + public void Dispose () +#else + void IDisposable.Dispose () +#endif { if (_t != null) { Undo (); From 82579609f64903b672d7f0daecc410cf902cd165 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 09:29:45 +0000 Subject: [PATCH 39/93] Add IKVM.Reflection --- .../AmbiguousMatchException.cs | 51 + mcs/class/IKVM.Reflection/Assembly.cs | 159 ++ mcs/class/IKVM.Reflection/AssemblyName.cs | 209 ++ .../BadImageFormatException.cs | 51 + mcs/class/IKVM.Reflection/Binder.cs | 43 + mcs/class/IKVM.Reflection/ConstructorInfo.cs | 224 ++ .../IKVM.Reflection/CustomAttributeData.cs | 612 ++++ .../CustomAttributeNamedArgument.cs | 71 + .../CustomAttributeTypedArgument.cs | 71 + .../IKVM.Reflection/Emit/AssemblyBuilder.cs | 721 +++++ .../Emit/ConstructorBuilder.cs | 174 ++ .../Emit/CustomAttributeBuilder.cs | 492 ++++ mcs/class/IKVM.Reflection/Emit/EnumBuilder.cs | 98 + mcs/class/IKVM.Reflection/Emit/Enums.cs | 129 + .../IKVM.Reflection/Emit/EventBuilder.cs | 250 ++ .../IKVM.Reflection/Emit/FieldBuilder.cs | 184 ++ mcs/class/IKVM.Reflection/Emit/ILGenerator.cs | 1143 ++++++++ .../IKVM.Reflection/Emit/MethodBuilder.cs | 693 +++++ .../IKVM.Reflection/Emit/ModuleBuilder.cs | 1364 +++++++++ mcs/class/IKVM.Reflection/Emit/OpCode.cs | 288 ++ mcs/class/IKVM.Reflection/Emit/OpCodes.cs | 749 +++++ .../IKVM.Reflection/Emit/ParameterBuilder.cs | 143 + .../IKVM.Reflection/Emit/PropertyBuilder.cs | 275 ++ .../IKVM.Reflection/Emit/SignatureHelper.cs | 239 ++ mcs/class/IKVM.Reflection/Emit/Tokens.cs | 281 ++ mcs/class/IKVM.Reflection/Emit/TypeBuilder.cs | 1163 ++++++++ mcs/class/IKVM.Reflection/Enums.cs | 274 ++ mcs/class/IKVM.Reflection/EventInfo.cs | 73 + .../ExceptionHandlingClause.cs | 93 + mcs/class/IKVM.Reflection/FieldInfo.cs | 122 + mcs/class/IKVM.Reflection/FieldSignature.cs | 111 + mcs/class/IKVM.Reflection/Fusion.cs | 318 +++ mcs/class/IKVM.Reflection/GenericWrappers.cs | 631 +++++ .../IKVM.Reflection/IKVM.Reflection.csproj | 141 + .../IKVM.Reflection/Impl/CryptoConvert.cs | 743 +++++ mcs/class/IKVM.Reflection/Impl/CryptoHack.cs | 56 + mcs/class/IKVM.Reflection/Impl/ITypeOwner.cs | 32 + mcs/class/IKVM.Reflection/Impl/MdbWriter.cs | 230 ++ mcs/class/IKVM.Reflection/Impl/PdbWriter.cs | 1180 ++++++++ .../IKVM.Reflection/Impl/SymbolSupport.cs | 85 + mcs/class/IKVM.Reflection/InterfaceMapping.cs | 35 + .../IKVM.Reflection/LocalVariableInfo.cs | 56 + .../IKVM.Reflection/ManifestResourceInfo.cs | 91 + mcs/class/IKVM.Reflection/MarshalSpec.cs | 299 ++ mcs/class/IKVM.Reflection/MemberInfo.cs | 81 + .../IKVM.Reflection/Metadata/CliHeader.cs | 92 + .../IKVM.Reflection/Metadata/MetadataRW.cs | 101 + mcs/class/IKVM.Reflection/Metadata/Tables.cs | 2483 +++++++++++++++++ mcs/class/IKVM.Reflection/MethodBase.cs | 139 + mcs/class/IKVM.Reflection/MethodBody.cs | 161 ++ mcs/class/IKVM.Reflection/MethodImplMap.cs | 36 + mcs/class/IKVM.Reflection/MethodInfo.cs | 146 + mcs/class/IKVM.Reflection/MethodSignature.cs | 492 ++++ mcs/class/IKVM.Reflection/Module.cs | 462 +++ mcs/class/IKVM.Reflection/ParameterInfo.cs | 102 + .../IKVM.Reflection/ParameterModifier.cs | 45 + .../Properties/AssemblyInfo.cs | 28 + mcs/class/IKVM.Reflection/PropertyInfo.cs | 158 ++ .../IKVM.Reflection/PropertySignature.cs | 218 ++ .../IKVM.Reflection/Reader/AssemblyReader.cs | 255 ++ .../IKVM.Reflection/Reader/ByteReader.cs | 198 ++ .../IKVM.Reflection/Reader/EventInfoImpl.cs | 138 + mcs/class/IKVM.Reflection/Reader/Field.cs | 152 + .../Reader/GenericTypeParameter.cs | 380 +++ .../IKVM.Reflection/Reader/MetadataReader.cs | 522 ++++ mcs/class/IKVM.Reflection/Reader/Method.cs | 485 ++++ .../IKVM.Reflection/Reader/ModuleReader.cs | 1028 +++++++ mcs/class/IKVM.Reflection/Reader/PEReader.cs | 318 +++ .../Reader/PropertyInfoImpl.cs | 156 ++ .../IKVM.Reflection/Reader/ResourceModule.cs | 132 + .../IKVM.Reflection/Reader/TypeDefImpl.cs | 378 +++ mcs/class/IKVM.Reflection/Signature.cs | 798 ++++++ .../IKVM.Reflection/StandAloneMethodSig.cs | 79 + .../IKVM.Reflection/StrongNameKeyPair.cs | 59 + mcs/class/IKVM.Reflection/Type.cs | 2398 ++++++++++++++++ mcs/class/IKVM.Reflection/TypeNameParser.cs | 458 +++ mcs/class/IKVM.Reflection/Universe.cs | 795 ++++++ mcs/class/IKVM.Reflection/Util.cs | 268 ++ .../IKVM.Reflection/Writer/ByteBuffer.cs | 311 +++ mcs/class/IKVM.Reflection/Writer/Heaps.cs | 382 +++ .../IKVM.Reflection/Writer/MetadataWriter.cs | 565 ++++ .../IKVM.Reflection/Writer/ModuleWriter.cs | 382 +++ mcs/class/IKVM.Reflection/Writer/PEWriter.cs | 303 ++ .../IKVM.Reflection/Writer/ResourceSection.cs | 372 +++ .../IKVM.Reflection/Writer/TextSection.cs | 445 +++ .../IKVM.Reflection/Writer/VersionInfo.cs | 280 ++ mcs/class/IKVM.Reflection/reflect.build | 113 + 87 files changed, 31341 insertions(+) create mode 100644 mcs/class/IKVM.Reflection/AmbiguousMatchException.cs create mode 100644 mcs/class/IKVM.Reflection/Assembly.cs create mode 100644 mcs/class/IKVM.Reflection/AssemblyName.cs create mode 100644 mcs/class/IKVM.Reflection/BadImageFormatException.cs create mode 100644 mcs/class/IKVM.Reflection/Binder.cs create mode 100644 mcs/class/IKVM.Reflection/ConstructorInfo.cs create mode 100644 mcs/class/IKVM.Reflection/CustomAttributeData.cs create mode 100644 mcs/class/IKVM.Reflection/CustomAttributeNamedArgument.cs create mode 100644 mcs/class/IKVM.Reflection/CustomAttributeTypedArgument.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/AssemblyBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/ConstructorBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/CustomAttributeBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/EnumBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/Enums.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/EventBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/FieldBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/ILGenerator.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/MethodBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/ModuleBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/OpCode.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/OpCodes.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/ParameterBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/PropertyBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/SignatureHelper.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/Tokens.cs create mode 100644 mcs/class/IKVM.Reflection/Emit/TypeBuilder.cs create mode 100644 mcs/class/IKVM.Reflection/Enums.cs create mode 100644 mcs/class/IKVM.Reflection/EventInfo.cs create mode 100644 mcs/class/IKVM.Reflection/ExceptionHandlingClause.cs create mode 100644 mcs/class/IKVM.Reflection/FieldInfo.cs create mode 100644 mcs/class/IKVM.Reflection/FieldSignature.cs create mode 100644 mcs/class/IKVM.Reflection/Fusion.cs create mode 100644 mcs/class/IKVM.Reflection/GenericWrappers.cs create mode 100644 mcs/class/IKVM.Reflection/IKVM.Reflection.csproj create mode 100644 mcs/class/IKVM.Reflection/Impl/CryptoConvert.cs create mode 100644 mcs/class/IKVM.Reflection/Impl/CryptoHack.cs create mode 100644 mcs/class/IKVM.Reflection/Impl/ITypeOwner.cs create mode 100644 mcs/class/IKVM.Reflection/Impl/MdbWriter.cs create mode 100644 mcs/class/IKVM.Reflection/Impl/PdbWriter.cs create mode 100644 mcs/class/IKVM.Reflection/Impl/SymbolSupport.cs create mode 100644 mcs/class/IKVM.Reflection/InterfaceMapping.cs create mode 100644 mcs/class/IKVM.Reflection/LocalVariableInfo.cs create mode 100644 mcs/class/IKVM.Reflection/ManifestResourceInfo.cs create mode 100644 mcs/class/IKVM.Reflection/MarshalSpec.cs create mode 100644 mcs/class/IKVM.Reflection/MemberInfo.cs create mode 100644 mcs/class/IKVM.Reflection/Metadata/CliHeader.cs create mode 100644 mcs/class/IKVM.Reflection/Metadata/MetadataRW.cs create mode 100644 mcs/class/IKVM.Reflection/Metadata/Tables.cs create mode 100644 mcs/class/IKVM.Reflection/MethodBase.cs create mode 100644 mcs/class/IKVM.Reflection/MethodBody.cs create mode 100644 mcs/class/IKVM.Reflection/MethodImplMap.cs create mode 100644 mcs/class/IKVM.Reflection/MethodInfo.cs create mode 100644 mcs/class/IKVM.Reflection/MethodSignature.cs create mode 100644 mcs/class/IKVM.Reflection/Module.cs create mode 100644 mcs/class/IKVM.Reflection/ParameterInfo.cs create mode 100644 mcs/class/IKVM.Reflection/ParameterModifier.cs create mode 100644 mcs/class/IKVM.Reflection/Properties/AssemblyInfo.cs create mode 100644 mcs/class/IKVM.Reflection/PropertyInfo.cs create mode 100644 mcs/class/IKVM.Reflection/PropertySignature.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/AssemblyReader.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/ByteReader.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/EventInfoImpl.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/Field.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/GenericTypeParameter.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/MetadataReader.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/Method.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/ModuleReader.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/PEReader.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/PropertyInfoImpl.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/ResourceModule.cs create mode 100644 mcs/class/IKVM.Reflection/Reader/TypeDefImpl.cs create mode 100644 mcs/class/IKVM.Reflection/Signature.cs create mode 100644 mcs/class/IKVM.Reflection/StandAloneMethodSig.cs create mode 100644 mcs/class/IKVM.Reflection/StrongNameKeyPair.cs create mode 100644 mcs/class/IKVM.Reflection/Type.cs create mode 100644 mcs/class/IKVM.Reflection/TypeNameParser.cs create mode 100644 mcs/class/IKVM.Reflection/Universe.cs create mode 100644 mcs/class/IKVM.Reflection/Util.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/ByteBuffer.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/Heaps.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/MetadataWriter.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/ModuleWriter.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/PEWriter.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/ResourceSection.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/TextSection.cs create mode 100644 mcs/class/IKVM.Reflection/Writer/VersionInfo.cs create mode 100644 mcs/class/IKVM.Reflection/reflect.build diff --git a/mcs/class/IKVM.Reflection/AmbiguousMatchException.cs b/mcs/class/IKVM.Reflection/AmbiguousMatchException.cs new file mode 100644 index 000000000000..121d69fbaa1c --- /dev/null +++ b/mcs/class/IKVM.Reflection/AmbiguousMatchException.cs @@ -0,0 +1,51 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.Serialization; + +namespace IKVM.Reflection +{ + [Serializable] + public sealed class AmbiguousMatchException : Exception + { + public AmbiguousMatchException() + { + } + + public AmbiguousMatchException(string message) + : base(message) + { + } + + public AmbiguousMatchException(string message, Exception inner) + : base(message, inner) + { + } + + private AmbiguousMatchException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/mcs/class/IKVM.Reflection/Assembly.cs b/mcs/class/IKVM.Reflection/Assembly.cs new file mode 100644 index 000000000000..8e547aeef7a5 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Assembly.cs @@ -0,0 +1,159 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; + +namespace IKVM.Reflection +{ + public abstract class Assembly : ICustomAttributeProvider + { + internal readonly Universe universe; + + internal Assembly(Universe universe) + { + this.universe = universe; + } + + public abstract Type[] GetTypes(); + public abstract string FullName { get; } + public abstract AssemblyName GetName(); + public abstract string ImageRuntimeVersion { get; } + public abstract Module ManifestModule { get; } + public abstract MethodInfo EntryPoint { get; } + public abstract string Location { get; } + public abstract AssemblyName[] GetReferencedAssemblies(); + public abstract Module[] GetModules(bool getResourceModules); + public abstract Module[] GetLoadedModules(bool getResourceModules); + public abstract Module GetModule(string name); + public abstract string[] GetManifestResourceNames(); + public abstract ManifestResourceInfo GetManifestResourceInfo(string resourceName); + public abstract System.IO.Stream GetManifestResourceStream(string resourceName); + + internal abstract Type GetTypeImpl(string typeName); + + public Module[] GetModules() + { + return GetModules(true); + } + + public Module[] GetLoadedModules() + { + return GetLoadedModules(true); + } + + public AssemblyName GetName(bool copiedName) + { + return GetName(); + } + + public bool ReflectionOnly + { + get { return true; } + } + + public Type[] GetExportedTypes() + { + List list = new List(); + foreach (Type type in GetTypes()) + { + if (type.IsVisible) + { + list.Add(type); + } + } + return list.ToArray(); + } + + public Type GetType(string typeName) + { + return GetType(typeName, false); + } + + public Type GetType(string typeName, bool throwOnError) + { + TypeNameParser parser = TypeNameParser.Parse(typeName, throwOnError); + if (parser.Error) + { + return null; + } + if (parser.AssemblyName != null) + { + if (throwOnError) + { + throw new ArgumentException("Type names passed to Assembly.GetType() must not specify an assembly."); + } + else + { + return null; + } + } + return parser.Expand(GetTypeImpl(parser.FirstNamePart), this, throwOnError, typeName); + } + + public virtual Module LoadModule(string moduleName, byte[] rawModule) + { + throw new NotSupportedException(); + } + + public Module LoadModule(string moduleName, byte[] rawModule, byte[] rawSymbolStore) + { + return LoadModule(moduleName, rawModule); + } + + public bool IsDefined(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0; + } + + public IList __GetCustomAttributes(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit); + } + + public static string CreateQualifiedName(string assemblyName, string typeName) + { + return assemblyName == null ? typeName : typeName + ", " + assemblyName; + } + + public static Assembly GetAssembly(Type type) + { + return type.Assembly; + } + + public string CodeBase + { + get + { + string path = this.Location.Replace(System.IO.Path.DirectorySeparatorChar, '/'); + if (!path.StartsWith("/")) + { + path = "/" + path; + } + return "file://" + path; + } + } + + internal abstract IList GetCustomAttributesData(Type attributeType); + } +} diff --git a/mcs/class/IKVM.Reflection/AssemblyName.cs b/mcs/class/IKVM.Reflection/AssemblyName.cs new file mode 100644 index 000000000000..e89e80d9bd4b --- /dev/null +++ b/mcs/class/IKVM.Reflection/AssemblyName.cs @@ -0,0 +1,209 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Globalization; +using System.Configuration.Assemblies; +using System.IO; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + public sealed class AssemblyName : ICloneable + { + private readonly System.Reflection.AssemblyName name; + private string culture; + + private AssemblyName(System.Reflection.AssemblyName name, string culture) + { + this.name = name; + this.culture = culture; + } + + public AssemblyName() + { + name = new System.Reflection.AssemblyName(); + } + + public AssemblyName(string assemblyName) + { + name = new System.Reflection.AssemblyName(assemblyName); + } + + public override string ToString() + { + string str = name.ToString(); + if (culture != null) + { + str = str.Replace("Culture=neutral", "Culture=" + culture); + } + return str; + } + + public string Name + { + get { return name.Name; } + set { name.Name = value; } + } + + public CultureInfo CultureInfo + { + get { return name.CultureInfo; } + set + { + name.CultureInfo = value; + culture = null; + } + } + + internal string Culture + { + set + { + culture = value; + name.CultureInfo = CultureInfo.InvariantCulture; + } + } + + public Version Version + { + get { return name.Version; } + set { name.Version = value; } + } + + public StrongNameKeyPair KeyPair + { + get { return name.KeyPair == null ? null : new StrongNameKeyPair(name.KeyPair); } + set { name.KeyPair = value == null ? null : value.keyPair; } + } + + public string CodeBase + { + get { return name.CodeBase; } + set { name.CodeBase = value; } + } + + public ProcessorArchitecture ProcessorArchitecture + { + get { return (ProcessorArchitecture)name.ProcessorArchitecture; } + set { name.ProcessorArchitecture = (System.Reflection.ProcessorArchitecture)value; } + } + + public AssemblyNameFlags Flags + { + get { return (AssemblyNameFlags)name.Flags; } + set { name.Flags = (System.Reflection.AssemblyNameFlags)value; } + } + + public AssemblyVersionCompatibility VersionCompatibility + { + get { return name.VersionCompatibility; } + set { name.VersionCompatibility = value; } + } + + public byte[] GetPublicKey() + { + return name.GetPublicKey(); + } + + public void SetPublicKey(byte[] publicKey) + { + name.SetPublicKey(publicKey); + } + + public byte[] GetPublicKeyToken() + { + return name.GetPublicKeyToken(); + } + + public void SetPublicKeyToken(byte[] publicKeyToken) + { + name.SetPublicKeyToken(publicKeyToken); + } + + public AssemblyHashAlgorithm HashAlgorithm + { + get { return name.HashAlgorithm; } + set { name.HashAlgorithm = value; } + } + + public string FullName + { + get + { + string str = name.FullName; + if (culture != null) + { + str = str.Replace("Culture=neutral", "Culture=" + culture); + } + return str; + } + } + + public override bool Equals(object obj) + { + AssemblyName other = obj as AssemblyName; + return other != null && other.FullName == this.FullName; + } + + public override int GetHashCode() + { + return FullName.GetHashCode(); + } + + public object Clone() + { + return new AssemblyName((System.Reflection.AssemblyName)name.Clone(), culture); + } + + public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition) + { + return System.Reflection.AssemblyName.ReferenceMatchesDefinition(reference.name, definition.name); + } + + public static AssemblyName GetAssemblyName(string path) + { + try + { + path = Path.GetFullPath(path); + using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + ModuleReader module = new ModuleReader(null, null, fs, path); + if (module.Assembly == null) + { + throw new BadImageFormatException("Module does not contain a manifest"); + } + return module.Assembly.GetName(); + } + } + catch (IOException x) + { + throw new FileNotFoundException(x.Message, x); + } + catch (UnauthorizedAccessException x) + { + throw new FileNotFoundException(x.Message, x); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/BadImageFormatException.cs b/mcs/class/IKVM.Reflection/BadImageFormatException.cs new file mode 100644 index 000000000000..330f9839d375 --- /dev/null +++ b/mcs/class/IKVM.Reflection/BadImageFormatException.cs @@ -0,0 +1,51 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.Serialization; + +namespace IKVM.Reflection +{ + [Serializable] + public sealed class BadImageFormatException : Exception + { + public BadImageFormatException() + { + } + + public BadImageFormatException(string message) + : base(message) + { + } + + public BadImageFormatException(string message, Exception inner) + : base(message, inner) + { + } + + private BadImageFormatException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/mcs/class/IKVM.Reflection/Binder.cs b/mcs/class/IKVM.Reflection/Binder.cs new file mode 100644 index 000000000000..1307f00de187 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Binder.cs @@ -0,0 +1,43 @@ +/* + Copyright (C) 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Globalization; + +namespace IKVM.Reflection +{ + public abstract class Binder + { + protected Binder() + { + throw new NotSupportedException(); + } + + public abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state); + public abstract FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture); + public abstract object ChangeType(object value, Type type, CultureInfo culture); + public abstract void ReorderArgumentArray(ref object[] args, object state); + public abstract MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers); + public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers); + } +} diff --git a/mcs/class/IKVM.Reflection/ConstructorInfo.cs b/mcs/class/IKVM.Reflection/ConstructorInfo.cs new file mode 100644 index 000000000000..69e2b4df6fae --- /dev/null +++ b/mcs/class/IKVM.Reflection/ConstructorInfo.cs @@ -0,0 +1,224 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; + +namespace IKVM.Reflection +{ + public abstract class ConstructorInfo : MethodBase + { + public static readonly string ConstructorName = ".ctor"; + public static readonly string TypeConstructorName = ".cctor"; + + internal abstract MethodInfo GetMethodInfo(); + + internal override MethodBase BindTypeParameters(Type type) + { + return new ConstructorInfoImpl((MethodInfo)GetMethodInfo().BindTypeParameters(type)); + } + + public sealed override MemberTypes MemberType + { + get { return MemberTypes.Constructor; } + } + + public override bool ContainsGenericParameters + { + get { return GetMethodInfo().ContainsGenericParameters; } + } + + public sealed override ParameterInfo[] GetParameters() + { + ParameterInfo[] parameters = GetMethodInfo().GetParameters(); + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = new ParameterInfoWrapper(this, parameters[i]); + } + return parameters; + } + + private sealed class ParameterInfoWrapper : ParameterInfo + { + private readonly ConstructorInfo ctor; + private readonly ParameterInfo forward; + + internal ParameterInfoWrapper(ConstructorInfo ctor, ParameterInfo forward) + { + this.ctor = ctor; + this.forward = forward; + } + + public override string Name + { + get { return forward.Name; } + } + + public override Type ParameterType + { + get { return forward.ParameterType; } + } + + public override ParameterAttributes Attributes + { + get { return forward.Attributes; } + } + + public override int Position + { + get { return forward.Position; } + } + + public override object RawDefaultValue + { + get { return forward.RawDefaultValue; } + } + + public override Type[] GetOptionalCustomModifiers() + { + return forward.GetOptionalCustomModifiers(); + } + + public override Type[] GetRequiredCustomModifiers() + { + return forward.GetRequiredCustomModifiers(); + } + + public override MemberInfo Member + { + get { return ctor; } + } + + public override int MetadataToken + { + get { return forward.MetadataToken; } + } + + internal override Module Module + { + get { return ctor.Module; } + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return forward.GetCustomAttributesData(attributeType); + } + } + } + + sealed class ConstructorInfoImpl : ConstructorInfo + { + private readonly MethodInfo method; + + internal ConstructorInfoImpl(MethodInfo method) + { + this.method = method; + } + + public override bool Equals(object obj) + { + ConstructorInfoImpl other = obj as ConstructorInfoImpl; + return other != null && other.method.Equals(method); + } + + public override int GetHashCode() + { + return method.GetHashCode(); + } + + public override MethodBody GetMethodBody() + { + return method.GetMethodBody(); + } + + public override CallingConventions CallingConvention + { + get { return method.CallingConvention; } + } + + public override MethodAttributes Attributes + { + get { return method.Attributes; } + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return method.GetMethodImplementationFlags(); + } + + internal override int ParameterCount + { + get { return method.ParameterCount; } + } + + public override Type DeclaringType + { + get { return method.DeclaringType; } + } + + public override string Name + { + get { return method.Name; } + } + + public override string ToString() + { + return method.ToString(); + } + + public override Module Module + { + get { return method.Module; } + } + + public override int MetadataToken + { + get { return method.MetadataToken; } + } + + internal override MethodInfo GetMethodInfo() + { + return method; + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return method.GetCustomAttributesData(attributeType); + } + + internal override MethodInfo GetMethodOnTypeDefinition() + { + return method.GetMethodOnTypeDefinition(); + } + + internal override MethodSignature MethodSignature + { + get { return method.MethodSignature; } + } + + internal override int ImportTo(Emit.ModuleBuilder module) + { + return method.ImportTo(module); + } + } +} diff --git a/mcs/class/IKVM.Reflection/CustomAttributeData.cs b/mcs/class/IKVM.Reflection/CustomAttributeData.cs new file mode 100644 index 000000000000..5af366b12850 --- /dev/null +++ b/mcs/class/IKVM.Reflection/CustomAttributeData.cs @@ -0,0 +1,612 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection +{ + public sealed class CustomAttributeData + { + internal static readonly IList EmptyList = new List(0).AsReadOnly(); + private Module module; + private int index; + private ConstructorInfo lazyConstructor; + private IList lazyConstructorArguments; + private IList lazyNamedArguments; + + internal CustomAttributeData(Module module, int index) + { + this.module = module; + this.index = index; + } + + internal CustomAttributeData(ConstructorInfo constructor, object[] args, List namedArguments) + { + this.lazyConstructor = constructor; + MethodSignature sig = constructor.MethodSignature; + List list = new List(); + for (int i = 0; i < args.Length; i++) + { + list.Add(new CustomAttributeTypedArgument(sig.GetParameterType(i), args[i])); + } + lazyConstructorArguments = list.AsReadOnly(); + if (namedArguments == null) + { + this.lazyNamedArguments = Empty.Array; + } + else + { + this.lazyNamedArguments = namedArguments.AsReadOnly(); + } + } + + internal CustomAttributeData(Assembly asm, ConstructorInfo constructor, ByteReader br) + { + this.lazyConstructor = constructor; + if (br.Length == 0) + { + // it's legal to have an empty blob + lazyConstructorArguments = Empty.Array; + lazyNamedArguments = Empty.Array; + } + else + { + if (br.ReadUInt16() != 1) + { + throw new BadImageFormatException(); + } + lazyConstructorArguments = ReadConstructorArguments(asm, br, constructor); + lazyNamedArguments = ReadNamedArguments(asm, br, br.ReadUInt16(), constructor.DeclaringType); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append('['); + sb.Append(Constructor.DeclaringType.FullName); + sb.Append('('); + string sep = ""; + foreach (CustomAttributeTypedArgument arg in ConstructorArguments) + { + sb.Append(sep); + sep = ", "; + AppendValue(sb, arg); + } + foreach (CustomAttributeNamedArgument named in NamedArguments) + { + sb.Append(sep); + sep = ", "; + sb.Append(named.MemberInfo.Name); + sb.Append(" = "); + AppendValue(sb, named.TypedValue); + } + sb.Append(')'); + sb.Append(']'); + return sb.ToString(); + } + + private static void AppendValue(StringBuilder sb, CustomAttributeTypedArgument arg) + { + if (arg.ArgumentType == arg.ArgumentType.Module.universe.System_String) + { + sb.Append('"').Append(arg.Value).Append('"'); + } + else + { + if (arg.ArgumentType.IsEnum) + { + sb.Append('('); + sb.Append(arg.ArgumentType.FullName); + sb.Append(')'); + } + sb.Append(arg.Value); + } + } + + internal static void ReadDeclarativeSecurity(Assembly asm, List list, int action, ByteReader br) + { + Universe u = asm.universe; + if (br.PeekByte() == '.') + { + br.ReadByte(); + int count = br.ReadCompressedInt(); + for (int j = 0; j < count; j++) + { + Type type = ReadType(asm, br); + ConstructorInfo constructor; + if (type == u.System_Security_Permissions_HostProtectionAttribute && action == (int)System.Security.Permissions.SecurityAction.LinkDemand) + { + constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); + } + else + { + constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { u.System_Security_Permissions_SecurityAction }, null); + } + // LAMESPEC there is an additional length here (probably of the named argument list) + ByteReader slice = br.Slice(br.ReadCompressedInt()); + // LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes) + list.Add(new CustomAttributeData(constructor, action, ReadNamedArguments(asm, slice, slice.ReadCompressedInt(), type))); + } + } + else + { + // .NET 1.x format (xml) + char[] buf = new char[br.Length / 2]; + for (int i = 0; i < buf.Length; i++) + { + buf[i] = br.ReadChar(); + } + string xml = new String(buf); + ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetConstructor(new Type[] { u.System_Security_Permissions_SecurityAction }); + List args = new List(); + args.Add(new CustomAttributeNamedArgument(u.System_Security_Permissions_PermissionSetAttribute.GetProperty("XML"), + new CustomAttributeTypedArgument(u.System_String, xml))); + list.Add(new CustomAttributeData(constructor, action, args)); + } + } + + private CustomAttributeData(ConstructorInfo constructor, int securityAction, IList namedArguments) + { + Universe u = constructor.Module.universe; + this.lazyConstructor = constructor; + List list = new List(); + list.Add(new CustomAttributeTypedArgument(u.System_Security_Permissions_SecurityAction, securityAction)); + this.lazyConstructorArguments = list.AsReadOnly(); + this.lazyNamedArguments = namedArguments; + } + + private static Type ReadFieldOrPropType(Assembly asm, ByteReader br) + { + Universe u = asm.universe; + switch (br.ReadByte()) + { + case Signature.ELEMENT_TYPE_BOOLEAN: + return u.System_Boolean; + case Signature.ELEMENT_TYPE_CHAR: + return u.System_Char; + case Signature.ELEMENT_TYPE_I1: + return u.System_SByte; + case Signature.ELEMENT_TYPE_U1: + return u.System_Byte; + case Signature.ELEMENT_TYPE_I2: + return u.System_Int16; + case Signature.ELEMENT_TYPE_U2: + return u.System_UInt16; + case Signature.ELEMENT_TYPE_I4: + return u.System_Int32; + case Signature.ELEMENT_TYPE_U4: + return u.System_UInt32; + case Signature.ELEMENT_TYPE_I8: + return u.System_Int64; + case Signature.ELEMENT_TYPE_U8: + return u.System_UInt64; + case Signature.ELEMENT_TYPE_R4: + return u.System_Single; + case Signature.ELEMENT_TYPE_R8: + return u.System_Double; + case Signature.ELEMENT_TYPE_STRING: + return u.System_String; + case Signature.ELEMENT_TYPE_SZARRAY: + return ReadFieldOrPropType(asm, br).MakeArrayType(); + case 0x55: + return ReadType(asm, br); + case 0x50: + return u.System_Type; + case 0x51: + return u.System_Object; + default: + throw new InvalidOperationException(); + } + } + + private static CustomAttributeTypedArgument ReadFixedArg(Assembly asm, ByteReader br, Type type) + { + Universe u = asm.universe; + if (type == u.System_String) + { + return new CustomAttributeTypedArgument(type, br.ReadString()); + } + else if (type == u.System_Type) + { + return new CustomAttributeTypedArgument(type, ReadType(asm, br)); + } + else if (type == u.System_Object) + { + return ReadFixedArg(asm, br, ReadFieldOrPropType(asm, br)); + } + else if (type.IsArray) + { + int length = br.ReadInt32(); + if (length == -1) + { + return new CustomAttributeTypedArgument(type, null); + } + Type elementType = type.GetElementType(); + CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[length]; + for (int i = 0; i < length; i++) + { + array[i] = ReadFixedArg(asm, br, elementType); + } + return new CustomAttributeTypedArgument(type, array); + } + else if (type.IsEnum) + { + return new CustomAttributeTypedArgument(type, ReadFixedArg(asm, br, type.GetEnumUnderlyingTypeImpl()).Value); + } + else + { + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + return new CustomAttributeTypedArgument(type, br.ReadByte() != 0); + case TypeCode.Char: + return new CustomAttributeTypedArgument(type, br.ReadChar()); + case TypeCode.Single: + return new CustomAttributeTypedArgument(type, br.ReadSingle()); + case TypeCode.Double: + return new CustomAttributeTypedArgument(type, br.ReadDouble()); + case TypeCode.SByte: + return new CustomAttributeTypedArgument(type, br.ReadSByte()); + case TypeCode.Int16: + return new CustomAttributeTypedArgument(type, br.ReadInt16()); + case TypeCode.Int32: + return new CustomAttributeTypedArgument(type, br.ReadInt32()); + case TypeCode.Int64: + return new CustomAttributeTypedArgument(type, br.ReadInt64()); + case TypeCode.Byte: + return new CustomAttributeTypedArgument(type, br.ReadByte()); + case TypeCode.UInt16: + return new CustomAttributeTypedArgument(type, br.ReadUInt16()); + case TypeCode.UInt32: + return new CustomAttributeTypedArgument(type, br.ReadUInt32()); + case TypeCode.UInt64: + return new CustomAttributeTypedArgument(type, br.ReadUInt64()); + default: + throw new InvalidOperationException(); + } + } + } + + private static Type ReadType(Assembly asm, ByteReader br) + { + string typeName = br.ReadString(); + if (typeName == null) + { + return null; + } + if (typeName.Length > 0 && typeName[typeName.Length - 1] == 0) + { + // there are broken compilers that emit an extra NUL character after the type name + typeName = typeName.Substring(0, typeName.Length - 1); + } + return asm.universe.GetType(asm, typeName, true); + } + + private static IList ReadConstructorArguments(Assembly asm, ByteReader br, ConstructorInfo constructor) + { + MethodSignature sig = constructor.MethodSignature; + int count = sig.GetParameterCount(); + List list = new List(count); + for (int i = 0; i < count; i++) + { + list.Add(ReadFixedArg(asm, br, sig.GetParameterType(i))); + } + return list.AsReadOnly(); + } + + private static IList ReadNamedArguments(Assembly asm, ByteReader br, int named, Type type) + { + List list = new List(named); + for (int i = 0; i < named; i++) + { + byte fieldOrProperty = br.ReadByte(); + Type fieldOrPropertyType = ReadFieldOrPropType(asm, br); + string name = br.ReadString(); + CustomAttributeTypedArgument value = ReadFixedArg(asm, br, fieldOrPropertyType); + MemberInfo member; + switch (fieldOrProperty) + { + case 0x53: + member = GetField(type, name); + break; + case 0x54: + member = GetProperty(type, name); + break; + default: + throw new BadImageFormatException(); + } + if (member == null) + { + throw new BadImageFormatException(); + } + list.Add(new CustomAttributeNamedArgument(member, value)); + } + return list.AsReadOnly(); + } + + private static FieldInfo GetField(Type type, string name) + { + for (; type != null; type = type.BaseType) + { + foreach (FieldInfo field in type.__GetDeclaredFields()) + { + if (field.IsPublic && !field.IsStatic && field.Name == name) + { + return field; + } + } + } + return null; + } + + private static PropertyInfo GetProperty(Type type, string name) + { + for (; type != null; type = type.BaseType) + { + foreach (PropertyInfo property in type.__GetDeclaredProperties()) + { + if (property.IsPublic && !property.IsStatic && property.Name == name) + { + return property; + } + } + } + return null; + } + + public void __ReadTypeName(out string ns, out string name) + { + if (lazyConstructor == null) + { + ModuleReader mod = module as ModuleReader; + if (mod != null) + { + int methodToken = mod.CustomAttribute.records[index].Type; + if ((methodToken >> 24) == MemberRefTable.Index) + { + int methodIndex = (methodToken & 0xFFFFFF) - 1; + int typeToken = mod.MemberRef.records[methodIndex].Class; + if ((typeToken >> 24) == TypeRefTable.Index) + { + int typeIndex = (typeToken & 0xFFFFFF) - 1; + int typeNameSpace = mod.TypeRef.records[typeIndex].TypeNameSpace; + ns = typeNameSpace == 0 ? null : mod.GetString(typeNameSpace); + name = mod.GetString(mod.TypeRef.records[typeIndex].TypeName); + return; + } + } + } + } + ns = Constructor.DeclaringType.Namespace; + name = Constructor.DeclaringType.Name; + } + + public ConstructorInfo Constructor + { + get + { + if (lazyConstructor == null) + { + lazyConstructor = (ConstructorInfo)module.ResolveMethod(module.CustomAttribute.records[index].Type); + } + return lazyConstructor; + } + } + + public IList ConstructorArguments + { + get + { + if (lazyConstructorArguments == null) + { + LazyParseArguments(); + } + return lazyConstructorArguments; + } + } + + public IList NamedArguments + { + get + { + if (lazyNamedArguments == null) + { + LazyParseArguments(); + } + return lazyNamedArguments; + } + } + + private void LazyParseArguments() + { + ByteReader br = module.GetBlob(module.CustomAttribute.records[index].Value); + if (br.Length == 0) + { + // it's legal to have an empty blob + lazyConstructorArguments = Empty.Array; + lazyNamedArguments = Empty.Array; + } + else + { + if (br.ReadUInt16() != 1) + { + throw new BadImageFormatException(); + } + lazyConstructorArguments = ReadConstructorArguments(module.Assembly, br, Constructor); + lazyNamedArguments = ReadNamedArguments(module.Assembly, br, br.ReadUInt16(), Constructor.DeclaringType); + } + } + + public CustomAttributeBuilder __ToBuilder() + { + object[] args = new object[ConstructorArguments.Count]; + for (int i = 0; i < args.Length; i++) + { + args[i] = ConstructorArguments[i].Value; + } + List namedProperties = new List(); + List propertyValues = new List(); + List namedFields = new List(); + List fieldValues = new List(); + foreach (CustomAttributeNamedArgument named in NamedArguments) + { + if (named.MemberInfo is PropertyInfo) + { + namedProperties.Add((PropertyInfo)named.MemberInfo); + propertyValues.Add(named.TypedValue.Value); + } + else + { + namedFields.Add((FieldInfo)named.MemberInfo); + fieldValues.Add(named.TypedValue.Value); + } + } + return new CustomAttributeBuilder(Constructor, args, namedProperties.ToArray(), propertyValues.ToArray(), namedFields.ToArray(), fieldValues.ToArray()); + } + + public static IList GetCustomAttributes(MemberInfo member) + { + return member.GetCustomAttributesData(null); + } + + public static IList GetCustomAttributes(Assembly assembly) + { + return assembly.GetCustomAttributesData(null); + } + + public static IList GetCustomAttributes(Module module) + { + return module.GetCustomAttributesData(null); + } + + public static IList GetCustomAttributes(ParameterInfo parameter) + { + return parameter.GetCustomAttributesData(null); + } + + public static IList __GetCustomAttributes(Assembly assembly, Type attributeType, bool inherit) + { + return assembly.GetCustomAttributesData(attributeType); + } + + public static IList __GetCustomAttributes(Module module, Type attributeType, bool inherit) + { + return module.GetCustomAttributesData(attributeType); + } + + public static IList __GetCustomAttributes(ParameterInfo parameter, Type attributeType, bool inherit) + { + return parameter.GetCustomAttributesData(attributeType); + } + + public static IList __GetCustomAttributes(MemberInfo member, Type attributeType, bool inherit) + { + if (!inherit || !IsInheritableAttribute(attributeType)) + { + return member.GetCustomAttributesData(attributeType); + } + List list = new List(); + for (; ; ) + { + list.AddRange(member.GetCustomAttributesData(attributeType)); + Type type = member as Type; + if (type != null) + { + type = type.BaseType; + if (type == null) + { + return list; + } + member = type; + continue; + } + MethodInfo method = member as MethodInfo; + if (method != null) + { + MemberInfo prev = member; + method = method.GetBaseDefinition(); + if (method == null || method == prev) + { + return list; + } + member = method; + continue; + } + return list; + } + } + + public static IList __GetDeclarativeSecurity(Assembly assembly) + { + return assembly.ManifestModule.GetDeclarativeSecurity(0x20000001); + } + + public static IList __GetDeclarativeSecurity(Type type) + { + if ((type.Attributes & TypeAttributes.HasSecurity) != 0) + { + return type.Module.GetDeclarativeSecurity(type.MetadataToken); + } + else + { + return EmptyList; + } + } + + public static IList __GetDeclarativeSecurity(MethodBase method) + { + if ((method.Attributes & MethodAttributes.HasSecurity) != 0) + { + return method.Module.GetDeclarativeSecurity(method.MetadataToken); + } + else + { + return EmptyList; + } + } + + private static bool IsInheritableAttribute(Type attribute) + { + Type attributeUsageAttribute = attribute.Module.universe.System_AttributeUsageAttribute; + IList attr = attribute.GetCustomAttributesData(attributeUsageAttribute); + if (attr.Count != 0) + { + foreach (CustomAttributeNamedArgument named in attr[0].NamedArguments) + { + if (named.MemberInfo.Name == "Inherited") + { + return (bool)named.TypedValue.Value; + } + } + } + return true; + } + } +} diff --git a/mcs/class/IKVM.Reflection/CustomAttributeNamedArgument.cs b/mcs/class/IKVM.Reflection/CustomAttributeNamedArgument.cs new file mode 100644 index 000000000000..d9a84b7a74a8 --- /dev/null +++ b/mcs/class/IKVM.Reflection/CustomAttributeNamedArgument.cs @@ -0,0 +1,71 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + public struct CustomAttributeNamedArgument + { + private readonly MemberInfo member; + private readonly CustomAttributeTypedArgument value; + + internal CustomAttributeNamedArgument(MemberInfo member, CustomAttributeTypedArgument value) + { + this.member = member; + this.value = value; + } + + public override bool Equals(object obj) + { + return this == obj as CustomAttributeNamedArgument?; + } + + public override int GetHashCode() + { + return member.GetHashCode() ^ 53 * value.GetHashCode(); + } + + public MemberInfo MemberInfo + { + get { return member; } + } + + public CustomAttributeTypedArgument TypedValue + { + get { return value; } + } + + public static bool operator ==(CustomAttributeNamedArgument arg1, CustomAttributeNamedArgument arg2) + { + return arg1.member.Equals(arg2.member) && arg1.value == arg2.value; + } + + public static bool operator !=(CustomAttributeNamedArgument arg1, CustomAttributeNamedArgument arg2) + { + return !(arg1 == arg2); + } + } +} diff --git a/mcs/class/IKVM.Reflection/CustomAttributeTypedArgument.cs b/mcs/class/IKVM.Reflection/CustomAttributeTypedArgument.cs new file mode 100644 index 000000000000..3403135af7e9 --- /dev/null +++ b/mcs/class/IKVM.Reflection/CustomAttributeTypedArgument.cs @@ -0,0 +1,71 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + public struct CustomAttributeTypedArgument + { + private readonly Type type; + private readonly object value; + + internal CustomAttributeTypedArgument(Type type, object value) + { + this.type = type; + this.value = value; + } + + public override bool Equals(object obj) + { + return this == obj as CustomAttributeTypedArgument?; + } + + public override int GetHashCode() + { + return type.GetHashCode() ^ 77 * (value == null ? 0 : value.GetHashCode()); + } + + public Type ArgumentType + { + get { return type; } + } + + public Object Value + { + get { return value; } + } + + public static bool operator ==(CustomAttributeTypedArgument arg1, CustomAttributeTypedArgument arg2) + { + return arg1.type.Equals(arg2.type) && (arg1.value == arg2.value || (arg1.value != null && arg1.value.Equals(arg2.value))); + } + + public static bool operator !=(CustomAttributeTypedArgument arg1, CustomAttributeTypedArgument arg2) + { + return !(arg1 == arg2); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/AssemblyBuilder.cs b/mcs/class/IKVM.Reflection/Emit/AssemblyBuilder.cs new file mode 100644 index 000000000000..9919fd3b22e2 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/AssemblyBuilder.cs @@ -0,0 +1,721 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Configuration.Assemblies; +using System.IO; +using System.Diagnostics; +using System.Globalization; +using System.Security.Cryptography; +using System.Security; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Impl; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class AssemblyBuilder : Assembly + { + private readonly string name; + private ushort majorVersion; + private ushort minorVersion; + private ushort buildVersion; + private ushort revisionVersion; + private string culture; + private AssemblyNameFlags flags; + private AssemblyHashAlgorithm hashAlgorithm; + private StrongNameKeyPair keyPair; + private byte[] publicKey; + internal readonly string dir; + private readonly PermissionSet requiredPermissions; + private readonly PermissionSet optionalPermissions; + private readonly PermissionSet refusedPermissions; + private PEFileKinds fileKind = PEFileKinds.Dll; + private MethodInfo entryPoint; + private VersionInfo versionInfo; + private ResourceSection unmanagedResources; + private string imageRuntimeVersion; + internal int mdStreamVersion = 0x20000; + private Module pseudoManifestModule; + private readonly List resourceFiles = new List(); + private readonly List modules = new List(); + private readonly List addedModules = new List(); + private readonly List customAttributes = new List(); + private readonly List declarativeSecurity = new List(); + private readonly List typeForwarders = new List(); + + private struct ResourceFile + { + internal string Name; + internal string FileName; + internal ResourceAttributes Attributes; + } + + internal AssemblyBuilder(Universe universe, AssemblyName name, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions) + : base(universe) + { + this.name = name.Name; + SetVersionHelper(name.Version); + if (name.CultureInfo != null && !string.IsNullOrEmpty(name.CultureInfo.Name)) + { + this.culture = name.CultureInfo.Name; + } + this.flags = name.Flags; + this.hashAlgorithm = name.HashAlgorithm; + if (this.hashAlgorithm == AssemblyHashAlgorithm.None) + { + this.hashAlgorithm = AssemblyHashAlgorithm.SHA1; + } + this.keyPair = name.KeyPair; + if (this.keyPair != null) + { + this.publicKey = this.keyPair.PublicKey; + } + else + { + byte[] publicKey = name.GetPublicKey(); + if (publicKey != null && publicKey.Length != 0) + { + this.publicKey = (byte[])publicKey.Clone(); + } + } + this.dir = dir ?? "."; + this.requiredPermissions = requiredPermissions; + this.optionalPermissions = optionalPermissions; + this.refusedPermissions = refusedPermissions; + if (universe.HasMscorlib && universe.Mscorlib.ImageRuntimeVersion != null) + { + this.imageRuntimeVersion = universe.Mscorlib.ImageRuntimeVersion; + } + else + { + this.imageRuntimeVersion = typeof(object).Assembly.ImageRuntimeVersion; + } + } + + private void SetVersionHelper(Version version) + { + if (version == null) + { + majorVersion = 0; + minorVersion = 0; + buildVersion = 0; + revisionVersion = 0; + } + else + { + majorVersion = (ushort)version.Major; + minorVersion = (ushort)version.Minor; + buildVersion = version.Build == -1 ? (ushort)0 : (ushort)version.Build; + revisionVersion = version.Revision == -1 ? (ushort)0 : (ushort)version.Revision; + } + } + + public void __SetAssemblyVersion(Version version) + { + AssemblyName oldName = GetName(); + SetVersionHelper(version); + universe.RenameAssembly(this, oldName); + } + + public void __SetAssemblyCulture(string cultureName) + { + AssemblyName oldName = GetName(); + this.culture = cultureName; + universe.RenameAssembly(this, oldName); + } + + public void __SetAssemblyKeyPair(StrongNameKeyPair keyPair) + { + AssemblyName oldName = GetName(); + this.keyPair = keyPair; + if (keyPair != null) + { + this.publicKey = keyPair.PublicKey; + } + universe.RenameAssembly(this, oldName); + } + + // this is used in combination with delay signing + public void __SetAssemblyPublicKey(byte[] publicKey) + { + AssemblyName oldName = GetName(); + this.publicKey = publicKey == null ? null : (byte[])publicKey.Clone(); + universe.RenameAssembly(this, oldName); + } + + public void __SetAssemblyAlgorithmId(AssemblyHashAlgorithm hashAlgorithm) + { + this.hashAlgorithm = hashAlgorithm; + } + + public void __SetAssemblyFlags(AssemblyNameFlags flags) + { + this.flags = flags; + } + + public override AssemblyName GetName() + { + AssemblyName n = new AssemblyName(); + n.Name = name; + n.Version = new Version(majorVersion, minorVersion, buildVersion, revisionVersion); + n.Culture = culture; + n.HashAlgorithm = hashAlgorithm; + n.Flags = flags; + n.SetPublicKey(publicKey != null ? (byte[])publicKey.Clone() : Empty.Array); + n.KeyPair = keyPair; + return n; + } + + public override string FullName + { + get { return GetName().FullName; } + } + + public override string Location + { + get { throw new NotSupportedException(); } + } + + public ModuleBuilder DefineDynamicModule(string name, string fileName) + { + return DefineDynamicModule(name, fileName, false); + } + + public ModuleBuilder DefineDynamicModule(string name, string fileName, bool emitSymbolInfo) + { + ModuleBuilder module = new ModuleBuilder(this, name, fileName, emitSymbolInfo); + modules.Add(module); + return module; + } + + public ModuleBuilder GetDynamicModule(string name) + { + foreach (ModuleBuilder module in modules) + { + if (module.Name == name) + { + return module; + } + } + return null; + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + customAttributes.Add(customBuilder); + } + + public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder) + { + declarativeSecurity.Add(customBuilder); + } + + public void __AddTypeForwarder(Type type) + { + typeForwarders.Add(type); + } + + public void SetEntryPoint(MethodInfo entryMethod) + { + SetEntryPoint(entryMethod, PEFileKinds.ConsoleApplication); + } + + public void SetEntryPoint(MethodInfo entryMethod, PEFileKinds fileKind) + { + this.entryPoint = entryMethod; + this.fileKind = fileKind; + } + + public void Save(string assemblyFileName) + { + Save(assemblyFileName, PortableExecutableKinds.ILOnly, ImageFileMachine.I386); + } + + public void Save(string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine) + { + ModuleBuilder manifestModule = null; + + foreach (ModuleBuilder moduleBuilder in modules) + { + moduleBuilder.PopulatePropertyAndEventTables(); + + if (manifestModule == null + && string.Compare(moduleBuilder.fileName, assemblyFileName, StringComparison.OrdinalIgnoreCase) == 0) + { + manifestModule = moduleBuilder; + } + } + + if (manifestModule == null) + { + manifestModule = DefineDynamicModule("RefEmit_OnDiskManifestModule", assemblyFileName, false); + } + + AssemblyTable.Record assemblyRecord = new AssemblyTable.Record(); + assemblyRecord.HashAlgId = (int)hashAlgorithm; + assemblyRecord.Name = manifestModule.Strings.Add(name); + assemblyRecord.MajorVersion = majorVersion; + assemblyRecord.MinorVersion = minorVersion; + assemblyRecord.BuildNumber = buildVersion; + assemblyRecord.RevisionNumber = revisionVersion; + if (publicKey != null) + { + assemblyRecord.PublicKey = manifestModule.Blobs.Add(ByteBuffer.Wrap(publicKey)); + assemblyRecord.Flags = (int)(flags | AssemblyNameFlags.PublicKey); + } + else + { + assemblyRecord.Flags = (int)(flags & ~AssemblyNameFlags.PublicKey); + } + if (culture != null) + { + assemblyRecord.Culture = manifestModule.Strings.Add(culture); + } + int token = 0x20000000 + manifestModule.AssemblyTable.AddRecord(assemblyRecord); + +#pragma warning disable 618 + // this values are obsolete, but we already know that so we disable the warning + System.Security.Permissions.SecurityAction requestMinimum = System.Security.Permissions.SecurityAction.RequestMinimum; + System.Security.Permissions.SecurityAction requestOptional = System.Security.Permissions.SecurityAction.RequestOptional; + System.Security.Permissions.SecurityAction requestRefuse = System.Security.Permissions.SecurityAction.RequestRefuse; +#pragma warning restore 618 + if (requiredPermissions != null) + { + manifestModule.AddDeclarativeSecurity(token, requestMinimum, requiredPermissions); + } + if (optionalPermissions != null) + { + manifestModule.AddDeclarativeSecurity(token, requestOptional, optionalPermissions); + } + if (refusedPermissions != null) + { + manifestModule.AddDeclarativeSecurity(token, requestRefuse, refusedPermissions); + } + + if (versionInfo != null) + { + versionInfo.SetName(GetName()); + versionInfo.SetFileName(assemblyFileName); + foreach (CustomAttributeBuilder cab in customAttributes) + { + // .NET doesn't support copying blob custom attributes into the version info + if (!cab.HasBlob) + { + versionInfo.SetAttribute(cab); + } + } + ByteBuffer versionInfoData = new ByteBuffer(512); + versionInfo.Write(versionInfoData); + if (unmanagedResources == null) + { + unmanagedResources = new ResourceSection(); + } + unmanagedResources.AddVersionInfo(versionInfoData); + } + + foreach (CustomAttributeBuilder cab in customAttributes) + { + // we intentionally don't filter out the version info (pseudo) custom attributes (to be compatible with .NET) + manifestModule.SetCustomAttribute(0x20000001, cab); + } + + manifestModule.AddDeclarativeSecurity(0x20000001, declarativeSecurity); + + foreach (Type type in typeForwarders) + { + manifestModule.AddTypeForwarder(type); + } + + foreach (ResourceFile resfile in resourceFiles) + { + int fileToken = AddFile(manifestModule, resfile.FileName, 1 /*ContainsNoMetaData*/); + ManifestResourceTable.Record rec = new ManifestResourceTable.Record(); + rec.Offset = 0; + rec.Flags = (int)resfile.Attributes; + rec.Name = manifestModule.Strings.Add(resfile.Name); + rec.Implementation = fileToken; + manifestModule.ManifestResource.AddRecord(rec); + } + + int entryPointToken = 0; + + foreach (ModuleBuilder moduleBuilder in modules) + { + moduleBuilder.FillAssemblyRefTable(); + if (moduleBuilder != manifestModule) + { + int fileToken; + if (entryPoint != null && entryPoint.Module == moduleBuilder) + { + ModuleWriter.WriteModule(null, null, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, moduleBuilder.unmanagedResources, entryPoint.MetadataToken); + entryPointToken = fileToken = AddFile(manifestModule, moduleBuilder.fileName, 0 /*ContainsMetaData*/); + } + else + { + ModuleWriter.WriteModule(null, null, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, moduleBuilder.unmanagedResources, 0); + fileToken = AddFile(manifestModule, moduleBuilder.fileName, 0 /*ContainsMetaData*/); + } + moduleBuilder.ExportTypes(fileToken, manifestModule); + } + } + + foreach (Module module in addedModules) + { + int fileToken = AddFile(manifestModule, module.FullyQualifiedName, 0 /*ContainsMetaData*/); + module.ExportTypes(fileToken, manifestModule); + } + + if (entryPointToken == 0 && entryPoint != null) + { + entryPointToken = entryPoint.MetadataToken; + } + + // finally, write the manifest module + ModuleWriter.WriteModule(keyPair, publicKey, manifestModule, fileKind, portableExecutableKind, imageFileMachine, unmanagedResources ?? manifestModule.unmanagedResources, entryPointToken); + } + + private int AddFile(ModuleBuilder manifestModule, string fileName, int flags) + { + SHA1Managed hash = new SHA1Managed(); + string fullPath = fileName; + if (dir != null) + { + fullPath = Path.Combine(dir, fileName); + } + using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) + { + using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write)) + { + byte[] buf = new byte[8192]; + ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length); + } + } + FileTable.Record file = new FileTable.Record(); + file.Flags = flags; + file.Name = manifestModule.Strings.Add(Path.GetFileName(fileName)); + file.HashValue = manifestModule.Blobs.Add(ByteBuffer.Wrap(hash.Hash)); + return 0x26000000 + manifestModule.File.AddRecord(file); + } + + public void AddResourceFile(string name, string fileName) + { + AddResourceFile(name, fileName, ResourceAttributes.Public); + } + + public void AddResourceFile(string name, string fileName, ResourceAttributes attribs) + { + ResourceFile resfile = new ResourceFile(); + resfile.Name = name; + resfile.FileName = fileName; + resfile.Attributes = attribs; + resourceFiles.Add(resfile); + } + + public void DefineVersionInfoResource() + { + versionInfo = new VersionInfo(); + } + + public void DefineVersionInfoResource(string product, string productVersion, string company, string copyright, string trademark) + { + versionInfo = new VersionInfo(); + versionInfo.product = product; + versionInfo.informationalVersion = productVersion; + versionInfo.company = company; + versionInfo.copyright = copyright; + versionInfo.trademark = trademark; + } + + public void __DefineIconResource(byte[] iconFile) + { + unmanagedResources = new ResourceSection(); + unmanagedResources.AddIcon(iconFile); + } + + public void __DefineUnmanagedResource(byte[] resource) + { + // The standard .NET DefineUnmanagedResource(byte[]) is useless, because it embeds "resource" (as-is) as the .rsrc section, + // but it doesn't set the PE file Resource Directory entry to point to it. That's why we have a renamed version, which behaves + // like DefineUnmanagedResource(string). + unmanagedResources = new ResourceSection(); + unmanagedResources.ExtractResources(resource); + } + + public void DefineUnmanagedResource(string resourceFileName) + { + // This method reads the specified resource file (Win32 .res file) and converts it into the appropriate format and embeds it in the .rsrc section, + // also setting the Resource Directory entry. + __DefineUnmanagedResource(File.ReadAllBytes(resourceFileName)); + } + + public override Type[] GetTypes() + { + List list = new List(); + foreach (ModuleBuilder module in modules) + { + module.GetTypesImpl(list); + } + foreach (Module module in addedModules) + { + module.GetTypesImpl(list); + } + return list.ToArray(); + } + + internal override Type GetTypeImpl(string typeName) + { + foreach (ModuleBuilder mb in modules) + { + Type type = mb.GetTypeImpl(typeName); + if (type != null) + { + return type; + } + } + foreach (Module module in addedModules) + { + Type type = module.GetTypeImpl(typeName); + if (type != null) + { + return type; + } + } + return null; + } + + public override string ImageRuntimeVersion + { + get { return imageRuntimeVersion; } + } + + public void __SetImageRuntimeVersion(string imageRuntimeVersion, int mdStreamVersion) + { + this.imageRuntimeVersion = imageRuntimeVersion; + this.mdStreamVersion = mdStreamVersion; + } + + public override Module ManifestModule + { + get + { + if (pseudoManifestModule == null) + { + pseudoManifestModule = new ManifestModule(this); + } + return pseudoManifestModule; + } + } + + public override MethodInfo EntryPoint + { + get { return entryPoint; } + } + + public override AssemblyName[] GetReferencedAssemblies() + { + return Empty.Array; + } + + public override Module[] GetLoadedModules(bool getResourceModules) + { + return GetModules(getResourceModules); + } + + public override Module[] GetModules(bool getResourceModules) + { + List list = new List(); + foreach (ModuleBuilder module in modules) + { + if (getResourceModules || !module.IsResource()) + { + list.Add(module); + } + } + foreach (Module module in addedModules) + { + if (getResourceModules || !module.IsResource()) + { + list.Add(module); + } + } + return list.ToArray(); + } + + public override Module GetModule(string name) + { + foreach (ModuleBuilder module in modules) + { + if (module.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)) + { + return module; + } + } + foreach (Module module in addedModules) + { + if (module.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)) + { + return module; + } + } + return null; + } + + public Module __AddModule(RawModule module) + { + Module mod = module.ToModule(this); + addedModules.Add(mod); + return mod; + } + + public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) + { + throw new NotSupportedException(); + } + + public override string[] GetManifestResourceNames() + { + throw new NotSupportedException(); + } + + public override Stream GetManifestResourceStream(string resourceName) + { + throw new NotSupportedException(); + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + List list = new List(); + foreach (CustomAttributeBuilder cab in customAttributes) + { + if (attributeType == null || attributeType.IsAssignableFrom(cab.Constructor.DeclaringType)) + { + list.Add(cab.ToData(this)); + } + } + return list; + } + } + + sealed class ManifestModule : Module + { + private readonly AssemblyBuilder assembly; + private readonly Guid guid = Guid.NewGuid(); + + internal ManifestModule(AssemblyBuilder assembly) + : base(assembly.universe) + { + this.assembly = assembly; + } + + public override int MDStreamVersion + { + get { return assembly.mdStreamVersion; } + } + + public override Assembly Assembly + { + get { return assembly; } + } + + internal override Type GetTypeImpl(string typeName) + { + return null; + } + + internal override void GetTypesImpl(List list) + { + } + + public override string FullyQualifiedName + { + get { return Path.Combine(assembly.dir, "RefEmit_InMemoryManifestModule"); } + } + + public override string Name + { + get { return ""; } + } + + public override Guid ModuleVersionId + { + get { return guid; } + } + + public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new ArgumentException(); + } + + public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new ArgumentException(); + } + + public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new ArgumentException(); + } + + public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new ArgumentException(); + } + + public override string ResolveString(int metadataToken) + { + throw new ArgumentException(); + } + + public override Type[] __ResolveOptionalParameterTypes(int metadataToken) + { + throw new ArgumentException(); + } + + public override string ScopeName + { + get { return "RefEmit_InMemoryManifestModule"; } + } + + public override AssemblyName[] __GetReferencedAssemblies() + { + throw new InvalidOperationException(); + } + + internal override Type GetModuleType() + { + throw new InvalidOperationException(); + } + + internal override IKVM.Reflection.Reader.ByteReader GetBlob(int blobIndex) + { + throw new InvalidOperationException(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/ConstructorBuilder.cs b/mcs/class/IKVM.Reflection/Emit/ConstructorBuilder.cs new file mode 100644 index 000000000000..9ffc91860f25 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/ConstructorBuilder.cs @@ -0,0 +1,174 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection.Emit +{ + public sealed class ConstructorBuilder : ConstructorInfo + { + private readonly MethodBuilder methodBuilder; + + internal ConstructorBuilder(MethodBuilder mb) + { + this.methodBuilder = mb; + } + + public override bool Equals(object obj) + { + ConstructorBuilder other = obj as ConstructorBuilder; + return other != null && other.methodBuilder.Equals(methodBuilder); + } + + public override int GetHashCode() + { + return methodBuilder.GetHashCode(); + } + + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) + { + return methodBuilder.DefineParameter(position, attributes, strParamName); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + methodBuilder.SetCustomAttribute(customBuilder); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + methodBuilder.SetCustomAttribute(con, binaryAttribute); + } + + public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder) + { + methodBuilder.__AddDeclarativeSecurity(customBuilder); + } + + public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet) + { + methodBuilder.AddDeclarativeSecurity(securityAction, permissionSet); + } + + public void SetImplementationFlags(MethodImplAttributes attributes) + { + methodBuilder.SetImplementationFlags(attributes); + } + + public ILGenerator GetILGenerator() + { + return methodBuilder.GetILGenerator(); + } + + public ILGenerator GetILGenerator(int streamSize) + { + return methodBuilder.GetILGenerator(streamSize); + } + + public override CallingConventions CallingConvention + { + get { return methodBuilder.CallingConvention; } + } + + public override MethodAttributes Attributes + { + get { return methodBuilder.Attributes; } + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return methodBuilder.GetMethodImplementationFlags(); + } + + public Type ReturnType + { + get { return methodBuilder.ReturnType; } + } + + internal override int ParameterCount + { + get { return methodBuilder.ParameterCount; } + } + + public override Type DeclaringType + { + get { return methodBuilder.DeclaringType; } + } + + public override string Name + { + get { return methodBuilder.Name; } + } + + public override int MetadataToken + { + get { return methodBuilder.MetadataToken; } + } + + public override Module Module + { + get { return methodBuilder.Module; } + } + + public Module GetModule() + { + return methodBuilder.GetModule(); + } + + public MethodToken GetToken() + { + return methodBuilder.GetToken(); + } + + public override MethodBody GetMethodBody() + { + return methodBuilder.GetMethodBody(); + } + + public bool InitLocals + { + get { return methodBuilder.InitLocals; } + set { methodBuilder.InitLocals = value; } + } + + internal override MethodInfo GetMethodInfo() + { + return methodBuilder; + } + + internal override MethodInfo GetMethodOnTypeDefinition() + { + return methodBuilder; + } + + internal override MethodSignature MethodSignature + { + get { return methodBuilder.MethodSignature; } + } + + internal override int ImportTo(ModuleBuilder module) + { + return module.ImportMember(methodBuilder); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/CustomAttributeBuilder.cs b/mcs/class/IKVM.Reflection/Emit/CustomAttributeBuilder.cs new file mode 100644 index 000000000000..e4fcff25c4e5 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/CustomAttributeBuilder.cs @@ -0,0 +1,492 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using System.Collections.Generic; +using System.Diagnostics; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class CustomAttributeBuilder + { + private readonly ConstructorInfo con; + private readonly byte[] blob; + private readonly object[] constructorArgs; + private readonly PropertyInfo[] namedProperties; + private readonly object[] propertyValues; + private readonly FieldInfo[] namedFields; + private readonly object[] fieldValues; + + internal CustomAttributeBuilder(ConstructorInfo con, byte[] blob) + { + this.con = con; + this.blob = blob; + } + + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs) + : this(con, constructorArgs, null, null, null,null) + { + } + + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, FieldInfo[] namedFields, object[] fieldValues) + : this(con, constructorArgs, null, null, namedFields, fieldValues) + { + } + + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues) + : this(con, constructorArgs, namedProperties, propertyValues, null, null) + { + } + + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues) + { + this.con = con; + this.constructorArgs = constructorArgs; + this.namedProperties = namedProperties; + this.propertyValues = propertyValues; + this.namedFields = namedFields; + this.fieldValues = fieldValues; + } + + private sealed class BlobWriter + { + private readonly ModuleBuilder moduleBuilder; + private readonly CustomAttributeBuilder cab; + private readonly ByteBuffer bb; + + internal BlobWriter(ModuleBuilder moduleBuilder, CustomAttributeBuilder cab, ByteBuffer bb) + { + this.moduleBuilder = moduleBuilder; + this.cab = cab; + this.bb = bb; + } + + internal void WriteCustomAttributeBlob() + { + // prolog + WriteUInt16(1); + ParameterInfo[] pi = cab.con.GetParameters(); + for (int i = 0; i < pi.Length; i++) + { + WriteFixedArg(pi[i].ParameterType, cab.constructorArgs[i]); + } + WriteNamedArguments(false); + } + + internal void WriteNamedArguments(bool forDeclSecurity) + { + // NumNamed + int named = 0; + if (cab.namedFields != null) + { + named += cab.namedFields.Length; + } + if (cab.namedProperties != null) + { + named += cab.namedProperties.Length; + } + if (forDeclSecurity) + { + WritePackedLen(named); + } + else + { + WriteUInt16((ushort)named); + } + if (cab.namedFields != null) + { + for (int i = 0; i < cab.namedFields.Length; i++) + { + WriteNamedArg(0x53, cab.namedFields[i].FieldType, cab.namedFields[i].Name, cab.fieldValues[i]); + } + } + if (cab.namedProperties != null) + { + for (int i = 0; i < cab.namedProperties.Length; i++) + { + WriteNamedArg(0x54, cab.namedProperties[i].PropertyType, cab.namedProperties[i].Name, cab.propertyValues[i]); + } + } + } + + private void WriteNamedArg(byte fieldOrProperty, Type type, string name, object value) + { + WriteByte(fieldOrProperty); + WriteFieldOrPropType(type); + WriteString(name); + WriteFixedArg(type, value); + } + + private void WriteByte(byte value) + { + bb.Write(value); + } + + private void WriteUInt16(ushort value) + { + bb.Write(value); + } + + private void WriteInt32(int value) + { + bb.Write(value); + } + + private void WriteFixedArg(Type type, object value) + { + Universe u = moduleBuilder.universe; + if (type == u.System_String) + { + WriteString((string)value); + } + else if (type == u.System_Type) + { + WriteTypeName((Type)value); + } + else if (type == u.System_Object) + { + if (value == null) + { + type = u.System_String; + } + else if (value is Type) + { + // value.GetType() would return a subclass of Type, but we don't want to deal with that + type = u.System_Type; + } + else + { + type = u.Import(value.GetType()); + } + WriteFieldOrPropType(type); + WriteFixedArg(type, value); + } + else if (type.IsArray) + { + if (value == null) + { + WriteInt32(-1); + } + else + { + Array array = (Array)value; + Type elemType = type.GetElementType(); + WriteInt32(array.Length); + foreach (object val in array) + { + WriteFixedArg(elemType, val); + } + } + } + else if (type.IsEnum) + { + WriteFixedArg(type.GetEnumUnderlyingTypeImpl(), value); + } + else + { + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + WriteByte((bool)value ? (byte)1 : (byte)0); + break; + case TypeCode.Char: + WriteUInt16((char)value); + break; + case TypeCode.SByte: + WriteByte((byte)(sbyte)value); + break; + case TypeCode.Byte: + WriteByte((byte)value); + break; + case TypeCode.Int16: + WriteUInt16((ushort)(short)value); + break; + case TypeCode.UInt16: + WriteUInt16((ushort)value); + break; + case TypeCode.Int32: + WriteInt32((int)value); + break; + case TypeCode.UInt32: + WriteInt32((int)(uint)value); + break; + case TypeCode.Int64: + WriteInt64((long)value); + break; + case TypeCode.UInt64: + WriteInt64((long)(ulong)value); + break; + case TypeCode.Single: + WriteSingle((float)value); + break; + case TypeCode.Double: + WriteDouble((double)value); + break; + default: + throw new ArgumentException(); + } + } + } + + private void WriteInt64(long value) + { + bb.Write(value); + } + + private void WriteSingle(float value) + { + bb.Write(value); + } + + private void WriteDouble(double value) + { + bb.Write(value); + } + + private void WriteTypeName(Type type) + { + string name = null; + if (type != null) + { + if (type.Assembly == moduleBuilder.Assembly) + { + name = type.FullName; + } + else + { + name = type.AssemblyQualifiedName; + } + } + WriteString(name); + } + + private void WriteString(string val) + { + bb.Write(val); + } + + private void WritePackedLen(int len) + { + bb.WriteCompressedInt(len); + } + + private void WriteFieldOrPropType(Type type) + { + Universe u = type.Module.universe; + if (type == u.System_Type) + { + WriteByte(0x50); + } + else if (type == u.System_Object) + { + WriteByte(0x51); + } + else if (type.IsArray) + { + WriteByte(0x1D); + WriteFieldOrPropType(type.GetElementType()); + } + else if (type.IsEnum) + { + WriteByte(0x55); + WriteTypeName(type); + } + else + { + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + WriteByte(0x02); + break; + case TypeCode.Char: + WriteByte(0x03); + break; + case TypeCode.SByte: + WriteByte(0x04); + break; + case TypeCode.Byte: + WriteByte(0x05); + break; + case TypeCode.Int16: + WriteByte(0x06); + break; + case TypeCode.UInt16: + WriteByte(0x07); + break; + case TypeCode.Int32: + WriteByte(0x08); + break; + case TypeCode.UInt32: + WriteByte(0x09); + break; + case TypeCode.Int64: + WriteByte(0x0A); + break; + case TypeCode.UInt64: + WriteByte(0x0B); + break; + case TypeCode.Single: + WriteByte(0x0C); + break; + case TypeCode.Double: + WriteByte(0x0D); + break; + case TypeCode.String: + WriteByte(0x0E); + break; + default: + throw new ArgumentException(); + } + } + } + } + + internal bool IsPseudoCustomAttribute + { + get { return con.DeclaringType.IsPseudoCustomAttribute; } + } + + internal ConstructorInfo Constructor + { + get { return con; } + } + + internal int WriteBlob(ModuleBuilder moduleBuilder) + { + ByteBuffer bb = new ByteBuffer(100); + if (blob != null) + { + bb.Write(blob); + } + else + { + BlobWriter bw = new BlobWriter(moduleBuilder, this, bb); + bw.WriteCustomAttributeBlob(); + } + return moduleBuilder.Blobs.Add(bb); + } + + internal object GetConstructorArgument(int pos) + { + return constructorArgs[pos]; + } + + internal int ConstructorArgumentCount + { + get { return constructorArgs == null ? 0 : constructorArgs.Length; } + } + + internal T? GetFieldValue(string name) where T : struct + { + object val = GetFieldValue(name); + if (val is T) + { + return (T)val; + } + else if (val != null) + { + if (typeof(T).IsEnum) + { + Debug.Assert(Enum.GetUnderlyingType(typeof(T)) == val.GetType()); + return (T)Enum.ToObject(typeof(T), val); + } + else + { + Debug.Assert(Enum.GetUnderlyingType(val.GetType()) == typeof(T)); + return (T)Convert.ChangeType(val, typeof(T)); + } + } + else + { + return null; + } + } + + internal object GetFieldValue(string name) + { + if (namedFields != null) + { + for (int i = 0; i < namedFields.Length; i++) + { + if (namedFields[i].Name == name) + { + return fieldValues[i]; + } + } + } + return null; + } + + internal void WriteNamedArgumentsForDeclSecurity(ModuleBuilder moduleBuilder, ByteBuffer bb) + { + BlobWriter bw = new BlobWriter(moduleBuilder, this, bb); + bw.WriteNamedArguments(true); + } + + internal CustomAttributeData ToData(Assembly asm) + { + if (blob != null) + { + return new CustomAttributeData(asm, con, new IKVM.Reflection.Reader.ByteReader(blob, 0, blob.Length)); + } + else + { + List namedArgs = new List(); + if (namedProperties != null) + { + for (int i = 0; i < namedProperties.Length; i++) + { + namedArgs.Add(new CustomAttributeNamedArgument(namedProperties[i], new CustomAttributeTypedArgument(namedProperties[i].PropertyType, propertyValues[i]))); + } + } + if (namedFields != null) + { + for (int i = 0; i < namedFields.Length; i++) + { + namedArgs.Add(new CustomAttributeNamedArgument(namedFields[i], new CustomAttributeTypedArgument(namedFields[i].FieldType, fieldValues[i]))); + } + } + return new CustomAttributeData(con, constructorArgs, namedArgs); + } + } + + internal bool HasBlob + { + get { return blob != null; } + } + + internal CustomAttributeBuilder DecodeBlob(Assembly asm) + { + if (blob == null) + { + return this; + } + else + { + return ToData(asm).__ToBuilder(); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/EnumBuilder.cs b/mcs/class/IKVM.Reflection/Emit/EnumBuilder.cs new file mode 100644 index 000000000000..5ad9686b5617 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/EnumBuilder.cs @@ -0,0 +1,98 @@ +/* + Copyright (C) 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection.Emit +{ + public sealed class EnumBuilder : Type + { + private readonly TypeBuilder typeBuilder; + private readonly FieldBuilder fieldBuilder; + + internal EnumBuilder(TypeBuilder typeBuilder, FieldBuilder fieldBuilder) + { + this.typeBuilder = typeBuilder; + this.fieldBuilder = fieldBuilder; + } + + public override Type UnderlyingSystemType + { + get { return typeBuilder.UnderlyingSystemType; } + } + + public override Type BaseType + { + get { return typeBuilder.BaseType; } + } + + public override TypeAttributes Attributes + { + get { return typeBuilder.Attributes; } + } + + public override Module Module + { + get { return typeBuilder.Module; } + } + + public FieldBuilder DefineLiteral(string literalName, object literalValue) + { + FieldBuilder fb = typeBuilder.DefineField(literalName, typeBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); + fb.SetConstant(literalValue); + return fb; + } + + public Type CreateType() + { + return typeBuilder.CreateType(); + } + + public TypeToken TypeToken + { + get { return typeBuilder.TypeToken; } + } + + public FieldBuilder UnderlyingField + { + get { return fieldBuilder; } + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + typeBuilder.SetCustomAttribute(con, binaryAttribute); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + typeBuilder.SetCustomAttribute(customBuilder); + } + + public override Type GetEnumUnderlyingType() + { + return fieldBuilder.FieldType; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/Enums.cs b/mcs/class/IKVM.Reflection/Emit/Enums.cs new file mode 100644 index 000000000000..7c85a55f67f4 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/Enums.cs @@ -0,0 +1,129 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ + +namespace IKVM.Reflection.Emit +{ + public enum AssemblyBuilderAccess + { + Save = 2, + ReflectionOnly = 6, + } + + public enum OpCodeType + { + Annotation = 0, + Macro = 1, + Nternal = 2, + Objmodel = 3, + Prefix = 4, + Primitive = 5, + } + + public enum OperandType + { + InlineBrTarget = 0, + InlineField = 1, + InlineI = 2, + InlineI8 = 3, + InlineMethod = 4, + InlineNone = 5, + InlinePhi = 6, + InlineR = 7, + InlineSig = 9, + InlineString = 10, + InlineSwitch = 11, + InlineTok = 12, + InlineType = 13, + InlineVar = 14, + ShortInlineBrTarget = 15, + ShortInlineI = 16, + ShortInlineR = 17, + ShortInlineVar = 18, + } + + public enum FlowControl + { + Branch = 0, + Break = 1, + Call = 2, + Cond_Branch = 3, + Meta = 4, + Next = 5, + Return = 7, + Throw = 8, + } + + public enum PackingSize + { + Unspecified = 0, + Size1 = 1, + Size2 = 2, + Size4 = 4, + Size8 = 8, + Size16 = 16, + Size32 = 32, + Size64 = 64, + Size128 = 128, + } + + public enum PEFileKinds + { + Dll = 1, + ConsoleApplication = 2, + WindowApplication = 3, + } + + public enum StackBehaviour + { + Pop0 = 0, + Pop1 = 1, + Pop1_pop1 = 2, + Popi = 3, + Popi_pop1 = 4, + Popi_popi = 5, + Popi_popi8 = 6, + Popi_popi_popi = 7, + Popi_popr4 = 8, + Popi_popr8 = 9, + Popref = 10, + Popref_pop1 = 11, + Popref_popi = 12, + Popref_popi_popi = 13, + Popref_popi_popi8 = 14, + Popref_popi_popr4 = 15, + Popref_popi_popr8 = 16, + Popref_popi_popref = 17, + Push0 = 18, + Push1 = 19, + Push1_push1 = 20, + Pushi = 21, + Pushi8 = 22, + Pushr4 = 23, + Pushr8 = 24, + Pushref = 25, + Varpop = 26, + Varpush = 27, + Popref_popi_pop1 = 28, + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/EventBuilder.cs b/mcs/class/IKVM.Reflection/Emit/EventBuilder.cs new file mode 100644 index 000000000000..be29644456e4 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/EventBuilder.cs @@ -0,0 +1,250 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class EventBuilder : EventInfo + { + private readonly TypeBuilder typeBuilder; + private readonly string name; + private EventAttributes attributes; + private readonly int eventtype; + private MethodBuilder addOnMethod; + private MethodBuilder removeOnMethod; + private MethodBuilder fireMethod; + private List otherMethods; + private int lazyPseudoToken; + + internal EventBuilder(TypeBuilder typeBuilder, string name, EventAttributes attributes, Type eventtype) + { + this.typeBuilder = typeBuilder; + this.name = name; + this.attributes = attributes; + this.eventtype = typeBuilder.ModuleBuilder.GetTypeTokenForMemberRef(eventtype); + } + + public void SetAddOnMethod(MethodBuilder mdBuilder) + { + addOnMethod = mdBuilder; + } + + public void SetRemoveOnMethod(MethodBuilder mdBuilder) + { + removeOnMethod = mdBuilder; + } + + public void SetRaiseMethod(MethodBuilder mdBuilder) + { + fireMethod = mdBuilder; + } + + public void AddOtherMethod(MethodBuilder mdBuilder) + { + if (otherMethods == null) + { + otherMethods = new List(); + } + otherMethods.Add(mdBuilder); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + Universe u = typeBuilder.ModuleBuilder.universe; + if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute) + { + attributes |= EventAttributes.SpecialName; + } + else + { + if (lazyPseudoToken == 0) + { + lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken(); + } + typeBuilder.ModuleBuilder.SetCustomAttribute(lazyPseudoToken, customBuilder); + } + } + + public override EventAttributes Attributes + { + get { return attributes; } + } + + public override MethodInfo GetAddMethod(bool nonPublic) + { + return nonPublic || (addOnMethod != null && addOnMethod.IsPublic) ? addOnMethod : null; + } + + public override MethodInfo GetRemoveMethod(bool nonPublic) + { + return nonPublic || (removeOnMethod != null && removeOnMethod.IsPublic) ? removeOnMethod : null; + } + + public override MethodInfo GetRaiseMethod(bool nonPublic) + { + return nonPublic || (fireMethod != null && fireMethod.IsPublic) ? fireMethod : null; + } + + public override MethodInfo[] GetOtherMethods(bool nonPublic) + { + List list = new List(); + if (otherMethods != null) + { + foreach (MethodInfo method in otherMethods) + { + if (nonPublic || method.IsPublic) + { + list.Add(method); + } + } + } + return list.ToArray(); + } + + public override Type DeclaringType + { + get { return typeBuilder; } + } + + public override string Name + { + get { return name; } + } + + public override Module Module + { + get { return typeBuilder.ModuleBuilder; } + } + + public EventToken GetEventToken() + { + if (lazyPseudoToken == 0) + { + lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken(); + } + return new EventToken(lazyPseudoToken); + } + + public override Type EventHandlerType + { + get { return typeBuilder.ModuleBuilder.ResolveType(eventtype); } + } + + internal void Bake() + { + EventTable.Record rec = new EventTable.Record(); + rec.EventFlags = (short)attributes; + rec.Name = typeBuilder.ModuleBuilder.Strings.Add(name); + rec.EventType = eventtype; + int token = 0x14000000 | typeBuilder.ModuleBuilder.Event.AddRecord(rec); + + if (lazyPseudoToken != 0) + { + typeBuilder.ModuleBuilder.RegisterTokenFixup(lazyPseudoToken, token); + } + + if (addOnMethod != null) + { + AddMethodSemantics(MethodSemanticsTable.AddOn, addOnMethod.MetadataToken, token); + } + if (removeOnMethod != null) + { + AddMethodSemantics(MethodSemanticsTable.RemoveOn, removeOnMethod.MetadataToken, token); + } + if (fireMethod != null) + { + AddMethodSemantics(MethodSemanticsTable.Fire, fireMethod.MetadataToken, token); + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + AddMethodSemantics(MethodSemanticsTable.Other, method.MetadataToken, token); + } + } + } + + private void AddMethodSemantics(short semantics, int methodToken, int propertyToken) + { + MethodSemanticsTable.Record rec = new MethodSemanticsTable.Record(); + rec.Semantics = semantics; + rec.Method = methodToken; + rec.Association = propertyToken; + typeBuilder.ModuleBuilder.MethodSemantics.AddRecord(rec); + } + + internal override bool IsPublic + { + get + { + if ((addOnMethod != null && addOnMethod.IsPublic) || (removeOnMethod != null && removeOnMethod.IsPublic) || (fireMethod != null && fireMethod.IsPublic)) + { + return true; + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + if (method.IsPublic) + { + return true; + } + } + } + return false; + } + } + + internal override bool IsStatic + { + get + { + if ((addOnMethod != null && addOnMethod.IsStatic) || (removeOnMethod != null && removeOnMethod.IsStatic) || (fireMethod != null && fireMethod.IsStatic)) + { + return true; + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + if (method.IsStatic) + { + return true; + } + } + } + return false; + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/FieldBuilder.cs b/mcs/class/IKVM.Reflection/Emit/FieldBuilder.cs new file mode 100644 index 000000000000..43161176cfde --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/FieldBuilder.cs @@ -0,0 +1,184 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.CompilerServices; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class FieldBuilder : FieldInfo + { + private readonly TypeBuilder typeBuilder; + private readonly string name; + private readonly int pseudoToken; + private FieldAttributes attribs; + private readonly int nameIndex; + private readonly int signature; + private readonly FieldSignature fieldSig; + + internal FieldBuilder(TypeBuilder type, string name, Type fieldType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attribs) + { + this.typeBuilder = type; + this.name = name; + this.pseudoToken = type.ModuleBuilder.AllocPseudoToken(); + this.nameIndex = type.ModuleBuilder.Strings.Add(name); + this.fieldSig = FieldSignature.Create(fieldType, optionalCustomModifiers, requiredCustomModifiers); + ByteBuffer sig = new ByteBuffer(5); + fieldSig.WriteSig(this.typeBuilder.ModuleBuilder, sig); + this.signature = this.typeBuilder.ModuleBuilder.Blobs.Add(sig); + this.attribs = attribs; + this.typeBuilder.ModuleBuilder.Field.AddVirtualRecord(); + } + + public void SetConstant(object defaultValue) + { + attribs |= FieldAttributes.HasDefault; + typeBuilder.ModuleBuilder.AddConstant(pseudoToken, defaultValue); + } + + public override object GetRawConstantValue() + { + return typeBuilder.Module.Constant.GetRawConstantValue(typeBuilder.Module, this.MetadataToken); + } + + public void __SetDataAndRVA(byte[] data) + { + attribs |= FieldAttributes.HasFieldRVA; + FieldRVATable.Record rec = new FieldRVATable.Record(); + rec.RVA = typeBuilder.ModuleBuilder.initializedData.Position; + rec.Field = pseudoToken; + typeBuilder.ModuleBuilder.FieldRVA.AddRecord(rec); + typeBuilder.ModuleBuilder.initializedData.Write(data); + } + + public override void __GetDataFromRVA(byte[] data, int offset, int length) + { + throw new NotImplementedException(); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + Universe u = this.Module.universe; + if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_FieldOffsetAttribute) + { + customBuilder = customBuilder.DecodeBlob(this.Module.Assembly); + SetOffset((int)customBuilder.GetConstructorArgument(0)); + } + else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute) + { + MarshalSpec.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder); + attribs |= FieldAttributes.HasFieldMarshal; + } + else if (customBuilder.Constructor.DeclaringType == u.System_NonSerializedAttribute) + { + attribs |= FieldAttributes.NotSerialized; + } + else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute) + { + attribs |= FieldAttributes.SpecialName; + } + else + { + typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder); + } + } + + public void SetOffset(int iOffset) + { + FieldLayoutTable.Record rec = new FieldLayoutTable.Record(); + rec.Offset = iOffset; + rec.Field = pseudoToken; + typeBuilder.ModuleBuilder.FieldLayout.AddRecord(rec); + } + + public override FieldAttributes Attributes + { + get { return attribs; } + } + + public override Type DeclaringType + { + get { return typeBuilder.IsModulePseudoType ? null : typeBuilder; } + } + + public override string Name + { + get { return name; } + } + + public override int MetadataToken + { + get { return pseudoToken; } + } + + public override Module Module + { + get { return typeBuilder.Module; } + } + + public FieldToken GetToken() + { + return new FieldToken(pseudoToken); + } + + internal void WriteFieldRecords(MetadataWriter mw) + { + mw.Write((short)attribs); + mw.WriteStringIndex(nameIndex); + mw.WriteBlobIndex(signature); + } + + internal void FixupToken(int token) + { + typeBuilder.ModuleBuilder.RegisterTokenFixup(this.pseudoToken, token); + } + + internal override FieldSignature FieldSignature + { + get { return fieldSig; } + } + + internal override int ImportTo(ModuleBuilder other) + { + if (typeBuilder.IsGenericTypeDefinition) + { + return other.ImportMember(TypeBuilder.GetField(typeBuilder, this)); + } + else if (other == typeBuilder.ModuleBuilder) + { + return pseudoToken; + } + else + { + return other.ImportMethodOrField(typeBuilder, name, fieldSig); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/ILGenerator.cs b/mcs/class/IKVM.Reflection/Emit/ILGenerator.cs new file mode 100644 index 000000000000..5a86d1f9829f --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/ILGenerator.cs @@ -0,0 +1,1143 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Diagnostics.SymbolStore; +using System.Diagnostics; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public struct Label + { + // 1-based here, to make sure that an uninitialized Label isn't valid + private readonly int index1; + + internal Label(int index) + { + this.index1 = index + 1; + } + + internal int Index + { + get { return index1 - 1; } + } + + public bool Equals(Label other) + { + return other.index1 == index1; + } + + public override bool Equals(object obj) + { + return this == obj as Label?; + } + + public override int GetHashCode() + { + return index1; + } + + public static bool operator ==(Label arg1, Label arg2) + { + return arg1.index1 == arg2.index1; + } + + public static bool operator !=(Label arg1, Label arg2) + { + return !(arg1 == arg2); + } + } + + public sealed class LocalBuilder + { + private readonly Type localType; + private readonly int index; + private readonly bool pinned; + internal string name; + internal int startOffset; + internal int endOffset; + + internal LocalBuilder(Type localType, int index, bool pinned) + { + this.localType = localType; + this.index = index; + this.pinned = pinned; + } + + public void SetLocalSymInfo(string name) + { + this.name = name; + } + + public void SetLocalSymInfo(string name, int startOffset, int endOffset) + { + this.name = name; + this.startOffset = startOffset; + this.endOffset = endOffset; + } + + public Type LocalType + { + get { return localType; } + } + + public int LocalIndex + { + get { return index; } + } + + public bool IsPinned + { + get { return pinned; } + } + } + + public sealed class ILGenerator + { + private static readonly Type FAULT = new BakedType(null); // the type we use here doesn't matter, as long as it can never be used as a real exception type + private readonly ModuleBuilder moduleBuilder; + private readonly ByteBuffer code; + private readonly List locals = new List(); + private readonly List tokenFixups = new List(); + private readonly List labels = new List(); + private readonly List labelStackHeight = new List(); + private readonly List labelFixups = new List(); + private readonly List sequencePoints = new List(); + private readonly List exceptions = new List(); + private readonly Stack exceptionStack = new Stack(); + private ushort maxStack; + private int stackHeight; + private Scope scope; + private byte exceptionBlockAssistanceMode = EBAM_COMPAT; + private const byte EBAM_COMPAT = 0; + private const byte EBAM_DISABLE = 1; + private const byte EBAM_CLEVER = 2; + + private struct LabelFixup + { + internal int label; + internal int offset; + } + + private sealed class ExceptionBlock : IComparer + { + internal readonly int ordinal; + internal Label labelEnd; + internal int tryOffset; + internal int tryLength; + internal int handlerOffset; + internal int handlerLength; + internal Type exceptionType; // null = finally block or handler with filter, FAULT = fault block + internal int filterOffset; + + internal ExceptionBlock(int ordinal) + { + this.ordinal = ordinal; + } + + int IComparer.Compare(ExceptionBlock x, ExceptionBlock y) + { + // Mono's sort insists on doing unnecessary comparisons + if (x == y) + { + return 0; + } + if (x.tryOffset >= y.handlerOffset && x.tryOffset + x.tryLength <= y.handlerOffset + y.handlerLength) + { + return -1; + } + if (y.tryOffset >= x.handlerOffset && y.tryOffset + y.tryLength <= x.handlerOffset + x.handlerLength) + { + return 1; + } + if (x.tryOffset == y.tryOffset && x.tryLength == y.tryLength) + { + return x.ordinal < y.ordinal ? -1 : 1; + } + if (x.tryOffset + x.tryLength <= y.tryOffset) + { + return -1; + } + if (y.tryOffset + y.tryLength <= x.tryOffset) + { + return 1; + } + if (x.tryOffset > y.tryOffset || (x.tryOffset == y.tryOffset && x.tryLength < y.tryLength)) + { + return -1; + } + else + { + return 1; + } + } + } + + private struct SequencePoint + { + internal ISymbolDocumentWriter document; + internal int offset; + internal int startLine; + internal int startColumn; + internal int endLine; + internal int endColumn; + } + + private sealed class Scope + { + internal readonly Scope parent; + internal readonly List children = new List(); + internal readonly List locals = new List(); + internal int startOffset; + internal int endOffset; + + internal Scope(Scope parent) + { + this.parent = parent; + } + } + + internal ILGenerator(ModuleBuilder moduleBuilder, int initialCapacity) + { + this.code = new ByteBuffer(initialCapacity); + this.moduleBuilder = moduleBuilder; + if (moduleBuilder.symbolWriter != null) + { + scope = new Scope(null); + } + } + + private bool IsLabelReachable(Label label) + { + return labelStackHeight[label.Index] != -1; + } + + // non-standard API + public void __DisableExceptionBlockAssistance() + { + exceptionBlockAssistanceMode = EBAM_DISABLE; + } + + // non-standard API + public void __CleverExceptionBlockAssistance() + { + exceptionBlockAssistanceMode = EBAM_CLEVER; + } + + // new in .NET 4.0 + public int ILOffset + { + get { return code.Position; } + } + + public void BeginCatchBlock(Type exceptionType) + { + ExceptionBlock block = exceptionStack.Peek(); + if (exceptionBlockAssistanceMode == EBAM_COMPAT || (exceptionBlockAssistanceMode == EBAM_CLEVER && stackHeight != -1)) + { + if (exceptionType == null) + { + Emit(OpCodes.Endfilter); + } + else + { + Emit(OpCodes.Leave, block.labelEnd); + } + } + stackHeight = 0; + UpdateStack(1); + if (block.tryLength == 0) + { + block.tryLength = code.Position - block.tryOffset; + } + else if (exceptionType != null) + { + block.handlerLength = code.Position - block.handlerOffset; + exceptionStack.Pop(); + ExceptionBlock newBlock = new ExceptionBlock(exceptions.Count); + newBlock.labelEnd = block.labelEnd; + newBlock.tryOffset = block.tryOffset; + newBlock.tryLength = block.tryLength; + block = newBlock; + exceptions.Add(block); + exceptionStack.Push(block); + } + block.handlerOffset = code.Position; + block.exceptionType = exceptionType; + } + + public Label BeginExceptionBlock() + { + ExceptionBlock block = new ExceptionBlock(exceptions.Count); + block.labelEnd = DefineLabel(); + block.tryOffset = code.Position; + exceptionStack.Push(block); + exceptions.Add(block); + return block.labelEnd; + } + + public void BeginExceptFilterBlock() + { + ExceptionBlock block = BeginFinallyFilterFaultBlock(); + block.filterOffset = code.Position; + UpdateStack(1); + } + + public void BeginFaultBlock() + { + ExceptionBlock block = BeginFinallyFilterFaultBlock(); + block.handlerOffset = code.Position; + block.exceptionType = FAULT; + } + + public void BeginFinallyBlock() + { + ExceptionBlock block = BeginFinallyFilterFaultBlock(); + block.handlerOffset = code.Position; + } + + private ExceptionBlock BeginFinallyFilterFaultBlock() + { + ExceptionBlock block = exceptionStack.Peek(); + if (exceptionBlockAssistanceMode == EBAM_COMPAT || (exceptionBlockAssistanceMode == EBAM_CLEVER && stackHeight != -1)) + { + Emit(OpCodes.Leave, block.labelEnd); + } + if (block.handlerOffset == 0) + { + block.tryLength = code.Position - block.tryOffset; + } + else + { + block.handlerLength = code.Position - block.handlerOffset; + Label labelEnd; + if (exceptionBlockAssistanceMode != EBAM_COMPAT) + { + labelEnd = block.labelEnd; + } + else + { + MarkLabel(block.labelEnd); + labelEnd = DefineLabel(); + Emit(OpCodes.Leave, labelEnd); + } + exceptionStack.Pop(); + ExceptionBlock newBlock = new ExceptionBlock(exceptions.Count); + newBlock.labelEnd = labelEnd; + newBlock.tryOffset = block.tryOffset; + newBlock.tryLength = code.Position - block.tryOffset; + block = newBlock; + exceptions.Add(block); + exceptionStack.Push(block); + } + stackHeight = 0; + return block; + } + + public void EndExceptionBlock() + { + ExceptionBlock block = exceptionStack.Pop(); + if (exceptionBlockAssistanceMode == EBAM_COMPAT || (exceptionBlockAssistanceMode == EBAM_CLEVER && stackHeight != -1)) + { + if (block.filterOffset != 0 || (block.exceptionType != null && block.exceptionType != FAULT)) + { + Emit(OpCodes.Leave, block.labelEnd); + } + else + { + Emit(OpCodes.Endfinally); + } + } + MarkLabel(block.labelEnd); + block.handlerLength = code.Position - block.handlerOffset; + } + + public void BeginScope() + { + Scope newScope = new Scope(scope); + scope.children.Add(newScope); + scope = newScope; + scope.startOffset = code.Position; + } + + public void UsingNamespace(string usingNamespace) + { + if (moduleBuilder.symbolWriter != null) + { + moduleBuilder.symbolWriter.UsingNamespace(usingNamespace); + } + } + + public LocalBuilder DeclareLocal(Type localType) + { + return DeclareLocal(localType, false); + } + + public LocalBuilder DeclareLocal(Type localType, bool pinned) + { + LocalBuilder local = new LocalBuilder(localType, locals.Count, pinned); + locals.Add(local); + if (scope != null) + { + scope.locals.Add(local); + } + return local; + } + + public Label DefineLabel() + { + Label label = new Label(labels.Count); + labels.Add(-1); + labelStackHeight.Add(-1); + return label; + } + + public void Emit(OpCode opc) + { + Debug.Assert(opc != OpCodes.Ret || (opc == OpCodes.Ret && stackHeight <= 1)); + if (opc.Value < 0) + { + code.Write((byte)(opc.Value >> 8)); + } + code.Write((byte)opc.Value); + switch (opc.FlowControl) + { + case FlowControl.Branch: + case FlowControl.Break: + case FlowControl.Return: + case FlowControl.Throw: + stackHeight = -1; + break; + default: + UpdateStack(opc.StackDiff); + break; + } + } + + private void UpdateStack(int stackdiff) + { + if (stackHeight == -1) + { + // we're about to emit code that is either unreachable or reachable only via a backward branch + stackHeight = 0; + } + Debug.Assert(stackHeight >= 0 && stackHeight <= ushort.MaxValue); + stackHeight += stackdiff; + Debug.Assert(stackHeight >= 0 && stackHeight <= ushort.MaxValue); + maxStack = Math.Max(maxStack, (ushort)stackHeight); + } + + public void Emit(OpCode opc, byte arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, double arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, FieldInfo field) + { + Emit(opc); + WriteToken(moduleBuilder.GetFieldToken(field)); + } + + public void Emit(OpCode opc, short arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, int arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, long arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, Label label) + { + // We need special stackHeight handling for unconditional branches, + // because the branch and next flows have differing stack heights. + // Note that this assumes that unconditional branches do not push/pop. + int flowStackHeight = this.stackHeight; + Emit(opc); + if (opc == OpCodes.Leave || opc == OpCodes.Leave_S) + { + flowStackHeight = 0; + } + else if (opc.FlowControl != FlowControl.Branch) + { + flowStackHeight = this.stackHeight; + } + // if the label has already been marked, we can emit the branch offset directly + if (labels[label.Index] != -1) + { + if (labelStackHeight[label.Index] != flowStackHeight && (labelStackHeight[label.Index] != 0 || flowStackHeight != -1)) + { + // the "backward branch constraint" prohibits this, so we don't need to support it + throw new NotSupportedException("'Backward branch constraints' violated"); + } + if (opc.OperandType == OperandType.ShortInlineBrTarget) + { + WriteByteBranchOffset(labels[label.Index] - (code.Position + 1)); + } + else + { + code.Write(labels[label.Index] - (code.Position + 4)); + } + } + else + { + Debug.Assert(labelStackHeight[label.Index] == -1 || labelStackHeight[label.Index] == flowStackHeight || (flowStackHeight == -1 && labelStackHeight[label.Index] == 0)); + labelStackHeight[label.Index] = flowStackHeight; + LabelFixup fix = new LabelFixup(); + fix.label = label.Index; + fix.offset = code.Position; + labelFixups.Add(fix); + if (opc.OperandType == OperandType.ShortInlineBrTarget) + { + code.Write((byte)1); + } + else + { + code.Write(4); + } + } + } + + private void WriteByteBranchOffset(int offset) + { + if (offset < -128 || offset > 127) + { + throw new NotSupportedException("Branch offset of " + offset + " does not fit in one-byte branch target at position " + code.Position); + } + code.Write((byte)offset); + } + + public void Emit(OpCode opc, Label[] labels) + { + Emit(opc); + LabelFixup fix = new LabelFixup(); + fix.label = -1; + fix.offset = code.Position; + labelFixups.Add(fix); + code.Write(labels.Length); + foreach (Label label in labels) + { + code.Write(label.Index); + if (this.labels[label.Index] != -1) + { + if (labelStackHeight[label.Index] != stackHeight) + { + // the "backward branch constraint" prohibits this, so we don't need to support it + throw new NotSupportedException(); + } + } + else + { + Debug.Assert(labelStackHeight[label.Index] == -1 || labelStackHeight[label.Index] == stackHeight); + labelStackHeight[label.Index] = stackHeight; + } + } + } + + public void Emit(OpCode opc, LocalBuilder local) + { + if ((opc == OpCodes.Ldloc || opc == OpCodes.Ldloca || opc == OpCodes.Stloc) && local.LocalIndex < 256) + { + if (opc == OpCodes.Ldloc) + { + switch (local.LocalIndex) + { + case 0: + Emit(OpCodes.Ldloc_0); + break; + case 1: + Emit(OpCodes.Ldloc_1); + break; + case 2: + Emit(OpCodes.Ldloc_2); + break; + case 3: + Emit(OpCodes.Ldloc_3); + break; + default: + Emit(OpCodes.Ldloc_S); + code.Write((byte)local.LocalIndex); + break; + } + } + else if (opc == OpCodes.Ldloca) + { + Emit(OpCodes.Ldloca_S); + code.Write((byte)local.LocalIndex); + } + else if (opc == OpCodes.Stloc) + { + switch (local.LocalIndex) + { + case 0: + Emit(OpCodes.Stloc_0); + break; + case 1: + Emit(OpCodes.Stloc_1); + break; + case 2: + Emit(OpCodes.Stloc_2); + break; + case 3: + Emit(OpCodes.Stloc_3); + break; + default: + Emit(OpCodes.Stloc_S); + code.Write((byte)local.LocalIndex); + break; + } + } + } + else + { + Emit(opc); + switch (opc.OperandType) + { + case OperandType.InlineVar: + code.Write((ushort)local.LocalIndex); + break; + case OperandType.ShortInlineVar: + code.Write((byte)local.LocalIndex); + break; + } + } + } + + private void WriteToken(FieldToken token) + { + if (token.IsPseudoToken) + { + tokenFixups.Add(code.Position); + } + code.Write(token.Token); + } + + private void WriteToken(MethodToken token) + { + if (token.IsPseudoToken) + { + tokenFixups.Add(code.Position); + } + code.Write(token.Token); + } + + private void UpdateStack(OpCode opc, bool hasthis, Type returnType, int parameterCount) + { + if (opc == OpCodes.Jmp) + { + stackHeight = -1; + } + else if (opc.FlowControl == FlowControl.Call) + { + int stackdiff = 0; + if ((hasthis && opc != OpCodes.Newobj) || opc == OpCodes.Calli) + { + // pop this + stackdiff--; + } + // pop parameters + stackdiff -= parameterCount; + if (returnType != moduleBuilder.universe.System_Void) + { + // push return value + stackdiff++; + } + UpdateStack(stackdiff); + } + } + + public void Emit(OpCode opc, MethodInfo method) + { + Emit(opc); + WriteToken(moduleBuilder.GetMethodTokenForIL(method)); + UpdateStack(opc, method.HasThis, method.ReturnType, method.ParameterCount); + } + + public void Emit(OpCode opc, ConstructorInfo constructor) + { + Emit(opc, constructor.GetMethodInfo()); + } + + public void Emit(OpCode opc, sbyte arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, float arg) + { + Emit(opc); + code.Write(arg); + } + + public void Emit(OpCode opc, string str) + { + Emit(opc); + code.Write(0x70000000 | moduleBuilder.UserStrings.Add(str)); + } + + public void Emit(OpCode opc, Type type) + { + Emit(opc); + if (opc == OpCodes.Ldtoken) + { + code.Write(moduleBuilder.GetTypeToken(type).Token); + } + else + { + code.Write(moduleBuilder.GetTypeTokenForMemberRef(type)); + } + } + + public void Emit(OpCode opcode, SignatureHelper signature) + { + Emit(opcode); + UpdateStack(opcode, signature.HasThis, signature.ReturnType, signature.ParameterCount); + code.Write(0x11000000 | moduleBuilder.StandAloneSig.FindOrAddRecord(moduleBuilder.Blobs.Add(signature.GetSignature(moduleBuilder)))); + } + + public void EmitCall(OpCode opc, MethodInfo method, Type[] optionalParameterTypes) + { + if (optionalParameterTypes == null || optionalParameterTypes.Length == 0) + { + Emit(opc, method); + } + else + { + Emit(opc); + UpdateStack(opc, method.HasThis, method.ReturnType, method.ParameterCount + optionalParameterTypes.Length); + ByteBuffer sig = new ByteBuffer(16); + method.MethodSignature.WriteMethodRefSig(moduleBuilder, sig, optionalParameterTypes); + MemberRefTable.Record record = new MemberRefTable.Record(); + if (method.Module == moduleBuilder) + { + record.Class = method.MetadataToken; + } + else + { + record.Class = moduleBuilder.GetTypeTokenForMemberRef(method.DeclaringType ?? method.Module.GetModuleType()); + } + record.Name = moduleBuilder.Strings.Add(method.Name); + record.Signature = moduleBuilder.Blobs.Add(sig); + code.Write(0x0A000000 | moduleBuilder.MemberRef.FindOrAddRecord(record)); + } + } + + public void __EmitCall(OpCode opc, ConstructorInfo constructor, Type[] optionalParameterTypes) + { + EmitCall(opc, constructor.GetMethodInfo(), optionalParameterTypes); + } + + public void EmitCalli(OpCode opc, CallingConvention callingConvention, Type returnType, Type[] parameterTypes) + { + returnType = returnType ?? moduleBuilder.universe.System_Void; + Emit(opc); + UpdateStack(opc, false, returnType, parameterTypes.Length); + ByteBuffer sig = new ByteBuffer(16); + Signature.WriteStandAloneMethodSig(moduleBuilder, sig, callingConvention, returnType, parameterTypes); + code.Write(0x11000000 | moduleBuilder.StandAloneSig.FindOrAddRecord(moduleBuilder.Blobs.Add(sig))); + } + + public void EmitCalli(OpCode opc, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) + { + returnType = returnType ?? moduleBuilder.universe.System_Void; + optionalParameterTypes = optionalParameterTypes ?? Type.EmptyTypes; + Emit(opc); + UpdateStack(opc, (callingConvention & CallingConventions.HasThis | CallingConventions.ExplicitThis) == CallingConventions.HasThis, returnType, parameterTypes.Length + optionalParameterTypes.Length); + ByteBuffer sig = new ByteBuffer(16); + Signature.WriteStandAloneMethodSig(moduleBuilder, sig, callingConvention, returnType, parameterTypes, optionalParameterTypes); + code.Write(0x11000000 | moduleBuilder.StandAloneSig.FindOrAddRecord(moduleBuilder.Blobs.Add(sig))); + } + + public void EmitWriteLine(string text) + { + Universe u = moduleBuilder.universe; + Emit(OpCodes.Ldstr, text); + Emit(OpCodes.Call, u.Import(typeof(Console)).GetMethod("WriteLine", new Type[] { u.System_String })); + } + + public void EmitWriteLine(FieldInfo field) + { + Universe u = moduleBuilder.universe; + Emit(OpCodes.Call, u.Import(typeof(Console)).GetMethod("get_Out")); + if (field.IsStatic) + { + Emit(OpCodes.Ldsfld, field); + } + else + { + Emit(OpCodes.Ldarg_0); + Emit(OpCodes.Ldfld, field); + } + Emit(OpCodes.Callvirt, u.Import(typeof(System.IO.TextWriter)).GetMethod("WriteLine", new Type[] { field.FieldType })); + } + + public void EmitWriteLine(LocalBuilder local) + { + Universe u = moduleBuilder.universe; + Emit(OpCodes.Call, u.Import(typeof(Console)).GetMethod("get_Out")); + Emit(OpCodes.Ldloc, local); + Emit(OpCodes.Callvirt, u.Import(typeof(System.IO.TextWriter)).GetMethod("WriteLine", new Type[] { local.LocalType })); + } + + public void EndScope() + { + scope.endOffset = code.Position; + scope = scope.parent; + } + + public void MarkLabel(Label loc) + { + Debug.Assert(stackHeight == -1 || labelStackHeight[loc.Index] == -1 || stackHeight == labelStackHeight[loc.Index]); + labels[loc.Index] = code.Position; + if (labelStackHeight[loc.Index] == -1) + { + if (stackHeight == -1) + { + // We're at a location that can only be reached by a backward branch, + // so according to the "backward branch constraint" that must mean the stack is empty, + // but note that this may be an unused label followed by another label that is used and + // that does have a non-zero stack height, so we don't yet set stackHeight here. + labelStackHeight[loc.Index] = 0; + } + else + { + labelStackHeight[loc.Index] = stackHeight; + } + } + else + { + Debug.Assert(stackHeight == -1 || stackHeight == labelStackHeight[loc.Index]); + stackHeight = labelStackHeight[loc.Index]; + } + } + + public void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) + { + SequencePoint sp = new SequencePoint(); + sp.document = document; + sp.offset = code.Position; + sp.startLine = startLine; + sp.startColumn = startColumn; + sp.endLine = endLine; + sp.endColumn = endColumn; + sequencePoints.Add(sp); + } + + public void ThrowException(Type excType) + { + Emit(OpCodes.Newobj, excType.GetConstructor(Type.EmptyTypes)); + Emit(OpCodes.Throw); + } + + internal int WriteBody(bool initLocals) + { + if (moduleBuilder.symbolWriter != null) + { + Debug.Assert(scope != null && scope.parent == null); + scope.endOffset = code.Position; + } + + ResolveBranches(); + + ByteBuffer bb = moduleBuilder.methodBodies; + + int localVarSigTok = 0; + + int rva; + if (locals.Count == 0 && exceptions.Count == 0 && maxStack <= 8 && code.Length < 64) + { + rva = WriteTinyHeaderAndCode(bb); + } + else + { + rva = WriteFatHeaderAndCode(bb, ref localVarSigTok, initLocals); + } + + if (moduleBuilder.symbolWriter != null) + { + if (sequencePoints.Count != 0) + { + ISymbolDocumentWriter document = sequencePoints[0].document; + int[] offsets = new int[sequencePoints.Count]; + int[] lines = new int[sequencePoints.Count]; + int[] columns = new int[sequencePoints.Count]; + int[] endLines = new int[sequencePoints.Count]; + int[] endColumns = new int[sequencePoints.Count]; + for (int i = 0; i < sequencePoints.Count; i++) + { + if (sequencePoints[i].document != document) + { + throw new NotImplementedException(); + } + offsets[i] = sequencePoints[i].offset; + lines[i] = sequencePoints[i].startLine; + columns[i] = sequencePoints[i].startColumn; + endLines[i] = sequencePoints[i].endLine; + endColumns[i] = sequencePoints[i].endColumn; + } + moduleBuilder.symbolWriter.DefineSequencePoints(document, offsets, lines, columns, endLines, endColumns); + } + + WriteScope(scope, localVarSigTok); + } + return rva; + } + + private void ResolveBranches() + { + foreach (LabelFixup fixup in labelFixups) + { + // is it a switch? + if (fixup.label == -1) + { + code.Position = fixup.offset; + int count = code.GetInt32AtCurrentPosition(); + int offset = fixup.offset + 4 + 4 * count; + code.Position += 4; + for (int i = 0; i < count; i++) + { + int index = code.GetInt32AtCurrentPosition(); + code.Write(labels[index] - offset); + } + } + else + { + code.Position = fixup.offset; + byte size = code.GetByteAtCurrentPosition(); + int branchOffset = labels[fixup.label] - (code.Position + size); + if (size == 1) + { + WriteByteBranchOffset(branchOffset); + } + else + { + code.Write(branchOffset); + } + } + } + } + + private int WriteTinyHeaderAndCode(ByteBuffer bb) + { + int rva = bb.Position; + const byte CorILMethod_TinyFormat = 0x2; + bb.Write((byte)(CorILMethod_TinyFormat | (code.Length << 2))); + WriteCode(bb); + return rva; + } + + private int WriteFatHeaderAndCode(ByteBuffer bb, ref int localVarSigTok, bool initLocals) + { + // fat headers require 4-byte alignment + bb.Align(4); + int rva = bb.Position; + + if (locals.Count != 0) + { + ByteBuffer localVarSig = new ByteBuffer(locals.Count + 2); + Signature.WriteLocalVarSig(moduleBuilder, localVarSig, locals); + localVarSigTok = 0x11000000 | moduleBuilder.StandAloneSig.FindOrAddRecord(moduleBuilder.Blobs.Add(localVarSig)); + } + + const byte CorILMethod_FatFormat = 0x03; + const byte CorILMethod_MoreSects = 0x08; + const byte CorILMethod_InitLocals = 0x10; + + short flagsAndSize = (short)(CorILMethod_FatFormat | (3 << 12)); + if (initLocals) + { + flagsAndSize |= CorILMethod_InitLocals; + } + + if (exceptions.Count > 0) + { + flagsAndSize |= CorILMethod_MoreSects; + } + + bb.Write(flagsAndSize); + bb.Write(maxStack); + bb.Write(code.Length); + bb.Write(localVarSigTok); + + WriteCode(bb); + + if (exceptions.Count > 0) + { + bb.Align(4); + + bool fat = false; + foreach (ExceptionBlock block in exceptions) + { + if (block.tryOffset > 65535 || block.tryLength > 255 || block.handlerOffset > 65535 || block.handlerLength > 255) + { + fat = true; + break; + } + } + exceptions.Sort(exceptions[0]); + if (exceptions.Count * 12 + 4 > 255) + { + fat = true; + } + const byte CorILMethod_Sect_EHTable = 0x1; + const byte CorILMethod_Sect_FatFormat = 0x40; + const short COR_ILEXCEPTION_CLAUSE_EXCEPTION = 0x0000; + const short COR_ILEXCEPTION_CLAUSE_FILTER = 0x0001; + const short COR_ILEXCEPTION_CLAUSE_FINALLY = 0x0002; + const short COR_ILEXCEPTION_CLAUSE_FAULT = 0x0004; + + if (fat) + { + bb.Write((byte)(CorILMethod_Sect_EHTable | CorILMethod_Sect_FatFormat)); + int dataSize = exceptions.Count * 24 + 4; + bb.Write((byte)dataSize); + bb.Write((short)(dataSize >> 8)); + foreach (ExceptionBlock block in exceptions) + { + if (block.exceptionType == FAULT) + { + bb.Write((int)COR_ILEXCEPTION_CLAUSE_FAULT); + } + else if (block.filterOffset != 0) + { + bb.Write((int)COR_ILEXCEPTION_CLAUSE_FILTER); + } + else if (block.exceptionType != null) + { + bb.Write((int)COR_ILEXCEPTION_CLAUSE_EXCEPTION); + } + else + { + bb.Write((int)COR_ILEXCEPTION_CLAUSE_FINALLY); + } + bb.Write(block.tryOffset); + bb.Write(block.tryLength); + bb.Write(block.handlerOffset); + bb.Write(block.handlerLength); + if (block.exceptionType != null && block.exceptionType != FAULT) + { + bb.Write(moduleBuilder.GetTypeTokenForMemberRef(block.exceptionType)); + } + else + { + bb.Write(block.filterOffset); + } + } + } + else + { + bb.Write(CorILMethod_Sect_EHTable); + bb.Write((byte)(exceptions.Count * 12 + 4)); + bb.Write((short)0); + foreach (ExceptionBlock block in exceptions) + { + if (block.exceptionType == FAULT) + { + bb.Write(COR_ILEXCEPTION_CLAUSE_FAULT); + } + else if (block.filterOffset != 0) + { + bb.Write(COR_ILEXCEPTION_CLAUSE_FILTER); + } + else if (block.exceptionType != null) + { + bb.Write(COR_ILEXCEPTION_CLAUSE_EXCEPTION); + } + else + { + bb.Write(COR_ILEXCEPTION_CLAUSE_FINALLY); + } + bb.Write((short)block.tryOffset); + bb.Write((byte)block.tryLength); + bb.Write((short)block.handlerOffset); + bb.Write((byte)block.handlerLength); + if (block.exceptionType != null && block.exceptionType != FAULT) + { + bb.Write(moduleBuilder.GetTypeTokenForMemberRef(block.exceptionType)); + } + else + { + bb.Write(block.filterOffset); + } + } + } + } + return rva; + } + + private void WriteCode(ByteBuffer bb) + { + int codeOffset = bb.Position; + foreach (int fixup in this.tokenFixups) + { + moduleBuilder.tokenFixupOffsets.Add(fixup + codeOffset); + } + bb.Write(code); + } + + private void WriteScope(Scope scope, int localVarSigTok) + { + moduleBuilder.symbolWriter.OpenScope(scope.startOffset); + foreach (LocalBuilder local in scope.locals) + { + if (local.name != null) + { + int startOffset = local.startOffset; + int endOffset = local.endOffset; + if (startOffset == 0 && endOffset == 0) + { + startOffset = scope.startOffset; + endOffset = scope.endOffset; + } + moduleBuilder.symbolWriter.DefineLocalVariable2(local.name, 0, localVarSigTok, SymAddressKind.ILOffset, local.LocalIndex, 0, 0, startOffset, endOffset); + } + } + foreach (Scope child in scope.children) + { + WriteScope(child, localVarSigTok); + } + moduleBuilder.symbolWriter.CloseScope(scope.endOffset); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/MethodBuilder.cs b/mcs/class/IKVM.Reflection/Emit/MethodBuilder.cs new file mode 100644 index 000000000000..a54e6377c9f6 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/MethodBuilder.cs @@ -0,0 +1,693 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using System.Diagnostics; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Diagnostics.SymbolStore; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class MethodBuilder : MethodInfo + { + private readonly TypeBuilder typeBuilder; + private readonly string name; + private readonly int nameIndex; + private readonly int pseudoToken; + private int signature; + private Type returnType; + private Type[] parameterTypes; + private Type[][][] modifiers; // see PackedCustomModifiers + private MethodAttributes attributes; + private MethodImplAttributes implFlags; + private ILGenerator ilgen; + private int rva; + private readonly CallingConventions callingConvention; + private List parameters; + private GenericTypeParameterBuilder[] gtpb; + private List declarativeSecurity; + private MethodSignature methodSignature; + private bool initLocals = true; + + internal MethodBuilder(TypeBuilder typeBuilder, string name, MethodAttributes attributes, CallingConventions callingConvention) + { + this.typeBuilder = typeBuilder; + this.name = name; + this.pseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken(); + // because all the MethodBuilders constitute a virtual MethodDef table, we cannot allocate the string during WriteMethodDefRecord, + // since by then the metadata has already been frozen + this.nameIndex = typeBuilder.ModuleBuilder.Strings.Add(name); + this.attributes = attributes; + if ((attributes & MethodAttributes.Static) == 0) + { + callingConvention |= CallingConventions.HasThis; + } + this.callingConvention = callingConvention; + } + + public ILGenerator GetILGenerator() + { + return GetILGenerator(16); + } + + public ILGenerator GetILGenerator(int streamSize) + { + if (ilgen == null) + { + ilgen = new ILGenerator(typeBuilder.ModuleBuilder, streamSize); + } + return ilgen; + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + private void SetDllImportPseudoCustomAttribute(CustomAttributeBuilder customBuilder) + { + CallingConvention? callingConvention = customBuilder.GetFieldValue("CallingConvention"); + CharSet? charSet = customBuilder.GetFieldValue("CharSet"); + SetDllImportPseudoCustomAttribute((string)customBuilder.GetConstructorArgument(0), + (string)customBuilder.GetFieldValue("EntryPoint"), + callingConvention, + charSet, + (bool?)customBuilder.GetFieldValue("BestFitMapping"), + (bool?)customBuilder.GetFieldValue("ThrowOnUnmappableChar"), + (bool?)customBuilder.GetFieldValue("SetLastError"), + (bool?)customBuilder.GetFieldValue("PreserveSig"), + (bool?)customBuilder.GetFieldValue("ExactSpelling")); + } + + internal void SetDllImportPseudoCustomAttribute(string dllName, string entryName, CallingConvention? nativeCallConv, CharSet? nativeCharSet, + bool? bestFitMapping, bool? throwOnUnmappableChar, bool? setLastError, bool? preserveSig, bool? exactSpelling) + { + const short NoMangle = 0x0001; + const short CharSetMask = 0x0006; + const short CharSetNotSpec = 0x0000; + const short CharSetAnsi = 0x0002; + const short CharSetUnicode = 0x0004; + const short CharSetAuto = 0x0006; + const short SupportsLastError = 0x0040; + const short CallConvMask = 0x0700; + const short CallConvWinapi = 0x0100; + const short CallConvCdecl = 0x0200; + const short CallConvStdcall = 0x0300; + const short CallConvThiscall = 0x0400; + const short CallConvFastcall = 0x0500; + // non-standard flags + const short BestFitOn = 0x0010; + const short BestFitOff = 0x0020; + const short CharMapErrorOn = 0x1000; + const short CharMapErrorOff = 0x2000; + int name = this.nameIndex; + short flags = CharSetNotSpec | CallConvWinapi; + if (bestFitMapping.HasValue) + { + flags |= bestFitMapping.Value ? BestFitOn : BestFitOff; + } + if (throwOnUnmappableChar.HasValue) + { + flags |= throwOnUnmappableChar.Value ? CharMapErrorOn : CharMapErrorOff; + } + if (nativeCallConv.HasValue) + { + flags &= ~CallConvMask; + switch (nativeCallConv.Value) + { + case System.Runtime.InteropServices.CallingConvention.Cdecl: + flags |= CallConvCdecl; + break; + case System.Runtime.InteropServices.CallingConvention.FastCall: + flags |= CallConvFastcall; + break; + case System.Runtime.InteropServices.CallingConvention.StdCall: + flags |= CallConvStdcall; + break; + case System.Runtime.InteropServices.CallingConvention.ThisCall: + flags |= CallConvThiscall; + break; + case System.Runtime.InteropServices.CallingConvention.Winapi: + flags |= CallConvWinapi; + break; + } + } + if (nativeCharSet.HasValue) + { + flags &= ~CharSetMask; + switch (nativeCharSet.Value) + { + case CharSet.Ansi: + case CharSet.None: + flags |= CharSetAnsi; + break; + case CharSet.Auto: + flags |= CharSetAuto; + break; + case CharSet.Unicode: + flags |= CharSetUnicode; + break; + } + } + if (entryName != null) + { + name = this.ModuleBuilder.Strings.Add(entryName); + } + if (exactSpelling.HasValue && exactSpelling.Value) + { + flags |= NoMangle; + } + if (!preserveSig.HasValue || preserveSig.Value) + { + implFlags |= MethodImplAttributes.PreserveSig; + } + if (setLastError.HasValue && setLastError.Value) + { + flags |= SupportsLastError; + } + ImplMapTable.Record rec = new ImplMapTable.Record(); + rec.MappingFlags = flags; + rec.MemberForwarded = pseudoToken; + rec.ImportName = name; + rec.ImportScope = this.ModuleBuilder.ModuleRef.FindOrAddRecord(dllName == null ? 0 : this.ModuleBuilder.Strings.Add(dllName)); + this.ModuleBuilder.ImplMap.AddRecord(rec); + } + + private void SetMethodImplAttribute(CustomAttributeBuilder customBuilder) + { + MethodImplOptions opt; + switch (customBuilder.Constructor.ParameterCount) + { + case 0: + opt = 0; + break; + case 1: + { + object val = customBuilder.GetConstructorArgument(0); + if (val is short) + { + opt = (MethodImplOptions)(short)val; + } + else if (val is int) + { + opt = (MethodImplOptions)(int)val; + } + else + { + opt = (MethodImplOptions)val; + } + break; + } + default: + throw new NotSupportedException(); + } + MethodCodeType? type = customBuilder.GetFieldValue("MethodCodeType"); + implFlags = (MethodImplAttributes)opt; + if (type.HasValue) + { + implFlags |= (MethodImplAttributes)type; + } + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + Universe u = this.ModuleBuilder.universe; + Type type = customBuilder.Constructor.DeclaringType; + if (type == u.System_Runtime_InteropServices_DllImportAttribute) + { + attributes |= MethodAttributes.PinvokeImpl; + SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly)); + } + else if (type == u.System_Runtime_CompilerServices_MethodImplAttribute) + { + SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly)); + } + else if (type == u.System_Runtime_InteropServices_PreserveSigAttribute) + { + implFlags |= MethodImplAttributes.PreserveSig; + } + else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute) + { + attributes |= MethodAttributes.SpecialName; + } + else + { + if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute) + { + attributes |= MethodAttributes.HasSecurity; + } + this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder); + } + } + + public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder) + { + attributes |= MethodAttributes.HasSecurity; + if (declarativeSecurity == null) + { + declarativeSecurity = new List(); + } + declarativeSecurity.Add(customBuilder); + } + + public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet) + { + this.ModuleBuilder.AddDeclarativeSecurity(pseudoToken, securityAction, permissionSet); + this.attributes |= MethodAttributes.HasSecurity; + } + + public void SetImplementationFlags(MethodImplAttributes attributes) + { + implFlags = attributes; + } + + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) + { + // the parameter is named "position", but it is actually a sequence number (i.e. 0 = return parameter, 1 = first parameter) + int sequence = position--; + if (parameters == null) + { + parameters = new List(); + } + this.ModuleBuilder.Param.AddVirtualRecord(); + ParameterBuilder pb = new ParameterBuilder(this.ModuleBuilder, sequence, attributes, strParamName); + if (parameters.Count == 0 || position > parameters[parameters.Count - 1].Position) + { + parameters.Add(pb); + } + else + { + for (int i = 0; i < parameters.Count; i++) + { + if (parameters[i].Position > position) + { + parameters.Insert(i, pb); + break; + } + } + } + return pb; + } + + public void SetParameters(params Type[] parameterTypes) + { + this.parameterTypes = Util.Copy(parameterTypes); + } + + public void SetReturnType(Type returnType) + { + this.returnType = returnType ?? this.Module.universe.System_Void; + } + + public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + this.returnType = returnType ?? this.Module.universe.System_Void; + this.parameterTypes = Util.Copy(parameterTypes); + this.modifiers = PackedCustomModifiers.CreateFromExternal(returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers, + parameterTypeOptionalCustomModifiers, parameterTypeRequiredCustomModifiers, this.parameterTypes.Length); + } + + public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) + { + gtpb = new GenericTypeParameterBuilder[names.Length]; + for (int i = 0; i < names.Length; i++) + { + gtpb[i] = new GenericTypeParameterBuilder(names[i], null, this, i); + } + return (GenericTypeParameterBuilder[])gtpb.Clone(); + } + + public override MethodInfo MakeGenericMethod(params Type[] typeArguments) + { + return new GenericMethodInstance(typeBuilder, this, typeArguments); + } + + public override MethodInfo GetGenericMethodDefinition() + { + if (gtpb == null) + { + throw new InvalidOperationException(); + } + return this; + } + + public override Type[] GetGenericArguments() + { + return Util.Copy(gtpb); + } + + internal override Type GetGenericMethodArgument(int index) + { + return gtpb[index]; + } + + internal override int GetGenericMethodArgumentCount() + { + return gtpb == null ? 0 : gtpb.Length; + } + + public override Type ReturnType + { + get { return returnType; } + } + + public override ParameterInfo ReturnParameter + { + get { return new ParameterInfoImpl(this, -1); } + } + + public override MethodAttributes Attributes + { + get { return attributes; } + } + + public void __SetAttributes(MethodAttributes attributes) + { + this.attributes = attributes; + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return implFlags; + } + + private sealed class ParameterInfoImpl : ParameterInfo + { + private readonly MethodBuilder method; + private readonly int parameter; + + internal ParameterInfoImpl(MethodBuilder method, int parameter) + { + this.method = method; + this.parameter = parameter; + } + + private ParameterBuilder ParameterBuilder + { + get + { + if (method.parameters != null) + { + foreach (ParameterBuilder pb in method.parameters) + { + if (pb.Position == parameter) + { + return pb; + } + } + } + return null; + } + } + + public override string Name + { + get + { + ParameterBuilder pb = this.ParameterBuilder; + return pb != null ? pb.Name : null; + } + } + + public override Type ParameterType + { + get { return parameter == -1 ? method.returnType : method.parameterTypes[parameter]; } + } + + public override ParameterAttributes Attributes + { + get + { + ParameterBuilder pb = this.ParameterBuilder; + return pb != null ? (ParameterAttributes)pb.Attributes : ParameterAttributes.None; + } + } + + public override int Position + { + get { return parameter; } + } + + public override object RawDefaultValue + { + get + { + ParameterBuilder pb = this.ParameterBuilder; + if (pb != null && (pb.Attributes & (int)ParameterAttributes.HasDefault) != 0) + { + return method.ModuleBuilder.Constant.GetRawConstantValue(method.ModuleBuilder, pb.PseudoToken); + } + if (pb != null && (pb.Attributes & (int)ParameterAttributes.Optional) != 0) + { + return Missing.Value; + } + return null; + } + } + + private Type[] GetCustomModifiers(int optOrReq) + { + if (method.modifiers == null || method.modifiers[parameter + 1] == null) + { + return Type.EmptyTypes; + } + return Util.Copy(method.modifiers[parameter + 1][optOrReq]); + } + + public override Type[] GetOptionalCustomModifiers() + { + return GetCustomModifiers(0); + } + + public override Type[] GetRequiredCustomModifiers() + { + return GetCustomModifiers(1); + } + + public override MemberInfo Member + { + get { return method; } + } + + public override int MetadataToken + { + get + { + ParameterBuilder pb = this.ParameterBuilder; + return pb != null ? pb.PseudoToken : 0x08000000; + } + } + + internal override Module Module + { + get { return method.Module; } + } + } + + public override ParameterInfo[] GetParameters() + { + ParameterInfo[] parameters = new ParameterInfo[parameterTypes.Length]; + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = new ParameterInfoImpl(this, i); + } + return parameters; + } + + internal override int ParameterCount + { + get { return parameterTypes.Length; } + } + + public override Type DeclaringType + { + get { return typeBuilder.IsModulePseudoType ? null : typeBuilder; } + } + + public override string Name + { + get { return name; } + } + + public override CallingConventions CallingConvention + { + get { return callingConvention; } + } + + public override int MetadataToken + { + get { return pseudoToken; } + } + + public override bool IsGenericMethod + { + get { return gtpb != null; } + } + + public override bool IsGenericMethodDefinition + { + get { return gtpb != null; } + } + + public override Module Module + { + get { return typeBuilder.Module; } + } + + public Module GetModule() + { + return typeBuilder.Module; + } + + public MethodToken GetToken() + { + return new MethodToken(pseudoToken); + } + + public override MethodBody GetMethodBody() + { + throw new NotSupportedException(); + } + + public bool InitLocals + { + get { return initLocals; } + set { initLocals = value; } + } + + internal void Bake() + { + this.signature = this.ModuleBuilder.GetSignatureBlobIndex(this.MethodSignature); + + if (ilgen != null) + { + if (this.ModuleBuilder.symbolWriter != null) + { + this.ModuleBuilder.symbolWriter.OpenMethod(new SymbolToken(-pseudoToken | 0x06000000)); + } + rva = ilgen.WriteBody(initLocals); + if (this.ModuleBuilder.symbolWriter != null) + { + this.ModuleBuilder.symbolWriter.CloseMethod(); + } + ilgen = null; + } + else + { + rva = -1; + } + + if (declarativeSecurity != null) + { + this.ModuleBuilder.AddDeclarativeSecurity(pseudoToken, declarativeSecurity); + } + } + + internal ModuleBuilder ModuleBuilder + { + get { return typeBuilder.ModuleBuilder; } + } + + internal void WriteMethodDefRecord(int baseRVA, MetadataWriter mw, ref int paramList) + { + if (rva != -1) + { + mw.Write(rva + baseRVA); + } + else + { + mw.Write(0); + } + mw.Write((short)implFlags); + mw.Write((short)attributes); + mw.WriteStringIndex(nameIndex); + mw.WriteBlobIndex(signature); + mw.WriteParam(paramList); + if (parameters != null) + { + paramList += parameters.Count; + } + } + + internal void WriteParamRecords(MetadataWriter mw) + { + if (parameters != null) + { + foreach (ParameterBuilder pb in parameters) + { + pb.WriteParamRecord(mw); + } + } + } + + internal void FixupToken(int token, ref int parameterToken) + { + typeBuilder.ModuleBuilder.RegisterTokenFixup(this.pseudoToken, token); + if (parameters != null) + { + foreach (ParameterBuilder pb in parameters) + { + pb.FixupToken(parameterToken++); + } + } + } + + internal override MethodSignature MethodSignature + { + get + { + if (methodSignature == null) + { + methodSignature = MethodSignature.MakeFromBuilder(returnType, parameterTypes, modifiers, callingConvention, gtpb == null ? 0 : gtpb.Length); + } + return methodSignature; + } + } + + internal override int ImportTo(ModuleBuilder other) + { + if (typeBuilder.IsGenericTypeDefinition) + { + return other.ImportMember(TypeBuilder.GetMethod(typeBuilder, this)); + } + else if (other == typeBuilder.ModuleBuilder) + { + return pseudoToken; + } + else + { + return other.ImportMethodOrField(typeBuilder, name, this.MethodSignature); + } + } + + internal void CheckBaked() + { + typeBuilder.CheckBaked(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/ModuleBuilder.cs b/mcs/class/IKVM.Reflection/Emit/ModuleBuilder.cs new file mode 100644 index 000000000000..07dc278c6bc7 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/ModuleBuilder.cs @@ -0,0 +1,1364 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Diagnostics.SymbolStore; +using System.Security.Cryptography; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using IKVM.Reflection.Impl; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class ModuleBuilder : Module, ITypeOwner + { + private static readonly bool usePublicKeyAssemblyReference = false; + private readonly Guid mvid = Guid.NewGuid(); + private long imageBaseAddress = 0x00400000; + private readonly AssemblyBuilder asm; + internal readonly string moduleName; + internal readonly string fileName; + internal readonly ISymbolWriterImpl symbolWriter; + private readonly TypeBuilder moduleType; + private readonly List types = new List(); + private readonly Dictionary typeTokens = new Dictionary(); + private readonly Dictionary memberRefTypeTokens = new Dictionary(); + private readonly Dictionary fullNameToType = new Dictionary(); + internal readonly ByteBuffer methodBodies = new ByteBuffer(128 * 1024); + internal readonly List tokenFixupOffsets = new List(); + internal readonly ByteBuffer initializedData = new ByteBuffer(512); + internal readonly ByteBuffer manifestResources = new ByteBuffer(512); + internal ResourceSection unmanagedResources; + private readonly Dictionary importedMembers = new Dictionary(); + private readonly Dictionary importedMemberRefs = new Dictionary(); + private readonly Dictionary referencedAssemblies = new Dictionary(); + private List referencedAssemblyNames; + private int nextPseudoToken = -1; + private readonly List resolvedTokens = new List(); + internal readonly TableHeap Tables = new TableHeap(); + internal readonly StringHeap Strings = new StringHeap(); + internal readonly UserStringHeap UserStrings = new UserStringHeap(); + internal readonly GuidHeap Guids = new GuidHeap(); + internal readonly BlobHeap Blobs = new BlobHeap(); + + struct MemberRefKey : IEquatable + { + private readonly Type type; + private readonly string name; + private readonly Signature signature; + + internal MemberRefKey(Type type, string name, Signature signature) + { + this.type = type; + this.name = name; + this.signature = signature; + } + + public bool Equals(MemberRefKey other) + { + return other.type.Equals(type) + && other.name == name + && other.signature.Equals(signature); + } + + public override bool Equals(object obj) + { + MemberRefKey? other = obj as MemberRefKey?; + return other != null && Equals(other); + } + + public override int GetHashCode() + { + return type.GetHashCode() + name.GetHashCode() + signature.GetHashCode(); + } + } + + internal ModuleBuilder(AssemblyBuilder asm, string moduleName, string fileName, bool emitSymbolInfo) + : base(asm.universe) + { + this.asm = asm; + this.moduleName = moduleName; + this.fileName = fileName; + if (emitSymbolInfo) + { + symbolWriter = SymbolSupport.CreateSymbolWriterFor(this); + } + // must be the first record in the TypeDef table + moduleType = new TypeBuilder(this, "", null, 0); + types.Add(moduleType); + } + + internal void PopulatePropertyAndEventTables() + { + // LAMESPEC the PropertyMap and EventMap tables are not required to be sorted by the CLI spec, + // but .NET sorts them and Mono requires them to be sorted, so we have to populate the + // tables in the right order + foreach (TypeBuilder type in types) + { + type.PopulatePropertyAndEventTables(); + } + } + + internal void WriteTypeDefTable(MetadataWriter mw) + { + int fieldList = 1; + int methodList = 1; + foreach (TypeBuilder type in types) + { + type.WriteTypeDefRecord(mw, ref fieldList, ref methodList); + } + } + + internal void WriteMethodDefTable(int baseRVA, MetadataWriter mw) + { + int paramList = 1; + foreach (TypeBuilder type in types) + { + type.WriteMethodDefRecords(baseRVA, mw, ref paramList); + } + } + + internal void WriteParamTable(MetadataWriter mw) + { + foreach (TypeBuilder type in types) + { + type.WriteParamRecords(mw); + } + } + + internal void WriteFieldTable(MetadataWriter mw) + { + foreach (TypeBuilder type in types) + { + type.WriteFieldRecords(mw); + } + } + + internal int AllocPseudoToken() + { + return nextPseudoToken--; + } + + public TypeBuilder DefineType(string name) + { + return DefineType(name, TypeAttributes.Class); + } + + public TypeBuilder DefineType(string name, TypeAttributes attr) + { + return DefineType(name, attr, null); + } + + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent) + { + return DefineType(name, attr, parent, PackingSize.Unspecified, 0); + } + + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, int typesize) + { + return DefineType(name, attr, parent, PackingSize.Unspecified, typesize); + } + + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packsize) + { + return DefineType(name, attr, parent, packsize, 0); + } + + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces) + { + TypeBuilder tb = DefineType(name, attr, parent); + foreach (Type iface in interfaces) + { + tb.AddInterfaceImplementation(iface); + } + return tb; + } + + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) + { + if (parent == null && (attr & TypeAttributes.Interface) == 0) + { + parent = universe.System_Object; + } + TypeBuilder typeBuilder = new TypeBuilder(this, name, parent, attr); + PostDefineType(typeBuilder, packingSize, typesize); + return typeBuilder; + } + + public EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type underlyingType) + { + TypeBuilder tb = DefineType(name, (visibility & TypeAttributes.VisibilityMask) | TypeAttributes.Sealed, universe.System_Enum); + FieldBuilder fb = tb.DefineField("value__", underlyingType, FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); + return new EnumBuilder(tb, fb); + } + + internal TypeBuilder DefineNestedTypeHelper(TypeBuilder enclosingType, string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) + { + if (parent == null && (attr & TypeAttributes.Interface) == 0) + { + parent = universe.System_Object; + } + TypeBuilder typeBuilder = new TypeBuilder(enclosingType, name, parent, attr); + PostDefineType(typeBuilder, packingSize, typesize); + if (enclosingType != null) + { + NestedClassTable.Record rec = new NestedClassTable.Record(); + rec.NestedClass = typeBuilder.MetadataToken; + rec.EnclosingClass = enclosingType.MetadataToken; + this.NestedClass.AddRecord(rec); + } + return typeBuilder; + } + + private void PostDefineType(TypeBuilder typeBuilder, PackingSize packingSize, int typesize) + { + types.Add(typeBuilder); + fullNameToType.Add(typeBuilder.FullName, typeBuilder); + if (packingSize != PackingSize.Unspecified || typesize != 0) + { + ClassLayoutTable.Record rec = new ClassLayoutTable.Record(); + rec.PackingSize = (short)packingSize; + rec.ClassSize = typesize; + rec.Parent = typeBuilder.MetadataToken; + this.ClassLayout.AddRecord(rec); + } + } + + public FieldBuilder __DefineField(string name, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) + { + return moduleType.DefineField(name, type, requiredCustomModifiers, optionalCustomModifiers, attributes); + } + + public ConstructorBuilder __DefineModuleInitializer(MethodAttributes visibility) + { + return moduleType.DefineConstructor(visibility | MethodAttributes.Static | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.Standard, Type.EmptyTypes); + } + + public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) + { + return moduleType.DefineUninitializedData(name, size, attributes); + } + + public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) + { + return moduleType.DefineInitializedData(name, data, attributes); + } + + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) + { + return moduleType.DefineMethod(name, attributes, returnType, parameterTypes); + } + + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + { + return moduleType.DefineMethod(name, attributes, callingConvention, returnType, parameterTypes); + } + + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) + { + return moduleType.DefineMethod(name, attributes, callingConvention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) + { + return moduleType.DefinePInvokeMethod(name, dllName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet); + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) + { + return moduleType.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet); + } + + public void CreateGlobalFunctions() + { + moduleType.CreateType(); + } + + internal void AddTypeForwarder(Type type) + { + ExportType(type); + foreach (Type nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)) + { + // we export all nested types (i.e. even the private ones) + // (this behavior is the same as the C# compiler) + AddTypeForwarder(nested); + } + } + + private int ExportType(Type type) + { + ExportedTypeTable.Record rec = new ExportedTypeTable.Record(); + rec.TypeDefId = type.MetadataToken; + rec.TypeName = this.Strings.Add(TypeNameParser.Unescape(type.Name)); + if (type.IsNested) + { + rec.Flags = 0; + rec.TypeNamespace = 0; + rec.Implementation = ExportType(type.DeclaringType); + } + else + { + rec.Flags = 0x00200000; // CorTypeAttr.tdForwarder + string ns = type.Namespace; + rec.TypeNamespace = ns == null ? 0 : this.Strings.Add(TypeNameParser.Unescape(ns)); + rec.Implementation = ImportAssemblyRef(type.Assembly); + } + return 0x27000000 | this.ExportedType.FindOrAddRecord(rec); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + SetCustomAttribute(0x00000001, customBuilder); + } + + internal void SetCustomAttribute(int token, CustomAttributeBuilder customBuilder) + { + Debug.Assert(!customBuilder.IsPseudoCustomAttribute); + CustomAttributeTable.Record rec = new CustomAttributeTable.Record(); + rec.Parent = token; + rec.Type = this.GetConstructorToken(customBuilder.Constructor).Token; + rec.Value = customBuilder.WriteBlob(this); + this.CustomAttribute.AddRecord(rec); + } + + internal void AddDeclarativeSecurity(int token, System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet) + { + DeclSecurityTable.Record rec = new DeclSecurityTable.Record(); + rec.Action = (short)securityAction; + rec.Parent = token; + // like Ref.Emit, we're using the .NET 1.x xml format + rec.PermissionSet = this.Blobs.Add(ByteBuffer.Wrap(System.Text.Encoding.Unicode.GetBytes(permissionSet.ToXml().ToString()))); + this.DeclSecurity.AddRecord(rec); + } + + internal void AddDeclarativeSecurity(int token, List declarativeSecurity) + { + Dictionary> ordered = new Dictionary>(); + foreach (CustomAttributeBuilder cab in declarativeSecurity) + { + int action; + // check for HostProtectionAttribute without SecurityAction + if (cab.ConstructorArgumentCount == 0) + { + action = (int)System.Security.Permissions.SecurityAction.LinkDemand; + } + else + { + action = (int)cab.GetConstructorArgument(0); + } + List list; + if (!ordered.TryGetValue(action, out list)) + { + list = new List(); + ordered.Add(action, list); + } + list.Add(cab); + } + foreach (KeyValuePair> kv in ordered) + { + DeclSecurityTable.Record rec = new DeclSecurityTable.Record(); + rec.Action = (short)kv.Key; + rec.Parent = token; + rec.PermissionSet = WriteDeclSecurityBlob(kv.Value); + this.DeclSecurity.AddRecord(rec); + } + } + + private int WriteDeclSecurityBlob(List list) + { + ByteBuffer namedArgs = new ByteBuffer(100); + ByteBuffer bb = new ByteBuffer(list.Count * 100); + bb.Write((byte)'.'); + bb.WriteCompressedInt(list.Count); + foreach (CustomAttributeBuilder cab in list) + { + bb.Write(cab.Constructor.DeclaringType.AssemblyQualifiedName); + namedArgs.Clear(); + cab.WriteNamedArgumentsForDeclSecurity(this, namedArgs); + bb.WriteCompressedInt(namedArgs.Length); + bb.Write(namedArgs); + } + return this.Blobs.Add(bb); + } + + public void DefineManifestResource(string name, Stream stream, ResourceAttributes attribute) + { + ManifestResourceTable.Record rec = new ManifestResourceTable.Record(); + rec.Offset = manifestResources.Position; + rec.Flags = (int)attribute; + rec.Name = this.Strings.Add(name); + rec.Implementation = 0; + this.ManifestResource.AddRecord(rec); + manifestResources.Write(0); // placeholder for the length + manifestResources.Write(stream); + int savePosition = manifestResources.Position; + manifestResources.Position = rec.Offset; + manifestResources.Write(savePosition - (manifestResources.Position + 4)); + manifestResources.Position = savePosition; + } + + public override Assembly Assembly + { + get { return asm; } + } + + internal override Type GetTypeImpl(string typeName) + { + TypeBuilder type; + fullNameToType.TryGetValue(typeName, out type); + return type; + } + + internal override void GetTypesImpl(List list) + { + foreach (Type type in types) + { + if (type != moduleType) + { + list.Add(type); + } + } + } + + public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) + { + return symbolWriter.DefineDocument(url, language, languageVendor, documentType); + } + + public TypeToken GetTypeToken(string name) + { + return new TypeToken(GetType(name, true, false).MetadataToken); + } + + public TypeToken GetTypeToken(Type type) + { + if (type.Module == this) + { + return new TypeToken(type.GetModuleBuilderToken()); + } + else + { + return new TypeToken(ImportType(type)); + } + } + + internal int GetTypeTokenForMemberRef(Type type) + { + if (type.IsGenericTypeDefinition) + { + int token; + if (!memberRefTypeTokens.TryGetValue(type, out token)) + { + ByteBuffer spec = new ByteBuffer(5); + Signature.WriteTypeSpec(this, spec, type); + token = 0x1B000000 | this.TypeSpec.AddRecord(this.Blobs.Add(spec)); + memberRefTypeTokens.Add(type, token); + } + return token; + } + else if (type.IsModulePseudoType) + { + return 0x1A000000 | this.ModuleRef.FindOrAddRecord(this.Strings.Add(type.Module.ScopeName)); + } + else + { + return GetTypeToken(type).Token; + } + } + + private static bool IsFromGenericTypeDefinition(MemberInfo member) + { + Type decl = member.DeclaringType; + return decl != null && decl.IsGenericTypeDefinition; + } + + public FieldToken GetFieldToken(FieldInfo field) + { + // NOTE for some reason, when TypeBuilder.GetFieldToken() is used on a field in a generic type definition, + // a memberref token is returned (confirmed on .NET) unlike for Get(Method|Constructor)Token which always + // simply returns the MethodDef token (if the method is from the same module). + FieldBuilder fb = field as FieldBuilder; + if (fb != null && fb.Module == this && !IsFromGenericTypeDefinition(fb)) + { + return new FieldToken(fb.MetadataToken); + } + else + { + return new FieldToken(ImportMember(field)); + } + } + + public MethodToken GetMethodToken(MethodInfo method) + { + MethodBuilder mb = method as MethodBuilder; + if (mb != null && mb.ModuleBuilder == this) + { + return new MethodToken(mb.MetadataToken); + } + else + { + return new MethodToken(ImportMember(method)); + } + } + + // when we refer to a method on a generic type definition in the IL stream, + // we need to use a MemberRef (even if the method is in the same module) + internal MethodToken GetMethodTokenForIL(MethodInfo method) + { + if (method.IsGenericMethodDefinition) + { + method = method.MakeGenericMethod(method.GetGenericArguments()); + } + if (IsFromGenericTypeDefinition(method)) + { + return new MethodToken(ImportMember(method)); + } + else + { + return GetMethodToken(method); + } + } + + public MethodToken GetConstructorToken(ConstructorInfo constructor) + { + if (constructor.Module == this && constructor.GetMethodInfo() is MethodBuilder) + { + return new MethodToken(constructor.MetadataToken); + } + else + { + return new MethodToken(ImportMember(constructor)); + } + } + + internal int ImportMember(MethodBase member) + { + int token; + if (!importedMembers.TryGetValue(member, out token)) + { + token = member.ImportTo(this); + importedMembers.Add(member, token); + } + return token; + } + + internal int ImportMember(FieldInfo member) + { + int token; + if (!importedMembers.TryGetValue(member, out token)) + { + token = member.ImportTo(this); + importedMembers.Add(member, token); + } + return token; + } + + internal int ImportMethodOrField(Type declaringType, string name, Signature sig) + { + int token; + if (!importedMemberRefs.TryGetValue(new MemberRefKey(declaringType, name, sig), out token)) + { + MemberRefTable.Record rec = new MemberRefTable.Record(); + rec.Class = GetTypeTokenForMemberRef(declaringType); + rec.Name = this.Strings.Add(name); + ByteBuffer bb = new ByteBuffer(16); + sig.WriteSig(this, bb); + rec.Signature = this.Blobs.Add(bb); + token = 0x0A000000 | this.MemberRef.AddRecord(rec); + importedMemberRefs.Add(new MemberRefKey(declaringType, name, sig), token); + } + return token; + } + + internal int ImportType(Type type) + { + int token; + if (!typeTokens.TryGetValue(type, out token)) + { + if (type.HasElementType || (type.IsGenericType && !type.IsGenericTypeDefinition)) + { + ByteBuffer spec = new ByteBuffer(5); + Signature.WriteTypeSpec(this, spec, type); + token = 0x1B000000 | this.TypeSpec.AddRecord(this.Blobs.Add(spec)); + } + else + { + TypeRefTable.Record rec = new TypeRefTable.Record(); + if (type.IsNested) + { + rec.ResolutionScope = GetTypeToken(type.DeclaringType).Token; + rec.TypeName = this.Strings.Add(TypeNameParser.Unescape(type.Name)); + rec.TypeNameSpace = 0; + } + else + { + rec.ResolutionScope = ImportAssemblyRef(type.Assembly); + rec.TypeName = this.Strings.Add(TypeNameParser.Unescape(type.Name)); + string ns = type.Namespace; + rec.TypeNameSpace = ns == null ? 0 : this.Strings.Add(TypeNameParser.Unescape(ns)); + } + token = 0x01000000 | this.TypeRef.AddRecord(rec); + } + typeTokens.Add(type, token); + } + return token; + } + + private int ImportAssemblyRef(Assembly asm) + { + int token; + if (!referencedAssemblies.TryGetValue(asm, out token)) + { + // We can't write the AssemblyRef record here yet, because the identity of the assembly can still change + // (if it's an AssemblyBuilder). + // We set the high bit of rid in the token to make sure we emit obviously broken metadata, + // if we forget to patch up the token somewhere. + token = 0x23800001 + referencedAssemblies.Count; + referencedAssemblies.Add(asm, token); + } + return token; + } + + internal void FillAssemblyRefTable() + { + int[] realtokens = new int[referencedAssemblies.Count]; + foreach (KeyValuePair kv in referencedAssemblies) + { + realtokens[(kv.Value & 0x7FFFFF) - 1] = FindOrAddAssemblyRef(kv.Key.GetName()); + } + // now fixup the resolution scopes in TypeRef + for (int i = 0; i < this.TypeRef.records.Length; i++) + { + int resolutionScope = this.TypeRef.records[i].ResolutionScope; + if ((resolutionScope >> 24) == AssemblyRefTable.Index) + { + this.TypeRef.records[i].ResolutionScope = realtokens[(resolutionScope & 0x7FFFFF) - 1]; + } + } + // and implementation in ExportedType + for (int i = 0; i < this.ExportedType.records.Length; i++) + { + int implementation = this.ExportedType.records[i].Implementation; + if ((implementation >> 24) == AssemblyRefTable.Index) + { + this.ExportedType.records[i].Implementation = realtokens[(implementation & 0x7FFFFF) - 1]; + } + } + } + + private int FindOrAddAssemblyRef(AssemblyName name) + { + AssemblyRefTable.Record rec = new AssemblyRefTable.Record(); + Version ver = name.Version; + rec.MajorVersion = (ushort)ver.Major; + rec.MinorVersion = (ushort)ver.Minor; + rec.BuildNumber = (ushort)ver.Build; + rec.RevisionNumber = (ushort)ver.Revision; + rec.Flags = (int)(name.Flags & AssemblyNameFlags.Retargetable); + byte[] publicKeyOrToken = null; + if (usePublicKeyAssemblyReference) + { + publicKeyOrToken = name.GetPublicKey(); + } + if (publicKeyOrToken == null || publicKeyOrToken.Length == 0) + { + publicKeyOrToken = name.GetPublicKeyToken(); + } + else + { + const int PublicKey = 0x0001; + rec.Flags |= PublicKey; + } + rec.PublicKeyOrToken = this.Blobs.Add(ByteBuffer.Wrap(publicKeyOrToken)); + rec.Name = this.Strings.Add(name.Name); + if (name.CultureInfo != null) + { + rec.Culture = this.Strings.Add(name.CultureInfo.Name); + } + else + { + rec.Culture = 0; + } + rec.HashValue = 0; + return 0x23000000 | this.AssemblyRef.FindOrAddRecord(rec); + } + + internal void WriteSymbolTokenMap() + { + for (int i = 0; i < resolvedTokens.Count; i++) + { + int newToken = resolvedTokens[i]; + // The symbol API doesn't support remapping arbitrary integers, the types have to be the same, + // so we copy the type from the newToken, because our pseudo tokens don't have a type. + // (see MethodToken.SymbolToken) + int oldToken = (i + 1) | (newToken & ~0xFFFFFF); + SymbolSupport.RemapToken(symbolWriter, oldToken, newToken); + } + } + + internal void RegisterTokenFixup(int pseudoToken, int realToken) + { + int index = -(pseudoToken + 1); + while (resolvedTokens.Count <= index) + { + resolvedTokens.Add(0); + } + resolvedTokens[index] = realToken; + } + + internal bool IsPseudoToken(int token) + { + return token < 0; + } + + internal int ResolvePseudoToken(int pseudoToken) + { + int index = -(pseudoToken + 1); + return resolvedTokens[index]; + } + + internal void FixupMethodBodyTokens() + { + int methodToken = 0x06000001; + int fieldToken = 0x04000001; + int parameterToken = 0x08000001; + foreach (TypeBuilder type in types) + { + type.ResolveMethodAndFieldTokens(ref methodToken, ref fieldToken, ref parameterToken); + } + foreach (int offset in tokenFixupOffsets) + { + methodBodies.Position = offset; + int pseudoToken = methodBodies.GetInt32AtCurrentPosition(); + methodBodies.Write(ResolvePseudoToken(pseudoToken)); + } + } + + private int GetHeaderLength() + { + return + 4 + // Signature + 2 + // MajorVersion + 2 + // MinorVersion + 4 + // Reserved + 4 + // ImageRuntimeVersion Length + StringToPaddedUTF8Length(asm.ImageRuntimeVersion) + + 2 + // Flags + 2 + // Streams + 4 + // #~ Offset + 4 + // #~ Size + 4 + // StringToPaddedUTF8Length("#~") + 4 + // #Strings Offset + 4 + // #Strings Size + 12 + // StringToPaddedUTF8Length("#Strings") + 4 + // #US Offset + 4 + // #US Size + 4 + // StringToPaddedUTF8Length("#US") + 4 + // #GUID Offset + 4 + // #GUID Size + 8 + // StringToPaddedUTF8Length("#GUID") + (Blobs.IsEmpty ? 0 : + ( + 4 + // #Blob Offset + 4 + // #Blob Size + 8 // StringToPaddedUTF8Length("#Blob") + )); + } + + internal int MetadataLength + { + get + { + return GetHeaderLength() + (Blobs.IsEmpty ? 0 : Blobs.Length) + Tables.Length + Strings.Length + UserStrings.Length + Guids.Length; + } + } + + internal void WriteMetadata(MetadataWriter mw) + { + mw.Write(0x424A5342); // Signature ("BSJB") + mw.Write((ushort)1); // MajorVersion + mw.Write((ushort)1); // MinorVersion + mw.Write(0); // Reserved + byte[] version = StringToPaddedUTF8(asm.ImageRuntimeVersion); + mw.Write(version.Length); // Length + mw.Write(version); + mw.Write((ushort)0); // Flags + // #Blob is the only optional heap + if (Blobs.IsEmpty) + { + mw.Write((ushort)4); // Streams + } + else + { + mw.Write((ushort)5); // Streams + } + + int offset = GetHeaderLength(); + + // Streams + mw.Write(offset); // Offset + mw.Write(Tables.Length); // Size + mw.Write(StringToPaddedUTF8("#~")); + offset += Tables.Length; + + mw.Write(offset); // Offset + mw.Write(Strings.Length); // Size + mw.Write(StringToPaddedUTF8("#Strings")); + offset += Strings.Length; + + mw.Write(offset); // Offset + mw.Write(UserStrings.Length); // Size + mw.Write(StringToPaddedUTF8("#US")); + offset += UserStrings.Length; + + mw.Write(offset); // Offset + mw.Write(Guids.Length); // Size + mw.Write(StringToPaddedUTF8("#GUID")); + offset += Guids.Length; + + if (!Blobs.IsEmpty) + { + mw.Write(offset); // Offset + mw.Write(Blobs.Length); // Size + mw.Write(StringToPaddedUTF8("#Blob")); + } + + Tables.Write(mw); + Strings.Write(mw); + UserStrings.Write(mw); + Guids.Write(mw); + if (!Blobs.IsEmpty) + { + Blobs.Write(mw); + } + } + + private static int StringToPaddedUTF8Length(string str) + { + return (System.Text.Encoding.UTF8.GetByteCount(str) + 4) & ~3; + } + + private static byte[] StringToPaddedUTF8(string str) + { + byte[] buf = new byte[(System.Text.Encoding.UTF8.GetByteCount(str) + 4) & ~3]; + System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, buf, 0); + return buf; + } + + internal override void ExportTypes(int fileToken, ModuleBuilder manifestModule) + { + manifestModule.ExportTypes(types.ToArray(), fileToken); + } + + internal void ExportTypes(Type[] types, int fileToken) + { + Dictionary declaringTypes = new Dictionary(); + foreach (Type type in types) + { + if (!type.IsModulePseudoType && IsVisible(type)) + { + ExportedTypeTable.Record rec = new ExportedTypeTable.Record(); + rec.Flags = (int)type.Attributes; + rec.TypeDefId = type.MetadataToken & 0xFFFFFF; + rec.TypeName = this.Strings.Add(TypeNameParser.Unescape(type.Name)); + string ns = type.Namespace; + rec.TypeNamespace = ns == null ? 0 : this.Strings.Add(TypeNameParser.Unescape(ns)); + if (type.IsNested) + { + rec.Implementation = declaringTypes[type.DeclaringType]; + } + else + { + rec.Implementation = fileToken; + } + int exportTypeToken = 0x27000000 | this.ExportedType.AddRecord(rec); + declaringTypes.Add(type, exportTypeToken); + } + } + } + + private static bool IsVisible(Type type) + { + // NOTE this is not the same as Type.IsVisible, because that doesn't take into account family access + return type.IsPublic || ((type.IsNestedFamily || type.IsNestedFamORAssem || type.IsNestedPublic) && IsVisible(type.DeclaringType)); + } + + internal void AddConstant(int parentToken, object defaultValue) + { + ConstantTable.Record rec = new ConstantTable.Record(); + rec.Parent = parentToken; + ByteBuffer val = new ByteBuffer(16); + if (defaultValue == null) + { + rec.Type = Signature.ELEMENT_TYPE_CLASS; + val.Write((int)0); + } + else if (defaultValue is bool) + { + rec.Type = Signature.ELEMENT_TYPE_BOOLEAN; + val.Write((bool)defaultValue ? (byte)1 : (byte)0); + } + else if (defaultValue is char) + { + rec.Type = Signature.ELEMENT_TYPE_CHAR; + val.Write((char)defaultValue); + } + else if (defaultValue is sbyte) + { + rec.Type = Signature.ELEMENT_TYPE_I1; + val.Write((sbyte)defaultValue); + } + else if (defaultValue is byte) + { + rec.Type = Signature.ELEMENT_TYPE_U1; + val.Write((byte)defaultValue); + } + else if (defaultValue is short) + { + rec.Type = Signature.ELEMENT_TYPE_I2; + val.Write((short)defaultValue); + } + else if (defaultValue is ushort) + { + rec.Type = Signature.ELEMENT_TYPE_U2; + val.Write((ushort)defaultValue); + } + else if (defaultValue is int) + { + rec.Type = Signature.ELEMENT_TYPE_I4; + val.Write((int)defaultValue); + } + else if (defaultValue is uint) + { + rec.Type = Signature.ELEMENT_TYPE_U4; + val.Write((uint)defaultValue); + } + else if (defaultValue is long) + { + rec.Type = Signature.ELEMENT_TYPE_I8; + val.Write((long)defaultValue); + } + else if (defaultValue is ulong) + { + rec.Type = Signature.ELEMENT_TYPE_U8; + val.Write((ulong)defaultValue); + } + else if (defaultValue is float) + { + rec.Type = Signature.ELEMENT_TYPE_R4; + val.Write((float)defaultValue); + } + else if (defaultValue is double) + { + rec.Type = Signature.ELEMENT_TYPE_R8; + val.Write((double)defaultValue); + } + else if (defaultValue is string) + { + rec.Type = Signature.ELEMENT_TYPE_STRING; + foreach (char c in (string)defaultValue) + { + val.Write(c); + } + } + else if (defaultValue is DateTime) + { + rec.Type = Signature.ELEMENT_TYPE_I8; + val.Write(((DateTime)defaultValue).Ticks); + } + else + { + throw new ArgumentException(); + } + rec.Value = this.Blobs.Add(val); + this.Constant.AddRecord(rec); + } + + ModuleBuilder ITypeOwner.ModuleBuilder + { + get { return this; } + } + + public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if (genericTypeArguments != null || genericMethodArguments != null) + { + throw new NotImplementedException(); + } + return types[(metadataToken & 0xFFFFFF) - 1]; + } + + public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if (genericTypeArguments != null || genericMethodArguments != null) + { + throw new NotImplementedException(); + } + // this method is inefficient, but since it isn't used we don't care + if ((metadataToken >> 24) == MemberRefTable.Index) + { + foreach (KeyValuePair kv in importedMembers) + { + if (kv.Value == metadataToken) + { + return (MethodBase)kv.Key; + } + } + } + // HACK if we're given a SymbolToken, we need to convert back + if ((metadataToken & 0xFF000000) == 0x06000000) + { + metadataToken = -(metadataToken & 0x00FFFFFF); + } + foreach (Type type in types) + { + MethodBase method = ((TypeBuilder)type).LookupMethod(metadataToken); + if (method != null) + { + return method; + } + } + return ((TypeBuilder)moduleType).LookupMethod(metadataToken); + } + + public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotImplementedException(); + } + + public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotImplementedException(); + } + + public override string ResolveString(int metadataToken) + { + throw new NotImplementedException(); + } + + public override string FullyQualifiedName + { + get { return Path.GetFullPath(Path.Combine(asm.dir, fileName)); } + } + + public override string Name + { + get { return fileName; } + } + + public override Guid ModuleVersionId + { + get { return mvid; } + } + + public override Type[] __ResolveOptionalParameterTypes(int metadataToken) + { + throw new NotImplementedException(); + } + + public override string ScopeName + { + get { return moduleName; } + } + + public ISymbolWriter GetSymWriter() + { + return symbolWriter; + } + + public void DefineUnmanagedResource(string resourceFileName) + { + // This method reads the specified resource file (Win32 .res file) and converts it into the appropriate format and embeds it in the .rsrc section, + // also setting the Resource Directory entry. + unmanagedResources = new ResourceSection(); + unmanagedResources.ExtractResources(System.IO.File.ReadAllBytes(resourceFileName)); + } + + public bool IsTransient() + { + return false; + } + + public void SetUserEntryPoint(MethodInfo entryPoint) + { + int token = entryPoint.MetadataToken; + if (token < 0) + { + token = -token | 0x06000000; + } + if (symbolWriter != null) + { + symbolWriter.SetUserEntryPoint(new SymbolToken(token)); + } + } + + public StringToken GetStringConstant(string str) + { + return new StringToken(this.UserStrings.Add(str) | (0x70 << 24)); + } + + public SignatureToken GetSignatureToken(SignatureHelper sigHelper) + { + return new SignatureToken(this.StandAloneSig.FindOrAddRecord(this.Blobs.Add(sigHelper.GetSignature(this))) | (StandAloneSigTable.Index << 24)); + } + + public SignatureToken GetSignatureToken(byte[] sigBytes, int sigLength) + { + return new SignatureToken(this.StandAloneSig.FindOrAddRecord(this.Blobs.Add(ByteBuffer.Wrap(sigBytes, sigLength))) | (StandAloneSigTable.Index << 24)); + } + + public MethodInfo GetArrayMethod(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + { + return new ArrayMethod(this, arrayClass, methodName, callingConvention, returnType, parameterTypes); + } + + public MethodToken GetArrayMethodToken(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + { + return GetMethodToken(GetArrayMethod(arrayClass, methodName, callingConvention, returnType, parameterTypes)); + } + + internal override Type GetModuleType() + { + return moduleType; + } + + internal override IKVM.Reflection.Reader.ByteReader GetBlob(int blobIndex) + { + return Blobs.GetBlob(blobIndex); + } + + internal int GetSignatureBlobIndex(Signature sig) + { + ByteBuffer bb = new ByteBuffer(16); + sig.WriteSig(this, bb); + return this.Blobs.Add(bb); + } + + // non-standard API + public long __ImageBase + { + get { return imageBaseAddress; } + set { imageBaseAddress = value; } + } + + public override int MDStreamVersion + { + get { return asm.mdStreamVersion; } + } + + private int AddTypeRefByName(int resolutionScope, string ns, string name) + { + TypeRefTable.Record rec = new TypeRefTable.Record(); + rec.ResolutionScope = resolutionScope; + rec.TypeName = this.Strings.Add(name); + rec.TypeNameSpace = ns == null ? 0 : this.Strings.Add(ns); + return 0x01000000 | this.TypeRef.AddRecord(rec); + } + + public void __Save(PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine) + { + PopulatePropertyAndEventTables(); + IList attributes = asm.GetCustomAttributesData(null); + if (attributes.Count > 0) + { + int mscorlib = ImportAssemblyRef(universe.Mscorlib); + int[] placeholderTokens = new int[4]; + string[] placeholderTypeNames = new string[] { "AssemblyAttributesGoHere", "AssemblyAttributesGoHereM", "AssemblyAttributesGoHereS", "AssemblyAttributesGoHereSM" }; + foreach (CustomAttributeData cad in attributes) + { + int index; + if (cad.Constructor.DeclaringType.BaseType == universe.System_Security_Permissions_CodeAccessSecurityAttribute) + { + if (cad.Constructor.DeclaringType.IsAllowMultipleCustomAttribute) + { + index = 3; + } + else + { + index = 2; + } + } + else if (cad.Constructor.DeclaringType.IsAllowMultipleCustomAttribute) + { + index = 1; + } + else + { + index = 0; + } + if (placeholderTokens[index] == 0) + { + // we manually add a TypeRef without looking it up in mscorlib, because Mono and Silverlight's mscorlib don't have these types + placeholderTokens[index] = AddTypeRefByName(mscorlib, "System.Runtime.CompilerServices", placeholderTypeNames[index]); + } + SetCustomAttribute(placeholderTokens[index], cad.__ToBuilder()); + } + } + FillAssemblyRefTable(); + ModuleWriter.WriteModule(null, null, this, PEFileKinds.Dll, portableExecutableKind, imageFileMachine, unmanagedResources, 0); + } + + public void __AddAssemblyReference(AssemblyName assemblyName) + { + if (referencedAssemblyNames == null) + { + referencedAssemblyNames = new List(); + } + FindOrAddAssemblyRef(assemblyName); + referencedAssemblyNames.Add((AssemblyName)assemblyName.Clone()); + } + + public override AssemblyName[] __GetReferencedAssemblies() + { + List list = new List(); + if (referencedAssemblyNames != null) + { + foreach (AssemblyName name in referencedAssemblyNames) + { + if (!list.Contains(name)) + { + list.Add(name); + } + } + } + foreach (Assembly asm in referencedAssemblies.Keys) + { + AssemblyName name = asm.GetName(); + if (!list.Contains(name)) + { + list.Add(name); + } + } + return list.ToArray(); + } + } + + class ArrayMethod : MethodInfo + { + private readonly Module module; + private readonly Type arrayClass; + private readonly string methodName; + private readonly CallingConventions callingConvention; + private readonly Type returnType; + protected readonly Type[] parameterTypes; + private MethodSignature methodSignature; + + internal ArrayMethod(Module module, Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + { + this.module = module; + this.arrayClass = arrayClass; + this.methodName = methodName; + this.callingConvention = callingConvention; + this.returnType = returnType ?? module.universe.System_Void; + this.parameterTypes = Util.Copy(parameterTypes); + } + + public override MethodBody GetMethodBody() + { + throw new InvalidOperationException(); + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + throw new NotSupportedException(); + } + + public override ParameterInfo[] GetParameters() + { + throw new NotSupportedException(); + } + + internal override int ImportTo(ModuleBuilder module) + { + return module.ImportMethodOrField(arrayClass, methodName, MethodSignature); + } + + public override MethodAttributes Attributes + { + get { throw new NotSupportedException(); } + } + + public override CallingConventions CallingConvention + { + get { return callingConvention; } + } + + public override Type DeclaringType + { + get { return arrayClass; } + } + + internal override MethodSignature MethodSignature + { + get + { + if (methodSignature == null) + { + methodSignature = MethodSignature.MakeFromBuilder(returnType, parameterTypes, null, callingConvention, 0); + } + return methodSignature; + } + } + + public override Module Module + { + // like .NET, we return the module that GetArrayMethod was called on, not the module associated with the array type + get { return module; } + } + + public override string Name + { + get { return methodName; } + } + + internal override int ParameterCount + { + get { return parameterTypes.Length; } + } + + public override ParameterInfo ReturnParameter + { + get { throw new NotImplementedException(); } + } + + public override Type ReturnType + { + get { return returnType; } + } + + internal override bool HasThis + { + get { return (callingConvention & (CallingConventions.HasThis | CallingConventions.ExplicitThis)) == CallingConventions.HasThis; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/OpCode.cs b/mcs/class/IKVM.Reflection/Emit/OpCode.cs new file mode 100644 index 000000000000..1d75a0a433a9 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/OpCode.cs @@ -0,0 +1,288 @@ +/* + Copyright (C) 2008, 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Diagnostics; + +namespace IKVM.Reflection.Emit +{ + public struct OpCode + { + private const int ValueCount = 1024; + private const int OperandTypeCount = 19; + private const int FlowControlCount = 9; + private const int StackDiffCount = 5; + private const int OpCodeTypeCount = 6; + private const int StackBehaviourPopCount = 20; + private const int StackBehaviourPushCount = 9; + private static readonly StackBehaviour[] pop = { + StackBehaviour.Pop0, + StackBehaviour.Pop1, + StackBehaviour.Pop1_pop1, + StackBehaviour.Popi, + StackBehaviour.Popi_pop1, + StackBehaviour.Popi_popi, + StackBehaviour.Popi_popi8, + StackBehaviour.Popi_popi_popi, + StackBehaviour.Popi_popr4, + StackBehaviour.Popi_popr8, + StackBehaviour.Popref, + StackBehaviour.Popref_pop1, + StackBehaviour.Popref_popi, + StackBehaviour.Popref_popi_popi, + StackBehaviour.Popref_popi_popi8, + StackBehaviour.Popref_popi_popr4, + StackBehaviour.Popref_popi_popr8, + StackBehaviour.Popref_popi_popref, + StackBehaviour.Varpop, + StackBehaviour.Popref_popi_pop1 + }; + private static readonly StackBehaviour[] push = { + StackBehaviour.Push0, + StackBehaviour.Push1, + StackBehaviour.Push1_push1, + StackBehaviour.Pushi, + StackBehaviour.Pushi8, + StackBehaviour.Pushr4, + StackBehaviour.Pushr8, + StackBehaviour.Pushref, + StackBehaviour.Varpush + }; + private readonly int value; + + internal OpCode(int value) + { + this.value = value; + } + + public override bool Equals(object obj) + { + return this == obj as OpCode?; + } + + public override int GetHashCode() + { + return value; + } + + public bool Equals(OpCode other) + { + return this == other; + } + + public static bool operator ==(OpCode a, OpCode b) + { + return a.value == b.value; + } + + public static bool operator !=(OpCode a, OpCode b) + { + return !(a == b); + } + + public short Value + { + get { return (short)(value >> 22); } + } + + public int Size + { + get { return value < 0 ? 2 : 1; } + } + +#if !GENERATOR + public string Name + { + get { return OpCodes.GetName(this.Value); } + } +#endif + + public OperandType OperandType + { + get { return (OperandType)((value & 0x3FFFFF) % OperandTypeCount); } + } + + public FlowControl FlowControl + { + get { return (FlowControl)(((value & 0x3FFFFF) / OperandTypeCount) % FlowControlCount); } + } + + internal int StackDiff + { + get { return ((((value & 0x3FFFFF) / (OperandTypeCount * FlowControlCount)) % StackDiffCount) - 3); } + } + + public OpCodeType OpCodeType + { + get { return (OpCodeType)(((value & 0x3FFFFF) / (OperandTypeCount * FlowControlCount * StackDiffCount)) % OpCodeTypeCount); } + } + + public StackBehaviour StackBehaviourPop + { + get { return pop[(((value & 0x3FFFFF) / (OperandTypeCount * FlowControlCount * StackDiffCount * OpCodeTypeCount)) % StackBehaviourPopCount)]; } + } + + public StackBehaviour StackBehaviourPush + { + get { return push[(((value & 0x3FFFFF) / (OperandTypeCount * FlowControlCount * StackDiffCount * OpCodeTypeCount * StackBehaviourPopCount)) % StackBehaviourPushCount)]; } + } + +#if GENERATOR + static void Main(string[] args) + { + Debug.Assert(pop.Length == StackBehaviourPopCount); + Debug.Assert(push.Length == StackBehaviourPushCount); + CheckEnumRange(typeof(FlowControl), FlowControlCount); + CheckEnumRange(typeof(OpCodeType), OpCodeTypeCount); + CheckEnumRange(typeof(OperandType), OperandTypeCount); + foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) + { + System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); + IKVM.Reflection.Emit.OpCode opc2 = new IKVM.Reflection.Emit.OpCode(Pack(opc1)); + Debug.Assert(opc1.Value == opc2.Value); + Debug.Assert(opc1.Size == opc2.Size); + Debug.Assert((int)opc1.FlowControl == (int)opc2.FlowControl); + Debug.Assert((int)opc1.OpCodeType == (int)opc2.OpCodeType); + Debug.Assert((int)opc1.OperandType == (int)opc2.OperandType); + Debug.Assert((int)opc1.StackBehaviourPop == (int)opc2.StackBehaviourPop); + Debug.Assert((int)opc1.StackBehaviourPush == (int)opc2.StackBehaviourPush); + Console.WriteLine("\t\tpublic static readonly OpCode {0} = new OpCode({1});", field.Name, Pack(opc1)); + } + Console.WriteLine(); + Console.WriteLine("\t\tinternal static string GetName(int value)"); + Console.WriteLine("\t\t{"); + Console.WriteLine("\t\t\tswitch (value)"); + Console.WriteLine("\t\t\t{"); + foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) + { + System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); + Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); + Console.WriteLine("\t\t\t\t\treturn \"{0}\";", opc1.Name); + } + Console.WriteLine("\t\t\t}"); + Console.WriteLine("\t\t\tthrow new ArgumentOutOfRangeException();"); + Console.WriteLine("\t\t}"); + Console.WriteLine(); + Console.WriteLine("\t\tpublic static bool TakesSingleByteArgument(OpCode inst)"); + Console.WriteLine("\t\t{"); + Console.WriteLine("\t\t\tswitch (inst.Value)"); + Console.WriteLine("\t\t\t{"); + foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) + { + System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); + if (System.Reflection.Emit.OpCodes.TakesSingleByteArgument(opc1)) + { + Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); + } + } + Console.WriteLine("\t\t\t\t\treturn true;"); + Console.WriteLine("\t\t\t\tdefault:"); + Console.WriteLine("\t\t\t\t\treturn false;"); + Console.WriteLine("\t\t\t}"); + Console.WriteLine("\t\t}"); + } + + private static void CheckEnumRange(System.Type type, int count) + { + foreach (var field in type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) + { + int value = (int)field.GetValue(null); + Debug.Assert(value >= 0 && value < count); + } + } + + static int Pack(System.Reflection.Emit.OpCode opcode) + { + int value = 0; + value *= StackBehaviourPushCount; + value += Map(push, opcode.StackBehaviourPush); + value *= StackBehaviourPopCount; + value += Map(pop, opcode.StackBehaviourPop); + value *= OpCodeTypeCount; + value += (int)opcode.OpCodeType; + value *= StackDiffCount; + value += 3 + GetStackDiff(opcode.StackBehaviourPush) + GetStackDiff(opcode.StackBehaviourPop); + value *= FlowControlCount; + value += (int)opcode.FlowControl; + value *= OperandTypeCount; + value += (int)opcode.OperandType; + return (opcode.Value << 22) | value; + } + + private static int Map(StackBehaviour[] array, System.Reflection.Emit.StackBehaviour stackBehaviour) + { + for (int i = 0; i < array.Length; i++) + { + if ((int)array[i] == (int)stackBehaviour) + { + return i; + } + } + throw new InvalidOperationException(); + } + + static int GetStackDiff(System.Reflection.Emit.StackBehaviour sb) + { + switch (sb) + { + case System.Reflection.Emit.StackBehaviour.Pop0: + case System.Reflection.Emit.StackBehaviour.Push0: + case System.Reflection.Emit.StackBehaviour.Varpop: + case System.Reflection.Emit.StackBehaviour.Varpush: + return 0; + case System.Reflection.Emit.StackBehaviour.Pop1: + case System.Reflection.Emit.StackBehaviour.Popi: + case System.Reflection.Emit.StackBehaviour.Popref: + return -1; + case System.Reflection.Emit.StackBehaviour.Pop1_pop1: + case System.Reflection.Emit.StackBehaviour.Popi_pop1: + case System.Reflection.Emit.StackBehaviour.Popi_popi: + case System.Reflection.Emit.StackBehaviour.Popi_popi8: + case System.Reflection.Emit.StackBehaviour.Popi_popr4: + case System.Reflection.Emit.StackBehaviour.Popi_popr8: + case System.Reflection.Emit.StackBehaviour.Popref_pop1: + case System.Reflection.Emit.StackBehaviour.Popref_popi: + return -2; + case System.Reflection.Emit.StackBehaviour.Popi_popi_popi: + case System.Reflection.Emit.StackBehaviour.Popref_popi_pop1: + case System.Reflection.Emit.StackBehaviour.Popref_popi_popi: + case System.Reflection.Emit.StackBehaviour.Popref_popi_popi8: + case System.Reflection.Emit.StackBehaviour.Popref_popi_popr4: + case System.Reflection.Emit.StackBehaviour.Popref_popi_popr8: + case System.Reflection.Emit.StackBehaviour.Popref_popi_popref: + return -3; + case System.Reflection.Emit.StackBehaviour.Push1: + case System.Reflection.Emit.StackBehaviour.Pushi: + case System.Reflection.Emit.StackBehaviour.Pushi8: + case System.Reflection.Emit.StackBehaviour.Pushr4: + case System.Reflection.Emit.StackBehaviour.Pushr8: + case System.Reflection.Emit.StackBehaviour.Pushref: + return 1; + case System.Reflection.Emit.StackBehaviour.Push1_push1: + return 2; + } + throw new InvalidOperationException(); + } +#endif // GENERATOR + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/OpCodes.cs b/mcs/class/IKVM.Reflection/Emit/OpCodes.cs new file mode 100644 index 000000000000..7d4bcb03407e --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/OpCodes.cs @@ -0,0 +1,749 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection.Emit +{ + public class OpCodes + { + public static readonly OpCode Nop = new OpCode(4888); + public static readonly OpCode Break = new OpCode(4199116); + public static readonly OpCode Ldarg_0 = new OpCode(8492847); + public static readonly OpCode Ldarg_1 = new OpCode(12687151); + public static readonly OpCode Ldarg_2 = new OpCode(16881455); + public static readonly OpCode Ldarg_3 = new OpCode(21075759); + public static readonly OpCode Ldloc_0 = new OpCode(25270063); + public static readonly OpCode Ldloc_1 = new OpCode(29464367); + public static readonly OpCode Ldloc_2 = new OpCode(33658671); + public static readonly OpCode Ldloc_3 = new OpCode(37852975); + public static readonly OpCode Stloc_0 = new OpCode(41949467); + public static readonly OpCode Stloc_1 = new OpCode(46143771); + public static readonly OpCode Stloc_2 = new OpCode(50338075); + public static readonly OpCode Stloc_3 = new OpCode(54532379); + public static readonly OpCode Ldarg_S = new OpCode(58824508); + public static readonly OpCode Ldarga_S = new OpCode(63224012); + public static readonly OpCode Starg_S = new OpCode(67115304); + public static readonly OpCode Ldloc_S = new OpCode(71407420); + public static readonly OpCode Ldloca_S = new OpCode(75806924); + public static readonly OpCode Stloc_S = new OpCode(79698216); + public static readonly OpCode Ldnull = new OpCode(84609339); + public static readonly OpCode Ldc_I4_M1 = new OpCode(88389823); + public static readonly OpCode Ldc_I4_0 = new OpCode(92584127); + public static readonly OpCode Ldc_I4_1 = new OpCode(96778431); + public static readonly OpCode Ldc_I4_2 = new OpCode(100972735); + public static readonly OpCode Ldc_I4_3 = new OpCode(105167039); + public static readonly OpCode Ldc_I4_4 = new OpCode(109361343); + public static readonly OpCode Ldc_I4_5 = new OpCode(113555647); + public static readonly OpCode Ldc_I4_6 = new OpCode(117749951); + public static readonly OpCode Ldc_I4_7 = new OpCode(121944255); + public static readonly OpCode Ldc_I4_8 = new OpCode(126138559); + public static readonly OpCode Ldc_I4_S = new OpCode(130332874); + public static readonly OpCode Ldc_I4 = new OpCode(134530584); + public static readonly OpCode Ldc_I8 = new OpCode(138827489); + public static readonly OpCode Ldc_R4 = new OpCode(143124407); + public static readonly OpCode Ldc_R8 = new OpCode(147421301); + public static readonly OpCode Dup = new OpCode(155404637); + public static readonly OpCode Pop = new OpCode(159393399); + public static readonly OpCode Jmp = new OpCode(163582686); + public static readonly OpCode Call = new OpCode(168690130); + public static readonly OpCode Calli = new OpCode(172884439); + public static readonly OpCode Ret = new OpCode(176258034); + public static readonly OpCode Br_S = new OpCode(180356455); + public static readonly OpCode Brfalse_S = new OpCode(184566035); + public static readonly OpCode Brtrue_S = new OpCode(188760339); + public static readonly OpCode Beq_S = new OpCode(192949342); + public static readonly OpCode Bge_S = new OpCode(197143646); + public static readonly OpCode Bgt_S = new OpCode(201337950); + public static readonly OpCode Ble_S = new OpCode(205532254); + public static readonly OpCode Blt_S = new OpCode(209726558); + public static readonly OpCode Bne_Un_S = new OpCode(213920862); + public static readonly OpCode Bge_Un_S = new OpCode(218115166); + public static readonly OpCode Bgt_Un_S = new OpCode(222309470); + public static readonly OpCode Ble_Un_S = new OpCode(226503774); + public static readonly OpCode Blt_Un_S = new OpCode(230698078); + public static readonly OpCode Br = new OpCode(234885812); + public static readonly OpCode Brfalse = new OpCode(239095392); + public static readonly OpCode Brtrue = new OpCode(243289696); + public static readonly OpCode Beq = new OpCode(247475279); + public static readonly OpCode Bge = new OpCode(251669583); + public static readonly OpCode Bgt = new OpCode(255863887); + public static readonly OpCode Ble = new OpCode(260058191); + public static readonly OpCode Blt = new OpCode(264252495); + public static readonly OpCode Bne_Un = new OpCode(268446799); + public static readonly OpCode Bge_Un = new OpCode(272641103); + public static readonly OpCode Bgt_Un = new OpCode(276835407); + public static readonly OpCode Ble_Un = new OpCode(281029711); + public static readonly OpCode Blt_Un = new OpCode(285224015); + public static readonly OpCode Switch = new OpCode(289427051); + public static readonly OpCode Ldind_I1 = new OpCode(293929358); + public static readonly OpCode Ldind_U1 = new OpCode(298123662); + public static readonly OpCode Ldind_I2 = new OpCode(302317966); + public static readonly OpCode Ldind_U2 = new OpCode(306512270); + public static readonly OpCode Ldind_I4 = new OpCode(310706574); + public static readonly OpCode Ldind_U4 = new OpCode(314900878); + public static readonly OpCode Ldind_I8 = new OpCode(319197782); + public static readonly OpCode Ldind_I = new OpCode(323289486); + public static readonly OpCode Ldind_R4 = new OpCode(327688990); + public static readonly OpCode Ldind_R8 = new OpCode(331985894); + public static readonly OpCode Ldind_Ref = new OpCode(336282798); + public static readonly OpCode Stind_Ref = new OpCode(339768820); + public static readonly OpCode Stind_I1 = new OpCode(343963124); + public static readonly OpCode Stind_I2 = new OpCode(348157428); + public static readonly OpCode Stind_I4 = new OpCode(352351732); + public static readonly OpCode Stind_I8 = new OpCode(356551166); + public static readonly OpCode Stind_R4 = new OpCode(360755730); + public static readonly OpCode Stind_R8 = new OpCode(364955164); + public static readonly OpCode Add = new OpCode(369216329); + public static readonly OpCode Sub = new OpCode(373410633); + public static readonly OpCode Mul = new OpCode(377604937); + public static readonly OpCode Div = new OpCode(381799241); + public static readonly OpCode Div_Un = new OpCode(385993545); + public static readonly OpCode Rem = new OpCode(390187849); + public static readonly OpCode Rem_Un = new OpCode(394382153); + public static readonly OpCode And = new OpCode(398576457); + public static readonly OpCode Or = new OpCode(402770761); + public static readonly OpCode Xor = new OpCode(406965065); + public static readonly OpCode Shl = new OpCode(411159369); + public static readonly OpCode Shr = new OpCode(415353673); + public static readonly OpCode Shr_Un = new OpCode(419547977); + public static readonly OpCode Neg = new OpCode(423737322); + public static readonly OpCode Not = new OpCode(427931626); + public static readonly OpCode Conv_I1 = new OpCode(432331130); + public static readonly OpCode Conv_I2 = new OpCode(436525434); + public static readonly OpCode Conv_I4 = new OpCode(440719738); + public static readonly OpCode Conv_I8 = new OpCode(445016642); + public static readonly OpCode Conv_R4 = new OpCode(449313546); + public static readonly OpCode Conv_R8 = new OpCode(453610450); + public static readonly OpCode Conv_U4 = new OpCode(457496954); + public static readonly OpCode Conv_U8 = new OpCode(461793858); + public static readonly OpCode Callvirt = new OpCode(466484004); + public static readonly OpCode Cpobj = new OpCode(469790542); + public static readonly OpCode Ldobj = new OpCode(474077528); + public static readonly OpCode Ldstr = new OpCode(478872210); + public static readonly OpCode Newobj = new OpCode(483158791); + public static readonly OpCode Castclass = new OpCode(487311950); + public static readonly OpCode Isinst = new OpCode(491095854); + public static readonly OpCode Conv_R_Un = new OpCode(495553490); + public static readonly OpCode Unbox = new OpCode(507874780); + public static readonly OpCode Throw = new OpCode(511759452); + public static readonly OpCode Ldfld = new OpCode(516056466); + public static readonly OpCode Ldflda = new OpCode(520455970); + public static readonly OpCode Stfld = new OpCode(524347262); + public static readonly OpCode Ldsfld = new OpCode(528588249); + public static readonly OpCode Ldsflda = new OpCode(532987753); + public static readonly OpCode Stsfld = new OpCode(536879045); + public static readonly OpCode Stobj = new OpCode(541090290); + public static readonly OpCode Conv_Ovf_I1_Un = new OpCode(545577338); + public static readonly OpCode Conv_Ovf_I2_Un = new OpCode(549771642); + public static readonly OpCode Conv_Ovf_I4_Un = new OpCode(553965946); + public static readonly OpCode Conv_Ovf_I8_Un = new OpCode(558262850); + public static readonly OpCode Conv_Ovf_U1_Un = new OpCode(562354554); + public static readonly OpCode Conv_Ovf_U2_Un = new OpCode(566548858); + public static readonly OpCode Conv_Ovf_U4_Un = new OpCode(570743162); + public static readonly OpCode Conv_Ovf_U8_Un = new OpCode(575040066); + public static readonly OpCode Conv_Ovf_I_Un = new OpCode(579131770); + public static readonly OpCode Conv_Ovf_U_Un = new OpCode(583326074); + public static readonly OpCode Box = new OpCode(587930786); + public static readonly OpCode Newarr = new OpCode(592133640); + public static readonly OpCode Ldlen = new OpCode(595953446); + public static readonly OpCode Ldelema = new OpCode(600157847); + public static readonly OpCode Ldelem_I1 = new OpCode(604352143); + public static readonly OpCode Ldelem_U1 = new OpCode(608546447); + public static readonly OpCode Ldelem_I2 = new OpCode(612740751); + public static readonly OpCode Ldelem_U2 = new OpCode(616935055); + public static readonly OpCode Ldelem_I4 = new OpCode(621129359); + public static readonly OpCode Ldelem_U4 = new OpCode(625323663); + public static readonly OpCode Ldelem_I8 = new OpCode(629620567); + public static readonly OpCode Ldelem_I = new OpCode(633712271); + public static readonly OpCode Ldelem_R4 = new OpCode(638111775); + public static readonly OpCode Ldelem_R8 = new OpCode(642408679); + public static readonly OpCode Ldelem_Ref = new OpCode(646705583); + public static readonly OpCode Stelem_I = new OpCode(650186475); + public static readonly OpCode Stelem_I1 = new OpCode(654380779); + public static readonly OpCode Stelem_I2 = new OpCode(658575083); + public static readonly OpCode Stelem_I4 = new OpCode(662769387); + public static readonly OpCode Stelem_I8 = new OpCode(666968821); + public static readonly OpCode Stelem_R4 = new OpCode(671168255); + public static readonly OpCode Stelem_R8 = new OpCode(675367689); + public static readonly OpCode Stelem_Ref = new OpCode(679567123); + public static readonly OpCode Ldelem = new OpCode(683838727); + public static readonly OpCode Stelem = new OpCode(687965999); + public static readonly OpCode Unbox_Any = new OpCode(692217246); + public static readonly OpCode Conv_Ovf_I1 = new OpCode(751098234); + public static readonly OpCode Conv_Ovf_U1 = new OpCode(755292538); + public static readonly OpCode Conv_Ovf_I2 = new OpCode(759486842); + public static readonly OpCode Conv_Ovf_U2 = new OpCode(763681146); + public static readonly OpCode Conv_Ovf_I4 = new OpCode(767875450); + public static readonly OpCode Conv_Ovf_U4 = new OpCode(772069754); + public static readonly OpCode Conv_Ovf_I8 = new OpCode(776366658); + public static readonly OpCode Conv_Ovf_U8 = new OpCode(780560962); + public static readonly OpCode Refanyval = new OpCode(814012802); + public static readonly OpCode Ckfinite = new OpCode(818514898); + public static readonly OpCode Mkrefany = new OpCode(830595078); + public static readonly OpCode Ldtoken = new OpCode(872728098); + public static readonly OpCode Conv_U2 = new OpCode(876927354); + public static readonly OpCode Conv_U1 = new OpCode(881121658); + public static readonly OpCode Conv_I = new OpCode(885315962); + public static readonly OpCode Conv_Ovf_I = new OpCode(889510266); + public static readonly OpCode Conv_Ovf_U = new OpCode(893704570); + public static readonly OpCode Add_Ovf = new OpCode(897698633); + public static readonly OpCode Add_Ovf_Un = new OpCode(901892937); + public static readonly OpCode Mul_Ovf = new OpCode(906087241); + public static readonly OpCode Mul_Ovf_Un = new OpCode(910281545); + public static readonly OpCode Sub_Ovf = new OpCode(914475849); + public static readonly OpCode Sub_Ovf_Un = new OpCode(918670153); + public static readonly OpCode Endfinally = new OpCode(922751806); + public static readonly OpCode Leave = new OpCode(926945972); + public static readonly OpCode Leave_S = new OpCode(931140291); + public static readonly OpCode Stind_I = new OpCode(935359988); + public static readonly OpCode Conv_U = new OpCode(939841914); + public static readonly OpCode Prefix7 = new OpCode(1040189696); + public static readonly OpCode Prefix6 = new OpCode(1044384000); + public static readonly OpCode Prefix5 = new OpCode(1048578304); + public static readonly OpCode Prefix4 = new OpCode(1052772608); + public static readonly OpCode Prefix3 = new OpCode(1056966912); + public static readonly OpCode Prefix2 = new OpCode(1061161216); + public static readonly OpCode Prefix1 = new OpCode(1065355520); + public static readonly OpCode Prefixref = new OpCode(1069549824); + public static readonly OpCode Arglist = new OpCode(-2147170789); + public static readonly OpCode Ceq = new OpCode(-2142966567); + public static readonly OpCode Cgt = new OpCode(-2138772263); + public static readonly OpCode Cgt_Un = new OpCode(-2134577959); + public static readonly OpCode Clt = new OpCode(-2130383655); + public static readonly OpCode Clt_Un = new OpCode(-2126189351); + public static readonly OpCode Ldftn = new OpCode(-2122004966); + public static readonly OpCode Ldvirtftn = new OpCode(-2117759533); + public static readonly OpCode Ldarg = new OpCode(-2109627244); + public static readonly OpCode Ldarga = new OpCode(-2105227740); + public static readonly OpCode Starg = new OpCode(-2101336448); + public static readonly OpCode Ldloc = new OpCode(-2097044332); + public static readonly OpCode Ldloca = new OpCode(-2092644828); + public static readonly OpCode Stloc = new OpCode(-2088753536); + public static readonly OpCode Localloc = new OpCode(-2084241010); + public static readonly OpCode Endfilter = new OpCode(-2076160335); + public static readonly OpCode Unaligned = new OpCode(-2071982151); + public static readonly OpCode Volatile = new OpCode(-2067787858); + public static readonly OpCode Tailcall = new OpCode(-2063593554); + public static readonly OpCode Initobj = new OpCode(-2059384859); + public static readonly OpCode Constrained = new OpCode(-2055204938); + public static readonly OpCode Cpblk = new OpCode(-2050974371); + public static readonly OpCode Initblk = new OpCode(-2046780067); + public static readonly OpCode Rethrow = new OpCode(-2038428509); + public static readonly OpCode Sizeof = new OpCode(-2029730269); + public static readonly OpCode Refanytype = new OpCode(-2025531014); + public static readonly OpCode Readonly = new OpCode(-2021650514); + + internal static string GetName(int value) + { + switch (value) + { + case 0: + return "nop"; + case 1: + return "break"; + case 2: + return "ldarg.0"; + case 3: + return "ldarg.1"; + case 4: + return "ldarg.2"; + case 5: + return "ldarg.3"; + case 6: + return "ldloc.0"; + case 7: + return "ldloc.1"; + case 8: + return "ldloc.2"; + case 9: + return "ldloc.3"; + case 10: + return "stloc.0"; + case 11: + return "stloc.1"; + case 12: + return "stloc.2"; + case 13: + return "stloc.3"; + case 14: + return "ldarg.s"; + case 15: + return "ldarga.s"; + case 16: + return "starg.s"; + case 17: + return "ldloc.s"; + case 18: + return "ldloca.s"; + case 19: + return "stloc.s"; + case 20: + return "ldnull"; + case 21: + return "ldc.i4.m1"; + case 22: + return "ldc.i4.0"; + case 23: + return "ldc.i4.1"; + case 24: + return "ldc.i4.2"; + case 25: + return "ldc.i4.3"; + case 26: + return "ldc.i4.4"; + case 27: + return "ldc.i4.5"; + case 28: + return "ldc.i4.6"; + case 29: + return "ldc.i4.7"; + case 30: + return "ldc.i4.8"; + case 31: + return "ldc.i4.s"; + case 32: + return "ldc.i4"; + case 33: + return "ldc.i8"; + case 34: + return "ldc.r4"; + case 35: + return "ldc.r8"; + case 37: + return "dup"; + case 38: + return "pop"; + case 39: + return "jmp"; + case 40: + return "call"; + case 41: + return "calli"; + case 42: + return "ret"; + case 43: + return "br.s"; + case 44: + return "brfalse.s"; + case 45: + return "brtrue.s"; + case 46: + return "beq.s"; + case 47: + return "bge.s"; + case 48: + return "bgt.s"; + case 49: + return "ble.s"; + case 50: + return "blt.s"; + case 51: + return "bne.un.s"; + case 52: + return "bge.un.s"; + case 53: + return "bgt.un.s"; + case 54: + return "ble.un.s"; + case 55: + return "blt.un.s"; + case 56: + return "br"; + case 57: + return "brfalse"; + case 58: + return "brtrue"; + case 59: + return "beq"; + case 60: + return "bge"; + case 61: + return "bgt"; + case 62: + return "ble"; + case 63: + return "blt"; + case 64: + return "bne.un"; + case 65: + return "bge.un"; + case 66: + return "bgt.un"; + case 67: + return "ble.un"; + case 68: + return "blt.un"; + case 69: + return "switch"; + case 70: + return "ldind.i1"; + case 71: + return "ldind.u1"; + case 72: + return "ldind.i2"; + case 73: + return "ldind.u2"; + case 74: + return "ldind.i4"; + case 75: + return "ldind.u4"; + case 76: + return "ldind.i8"; + case 77: + return "ldind.i"; + case 78: + return "ldind.r4"; + case 79: + return "ldind.r8"; + case 80: + return "ldind.ref"; + case 81: + return "stind.ref"; + case 82: + return "stind.i1"; + case 83: + return "stind.i2"; + case 84: + return "stind.i4"; + case 85: + return "stind.i8"; + case 86: + return "stind.r4"; + case 87: + return "stind.r8"; + case 88: + return "add"; + case 89: + return "sub"; + case 90: + return "mul"; + case 91: + return "div"; + case 92: + return "div.un"; + case 93: + return "rem"; + case 94: + return "rem.un"; + case 95: + return "and"; + case 96: + return "or"; + case 97: + return "xor"; + case 98: + return "shl"; + case 99: + return "shr"; + case 100: + return "shr.un"; + case 101: + return "neg"; + case 102: + return "not"; + case 103: + return "conv.i1"; + case 104: + return "conv.i2"; + case 105: + return "conv.i4"; + case 106: + return "conv.i8"; + case 107: + return "conv.r4"; + case 108: + return "conv.r8"; + case 109: + return "conv.u4"; + case 110: + return "conv.u8"; + case 111: + return "callvirt"; + case 112: + return "cpobj"; + case 113: + return "ldobj"; + case 114: + return "ldstr"; + case 115: + return "newobj"; + case 116: + return "castclass"; + case 117: + return "isinst"; + case 118: + return "conv.r.un"; + case 121: + return "unbox"; + case 122: + return "throw"; + case 123: + return "ldfld"; + case 124: + return "ldflda"; + case 125: + return "stfld"; + case 126: + return "ldsfld"; + case 127: + return "ldsflda"; + case 128: + return "stsfld"; + case 129: + return "stobj"; + case 130: + return "conv.ovf.i1.un"; + case 131: + return "conv.ovf.i2.un"; + case 132: + return "conv.ovf.i4.un"; + case 133: + return "conv.ovf.i8.un"; + case 134: + return "conv.ovf.u1.un"; + case 135: + return "conv.ovf.u2.un"; + case 136: + return "conv.ovf.u4.un"; + case 137: + return "conv.ovf.u8.un"; + case 138: + return "conv.ovf.i.un"; + case 139: + return "conv.ovf.u.un"; + case 140: + return "box"; + case 141: + return "newarr"; + case 142: + return "ldlen"; + case 143: + return "ldelema"; + case 144: + return "ldelem.i1"; + case 145: + return "ldelem.u1"; + case 146: + return "ldelem.i2"; + case 147: + return "ldelem.u2"; + case 148: + return "ldelem.i4"; + case 149: + return "ldelem.u4"; + case 150: + return "ldelem.i8"; + case 151: + return "ldelem.i"; + case 152: + return "ldelem.r4"; + case 153: + return "ldelem.r8"; + case 154: + return "ldelem.ref"; + case 155: + return "stelem.i"; + case 156: + return "stelem.i1"; + case 157: + return "stelem.i2"; + case 158: + return "stelem.i4"; + case 159: + return "stelem.i8"; + case 160: + return "stelem.r4"; + case 161: + return "stelem.r8"; + case 162: + return "stelem.ref"; + case 163: + return "ldelem"; + case 164: + return "stelem"; + case 165: + return "unbox.any"; + case 179: + return "conv.ovf.i1"; + case 180: + return "conv.ovf.u1"; + case 181: + return "conv.ovf.i2"; + case 182: + return "conv.ovf.u2"; + case 183: + return "conv.ovf.i4"; + case 184: + return "conv.ovf.u4"; + case 185: + return "conv.ovf.i8"; + case 186: + return "conv.ovf.u8"; + case 194: + return "refanyval"; + case 195: + return "ckfinite"; + case 198: + return "mkrefany"; + case 208: + return "ldtoken"; + case 209: + return "conv.u2"; + case 210: + return "conv.u1"; + case 211: + return "conv.i"; + case 212: + return "conv.ovf.i"; + case 213: + return "conv.ovf.u"; + case 214: + return "add.ovf"; + case 215: + return "add.ovf.un"; + case 216: + return "mul.ovf"; + case 217: + return "mul.ovf.un"; + case 218: + return "sub.ovf"; + case 219: + return "sub.ovf.un"; + case 220: + return "endfinally"; + case 221: + return "leave"; + case 222: + return "leave.s"; + case 223: + return "stind.i"; + case 224: + return "conv.u"; + case 248: + return "prefix7"; + case 249: + return "prefix6"; + case 250: + return "prefix5"; + case 251: + return "prefix4"; + case 252: + return "prefix3"; + case 253: + return "prefix2"; + case 254: + return "prefix1"; + case 255: + return "prefixref"; + case -512: + return "arglist"; + case -511: + return "ceq"; + case -510: + return "cgt"; + case -509: + return "cgt.un"; + case -508: + return "clt"; + case -507: + return "clt.un"; + case -506: + return "ldftn"; + case -505: + return "ldvirtftn"; + case -503: + return "ldarg"; + case -502: + return "ldarga"; + case -501: + return "starg"; + case -500: + return "ldloc"; + case -499: + return "ldloca"; + case -498: + return "stloc"; + case -497: + return "localloc"; + case -495: + return "endfilter"; + case -494: + return "unaligned."; + case -493: + return "volatile."; + case -492: + return "tail."; + case -491: + return "initobj"; + case -490: + return "constrained."; + case -489: + return "cpblk"; + case -488: + return "initblk"; + case -486: + return "rethrow"; + case -484: + return "sizeof"; + case -483: + return "refanytype"; + case -482: + return "readonly."; + } + throw new ArgumentOutOfRangeException(); + } + + public static bool TakesSingleByteArgument(OpCode inst) + { + switch (inst.Value) + { + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 31: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 222: + case -494: + return true; + default: + return false; + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/ParameterBuilder.cs b/mcs/class/IKVM.Reflection/Emit/ParameterBuilder.cs new file mode 100644 index 000000000000..a74e35091687 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/ParameterBuilder.cs @@ -0,0 +1,143 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Emit +{ + public sealed class ParameterBuilder + { + private readonly ModuleBuilder moduleBuilder; + private short flags; + private readonly short sequence; + private readonly int nameIndex; + private readonly string name; + private int lazyPseudoToken; + + internal ParameterBuilder(ModuleBuilder moduleBuilder, int sequence, ParameterAttributes attribs, string name) + { + this.moduleBuilder = moduleBuilder; + this.flags = (short)attribs; + this.sequence = (short)sequence; + this.nameIndex = name == null ? 0 : moduleBuilder.Strings.Add(name); + this.name = name; + } + + internal int PseudoToken + { + get + { + if (lazyPseudoToken == 0) + { + // we lazily create the token, because if we don't need it we don't want the token fixup cost + lazyPseudoToken = moduleBuilder.AllocPseudoToken(); + } + return lazyPseudoToken; + } + } + + public string Name + { + get { return name; } + } + + public int Position + { + get { return sequence - 1; } + } + + public int Attributes + { + get { return flags; } + } + + public bool IsIn + { + get { return (flags & (short)ParameterAttributes.In) != 0; } + } + + public bool IsOut + { + get { return (flags & (short)ParameterAttributes.Out) != 0; } + } + + public bool IsOptional + { + get { return (flags & (short)ParameterAttributes.Optional) != 0; } + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customAttributeBuilder) + { + Universe u = moduleBuilder.universe; + if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_InAttribute) + { + flags |= (short)ParameterAttributes.In; + } + else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OutAttribute) + { + flags |= (short)ParameterAttributes.Out; + } + else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OptionalAttribute) + { + flags |= (short)ParameterAttributes.Optional; + } + else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute) + { + MarshalSpec.SetMarshalAsAttribute(moduleBuilder, PseudoToken, customAttributeBuilder); + flags |= (short)ParameterAttributes.HasFieldMarshal; + } + else + { + moduleBuilder.SetCustomAttribute(PseudoToken, customAttributeBuilder); + } + } + + public void SetConstant(object defaultValue) + { + flags |= (short)ParameterAttributes.HasDefault; + moduleBuilder.AddConstant(PseudoToken, defaultValue); + } + + internal void WriteParamRecord(MetadataWriter mw) + { + mw.Write(flags); + mw.Write(sequence); + mw.WriteStringIndex(nameIndex); + } + + internal void FixupToken(int parameterToken) + { + if (lazyPseudoToken != 0) + { + moduleBuilder.RegisterTokenFixup(lazyPseudoToken, parameterToken); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/PropertyBuilder.cs b/mcs/class/IKVM.Reflection/Emit/PropertyBuilder.cs new file mode 100644 index 000000000000..1815355cbba1 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/PropertyBuilder.cs @@ -0,0 +1,275 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Emit +{ + public sealed class PropertyBuilder : PropertyInfo + { + private readonly TypeBuilder typeBuilder; + private readonly string name; + private PropertyAttributes attributes; + private PropertySignature sig; + private MethodBuilder getter; + private MethodBuilder setter; + private List otherMethods; + private int lazyPseudoToken; + private bool patchCallingConvention; + + internal PropertyBuilder(TypeBuilder typeBuilder, string name, PropertyAttributes attributes, PropertySignature sig, bool patchCallingConvention) + { + this.typeBuilder = typeBuilder; + this.name = name; + this.attributes = attributes; + this.sig = sig; + this.patchCallingConvention = patchCallingConvention; + } + + internal override PropertySignature PropertySignature + { + get { return sig; } + } + + private void PatchCallingConvention(MethodBuilder mdBuilder) + { + if (patchCallingConvention && !mdBuilder.IsStatic) + { + sig.HasThis = true; + } + } + + public void SetGetMethod(MethodBuilder mdBuilder) + { + PatchCallingConvention(mdBuilder); + getter = mdBuilder; + } + + public void SetSetMethod(MethodBuilder mdBuilder) + { + PatchCallingConvention(mdBuilder); + setter = mdBuilder; + } + + public void AddOtherMethod(MethodBuilder mdBuilder) + { + PatchCallingConvention(mdBuilder); + if (otherMethods == null) + { + otherMethods = new List(); + } + otherMethods.Add(mdBuilder); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + Universe u = typeBuilder.ModuleBuilder.universe; + if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute) + { + attributes |= PropertyAttributes.SpecialName; + } + else + { + if (lazyPseudoToken == 0) + { + lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken(); + } + typeBuilder.ModuleBuilder.SetCustomAttribute(lazyPseudoToken, customBuilder); + } + } + + public override object GetRawConstantValue() + { + if (lazyPseudoToken != 0) + { + return typeBuilder.ModuleBuilder.Constant.GetRawConstantValue(typeBuilder.ModuleBuilder, lazyPseudoToken); + } + throw new InvalidOperationException(); + } + + public override PropertyAttributes Attributes + { + get { return attributes; } + } + + public override bool CanRead + { + get { return getter != null; } + } + + public override bool CanWrite + { + get { return setter != null; } + } + + public override MethodInfo GetGetMethod(bool nonPublic) + { + return nonPublic || (getter != null && getter.IsPublic) ? getter : null; + } + + public override MethodInfo GetSetMethod(bool nonPublic) + { + return nonPublic || (setter != null && setter.IsPublic) ? setter : null; + } + + public override MethodInfo[] GetAccessors(bool nonPublic) + { + List list = new List(); + AddAccessor(list, nonPublic, getter); + AddAccessor(list, nonPublic, setter); + if (otherMethods != null) + { + foreach (MethodInfo method in otherMethods) + { + AddAccessor(list, nonPublic, method); + } + } + return list.ToArray(); + } + + private static void AddAccessor(List list, bool nonPublic, MethodInfo method) + { + if (method != null && (nonPublic || method.IsPublic)) + { + list.Add(method); + } + } + + public override Type DeclaringType + { + get { return typeBuilder; } + } + + public override string Name + { + get { return name; } + } + + public override Module Module + { + get { return typeBuilder.Module; } + } + + public void SetConstant(object defaultValue) + { + if (lazyPseudoToken == 0) + { + lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken(); + } + attributes |= PropertyAttributes.HasDefault; + typeBuilder.ModuleBuilder.AddConstant(lazyPseudoToken, defaultValue); + } + + internal void Bake() + { + PropertyTable.Record rec = new PropertyTable.Record(); + rec.Flags = (short)attributes; + rec.Name = typeBuilder.ModuleBuilder.Strings.Add(name); + rec.Type = typeBuilder.ModuleBuilder.GetSignatureBlobIndex(sig); + int token = 0x17000000 | typeBuilder.ModuleBuilder.Property.AddRecord(rec); + + if (lazyPseudoToken != 0) + { + typeBuilder.ModuleBuilder.RegisterTokenFixup(lazyPseudoToken, token); + } + + if (getter != null) + { + AddMethodSemantics(MethodSemanticsTable.Getter, getter.MetadataToken, token); + } + if (setter != null) + { + AddMethodSemantics(MethodSemanticsTable.Setter, setter.MetadataToken, token); + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + AddMethodSemantics(MethodSemanticsTable.Other, method.MetadataToken, token); + } + } + } + + private void AddMethodSemantics(short semantics, int methodToken, int propertyToken) + { + MethodSemanticsTable.Record rec = new MethodSemanticsTable.Record(); + rec.Semantics = semantics; + rec.Method = methodToken; + rec.Association = propertyToken; + typeBuilder.ModuleBuilder.MethodSemantics.AddRecord(rec); + } + + internal override bool IsPublic + { + get + { + if ((getter != null && getter.IsPublic) || (setter != null && setter.IsPublic)) + { + return true; + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + if (method.IsPublic) + { + return true; + } + } + } + return false; + } + } + + internal override bool IsStatic + { + get + { + if ((getter != null && getter.IsStatic) || (setter != null && setter.IsStatic)) + { + return true; + } + if (otherMethods != null) + { + foreach (MethodBuilder method in otherMethods) + { + if (method.IsStatic) + { + return true; + } + } + } + return false; + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/SignatureHelper.cs b/mcs/class/IKVM.Reflection/Emit/SignatureHelper.cs new file mode 100644 index 000000000000..788c3708946e --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/SignatureHelper.cs @@ -0,0 +1,239 @@ +/* + Copyright (C) 2008, 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using IKVM.Reflection; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class SignatureHelper + { + private readonly ModuleBuilder module; + private readonly byte type; + private readonly List args = new List(); + private readonly List locals = new List(); + private readonly List requiredCustomModifiers = new List(); + private readonly List optionalCustomModifiers = new List(); + private readonly List optionalArgs = new List(); + private Type returnType; + private Type[] returnTypeRequiredCustomModifiers; + private Type[] returnTypeOptionalCustomModifiers; + private CallingConventions callingConvention; + private CallingConvention unmanagedCallConv; + private bool unmanaged; + private bool optional; + + private SignatureHelper(ModuleBuilder module, byte type) + { + this.module = module; + this.type = type; + } + + internal bool HasThis + { + get { return (callingConvention & CallingConventions.HasThis) != 0; } + } + + internal Type ReturnType + { + get { return returnType; } + } + + internal int ParameterCount + { + get { return args.Count + optionalArgs.Count; } + } + + public static SignatureHelper GetFieldSigHelper(Module mod) + { + return new SignatureHelper(mod as ModuleBuilder, Signature.FIELD); + } + + public static SignatureHelper GetLocalVarSigHelper() + { + return new SignatureHelper(null, Signature.LOCAL_SIG); + } + + public static SignatureHelper GetLocalVarSigHelper(Module mod) + { + return new SignatureHelper(mod as ModuleBuilder, Signature.LOCAL_SIG); + } + + public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes) + { + SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, Signature.PROPERTY); + sig.returnType = returnType; + sig.returnTypeOptionalCustomModifiers = Type.EmptyTypes; + sig.returnTypeRequiredCustomModifiers = Type.EmptyTypes; + foreach (Type type in parameterTypes) + { + sig.AddArgument(type); + } + return sig; + } + + public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) + { + return GetPropertySigHelper(mod, CallingConventions.Standard, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); + } + + public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) + { + SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, Signature.PROPERTY); + sig.callingConvention = callingConvention; + sig.returnType = returnType; + sig.returnTypeOptionalCustomModifiers = requiredReturnTypeCustomModifiers; + sig.returnTypeRequiredCustomModifiers = optionalReturnTypeCustomModifiers; + sig.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); + return sig; + } + + public static SignatureHelper GetMethodSigHelper(CallingConvention unmanagedCallingConvention, Type returnType) + { + return GetMethodSigHelper(null, unmanagedCallingConvention, returnType); + } + + public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType) + { + return GetMethodSigHelper(null, callingConvention, returnType); + } + + public static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType) + { + SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, 0); + sig.returnType = returnType; + sig.unmanaged = true; + sig.unmanagedCallConv = unmanagedCallConv; + return sig; + } + + public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType) + { + SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, 0); + sig.returnType = returnType; + sig.callingConvention = callingConvention; + return sig; + } + + public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes) + { + SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, 0); + sig.returnType = returnType; + sig.callingConvention = CallingConventions.Standard; + foreach (Type type in parameterTypes) + { + sig.AddArgument(type); + } + return sig; + } + + public byte[] GetSignature() + { + if (module == null) + { + throw new NotSupportedException(); + } + return GetSignature(module).ToArray(); + } + + internal ByteBuffer GetSignature(ModuleBuilder module) + { + ByteBuffer bb = new ByteBuffer(16); + switch (type) + { + case 0: + if (unmanaged) + { + Signature.WriteStandAloneMethodSig(module, bb, unmanagedCallConv, returnType, args.ToArray()); + } + else + { + Signature.WriteStandAloneMethodSig(module, bb, callingConvention, returnType, args.ToArray(), optionalArgs.ToArray()); + } + break; + case Signature.FIELD: + FieldSignature.Create(args[0], optionalCustomModifiers[0], requiredCustomModifiers[0]).WriteSig(module, bb); + break; + case Signature.PROPERTY: + Signature.WritePropertySig(module, bb, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, args.ToArray(), requiredCustomModifiers.ToArray(), optionalCustomModifiers.ToArray()); + break; + case Signature.LOCAL_SIG: + Signature.WriteLocalVarSig(module, bb, locals); + break; + default: + throw new InvalidOperationException(); + } + return bb; + } + + public void AddSentinel() + { + optional = true; + callingConvention |= CallingConventions.VarArgs; + } + + public void AddArgument(Type clsArgument) + { + AddArgument(clsArgument, false); + } + + public void AddArgument(Type argument, bool pinned) + { + AddArgument(argument, pinned, Type.EmptyTypes, Type.EmptyTypes); + } + + public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + AddArgument(argument, false, requiredCustomModifiers, optionalCustomModifiers); + } + + private void AddArgument(Type argument, bool pinned, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + if (type == Signature.LOCAL_SIG) + { + locals.Add(new LocalBuilder(argument, 0, pinned)); + } + else if (optional) + { + this.optionalArgs.Add(argument); + } + else + { + this.args.Add(argument); + this.requiredCustomModifiers.Add(requiredCustomModifiers); + this.optionalCustomModifiers.Add(optionalCustomModifiers); + } + } + + public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) + { + for (int i = 0; i < arguments.Length; i++) + { + AddArgument(arguments[i], false, requiredCustomModifiers[i], optionalCustomModifiers[i]); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/Tokens.cs b/mcs/class/IKVM.Reflection/Emit/Tokens.cs new file mode 100644 index 000000000000..49ac4c6adb91 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/Tokens.cs @@ -0,0 +1,281 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ + +namespace IKVM.Reflection.Emit +{ + public struct EventToken + { + public static readonly EventToken Empty; + private readonly int token; + + internal EventToken(int token) + { + this.token = token; + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as EventToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(EventToken other) + { + return this == other; + } + + public static bool operator ==(EventToken et1, EventToken et2) + { + return et1.token == et2.token; + } + + public static bool operator !=(EventToken et1, EventToken et2) + { + return et1.token != et2.token; + } + } + + public struct FieldToken + { + public static readonly FieldToken Empty; + private readonly int token; + + internal FieldToken(int token) + { + this.token = token; + } + + internal bool IsPseudoToken + { + get { return token < 0; } + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as FieldToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(FieldToken other) + { + return this == other; + } + + public static bool operator ==(FieldToken ft1, FieldToken ft2) + { + return ft1.token == ft2.token; + } + + public static bool operator !=(FieldToken ft1, FieldToken ft2) + { + return ft1.token != ft2.token; + } + } + + public struct MethodToken + { + public static readonly MethodToken Empty; + private readonly int token; + + internal MethodToken(int token) + { + this.token = token; + } + + internal bool IsPseudoToken + { + get { return token < 0; } + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as MethodToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(MethodToken other) + { + return this == other; + } + + public static bool operator ==(MethodToken mt1, MethodToken mt2) + { + return mt1.token == mt2.token; + } + + public static bool operator !=(MethodToken mt1, MethodToken mt2) + { + return mt1.token != mt2.token; + } + } + + public struct SignatureToken + { + public static readonly SignatureToken Empty; + private readonly int token; + + internal SignatureToken(int token) + { + this.token = token; + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as SignatureToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(SignatureToken other) + { + return this == other; + } + + public static bool operator ==(SignatureToken st1, SignatureToken st2) + { + return st1.token == st2.token; + } + + public static bool operator !=(SignatureToken st1, SignatureToken st2) + { + return st1.token != st2.token; + } + } + + public struct StringToken + { + private readonly int token; + + internal StringToken(int token) + { + this.token = token; + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as StringToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(StringToken other) + { + return this == other; + } + + public static bool operator ==(StringToken st1, StringToken st2) + { + return st1.token == st2.token; + } + + public static bool operator !=(StringToken st1, StringToken st2) + { + return st1.token != st2.token; + } + } + + public struct TypeToken + { + public static readonly TypeToken Empty; + private readonly int token; + + internal TypeToken(int token) + { + this.token = token; + } + + public int Token + { + get { return token; } + } + + public override bool Equals(object obj) + { + return obj as TypeToken? == this; + } + + public override int GetHashCode() + { + return token; + } + + public bool Equals(TypeToken other) + { + return this == other; + } + + public static bool operator ==(TypeToken tt1, TypeToken tt2) + { + return tt1.token == tt2.token; + } + + public static bool operator !=(TypeToken tt1, TypeToken tt2) + { + return tt1.token != tt2.token; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Emit/TypeBuilder.cs b/mcs/class/IKVM.Reflection/Emit/TypeBuilder.cs new file mode 100644 index 000000000000..8b2e0ebde67e --- /dev/null +++ b/mcs/class/IKVM.Reflection/Emit/TypeBuilder.cs @@ -0,0 +1,1163 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; +using IKVM.Reflection.Impl; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Writer; + +namespace IKVM.Reflection.Emit +{ + public sealed class GenericTypeParameterBuilder : Type + { + private readonly string name; + private readonly TypeBuilder type; + private readonly MethodBuilder method; + private readonly int paramPseudoIndex; + private readonly int position; + private int typeToken; + private Type baseType; + private GenericParameterAttributes attr; + + internal GenericTypeParameterBuilder(string name, TypeBuilder type, MethodBuilder method, int position) + { + this.name = name; + this.type = type; + this.method = method; + this.position = position; + GenericParamTable.Record rec = new GenericParamTable.Record(); + rec.Number = (short)position; + rec.Flags = 0; + rec.Owner = type != null ? type.MetadataToken : method.MetadataToken; + rec.Name = this.ModuleBuilder.Strings.Add(name); + this.paramPseudoIndex = this.ModuleBuilder.GenericParam.AddRecord(rec); + } + + public override string AssemblyQualifiedName + { + get { return null; } + } + + public override bool IsValueType + { + get { return (this.GenericParameterAttributes & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0; } + } + + public override Type BaseType + { + get { return baseType; } + } + + public override Type[] __GetDeclaredInterfaces() + { + throw new NotImplementedException(); + } + + public override TypeAttributes Attributes + { + get { return TypeAttributes.Public; } + } + + public override string Namespace + { + get { return DeclaringType.Namespace; } + } + + public override Type UnderlyingSystemType + { + get { return this; } + } + + public override string Name + { + get { return name; } + } + + public override string FullName + { + get { return null; } + } + + public override string ToString() + { + return this.Name; + } + + private ModuleBuilder ModuleBuilder + { + get { return type != null ? type.ModuleBuilder : method.ModuleBuilder; } + } + + public override Module Module + { + get { return ModuleBuilder; } + } + + public override bool IsGenericParameter + { + get { return true; } + } + + public override int GenericParameterPosition + { + get { return position; } + } + + public override Type DeclaringType + { + get { return type; } + } + + public override MethodBase DeclaringMethod + { + get { return method; } + } + + public override Type[] GetGenericParameterConstraints() + { + throw new NotImplementedException(); + } + + public override GenericParameterAttributes GenericParameterAttributes + { + get + { + if (type != null) + { + type.CheckBaked(); + } + else + { + method.CheckBaked(); + } + return attr; + } + } + + private void AddConstraint(Type type) + { + GenericParamConstraintTable.Record rec = new GenericParamConstraintTable.Record(); + rec.Owner = paramPseudoIndex; + rec.Constraint = this.ModuleBuilder.GetTypeTokenForMemberRef(type); + this.ModuleBuilder.GenericParamConstraint.AddRecord(rec); + } + + public void SetBaseTypeConstraint(Type baseTypeConstraint) + { + this.baseType = baseTypeConstraint; + AddConstraint(baseTypeConstraint); + } + + public void SetInterfaceConstraints(params Type[] interfaceConstraints) + { + foreach (Type type in interfaceConstraints) + { + AddConstraint(type); + } + } + + public void SetGenericParameterAttributes(GenericParameterAttributes genericParameterAttributes) + { + this.attr = genericParameterAttributes; + // for now we'll back patch the table + this.ModuleBuilder.GenericParam.PatchAttribute(paramPseudoIndex, genericParameterAttributes); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + this.ModuleBuilder.SetCustomAttribute((GenericParamTable.Index << 24) | paramPseudoIndex, customBuilder); + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + internal override int GetModuleBuilderToken() + { + if (typeToken == 0) + { + ByteBuffer spec = new ByteBuffer(5); + Signature.WriteTypeSpec(this.ModuleBuilder, spec, this); + typeToken = 0x1B000000 | this.ModuleBuilder.TypeSpec.AddRecord(this.ModuleBuilder.Blobs.Add(spec)); + } + return typeToken; + } + + internal override Type BindTypeParameters(IGenericBinder binder) + { + if (type != null) + { + return binder.BindTypeParameter(this); + } + else + { + return binder.BindMethodParameter(this); + } + } + } + + public sealed class TypeBuilder : Type, ITypeOwner + { + public const int UnspecifiedTypeSize = 0; + private readonly ITypeOwner owner; + private readonly int token; + private int extends; + private Type baseType; + private readonly int typeName; + private readonly int typeNameSpace; + private readonly string nameOrFullName; + private readonly List methods = new List(); + private readonly List fields = new List(); + private List properties; + private List events; + private TypeAttributes attribs; + private TypeFlags typeFlags; + private GenericTypeParameterBuilder[] gtpb; + private List declarativeSecurity; + private List interfaces; + + [Flags] + private enum TypeFlags + { + IsGenericTypeDefinition = 1, + HasNestedTypes = 2, + Baked = 4, + } + + internal TypeBuilder(ITypeOwner owner, string name, Type baseType, TypeAttributes attribs) + { + this.owner = owner; + this.token = this.ModuleBuilder.TypeDef.AllocToken(); + this.nameOrFullName = TypeNameParser.Escape(name); + SetParent(baseType); + this.attribs = attribs; + if (!this.IsNested) + { + int lastdot = name.LastIndexOf('.'); + if (lastdot > 0) + { + this.typeNameSpace = this.ModuleBuilder.Strings.Add(name.Substring(0, lastdot)); + name = name.Substring(lastdot + 1); + } + } + this.typeName = this.ModuleBuilder.Strings.Add(name); + } + + public ConstructorBuilder DefineDefaultConstructor(MethodAttributes attributes) + { + ConstructorBuilder cb = DefineConstructor(attributes, CallingConventions.Standard, Type.EmptyTypes); + ILGenerator ilgen = cb.GetILGenerator(); + ilgen.Emit(OpCodes.Ldarg_0); + ilgen.Emit(OpCodes.Call, baseType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)); + ilgen.Emit(OpCodes.Ret); + return cb; + } + + public ConstructorBuilder DefineConstructor(MethodAttributes attribs, CallingConventions callConv, Type[] parameterTypes) + { + return DefineConstructor(attribs, callConv, parameterTypes, null, null); + } + + public ConstructorBuilder DefineConstructor(MethodAttributes attribs, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) + { + attribs |= MethodAttributes.RTSpecialName | MethodAttributes.SpecialName; + string name = (attribs & MethodAttributes.Static) == 0 ? ConstructorInfo.ConstructorName : ConstructorInfo.TypeConstructorName; + MethodBuilder mb = DefineMethod(name, attribs, callingConvention, null, null, null, parameterTypes, requiredCustomModifiers, optionalCustomModifiers); + return new ConstructorBuilder(mb); + } + + public ConstructorBuilder DefineTypeInitializer() + { + MethodBuilder mb = DefineMethod(ConstructorInfo.TypeConstructorName, MethodAttributes.Private | MethodAttributes.Static | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName, null, Type.EmptyTypes); + return new ConstructorBuilder(mb); + } + + private MethodBuilder CreateMethodBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention) + { + this.ModuleBuilder.MethodDef.AddVirtualRecord(); + MethodBuilder mb = new MethodBuilder(this, name, attributes, callingConvention); + methods.Add(mb); + return mb; + } + + public MethodBuilder DefineMethod(string name, MethodAttributes attribs) + { + return DefineMethod(name, attribs, CallingConventions.Standard); + } + + public MethodBuilder DefineMethod(string name, MethodAttributes attribs, CallingConventions callingConvention) + { + return CreateMethodBuilder(name, attribs, callingConvention); + } + + public MethodBuilder DefineMethod(string name, MethodAttributes attribs, Type returnType, Type[] parameterTypes) + { + return DefineMethod(name, attribs, CallingConventions.Standard, returnType, null, null, parameterTypes, null, null); + } + + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + { + return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); + } + + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + MethodBuilder mb = CreateMethodBuilder(name, attributes, callingConvention); + mb.SetSignature(returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + return mb; + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) + { + return DefinePInvokeMethod(name, dllName, null, attributes, callingConvention, returnType, null, null, parameterTypes, null, null, nativeCallConv, nativeCharSet); + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) + { + return DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, null, null, parameterTypes, null, null, nativeCallConv, nativeCharSet); + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + MethodBuilder mb = DefineMethod(name, attributes | MethodAttributes.PinvokeImpl, callingConvention, + returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + mb.SetDllImportPseudoCustomAttribute(dllName, entryName, nativeCallConv, nativeCharSet, null, null, null, null, null); + return mb; + } + + public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration) + { + MethodImplTable.Record rec = new MethodImplTable.Record(); + rec.Class = token; + rec.MethodBody = this.ModuleBuilder.GetMethodToken(methodInfoBody).Token; + rec.MethodDeclaration = this.ModuleBuilder.GetMethodToken(methodInfoDeclaration).Token; + this.ModuleBuilder.MethodImpl.AddRecord(rec); + } + + public FieldBuilder DefineField(string name, Type fieldType, FieldAttributes attribs) + { + return DefineField(name, fieldType, null, null, attribs); + } + + public FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) + { + FieldBuilder fb = new FieldBuilder(this, fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes); + fields.Add(fb); + return fb; + } + + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) + { + return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null); + } + + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + return DefinePropertyImpl(name, attributes, CallingConventions.Standard, true, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + } + + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + return DefinePropertyImpl(name, attributes, callingConvention, false, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + } + + private PropertyBuilder DefinePropertyImpl(string name, PropertyAttributes attributes, CallingConventions callingConvention, bool patchCallingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + if (properties == null) + { + properties = new List(); + } + PropertySignature sig = PropertySignature.Create(callingConvention, returnType, returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers, + parameterTypes, parameterTypeOptionalCustomModifiers, parameterTypeRequiredCustomModifiers); + PropertyBuilder pb = new PropertyBuilder(this, name, attributes, sig, patchCallingConvention); + properties.Add(pb); + return pb; + } + + public EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype) + { + if (events == null) + { + events = new List(); + } + EventBuilder eb = new EventBuilder(this, name, attributes, eventtype); + events.Add(eb); + return eb; + } + + public TypeBuilder DefineNestedType(string name) + { + return DefineNestedType(name, TypeAttributes.Class | TypeAttributes.NestedPrivate); + } + + public TypeBuilder DefineNestedType(string name, TypeAttributes attribs) + { + return DefineNestedType(name, attribs, null); + } + + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, Type[] interfaces) + { + TypeBuilder tb = DefineNestedType(name, attr, parent); + foreach (Type iface in interfaces) + { + tb.AddInterfaceImplementation(iface); + } + return tb; + } + + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent) + { + this.typeFlags |= TypeFlags.HasNestedTypes; + return this.ModuleBuilder.DefineNestedTypeHelper(this, name, attr, parent, PackingSize.Unspecified, 0); + } + + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, int typeSize) + { + this.typeFlags |= TypeFlags.HasNestedTypes; + return this.ModuleBuilder.DefineNestedTypeHelper(this, name, attr, parent, PackingSize.Unspecified, typeSize); + } + + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, PackingSize packSize) + { + this.typeFlags |= TypeFlags.HasNestedTypes; + return this.ModuleBuilder.DefineNestedTypeHelper(this, name, attr, parent, packSize, 0); + } + + public void SetParent(Type parent) + { + baseType = parent; + } + + public void AddInterfaceImplementation(Type interfaceType) + { + if (interfaces == null) + { + interfaces = new List(); + } + interfaces.Add(interfaceType); + } + + public int Size + { + get + { + for (int i = 0; i < this.ModuleBuilder.ClassLayout.records.Length; i++) + { + if (this.ModuleBuilder.ClassLayout.records[i].Parent == token) + { + return this.ModuleBuilder.ClassLayout.records[i].ClassSize; + } + } + return 0; + } + } + + public PackingSize PackingSize + { + get + { + for (int i = 0; i < this.ModuleBuilder.ClassLayout.records.Length; i++) + { + if (this.ModuleBuilder.ClassLayout.records[i].Parent == token) + { + return (PackingSize)this.ModuleBuilder.ClassLayout.records[i].PackingSize; + } + } + return PackingSize.Unspecified; + } + } + + private void SetStructLayoutPseudoCustomAttribute(CustomAttributeBuilder customBuilder) + { + object val = customBuilder.GetConstructorArgument(0); + LayoutKind layout; + if (val is short) + { + layout = (LayoutKind)(short)val; + } + else + { + layout = (LayoutKind)val; + } + int? pack = (int?)customBuilder.GetFieldValue("Pack"); + int? size = (int?)customBuilder.GetFieldValue("Size"); + if (pack.HasValue || size.HasValue) + { + ClassLayoutTable.Record rec = new ClassLayoutTable.Record(); + rec.PackingSize = (short)(pack ?? 0); + rec.ClassSize = size ?? 0; + rec.Parent = token; + this.ModuleBuilder.ClassLayout.AddRecord(rec); + } + attribs &= ~TypeAttributes.LayoutMask; + switch (layout) + { + case LayoutKind.Auto: + attribs |= TypeAttributes.AutoLayout; + break; + case LayoutKind.Explicit: + attribs |= TypeAttributes.ExplicitLayout; + break; + case LayoutKind.Sequential: + attribs |= TypeAttributes.SequentialLayout; + break; + } + CharSet? charSet = customBuilder.GetFieldValue("CharSet"); + attribs &= ~TypeAttributes.StringFormatMask; + switch (charSet ?? CharSet.None) + { + case CharSet.None: + case CharSet.Ansi: + attribs |= TypeAttributes.AnsiClass; + break; + case CharSet.Auto: + attribs |= TypeAttributes.AutoClass; + break; + case CharSet.Unicode: + attribs |= TypeAttributes.UnicodeClass; + break; + } + } + + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) + { + SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute)); + } + + public void SetCustomAttribute(CustomAttributeBuilder customBuilder) + { + Universe u = this.ModuleBuilder.universe; + Type type = customBuilder.Constructor.DeclaringType; + if (type == u.System_Runtime_InteropServices_StructLayoutAttribute) + { + SetStructLayoutPseudoCustomAttribute(customBuilder.DecodeBlob(this.Assembly)); + } + else if (type == u.System_SerializableAttribute) + { + attribs |= TypeAttributes.Serializable; + } + else if (type == u.System_Runtime_InteropServices_ComImportAttribute) + { + attribs |= TypeAttributes.Import; + } + else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute) + { + attribs |= TypeAttributes.SpecialName; + } + else + { + if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute) + { + attribs |= TypeAttributes.HasSecurity; + } + this.ModuleBuilder.SetCustomAttribute(token, customBuilder); + } + } + + public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder) + { + attribs |= TypeAttributes.HasSecurity; + if (declarativeSecurity == null) + { + declarativeSecurity = new List(); + } + declarativeSecurity.Add(customBuilder); + } + + public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet) + { + this.ModuleBuilder.AddDeclarativeSecurity(token, securityAction, permissionSet); + this.attribs |= TypeAttributes.HasSecurity; + } + + public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) + { + typeFlags |= TypeFlags.IsGenericTypeDefinition; + gtpb = new GenericTypeParameterBuilder[names.Length]; + for (int i = 0; i < names.Length; i++) + { + gtpb[i] = new GenericTypeParameterBuilder(names[i], this, null, i); + } + return (GenericTypeParameterBuilder[])gtpb.Clone(); + } + + public override Type[] GetGenericArguments() + { + return Util.Copy(gtpb); + } + + public override Type[][] __GetGenericArgumentsOptionalCustomModifiers() + { + return gtpb == null ? Empty.Array : Util.Copy(new Type[gtpb.Length][]); + } + + public override Type[][] __GetGenericArgumentsRequiredCustomModifiers() + { + return gtpb == null ? Empty.Array : Util.Copy(new Type[gtpb.Length][]); + } + + internal override Type GetGenericTypeArgument(int index) + { + return gtpb[index]; + } + + public override bool ContainsGenericParameters + { + get { return gtpb != null; } + } + + public override Type GetGenericTypeDefinition() + { + return this; + } + + public Type CreateType() + { + if ((typeFlags & TypeFlags.Baked) != 0) + { + // .NET allows multiple invocations (subsequent invocations return the same baked type) + throw new NotImplementedException(); + } + typeFlags |= TypeFlags.Baked; + foreach (MethodBuilder mb in methods) + { + mb.Bake(); + } + if (declarativeSecurity != null) + { + this.ModuleBuilder.AddDeclarativeSecurity(token, declarativeSecurity); + } + if (baseType != null) + { + extends = this.ModuleBuilder.GetTypeToken(baseType).Token; + } + if (interfaces != null) + { + foreach (Type interfaceType in interfaces) + { + InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); + rec.Class = token; + rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; + this.ModuleBuilder.InterfaceImpl.AddRecord(rec); + } + } + return new BakedType(this); + } + + internal void PopulatePropertyAndEventTables() + { + if (properties != null) + { + PropertyMapTable.Record rec = new PropertyMapTable.Record(); + rec.Parent = token; + rec.PropertyList = this.ModuleBuilder.Property.RowCount + 1; + this.ModuleBuilder.PropertyMap.AddRecord(rec); + foreach (PropertyBuilder pb in properties) + { + pb.Bake(); + } + } + if (events != null) + { + EventMapTable.Record rec = new EventMapTable.Record(); + rec.Parent = token; + rec.EventList = this.ModuleBuilder.Event.RowCount + 1; + this.ModuleBuilder.EventMap.AddRecord(rec); + foreach (EventBuilder eb in events) + { + eb.Bake(); + } + } + } + + public override Type BaseType + { + get { return baseType; } + } + + public override string FullName + { + get + { + if (this.IsNested) + { + return this.DeclaringType.FullName + "+" + nameOrFullName; + } + else + { + return nameOrFullName; + } + } + } + + public override string Name + { + get + { + if (this.IsNested) + { + return nameOrFullName; + } + else + { + return base.Name; + } + } + } + + public override string Namespace + { + get + { + // for some reason, TypeBuilder doesn't return null (and mcs depends on this) + return base.Namespace ?? ""; + } + } + + internal string GetBakedNamespace() + { + // if you refer to the TypeBuilder via its baked Type, Namespace will return null + // for the empty namespace (instead of "" like TypeBuilder.Namespace above does) + return base.Namespace; + } + + public override TypeAttributes Attributes + { + get { return attribs; } + } + + public void __SetAttributes(TypeAttributes attributes) + { + this.attribs = attributes; + } + + public override Type[] __GetDeclaredInterfaces() + { + return Util.ToArray(interfaces, Type.EmptyTypes); + } + + public override MethodBase[] __GetDeclaredMethods() + { + MethodBase[] methods = new MethodBase[this.methods.Count]; + for (int i = 0; i < methods.Length; i++) + { + MethodBuilder mb = this.methods[i]; + if (mb.IsConstructor) + { + methods[i] = new ConstructorInfoImpl(mb); + } + else + { + methods[i] = mb; + } + } + return methods; + } + + public override StructLayoutAttribute StructLayoutAttribute + { + get + { + StructLayoutAttribute attr; + if ((attribs & TypeAttributes.ExplicitLayout) != 0) + { + attr = new StructLayoutAttribute(LayoutKind.Explicit); + attr.Pack = 8; + attr.Size = 0; + this.ModuleBuilder.ClassLayout.GetLayout(token, ref attr.Pack, ref attr.Size); + } + else + { + attr = new StructLayoutAttribute((attribs & TypeAttributes.SequentialLayout) != 0 ? LayoutKind.Sequential : LayoutKind.Auto); + attr.Pack = 8; + attr.Size = 0; + } + switch (attribs & TypeAttributes.StringFormatMask) + { + case TypeAttributes.AutoClass: + attr.CharSet = CharSet.Auto; + break; + case TypeAttributes.UnicodeClass: + attr.CharSet = CharSet.Unicode; + break; + case TypeAttributes.AnsiClass: + attr.CharSet = CharSet.Ansi; + break; + } + return attr; + } + } + + public override Type DeclaringType + { + get { return owner as TypeBuilder; } + } + + public override bool IsGenericType + { + get { return IsGenericTypeDefinition; } + } + + public override bool IsGenericTypeDefinition + { + get { return (typeFlags & TypeFlags.IsGenericTypeDefinition) != 0; } + } + + public override int MetadataToken + { + get { return token; } + } + + public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) + { + return DefineInitializedData(name, new byte[size], attributes); + } + + public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) + { + Type fieldType = this.ModuleBuilder.GetType("$ArrayType$" + data.Length); + if (fieldType == null) + { + TypeBuilder tb = this.ModuleBuilder.DefineType("$ArrayType$" + data.Length, TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.ExplicitLayout, this.Module.universe.System_ValueType, PackingSize.Size1, data.Length); + tb.CreateType(); + fieldType = tb; + } + FieldBuilder fb = DefineField(name, fieldType, attributes | FieldAttributes.Static); + fb.__SetDataAndRVA(data); + return fb; + } + + public static MethodInfo GetMethod(Type type, MethodInfo method) + { + return new GenericMethodInstance(type, method, null); + } + + public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor) + { + return new ConstructorInfoImpl(GetMethod(type, constructor.GetMethodInfo())); + } + + public static FieldInfo GetField(Type type, FieldInfo field) + { + return new GenericFieldInstance(type, field); + } + + public override Module Module + { + get { return owner.ModuleBuilder; } + } + + public TypeToken TypeToken + { + get { return new TypeToken(token); } + } + + internal void WriteTypeDefRecord(MetadataWriter mw, ref int fieldList, ref int methodList) + { + mw.Write((int)attribs); + mw.WriteStringIndex(typeName); + mw.WriteStringIndex(typeNameSpace); + mw.WriteTypeDefOrRef(extends); + mw.WriteField(fieldList); + mw.WriteMethodDef(methodList); + methodList += methods.Count; + fieldList += fields.Count; + } + + internal void WriteMethodDefRecords(int baseRVA, MetadataWriter mw, ref int paramList) + { + foreach (MethodBuilder mb in methods) + { + mb.WriteMethodDefRecord(baseRVA, mw, ref paramList); + } + } + + internal void ResolveMethodAndFieldTokens(ref int methodToken, ref int fieldToken, ref int parameterToken) + { + foreach (MethodBuilder method in methods) + { + method.FixupToken(methodToken++, ref parameterToken); + } + foreach (FieldBuilder field in fields) + { + field.FixupToken(fieldToken++); + } + } + + internal void WriteParamRecords(MetadataWriter mw) + { + foreach (MethodBuilder mb in methods) + { + mb.WriteParamRecords(mw); + } + } + + internal void WriteFieldRecords(MetadataWriter mw) + { + foreach (FieldBuilder fb in fields) + { + fb.WriteFieldRecords(mw); + } + } + + internal ModuleBuilder ModuleBuilder + { + get { return owner.ModuleBuilder; } + } + + ModuleBuilder ITypeOwner.ModuleBuilder + { + get { return owner.ModuleBuilder; } + } + + internal override int GetModuleBuilderToken() + { + return token; + } + + internal bool HasNestedTypes + { + get { return (typeFlags & TypeFlags.HasNestedTypes) != 0; } + } + + // helper for ModuleBuilder.ResolveMethod() + internal MethodBase LookupMethod(int token) + { + foreach (MethodBuilder method in methods) + { + if (method.MetadataToken == token) + { + return method; + } + } + return null; + } + + public bool IsCreated() + { + return (typeFlags & TypeFlags.Baked) != 0; + } + + internal override void CheckBaked() + { + if ((typeFlags & TypeFlags.Baked) == 0) + { + throw new NotSupportedException(); + } + } + + public override Type[] __GetDeclaredTypes() + { + if (this.HasNestedTypes) + { + List types = new List(); + List classes = this.ModuleBuilder.NestedClass.GetNestedClasses(token); + foreach (int nestedClass in classes) + { + types.Add(this.ModuleBuilder.ResolveType(nestedClass)); + } + return types.ToArray(); + } + else + { + return Type.EmptyTypes; + } + } + + public override FieldInfo[] __GetDeclaredFields() + { + return Util.ToArray(fields, Empty.Array); + } + + public override EventInfo[] __GetDeclaredEvents() + { + return Util.ToArray(events, Empty.Array); + } + + public override PropertyInfo[] __GetDeclaredProperties() + { + return Util.ToArray(properties, Empty.Array); + } + + internal override bool IsModulePseudoType + { + get { return token == 0x02000001; } + } + } + + sealed class BakedType : Type + { + private readonly TypeBuilder typeBuilder; + + internal BakedType(TypeBuilder typeBuilder) + { + this.typeBuilder = typeBuilder; + } + + public override string AssemblyQualifiedName + { + get { return typeBuilder.AssemblyQualifiedName; } + } + + public override Type BaseType + { + get { return typeBuilder.BaseType; } + } + + public override string Name + { + get { return typeBuilder.Name; } + } + + public override string Namespace + { + get { return typeBuilder.GetBakedNamespace(); } + } + + public override string FullName + { + get { return typeBuilder.FullName; } + } + + public override TypeAttributes Attributes + { + get { return typeBuilder.Attributes; } + } + + public override Type[] __GetDeclaredInterfaces() + { + return typeBuilder.__GetDeclaredInterfaces(); + } + + public override MethodBase[] __GetDeclaredMethods() + { + return typeBuilder.__GetDeclaredMethods(); + } + + public override __MethodImplMap __GetMethodImplMap() + { + return typeBuilder.__GetMethodImplMap(); + } + + public override FieldInfo[] __GetDeclaredFields() + { + return typeBuilder.__GetDeclaredFields(); + } + + public override EventInfo[] __GetDeclaredEvents() + { + return typeBuilder.__GetDeclaredEvents(); + } + + public override PropertyInfo[] __GetDeclaredProperties() + { + return typeBuilder.__GetDeclaredProperties(); + } + + public override Type[] __GetDeclaredTypes() + { + return typeBuilder.__GetDeclaredTypes(); + } + + public override Type DeclaringType + { + get { return typeBuilder.DeclaringType; } + } + + public override StructLayoutAttribute StructLayoutAttribute + { + get { return typeBuilder.StructLayoutAttribute; } + } + + public override Type UnderlyingSystemType + { + // Type.Equals/GetHashCode relies on this + get { return typeBuilder; } + } + + public override Type[] GetGenericArguments() + { + return typeBuilder.GetGenericArguments(); + } + + internal override Type GetGenericTypeArgument(int index) + { + return typeBuilder.GetGenericTypeArgument(index); + } + + public override Type[][] __GetGenericArgumentsOptionalCustomModifiers() + { + return typeBuilder.__GetGenericArgumentsOptionalCustomModifiers(); + } + + public override Type[][] __GetGenericArgumentsRequiredCustomModifiers() + { + return typeBuilder.__GetGenericArgumentsRequiredCustomModifiers(); + } + + public override bool IsGenericType + { + get { return typeBuilder.IsGenericType; } + } + + public override bool IsGenericTypeDefinition + { + get { return typeBuilder.IsGenericTypeDefinition; } + } + + public override bool ContainsGenericParameters + { + get { return typeBuilder.ContainsGenericParameters; } + } + + public override int MetadataToken + { + get { return typeBuilder.MetadataToken; } + } + + public override Module Module + { + get { return typeBuilder.Module; } + } + + internal override int GetModuleBuilderToken() + { + return typeBuilder.GetModuleBuilderToken(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Enums.cs b/mcs/class/IKVM.Reflection/Enums.cs new file mode 100644 index 000000000000..7dd5b3487bff --- /dev/null +++ b/mcs/class/IKVM.Reflection/Enums.cs @@ -0,0 +1,274 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + [Flags] + public enum AssemblyNameFlags + { + None = 0, + PublicKey = 1, + Retargetable = 256, + EnableJITcompileOptimizer = 16384, + EnableJITcompileTracking = 32768, + } + + [Flags] + public enum BindingFlags + { + Default = 0, + DeclaredOnly = 2, + Instance = 4, + Static = 8, + Public = 16, + NonPublic = 32, + FlattenHierarchy = 64, + } + + [Flags] + public enum CallingConventions + { + Standard = 1, + VarArgs = 2, + Any = 3, + HasThis = 32, + ExplicitThis = 64, + } + + [Flags] + public enum EventAttributes + { + None = 0, + SpecialName = 512, + RTSpecialName = 1024, + ReservedMask = 1024, + } + + [Flags] + public enum FieldAttributes + { + PrivateScope = 0, + Private = 1, + FamANDAssem = 2, + Assembly = 3, + Family = 4, + FamORAssem = 5, + Public = 6, + FieldAccessMask = 7, + Static = 16, + InitOnly = 32, + Literal = 64, + NotSerialized = 128, + HasFieldRVA = 256, + SpecialName = 512, + RTSpecialName = 1024, + HasFieldMarshal = 4096, + PinvokeImpl = 8192, + HasDefault = 32768, + ReservedMask = 38144, + } + + [Flags] + public enum GenericParameterAttributes + { + None = 0, + Covariant = 1, + Contravariant = 2, + VarianceMask = 3, + ReferenceTypeConstraint = 4, + NotNullableValueTypeConstraint = 8, + DefaultConstructorConstraint = 16, + SpecialConstraintMask = 28, + } + + public enum ImageFileMachine + { + I386 = 332, + IA64 = 512, + AMD64 = 34404, + } + + [FlagsAttribute] + public enum MemberTypes + { + Constructor = 0x01, + Event = 0x02, + Field = 0x04, + Method = 0x08, + Property = 0x10, + TypeInfo = 0x20, + Custom = 0x40, + NestedType = 0x80, + All = Constructor | Event | Field | Method | Property | TypeInfo | NestedType + } + + [Flags] + public enum MethodAttributes + { + MemberAccessMask = 0x0007, + PrivateScope = 0x0000, + Private = 0x0001, + FamANDAssem = 0x0002, + Assembly = 0x0003, + Family = 0x0004, + FamORAssem = 0x0005, + Public = 0x0006, + Static = 0x0010, + Final = 0x0020, + Virtual = 0x0040, + HideBySig = 0x0080, + VtableLayoutMask = 0x0100, + ReuseSlot = 0x0000, + NewSlot = 0x0100, + CheckAccessOnOverride = 0x0200, + Abstract = 0x0400, + SpecialName = 0x0800, + + PinvokeImpl = 0x2000, + UnmanagedExport = 0x0008, + + RTSpecialName = 0x1000, + HasSecurity = 0x4000, + RequireSecObject = 0x8000, + + ReservedMask = 0xd000, + } + + [Flags] + public enum MethodImplAttributes + { + CodeTypeMask = 0x0003, + IL = 0x0000, + Native = 0x0001, + OPTIL = 0x0002, + Runtime = 0x0003, + ManagedMask = 0x0004, + Unmanaged = 0x0004, + Managed = 0x0000, + + ForwardRef = 0x0010, + PreserveSig = 0x0080, + InternalCall = 0x1000, + Synchronized = 0x0020, + NoInlining = 0x0008, + NoOptimization = 0x0040, + + MaxMethodImplVal = 0xffff, + } + + [Flags] + public enum ParameterAttributes + { + None = 0, + In = 1, + Out = 2, + Lcid = 4, + Retval = 8, + Optional = 16, + HasDefault = 4096, + HasFieldMarshal = 8192, + Reserved3 = 16384, + Reserved4 = 32768, + ReservedMask = 61440, + } + + [Flags] + public enum PortableExecutableKinds + { + NotAPortableExecutableImage = 0, + ILOnly = 1, + Required32Bit = 2, + PE32Plus = 4, + Unmanaged32Bit = 8, + } + + public enum ProcessorArchitecture + { + None = 0, + MSIL = 1, + X86 = 2, + IA64 = 3, + Amd64 = 4, + } + + [Flags] + public enum PropertyAttributes + { + None = 0, + SpecialName = 512, + RTSpecialName = 1024, + HasDefault = 4096, + } + + [Flags] + public enum ResourceAttributes + { + Public = 1, + Private = 2, + } + + public enum ResourceLocation + { + Embedded = 1, + ContainedInAnotherAssembly = 2, + ContainedInManifestFile = 4, + } + + [Flags] + public enum TypeAttributes + { + AnsiClass = 0, + Class = 0, + AutoLayout = 0, + NotPublic = 0, + Public = 1, + NestedPublic = 2, + NestedPrivate = 3, + NestedFamily = 4, + NestedAssembly = 5, + NestedFamANDAssem = 6, + VisibilityMask = 7, + NestedFamORAssem = 7, + SequentialLayout = 8, + ExplicitLayout = 16, + LayoutMask = 24, + ClassSemanticsMask = 32, + Interface = 32, + Abstract = 128, + Sealed = 256, + SpecialName = 1024, + RTSpecialName = 2048, + Import = 4096, + Serializable = 8192, + UnicodeClass = 65536, + AutoClass = 131072, + CustomFormatClass = 196608, + StringFormatMask = 196608, + HasSecurity = 262144, + ReservedMask = 264192, + BeforeFieldInit = 1048576, + CustomFormatMask = 12582912, + } +} diff --git a/mcs/class/IKVM.Reflection/EventInfo.cs b/mcs/class/IKVM.Reflection/EventInfo.cs new file mode 100644 index 000000000000..816acbc7b0d7 --- /dev/null +++ b/mcs/class/IKVM.Reflection/EventInfo.cs @@ -0,0 +1,73 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ + +namespace IKVM.Reflection +{ + public abstract class EventInfo : MemberInfo + { + public sealed override MemberTypes MemberType + { + get { return MemberTypes.Event; } + } + + public abstract EventAttributes Attributes { get; } + public abstract MethodInfo GetAddMethod(bool nonPublic); + public abstract MethodInfo GetRaiseMethod(bool nonPublic); + public abstract MethodInfo GetRemoveMethod(bool nonPublic); + public abstract MethodInfo[] GetOtherMethods(bool nonPublic); + public abstract Type EventHandlerType { get; } + internal abstract bool IsPublic { get; } + internal abstract bool IsStatic { get; } + + public bool IsSpecialName + { + get { return (Attributes & EventAttributes.SpecialName) != 0; } + } + + public MethodInfo GetAddMethod() + { + return GetAddMethod(false); + } + + public MethodInfo GetRaiseMethod() + { + return GetRaiseMethod(false); + } + + public MethodInfo GetRemoveMethod() + { + return GetRemoveMethod(false); + } + + public MethodInfo[] GetOtherMethods() + { + return GetOtherMethods(false); + } + + internal virtual EventInfo BindTypeParameters(Type type) + { + return new GenericEventInfo(this.DeclaringType.BindTypeParameters(type), this); + } + } +} diff --git a/mcs/class/IKVM.Reflection/ExceptionHandlingClause.cs b/mcs/class/IKVM.Reflection/ExceptionHandlingClause.cs new file mode 100644 index 000000000000..dddc53203049 --- /dev/null +++ b/mcs/class/IKVM.Reflection/ExceptionHandlingClause.cs @@ -0,0 +1,93 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + public enum ExceptionHandlingClauseOptions + { + Clause = 0x0000, + Filter = 0x0001, + Finally = 0x0002, + Fault = 0x0004, + } + + public sealed class ExceptionHandlingClause + { + private readonly int flags; + private readonly int tryOffset; + private readonly int tryLength; + private readonly int handlerOffset; + private readonly int handlerLength; + private readonly Type catchType; + private readonly int filterOffset; + + internal ExceptionHandlingClause(ModuleReader module, int flags, int tryOffset, int tryLength, int handlerOffset, int handlerLength, int classTokenOrfilterOffset, IGenericContext context) + { + this.flags = flags; + this.tryOffset = tryOffset; + this.tryLength = tryLength; + this.handlerOffset = handlerOffset; + this.handlerLength = handlerLength; + this.catchType = flags == (int)ExceptionHandlingClauseOptions.Clause && classTokenOrfilterOffset != 0 ? module.ResolveType(classTokenOrfilterOffset, context) : null; + this.filterOffset = flags == (int)ExceptionHandlingClauseOptions.Filter ? classTokenOrfilterOffset : 0; + } + + public Type CatchType + { + get { return catchType; } + } + + public int FilterOffset + { + get { return filterOffset; } + } + + public ExceptionHandlingClauseOptions Flags + { + get { return (ExceptionHandlingClauseOptions)flags; } + } + + public int HandlerLength + { + get { return handlerLength; } + } + + public int HandlerOffset + { + get { return handlerOffset; } + } + + public int TryLength + { + get { return tryLength; } + } + + public int TryOffset + { + get { return tryOffset; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/FieldInfo.cs b/mcs/class/IKVM.Reflection/FieldInfo.cs new file mode 100644 index 000000000000..b64ea2c25c10 --- /dev/null +++ b/mcs/class/IKVM.Reflection/FieldInfo.cs @@ -0,0 +1,122 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + public abstract class FieldInfo : MemberInfo + { + public sealed override MemberTypes MemberType + { + get { return MemberTypes.Field; } + } + + public abstract FieldAttributes Attributes { get; } + public abstract void __GetDataFromRVA(byte[] data, int offset, int length); + public abstract Object GetRawConstantValue(); + internal abstract FieldSignature FieldSignature { get; } + + public Type FieldType + { + get { return this.FieldSignature.FieldType; } + } + + public Type[] GetOptionalCustomModifiers() + { + return this.FieldSignature.GetOptionalCustomModifiers(); + } + + public Type[] GetRequiredCustomModifiers() + { + return this.FieldSignature.GetRequiredCustomModifiers(); + } + + public bool IsStatic + { + get { return (Attributes & FieldAttributes.Static) != 0; } + } + + public bool IsLiteral + { + get { return (Attributes & FieldAttributes.Literal) != 0; } + } + + public bool IsInitOnly + { + get { return (Attributes & FieldAttributes.InitOnly) != 0; } + } + + public bool IsNotSerialized + { + get { return (Attributes & FieldAttributes.NotSerialized) != 0; } + } + + public bool IsSpecialName + { + get { return (Attributes & FieldAttributes.SpecialName) != 0; } + } + + public bool IsPublic + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; } + } + + public bool IsPrivate + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; } + } + + public bool IsFamily + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; } + } + + public bool IsFamilyOrAssembly + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem; } + } + + public bool IsAssembly + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; } + } + + public bool IsFamilyAndAssembly + { + get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem; } + } + + public bool IsPinvokeImpl + { + get { return (Attributes & FieldAttributes.PinvokeImpl) != 0; } + } + + internal abstract int ImportTo(Emit.ModuleBuilder module); + + internal virtual FieldInfo BindTypeParameters(Type type) + { + return new GenericFieldInstance(this.DeclaringType.BindTypeParameters(type), this); + } + } +} diff --git a/mcs/class/IKVM.Reflection/FieldSignature.cs b/mcs/class/IKVM.Reflection/FieldSignature.cs new file mode 100644 index 000000000000..0a4ff94a29e0 --- /dev/null +++ b/mcs/class/IKVM.Reflection/FieldSignature.cs @@ -0,0 +1,111 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + sealed class FieldSignature : Signature + { + private readonly Type fieldType; + private readonly Type[] optionalCustomModifiers; + private readonly Type[] requiredCustomModifiers; + + internal static FieldSignature Create(Type fieldType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers) + { + return new FieldSignature(fieldType, Util.Copy(optionalCustomModifiers), Util.Copy(requiredCustomModifiers)); + } + + private FieldSignature(Type fieldType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers) + { + this.fieldType = fieldType; + this.optionalCustomModifiers = optionalCustomModifiers; + this.requiredCustomModifiers = requiredCustomModifiers; + } + + public override bool Equals(object obj) + { + FieldSignature other = obj as FieldSignature; + return other != null + && other.fieldType.Equals(fieldType) + && Util.ArrayEquals(other.optionalCustomModifiers, optionalCustomModifiers) + && Util.ArrayEquals(other.requiredCustomModifiers, requiredCustomModifiers); + } + + public override int GetHashCode() + { + return fieldType.GetHashCode() ^ Util.GetHashCode(optionalCustomModifiers) ^ Util.GetHashCode(requiredCustomModifiers); + } + + internal Type FieldType + { + get { return fieldType; } + } + + internal Type[] GetOptionalCustomModifiers() + { + return Util.Copy(optionalCustomModifiers); + } + + internal Type[] GetRequiredCustomModifiers() + { + return Util.Copy(requiredCustomModifiers); + } + + internal FieldSignature ExpandTypeParameters(Type declaringType) + { + return new FieldSignature( + fieldType.BindTypeParameters(declaringType), + BindTypeParameters(declaringType, optionalCustomModifiers), + BindTypeParameters(declaringType, requiredCustomModifiers)); + } + + internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context) + { + if (br.ReadByte() != FIELD) + { + throw new BadImageFormatException(); + } + Type fieldType; + Type[] optionalCustomModifiers; + Type[] requiredCustomModifiers; + ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers); + fieldType = ReadType(module, br, context); + return new FieldSignature(fieldType, optionalCustomModifiers, requiredCustomModifiers); + } + + internal override void WriteSig(ModuleBuilder module, ByteBuffer bb) + { + bb.Write(FIELD); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, optionalCustomModifiers); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, requiredCustomModifiers); + WriteType(module, bb, fieldType); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Fusion.cs b/mcs/class/IKVM.Reflection/Fusion.cs new file mode 100644 index 000000000000..4e81cd20074a --- /dev/null +++ b/mcs/class/IKVM.Reflection/Fusion.cs @@ -0,0 +1,318 @@ +/* + Copyright (C) 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ + +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace IKVM.Reflection +{ + struct ParsedAssemblyName + { + internal string Name; + internal Version Version; + internal string Culture; + internal string PublicKeyToken; + } + + static class Fusion + { + private static readonly bool UseNativeFusion = Environment.OSVersion.Platform == PlatformID.Win32NT && System.Type.GetType("Mono.Runtime") == null && Environment.GetEnvironmentVariable("IKVM_DISABLE_FUSION") == null; + + internal static bool CompareAssemblyIdentity(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result) + { + if (UseNativeFusion) + { + bool equivalent; + Marshal.ThrowExceptionForHR(CompareAssemblyIdentity(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out equivalent, out result)); + return equivalent; + } + else + { + return CompareAssemblyIdentityPure(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result); + } + } + + [DllImport("fusion", CharSet = CharSet.Unicode)] + private static extern int CompareAssemblyIdentity(string pwzAssemblyIdentity1, bool fUnified1, string pwzAssemblyIdentity2, bool fUnified2, out bool pfEquivalent, out AssemblyComparisonResult pResult); + + private static bool CompareAssemblyIdentityPure(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result) + { + ParsedAssemblyName name1; + ParsedAssemblyName name2; + + if (!ParseAssemblyName(assemblyIdentity1, out name1) + || !ParseAssemblyName(assemblyIdentity2, out name2)) + { + result = AssemblyComparisonResult.NonEquivalent; + throw new ArgumentException(); + } + + bool partial = IsPartial(name1); + + if ((partial && unified1) || IsPartial(name2)) + { + result = AssemblyComparisonResult.NonEquivalent; + throw new ArgumentException(); + } + if (!name1.Name.Equals(name2.Name, StringComparison.InvariantCultureIgnoreCase)) + { + result = AssemblyComparisonResult.NonEquivalent; + return false; + } + if (name1.Name.Equals("mscorlib", StringComparison.InvariantCultureIgnoreCase)) + { + result = AssemblyComparisonResult.EquivalentFullMatch; + return true; + } + if (partial && name1.Culture == null) + { + } + else if (!name1.Culture.Equals(name2.Culture, StringComparison.InvariantCultureIgnoreCase)) + { + result = AssemblyComparisonResult.NonEquivalent; + return false; + } + if (IsStrongNamed(name2)) + { + if (partial && name1.PublicKeyToken == null) + { + } + else if (name1.PublicKeyToken != name2.PublicKeyToken) + { + result = AssemblyComparisonResult.NonEquivalent; + return false; + } + if (partial && name1.Version == null) + { + result = AssemblyComparisonResult.EquivalentPartialMatch; + return true; + } + else if (name1.Version < name2.Version) + { + if (unified2) + { + result = partial ? AssemblyComparisonResult.EquivalentPartialUnified : AssemblyComparisonResult.EquivalentUnified; + return true; + } + else + { + result = partial ? AssemblyComparisonResult.NonEquivalentPartialVersion : AssemblyComparisonResult.NonEquivalentVersion; + return false; + } + } + else if (name1.Version > name2.Version) + { + if (unified1) + { + result = partial ? AssemblyComparisonResult.EquivalentPartialUnified : AssemblyComparisonResult.EquivalentUnified; + return true; + } + else + { + result = partial ? AssemblyComparisonResult.NonEquivalentPartialVersion : AssemblyComparisonResult.NonEquivalentVersion; + return false; + } + } + else + { + result = partial ? AssemblyComparisonResult.EquivalentPartialMatch : AssemblyComparisonResult.EquivalentFullMatch; + return true; + } + } + else + { + result = partial ? AssemblyComparisonResult.EquivalentPartialWeakNamed : AssemblyComparisonResult.EquivalentWeakNamed; + return true; + } + } + + // note that this is the fusion specific parser, it is not the same as System.Reflection.AssemblyName + private static bool ParseAssemblyName(string fullName, out ParsedAssemblyName parsedName) + { + parsedName = new ParsedAssemblyName(); + StringBuilder sb = new StringBuilder(); + int pos = 0; + while (pos < fullName.Length) + { + char ch = fullName[pos++]; + if (ch == '\\') + { + if (pos == fullName.Length) + { + return false; + } + ch = fullName[pos++]; + } + else if (ch == ',') + { + break; + } + sb.Append(ch); + } + parsedName.Name = sb.ToString().Trim(); + if (pos < fullName.Length) + { + string[] parts = fullName.Substring(pos).Split(','); + for (int i = 0; i < parts.Length; i++) + { + string[] kv = parts[i].Split('='); + if (kv.Length != 2) + { + return false; + } + switch (kv[0].Trim().ToLowerInvariant()) + { + case "version": + if (parsedName.Version != null) + { + return false; + } + if (!ParseVersion(kv[1].Trim(), out parsedName.Version)) + { + return false; + } + break; + case "culture": + if (parsedName.Culture != null) + { + return false; + } + if (!ParseCulture(kv[1].Trim(), out parsedName.Culture)) + { + return false; + } + break; + case "publickeytoken": + if (parsedName.PublicKeyToken != null) + { + return false; + } + if (!ParsePublicKeyToken(kv[1].Trim(), out parsedName.PublicKeyToken)) + { + return false; + } + break; + case "publickey": + if (parsedName.PublicKeyToken != null) + { + return false; + } + if (!ParsePublicKey(kv[1].Trim(), out parsedName.PublicKeyToken)) + { + return false; + } + break; + } + } + } + return true; + } + + private static bool ParseVersion(string str, out Version version) + { + string[] parts = str.Split('.'); + if (parts.Length == 4) + { + ushort major, minor, build, revision; + if (ushort.TryParse(parts[0], System.Globalization.NumberStyles.Integer, null, out major) + && ushort.TryParse(parts[1], System.Globalization.NumberStyles.Integer, null, out minor) + && ushort.TryParse(parts[2], System.Globalization.NumberStyles.Integer, null, out build) + && ushort.TryParse(parts[3], System.Globalization.NumberStyles.Integer, null, out revision)) + { + version = new Version(major, minor, build, revision); + return true; + } + } + version = null; + return false; + } + + private static bool ParseCulture(string str, out string culture) + { + if (str == null) + { + culture = null; + return false; + } + culture = str; + return true; + } + + private static bool ParsePublicKeyToken(string str, out string publicKeyToken) + { + if (str == null) + { + publicKeyToken = null; + return false; + } + publicKeyToken = str.ToLowerInvariant(); + return true; + } + + private static bool ParsePublicKey(string str, out string publicKeyToken) + { + if (str == null) + { + publicKeyToken = null; + return false; + } + // HACK use AssemblyName to convert PublicKey to PublicKeyToken + byte[] token = new AssemblyName("Foo, PublicKey=" + str).GetPublicKeyToken(); + StringBuilder sb = new StringBuilder(token.Length * 2); + for (int i = 0; i < token.Length; i++) + { + sb.AppendFormat("{0:x2}", token[i]); + } + publicKeyToken = sb.ToString(); + return true; + } + + private static bool IsPartial(ParsedAssemblyName name) + { + return name.Version == null || name.Culture == null || name.PublicKeyToken == null; + } + + private static bool IsStrongNamed(ParsedAssemblyName name) + { + return name.PublicKeyToken != null && name.PublicKeyToken != "null"; + } + + private static bool IsEqual(byte[] b1, byte[] b2) + { + if (b1.Length != b2.Length) + { + return false; + } + for (int i = 0; i < b1.Length; i++) + { + if (b1[i] != b2[i]) + { + return false; + } + } + return true; + } + } +} diff --git a/mcs/class/IKVM.Reflection/GenericWrappers.cs b/mcs/class/IKVM.Reflection/GenericWrappers.cs new file mode 100644 index 000000000000..8290f14096e0 --- /dev/null +++ b/mcs/class/IKVM.Reflection/GenericWrappers.cs @@ -0,0 +1,631 @@ +/* + Copyright (C) 2009, 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + // this represents both generic method instantiations and non-generic methods on generic type instantations + // (this means that it can be a generic method declaration as well as a generic method instance) + sealed class GenericMethodInstance : MethodInfo + { + private readonly Type declaringType; + private readonly MethodInfo method; + private readonly Type[] methodArgs; + private MethodSignature lazyMethodSignature; + + internal GenericMethodInstance(Type declaringType, MethodInfo method, Type[] methodArgs) + { + System.Diagnostics.Debug.Assert(!(method is GenericMethodInstance)); + this.declaringType = declaringType; + this.method = method; + this.methodArgs = methodArgs; + } + + public override bool Equals(object obj) + { + GenericMethodInstance other = obj as GenericMethodInstance; + return other != null + && other.method.Equals(method) + && other.declaringType.Equals(declaringType) + && Util.ArrayEquals(other.methodArgs, methodArgs); + } + + public override int GetHashCode() + { + return declaringType.GetHashCode() * 33 ^ method.GetHashCode() ^ Util.GetHashCode(methodArgs); + } + + public override Type ReturnType + { + get { return method.ReturnType.BindTypeParameters(this); } + } + + public override ParameterInfo ReturnParameter + { + get { return new GenericParameterInfoImpl(this, method.ReturnParameter); } + } + + public override ParameterInfo[] GetParameters() + { + ParameterInfo[] parameters = method.GetParameters(); + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = new GenericParameterInfoImpl(this, parameters[i]); + } + return parameters; + } + + internal override int ParameterCount + { + get { return method.ParameterCount; } + } + + public override CallingConventions CallingConvention + { + get { return method.CallingConvention; } + } + + public override MethodAttributes Attributes + { + get { return method.Attributes; } + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return method.GetMethodImplementationFlags(); + } + + public override string Name + { + get { return method.Name; } + } + + public override Type DeclaringType + { + get { return declaringType.IsModulePseudoType ? null : declaringType; } + } + + public override Module Module + { + get { return method.Module; } + } + + public override int MetadataToken + { + get { return method.MetadataToken; } + } + + public override MethodBody GetMethodBody() + { + IKVM.Reflection.Reader.MethodDefImpl md = method as IKVM.Reflection.Reader.MethodDefImpl; + if (md != null) + { + return md.GetMethodBody(this); + } + throw new NotSupportedException(); + } + + public override MethodInfo MakeGenericMethod(params Type[] typeArguments) + { + return new GenericMethodInstance(declaringType, method, typeArguments); + } + + public override bool IsGenericMethod + { + get { return method.IsGenericMethod; } + } + + public override bool IsGenericMethodDefinition + { + get { return method.IsGenericMethodDefinition && methodArgs == null; } + } + + public override bool ContainsGenericParameters + { + get + { + if (declaringType.ContainsGenericParameters) + { + return true; + } + if (methodArgs != null) + { + foreach (Type type in methodArgs) + { + if (type.ContainsGenericParameters) + { + return true; + } + } + } + return false; + } + } + + public override MethodInfo GetGenericMethodDefinition() + { + if (this.IsGenericMethod) + { + if (this.IsGenericMethodDefinition) + { + return this; + } + else if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition) + { + return new GenericMethodInstance(declaringType, method, null); + } + else + { + return method; + } + } + throw new InvalidOperationException(); + } + + public override Type[] GetGenericArguments() + { + if (methodArgs == null) + { + return method.GetGenericArguments(); + } + else + { + return (Type[])methodArgs.Clone(); + } + } + + internal override Type GetGenericMethodArgument(int index) + { + if (methodArgs == null) + { + return method.GetGenericMethodArgument(index); + } + else + { + return methodArgs[index]; + } + } + + internal override int GetGenericMethodArgumentCount() + { + return method.GetGenericMethodArgumentCount(); + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return method.GetCustomAttributesData(attributeType); + } + + internal override MethodInfo GetMethodOnTypeDefinition() + { + return method.GetMethodOnTypeDefinition(); + } + + internal override int ImportTo(Emit.ModuleBuilder module) + { + if (methodArgs == null) + { + return module.ImportMethodOrField(declaringType, method.Name, method.MethodSignature); + } + else + { + Writer.ByteBuffer spec = new Writer.ByteBuffer(10); + Signature.WriteMethodSpec(module, spec, methodArgs); + Metadata.MethodSpecTable.Record rec = new Metadata.MethodSpecTable.Record(); + Emit.MethodBuilder mb = method as Emit.MethodBuilder; + if (mb != null && mb.ModuleBuilder == module && !declaringType.IsGenericType) + { + rec.Method = mb.MetadataToken; + } + else + { + rec.Method = module.ImportMember(GetGenericMethodDefinition()); + } + rec.Instantiation = module.Blobs.Add(spec); + return 0x2B000000 | module.MethodSpec.FindOrAddRecord(rec); + } + } + + internal override MethodSignature MethodSignature + { + get { return lazyMethodSignature ?? (lazyMethodSignature = method.MethodSignature.Bind(declaringType, methodArgs)); } + } + + internal override MethodBase BindTypeParameters(Type type) + { + System.Diagnostics.Debug.Assert(methodArgs == null); + return new GenericMethodInstance(declaringType.BindTypeParameters(type), method, null); + } + } + + sealed class GenericFieldInstance : FieldInfo + { + private readonly Type declaringType; + private readonly FieldInfo field; + + internal GenericFieldInstance(Type declaringType, FieldInfo field) + { + this.declaringType = declaringType; + this.field = field; + } + + public override bool Equals(object obj) + { + GenericFieldInstance other = obj as GenericFieldInstance; + return other != null && other.declaringType.Equals(declaringType) && other.field.Equals(field); + } + + public override int GetHashCode() + { + return declaringType.GetHashCode() * 3 ^ field.GetHashCode(); + } + + public override FieldAttributes Attributes + { + get { return field.Attributes; } + } + + public override string Name + { + get { return field.Name; } + } + + public override Type DeclaringType + { + get { return declaringType; } + } + + public override Module Module + { + get { return declaringType.Module; } + } + + public override int MetadataToken + { + get { return field.MetadataToken; } + } + + public override object GetRawConstantValue() + { + return field.GetRawConstantValue(); + } + + public override void __GetDataFromRVA(byte[] data, int offset, int length) + { + field.__GetDataFromRVA(data, offset, length); + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return field.GetCustomAttributesData(attributeType); + } + + internal override FieldSignature FieldSignature + { + get { return field.FieldSignature.ExpandTypeParameters(declaringType); } + } + + internal override int ImportTo(Emit.ModuleBuilder module) + { + return module.ImportMethodOrField(declaringType, field.Name, field.FieldSignature); + } + + internal override FieldInfo BindTypeParameters(Type type) + { + return new GenericFieldInstance(declaringType.BindTypeParameters(type), field); + } + } + + sealed class GenericParameterInfoImpl : ParameterInfo + { + private readonly GenericMethodInstance method; + private readonly ParameterInfo parameterInfo; + + internal GenericParameterInfoImpl(GenericMethodInstance method, ParameterInfo parameterInfo) + { + this.method = method; + this.parameterInfo = parameterInfo; + } + + public override string Name + { + get { return parameterInfo.Name; } + } + + public override Type ParameterType + { + get { return parameterInfo.ParameterType.BindTypeParameters(method); } + } + + public override ParameterAttributes Attributes + { + get { return parameterInfo.Attributes; } + } + + public override int Position + { + get { return parameterInfo.Position; } + } + + public override object RawDefaultValue + { + get { return parameterInfo.RawDefaultValue; } + } + + public override Type[] GetOptionalCustomModifiers() + { + Type[] modifiers = parameterInfo.GetOptionalCustomModifiers(); + Type.InplaceBindTypeParameters(method, modifiers); + return modifiers; + } + + public override Type[] GetRequiredCustomModifiers() + { + Type[] modifiers = parameterInfo.GetRequiredCustomModifiers(); + Type.InplaceBindTypeParameters(method, modifiers); + return modifiers; + } + + public override MemberInfo Member + { + get { return method; } + } + + public override int MetadataToken + { + get { return parameterInfo.MetadataToken; } + } + + internal override Module Module + { + get { return method.Module; } + } + } + + sealed class GenericPropertyInfo : PropertyInfo + { + private readonly Type typeInstance; + private readonly PropertyInfo property; + + internal GenericPropertyInfo(Type typeInstance, PropertyInfo property) + { + this.typeInstance = typeInstance; + this.property = property; + } + + public override bool Equals(object obj) + { + GenericPropertyInfo other = obj as GenericPropertyInfo; + return other != null && other.typeInstance == typeInstance && other.property == property; + } + + public override int GetHashCode() + { + return typeInstance.GetHashCode() * 537 + property.GetHashCode(); + } + + public override PropertyAttributes Attributes + { + get { return property.Attributes; } + } + + public override bool CanRead + { + get { return property.CanRead; } + } + + public override bool CanWrite + { + get { return property.CanWrite; } + } + + private MethodInfo Wrap(MethodInfo method) + { + if (method == null) + { + return null; + } + return new GenericMethodInstance(typeInstance, method, null); + } + + public override MethodInfo GetGetMethod(bool nonPublic) + { + return Wrap(property.GetGetMethod(nonPublic)); + } + + public override MethodInfo GetSetMethod(bool nonPublic) + { + return Wrap(property.GetSetMethod(nonPublic)); + } + + public override MethodInfo[] GetAccessors(bool nonPublic) + { + MethodInfo[] accessors = property.GetAccessors(nonPublic); + for (int i = 0; i < accessors.Length; i++) + { + accessors[i] = Wrap(accessors[i]); + } + return accessors; + } + + public override object GetRawConstantValue() + { + return property.GetRawConstantValue(); + } + + internal override bool IsPublic + { + get { return property.IsPublic; } + } + + internal override bool IsStatic + { + get { return property.IsStatic; } + } + + internal override PropertySignature PropertySignature + { + get { return property.PropertySignature.ExpandTypeParameters(typeInstance); } + } + + public override string Name + { + get { return property.Name; } + } + + public override Type DeclaringType + { + get { return typeInstance; } + } + + public override Module Module + { + get { return typeInstance.Module; } + } + + public override int MetadataToken + { + get { return property.MetadataToken; } + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return property.GetCustomAttributesData(attributeType); + } + + internal override PropertyInfo BindTypeParameters(Type type) + { + return new GenericPropertyInfo(typeInstance.BindTypeParameters(type), property); + } + } + + sealed class GenericEventInfo : EventInfo + { + private readonly Type typeInstance; + private readonly EventInfo eventInfo; + + internal GenericEventInfo(Type typeInstance, EventInfo eventInfo) + { + this.typeInstance = typeInstance; + this.eventInfo = eventInfo; + } + + public override bool Equals(object obj) + { + GenericEventInfo other = obj as GenericEventInfo; + return other != null && other.typeInstance == typeInstance && other.eventInfo == eventInfo; + } + + public override int GetHashCode() + { + return typeInstance.GetHashCode() * 777 + eventInfo.GetHashCode(); + } + + public override EventAttributes Attributes + { + get { return eventInfo.Attributes; } + } + + private MethodInfo Wrap(MethodInfo method) + { + if (method == null) + { + return null; + } + return new GenericMethodInstance(typeInstance, method, null); + } + + public override MethodInfo GetAddMethod(bool nonPublic) + { + return Wrap(eventInfo.GetAddMethod(nonPublic)); + } + + public override MethodInfo GetRaiseMethod(bool nonPublic) + { + return Wrap(eventInfo.GetRaiseMethod(nonPublic)); + } + + public override MethodInfo GetRemoveMethod(bool nonPublic) + { + return Wrap(eventInfo.GetRemoveMethod(nonPublic)); + } + + public override MethodInfo[] GetOtherMethods(bool nonPublic) + { + MethodInfo[] others = eventInfo.GetOtherMethods(nonPublic); + for (int i = 0; i < others.Length; i++) + { + others[i] = Wrap(others[i]); + } + return others; + } + + public override Type EventHandlerType + { + get { return eventInfo.EventHandlerType.BindTypeParameters(typeInstance); } + } + + public override string Name + { + get { return eventInfo.Name; } + } + + public override Type DeclaringType + { + get { return typeInstance; } + } + + public override Module Module + { + get { return eventInfo.Module; } + } + + public override int MetadataToken + { + get { return eventInfo.MetadataToken; } + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return eventInfo.GetCustomAttributesData(attributeType); + } + + internal override EventInfo BindTypeParameters(Type type) + { + return new GenericEventInfo(typeInstance.BindTypeParameters(type), eventInfo); + } + + internal override bool IsPublic + { + get { return eventInfo.IsPublic; } + } + + internal override bool IsStatic + { + get { return eventInfo.IsStatic; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/IKVM.Reflection.csproj b/mcs/class/IKVM.Reflection/IKVM.Reflection.csproj new file mode 100644 index 000000000000..c0382740d267 --- /dev/null +++ b/mcs/class/IKVM.Reflection/IKVM.Reflection.csproj @@ -0,0 +1,141 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {4CB170EF-DFE6-4A56-9E1B-A85449E827A7} + Library + Properties + IKVM.Reflection + IKVM.Reflection + v2.0 + 512 + + + + + + + + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mcs/class/IKVM.Reflection/Impl/CryptoConvert.cs b/mcs/class/IKVM.Reflection/Impl/CryptoConvert.cs new file mode 100644 index 000000000000..14687dee3828 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/CryptoConvert.cs @@ -0,0 +1,743 @@ +// +// CryptoConvert.cs - Crypto Convertion Routines +// +// Author: +// Sebastien Pouliot +// +// (C) 2003 Motus Technologies Inc. (http://www.motus.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.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. +// +// [JF-20081013] begin modifications for IKVM +#define INSIDE_CORLIB +// end modifications for IKVM + +using System; +using System.Globalization; +using System.Security.Cryptography; +using System.Text; + +namespace Mono.Security.Cryptography { + +#if INSIDE_CORLIB + internal +#else + public +#endif + sealed class CryptoConvert { + + private CryptoConvert () + { + } + + static private int ToInt32LE (byte [] bytes, int offset) + { + return (bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]; + } + + static private uint ToUInt32LE (byte [] bytes, int offset) + { + return (uint)((bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]); + } + + static private byte [] GetBytesLE (int val) + { + return new byte [] { + (byte) (val & 0xff), + (byte) ((val >> 8) & 0xff), + (byte) ((val >> 16) & 0xff), + (byte) ((val >> 24) & 0xff) + }; + } + + static private byte[] Trim (byte[] array) + { + for (int i=0; i < array.Length; i++) { + if (array [i] != 0x00) { + byte[] result = new byte [array.Length - i]; + Buffer.BlockCopy (array, i, result, 0, result.Length); + return result; + } + } + return null; + } + + // convert the key from PRIVATEKEYBLOB to RSA + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/Security/private_key_blobs.asp + // e.g. SNK files, PVK files + static public RSA FromCapiPrivateKeyBlob (byte[] blob) + { + return FromCapiPrivateKeyBlob (blob, 0); + } + + static public RSA FromCapiPrivateKeyBlob (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + RSAParameters rsap = new RSAParameters (); + try { + if ((blob [offset] != 0x07) || // PRIVATEKEYBLOB (0x07) + (blob [offset+1] != 0x02) || // Version (0x02) + (blob [offset+2] != 0x00) || // Reserved (word) + (blob [offset+3] != 0x00) || + (ToUInt32LE (blob, offset+8) != 0x32415352)) // DWORD magic = RSA2 + throw new CryptographicException ("Invalid blob header"); + + // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...) + // int algId = ToInt32LE (blob, offset+4); + + // DWORD bitlen + int bitLen = ToInt32LE (blob, offset+12); + + // DWORD public exponent + byte[] exp = new byte [4]; + Buffer.BlockCopy (blob, offset+16, exp, 0, 4); + Array.Reverse (exp); + rsap.Exponent = Trim (exp); + + int pos = offset+20; + // BYTE modulus[rsapubkey.bitlen/8]; + int byteLen = (bitLen >> 3); + rsap.Modulus = new byte [byteLen]; + Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); + Array.Reverse (rsap.Modulus); + pos += byteLen; + + // BYTE prime1[rsapubkey.bitlen/16]; + int byteHalfLen = (byteLen >> 1); + rsap.P = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.P, 0, byteHalfLen); + Array.Reverse (rsap.P); + pos += byteHalfLen; + + // BYTE prime2[rsapubkey.bitlen/16]; + rsap.Q = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.Q, 0, byteHalfLen); + Array.Reverse (rsap.Q); + pos += byteHalfLen; + + // BYTE exponent1[rsapubkey.bitlen/16]; + rsap.DP = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.DP, 0, byteHalfLen); + Array.Reverse (rsap.DP); + pos += byteHalfLen; + + // BYTE exponent2[rsapubkey.bitlen/16]; + rsap.DQ = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.DQ, 0, byteHalfLen); + Array.Reverse (rsap.DQ); + pos += byteHalfLen; + + // BYTE coefficient[rsapubkey.bitlen/16]; + rsap.InverseQ = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.InverseQ, 0, byteHalfLen); + Array.Reverse (rsap.InverseQ); + pos += byteHalfLen; + + // ok, this is hackish but CryptoAPI support it so... + // note: only works because CRT is used by default + // http://bugzilla.ximian.com/show_bug.cgi?id=57941 + rsap.D = new byte [byteLen]; // must be allocated + if (pos + byteLen + offset <= blob.Length) { + // BYTE privateExponent[rsapubkey.bitlen/8]; + Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen); + Array.Reverse (rsap.D); + } + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException ce) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + try { + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } + catch { + // rethrow original, not the later, exception if this fails + throw ce; + } + } + return rsa; + } + + static public DSA FromCapiPrivateKeyBlobDSA (byte[] blob) + { + return FromCapiPrivateKeyBlobDSA (blob, 0); + } + + static public DSA FromCapiPrivateKeyBlobDSA (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + DSAParameters dsap = new DSAParameters (); + try { + if ((blob [offset] != 0x07) || // PRIVATEKEYBLOB (0x07) + (blob [offset + 1] != 0x02) || // Version (0x02) + (blob [offset + 2] != 0x00) || // Reserved (word) + (blob [offset + 3] != 0x00) || + (ToUInt32LE (blob, offset + 8) != 0x32535344)) // DWORD magic + throw new CryptographicException ("Invalid blob header"); + + int bitlen = ToInt32LE (blob, offset + 12); + int bytelen = bitlen >> 3; + int pos = offset + 16; + + dsap.P = new byte [bytelen]; + Buffer.BlockCopy (blob, pos, dsap.P, 0, bytelen); + Array.Reverse (dsap.P); + pos += bytelen; + + dsap.Q = new byte [20]; + Buffer.BlockCopy (blob, pos, dsap.Q, 0, 20); + Array.Reverse (dsap.Q); + pos += 20; + + dsap.G = new byte [bytelen]; + Buffer.BlockCopy (blob, pos, dsap.G, 0, bytelen); + Array.Reverse (dsap.G); + pos += bytelen; + + dsap.X = new byte [20]; + Buffer.BlockCopy (blob, pos, dsap.X, 0, 20); + Array.Reverse (dsap.X); + pos += 20; + + dsap.Counter = ToInt32LE (blob, pos); + pos += 4; + + dsap.Seed = new byte [20]; + Buffer.BlockCopy (blob, pos, dsap.Seed, 0, 20); + Array.Reverse (dsap.Seed); + pos += 20; + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + + DSA dsa = null; + try { + dsa = (DSA)DSA.Create (); + dsa.ImportParameters (dsap); + } + catch (CryptographicException ce) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + try { + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + dsa = new DSACryptoServiceProvider (csp); + dsa.ImportParameters (dsap); + } + catch { + // rethrow original, not the later, exception if this fails + throw ce; + } + } + return dsa; + } + + static public byte[] ToCapiPrivateKeyBlob (RSA rsa) + { + RSAParameters p = rsa.ExportParameters (true); + int keyLength = p.Modulus.Length; // in bytes + byte[] blob = new byte [20 + (keyLength << 2) + (keyLength >> 1)]; + + blob [0] = 0x07; // Type - PRIVATEKEYBLOB (0x07) + blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02) + // [2], [3] // RESERVED - Always 0 + blob [5] = 0x24; // ALGID - Always 00 24 00 00 (for CALG_RSA_SIGN) + blob [8] = 0x52; // Magic - RSA2 (ASCII in hex) + blob [9] = 0x53; + blob [10] = 0x41; + blob [11] = 0x32; + + byte[] bitlen = GetBytesLE (keyLength << 3); + blob [12] = bitlen [0]; // bitlen + blob [13] = bitlen [1]; + blob [14] = bitlen [2]; + blob [15] = bitlen [3]; + + // public exponent (DWORD) + int pos = 16; + int n = p.Exponent.Length; + while (n > 0) + blob [pos++] = p.Exponent [--n]; + // modulus + pos = 20; + byte[] part = p.Modulus; + int len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + // private key + part = p.P; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + + part = p.Q; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + + part = p.DP; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + + part = p.DQ; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + + part = p.InverseQ; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + + part = p.D; + len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + + return blob; + } + + static public byte[] ToCapiPrivateKeyBlob (DSA dsa) + { + DSAParameters p = dsa.ExportParameters (true); + int keyLength = p.P.Length; // in bytes + + // header + P + Q + G + X + count + seed + byte[] blob = new byte [16 + keyLength + 20 + keyLength + 20 + 4 + 20]; + + blob [0] = 0x07; // Type - PRIVATEKEYBLOB (0x07) + blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02) + // [2], [3] // RESERVED - Always 0 + blob [5] = 0x22; // ALGID + blob [8] = 0x44; // Magic + blob [9] = 0x53; + blob [10] = 0x53; + blob [11] = 0x32; + + byte[] bitlen = GetBytesLE (keyLength << 3); + blob [12] = bitlen [0]; + blob [13] = bitlen [1]; + blob [14] = bitlen [2]; + blob [15] = bitlen [3]; + + int pos = 16; + byte[] part = p.P; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, keyLength); + pos += keyLength; + + part = p.Q; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, 20); + pos += 20; + + part = p.G; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, keyLength); + pos += keyLength; + + part = p.X; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, 20); + pos += 20; + + Buffer.BlockCopy (GetBytesLE (p.Counter), 0, blob, pos, 4); + pos += 4; + + part = p.Seed; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, 20); + + return blob; + } + + static public RSA FromCapiPublicKeyBlob (byte[] blob) + { + return FromCapiPublicKeyBlob (blob, 0); + } + + static public RSA FromCapiPublicKeyBlob (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + try { + if ((blob [offset] != 0x06) || // PUBLICKEYBLOB (0x06) + (blob [offset+1] != 0x02) || // Version (0x02) + (blob [offset+2] != 0x00) || // Reserved (word) + (blob [offset+3] != 0x00) || + (ToUInt32LE (blob, offset+8) != 0x31415352)) // DWORD magic = RSA1 + throw new CryptographicException ("Invalid blob header"); + + // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...) + // int algId = ToInt32LE (blob, offset+4); + + // DWORD bitlen + int bitLen = ToInt32LE (blob, offset+12); + + // DWORD public exponent + RSAParameters rsap = new RSAParameters (); + rsap.Exponent = new byte [3]; + rsap.Exponent [0] = blob [offset+18]; + rsap.Exponent [1] = blob [offset+17]; + rsap.Exponent [2] = blob [offset+16]; + + int pos = offset+20; + // BYTE modulus[rsapubkey.bitlen/8]; + int byteLen = (bitLen >> 3); + rsap.Modulus = new byte [byteLen]; + Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); + Array.Reverse (rsap.Modulus); + + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } + return rsa; + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + } + + static public DSA FromCapiPublicKeyBlobDSA (byte[] blob) + { + return FromCapiPublicKeyBlobDSA (blob, 0); + } + + static public DSA FromCapiPublicKeyBlobDSA (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + try { + if ((blob [offset] != 0x06) || // PUBLICKEYBLOB (0x06) + (blob [offset + 1] != 0x02) || // Version (0x02) + (blob [offset + 2] != 0x00) || // Reserved (word) + (blob [offset + 3] != 0x00) || + (ToUInt32LE (blob, offset + 8) != 0x31535344)) // DWORD magic + throw new CryptographicException ("Invalid blob header"); + + int bitlen = ToInt32LE (blob, offset + 12); + DSAParameters dsap = new DSAParameters (); + int bytelen = bitlen >> 3; + int pos = offset + 16; + + dsap.P = new byte [bytelen]; + Buffer.BlockCopy (blob, pos, dsap.P, 0, bytelen); + Array.Reverse (dsap.P); + pos += bytelen; + + dsap.Q = new byte [20]; + Buffer.BlockCopy (blob, pos, dsap.Q, 0, 20); + Array.Reverse (dsap.Q); + pos += 20; + + dsap.G = new byte [bytelen]; + Buffer.BlockCopy (blob, pos, dsap.G, 0, bytelen); + Array.Reverse (dsap.G); + pos += bytelen; + + dsap.Y = new byte [bytelen]; + Buffer.BlockCopy (blob, pos, dsap.Y, 0, bytelen); + Array.Reverse (dsap.Y); + pos += bytelen; + + dsap.Counter = ToInt32LE (blob, pos); + pos += 4; + + dsap.Seed = new byte [20]; + Buffer.BlockCopy (blob, pos, dsap.Seed, 0, 20); + Array.Reverse (dsap.Seed); + pos += 20; + + DSA dsa = (DSA)DSA.Create (); + dsa.ImportParameters (dsap); + return dsa; + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + } + + static public byte[] ToCapiPublicKeyBlob (RSA rsa) + { + RSAParameters p = rsa.ExportParameters (false); + int keyLength = p.Modulus.Length; // in bytes + byte[] blob = new byte [20 + keyLength]; + + blob [0] = 0x06; // Type - PUBLICKEYBLOB (0x06) + blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02) + // [2], [3] // RESERVED - Always 0 + blob [5] = 0x24; // ALGID - Always 00 24 00 00 (for CALG_RSA_SIGN) + blob [8] = 0x52; // Magic - RSA1 (ASCII in hex) + blob [9] = 0x53; + blob [10] = 0x41; + blob [11] = 0x31; + + byte[] bitlen = GetBytesLE (keyLength << 3); + blob [12] = bitlen [0]; // bitlen + blob [13] = bitlen [1]; + blob [14] = bitlen [2]; + blob [15] = bitlen [3]; + + // public exponent (DWORD) + int pos = 16; + int n = p.Exponent.Length; + while (n > 0) + blob [pos++] = p.Exponent [--n]; + // modulus + pos = 20; + byte[] part = p.Modulus; + int len = part.Length; + Array.Reverse (part, 0, len); + Buffer.BlockCopy (part, 0, blob, pos, len); + pos += len; + return blob; + } + + static public byte[] ToCapiPublicKeyBlob (DSA dsa) + { + DSAParameters p = dsa.ExportParameters (false); + int keyLength = p.P.Length; // in bytes + + // header + P + Q + G + Y + count + seed + byte[] blob = new byte [16 + keyLength + 20 + keyLength + keyLength + 4 + 20]; + + blob [0] = 0x06; // Type - PUBLICKEYBLOB (0x06) + blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02) + // [2], [3] // RESERVED - Always 0 + blob [5] = 0x22; // ALGID + blob [8] = 0x44; // Magic + blob [9] = 0x53; + blob [10] = 0x53; + blob [11] = 0x31; + + byte[] bitlen = GetBytesLE (keyLength << 3); + blob [12] = bitlen [0]; + blob [13] = bitlen [1]; + blob [14] = bitlen [2]; + blob [15] = bitlen [3]; + + int pos = 16; + byte[] part; + + part = p.P; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, keyLength); + pos += keyLength; + + part = p.Q; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, 20); + pos += 20; + + part = p.G; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, keyLength); + pos += keyLength; + + part = p.Y; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, keyLength); + pos += keyLength; + + Buffer.BlockCopy (GetBytesLE (p.Counter), 0, blob, pos, 4); + pos += 4; + + part = p.Seed; + Array.Reverse (part); + Buffer.BlockCopy (part, 0, blob, pos, 20); + + return blob; + } + + // PRIVATEKEYBLOB + // PUBLICKEYBLOB + static public RSA FromCapiKeyBlob (byte[] blob) + { + return FromCapiKeyBlob (blob, 0); + } + + static public RSA FromCapiKeyBlob (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + switch (blob [offset]) { + case 0x00: + // this could be a public key inside an header + // like "sn -e" would produce + if (blob [offset + 12] == 0x06) { + return FromCapiPublicKeyBlob (blob, offset + 12); + } + break; + case 0x06: + return FromCapiPublicKeyBlob (blob, offset); + case 0x07: + return FromCapiPrivateKeyBlob (blob, offset); + } + throw new CryptographicException ("Unknown blob format."); + } + + static public DSA FromCapiKeyBlobDSA (byte[] blob) + { + return FromCapiKeyBlobDSA (blob, 0); + } + + static public DSA FromCapiKeyBlobDSA (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + switch (blob [offset]) { + case 0x06: + return FromCapiPublicKeyBlobDSA (blob, offset); + case 0x07: + return FromCapiPrivateKeyBlobDSA (blob, offset); + } + throw new CryptographicException ("Unknown blob format."); + } + + static public byte[] ToCapiKeyBlob (AsymmetricAlgorithm keypair, bool includePrivateKey) + { + if (keypair == null) + throw new ArgumentNullException ("keypair"); + + // check between RSA and DSA (and potentially others like DH) + if (keypair is RSA) + return ToCapiKeyBlob ((RSA)keypair, includePrivateKey); + else if (keypair is DSA) + return ToCapiKeyBlob ((DSA)keypair, includePrivateKey); + else + return null; // TODO + } + + static public byte[] ToCapiKeyBlob (RSA rsa, bool includePrivateKey) + { + if (rsa == null) + throw new ArgumentNullException ("rsa"); + + if (includePrivateKey) + return ToCapiPrivateKeyBlob (rsa); + else + return ToCapiPublicKeyBlob (rsa); + } + + static public byte[] ToCapiKeyBlob (DSA dsa, bool includePrivateKey) + { + if (dsa == null) + throw new ArgumentNullException ("dsa"); + + if (includePrivateKey) + return ToCapiPrivateKeyBlob (dsa); + else + return ToCapiPublicKeyBlob (dsa); + } + + static public string ToHex (byte[] input) + { + if (input == null) + return null; + + StringBuilder sb = new StringBuilder (input.Length * 2); + foreach (byte b in input) { + sb.Append (b.ToString ("X2", CultureInfo.InvariantCulture)); + } + return sb.ToString (); + } + + static private byte FromHexChar (char c) + { + if ((c >= 'a') && (c <= 'f')) + return (byte) (c - 'a' + 10); + if ((c >= 'A') && (c <= 'F')) + return (byte) (c - 'A' + 10); + if ((c >= '0') && (c <= '9')) + return (byte) (c - '0'); + throw new ArgumentException ("invalid hex char"); + } + + static public byte[] FromHex (string hex) + { + if (hex == null) + return null; + if ((hex.Length & 0x1) == 0x1) + throw new ArgumentException ("Length must be a multiple of 2"); + + byte[] result = new byte [hex.Length >> 1]; + int n = 0; + int i = 0; + while (n < result.Length) { + result [n] = (byte) (FromHexChar (hex [i++]) << 4); + result [n++] += FromHexChar (hex [i++]); + } + return result; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Impl/CryptoHack.cs b/mcs/class/IKVM.Reflection/Impl/CryptoHack.cs new file mode 100644 index 000000000000..1a8b46afb993 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/CryptoHack.cs @@ -0,0 +1,56 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.Security.Cryptography; +using System.Runtime.Serialization; + +namespace IKVM.Reflection.Impl +{ + static class CryptoHack + { + internal static RSA CreateRSA(StrongNameKeyPair keyPair) + { + // HACK use serialization to get at the private key or key container name, + // this should be more future proof than using reflection to access the fields directly. + SerializationInfo ser = new SerializationInfo(typeof(StrongNameKeyPair), new FormatterConverter()); + ((ISerializable)keyPair.keyPair).GetObjectData(ser, new StreamingContext()); + byte[] key = (byte[])ser.GetValue("_keyPairArray", typeof(byte[])); + string keycontainer = ser.GetString("_keyPairContainer"); + if (keycontainer != null) + { + CspParameters parm = new CspParameters(); + parm.Flags = CspProviderFlags.UseMachineKeyStore; + parm.KeyContainerName = keycontainer; + parm.KeyNumber = 2; // Signature + return new RSACryptoServiceProvider(parm); + } + else + { + return Mono.Security.Cryptography.CryptoConvert.FromCapiKeyBlob(key); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Impl/ITypeOwner.cs b/mcs/class/IKVM.Reflection/Impl/ITypeOwner.cs new file mode 100644 index 000000000000..10050f703d99 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/ITypeOwner.cs @@ -0,0 +1,32 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection.Impl +{ + interface ITypeOwner + { + ModuleBuilder ModuleBuilder { get; } + } +} diff --git a/mcs/class/IKVM.Reflection/Impl/MdbWriter.cs b/mcs/class/IKVM.Reflection/Impl/MdbWriter.cs new file mode 100644 index 000000000000..06d3ed0adb54 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/MdbWriter.cs @@ -0,0 +1,230 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +#if MONO +using System; +using System.Collections.Generic; +using Mono.CompilerServices.SymbolWriter; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection.Impl +{ + sealed class Method : IMethodDef + { + internal int token; + internal string name; + internal SymbolDocumentWriter document; + internal int[] offsets; + internal int[] lines; + internal int[] columns; + internal List variables = new List(); + + public string Name + { + get { return name; } + } + + public int Token + { + get { return token; } + } + } + + sealed class SymbolDocumentWriter : System.Diagnostics.SymbolStore.ISymbolDocumentWriter + { + internal readonly string url; + internal SourceFileEntry source; + + internal SymbolDocumentWriter(string url) + { + this.url = url; + } + + public void SetCheckSum(Guid algorithmId, byte[] checkSum) + { + } + + public void SetSource(byte[] source) + { + } + } + + sealed class MdbWriter : ISymbolWriterImpl + { + private readonly ModuleBuilder moduleBuilder; + private readonly Dictionary methods = new Dictionary(); + private readonly Dictionary documents = new Dictionary(); + private Method currentMethod; + + internal MdbWriter(ModuleBuilder moduleBuilder) + { + this.moduleBuilder = moduleBuilder; + } + + public byte[] GetDebugInfo(ref IMAGE_DEBUG_DIRECTORY idd) + { + return Empty.Array; + } + + public void RemapToken(int oldToken, int newToken) + { + if (methods.ContainsKey(oldToken)) + { + methods[oldToken].token = newToken; + } + } + + public void Close() + { + MonoSymbolWriter writer = new MonoSymbolWriter(moduleBuilder.FullyQualifiedName); + + foreach (Method method in methods.Values) + { + if (method.document != null) + { + if (method.document.source == null) + { + method.document.source = new SourceFileEntry(writer.SymbolFile, method.document.url); + } + ICompileUnit file = new CompileUnitEntry(writer.SymbolFile, method.document.source); + SourceMethodBuilder smb = writer.OpenMethod(file, 0, method); + for (int i = 0; i < method.offsets.Length; i++) + { + smb.MarkSequencePoint(method.offsets[i], method.document.source, method.lines[i], method.columns[i], false); + } + for (int i = 0; i < method.variables.Count; i++) + { + writer.DefineLocalVariable(i, method.variables[i]); + } + writer.CloseMethod(); + } + } + + writer.WriteSymbolFile(moduleBuilder.ModuleVersionId); + } + + public System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) + { + SymbolDocumentWriter writer; + if (!documents.TryGetValue(url, out writer)) + { + writer = new SymbolDocumentWriter(url); + documents.Add(url, writer); + } + return writer; + } + + public void OpenMethod(System.Diagnostics.SymbolStore.SymbolToken token) + { + Method method = new Method(); + method.token = token.GetToken(); + // name doesn't appear to be used. We can look it up, but ModuleBuilder.ResolveMethod() is inefficient, + // so if it isn't used, why bother? + method.name = null; // moduleBuilder.ResolveMethod(token.GetToken()).Name; + methods.Add(token.GetToken(), method); + currentMethod = method; + } + + public void CloseMethod() + { + currentMethod = null; + } + + public void DefineLocalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) + { + } + + public void DefineLocalVariable2(string name, FieldAttributes attributes, int signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) + { + currentMethod.variables.Add(name); + } + + public void DefineSequencePoints(System.Diagnostics.SymbolStore.ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) + { + currentMethod.document = (SymbolDocumentWriter)document; + currentMethod.offsets = offsets; + currentMethod.lines = lines; + currentMethod.columns = columns; + } + + public void DefineParameter(string name, System.Reflection.ParameterAttributes attributes, int sequence, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + } + + public void DefineField(System.Diagnostics.SymbolStore.SymbolToken parent, string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + } + + public void DefineGlobalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + } + + public void OpenNamespace(string name) + { + } + + public void CloseNamespace() + { + } + + public void UsingNamespace(string fullName) + { + } + + public int OpenScope(int startOffset) + { + return 0; + } + + public void CloseScope(int endOffset) + { + } + + public void SetMethodSourceRange(System.Diagnostics.SymbolStore.ISymbolDocumentWriter startDoc, int startLine, int startColumn, System.Diagnostics.SymbolStore.ISymbolDocumentWriter endDoc, int endLine, int endColumn) + { + } + + public void SetScopeRange(int scopeID, int startOffset, int endOffset) + { + } + + public void SetSymAttribute(System.Diagnostics.SymbolStore.SymbolToken parent, string name, byte[] data) + { + } + + public void SetUserEntryPoint(System.Diagnostics.SymbolStore.SymbolToken entryMethod) + { + } + + public void SetUnderlyingWriter(IntPtr underlyingWriter) + { + throw new InvalidOperationException(); + } + + public void Initialize(IntPtr emitter, string filename, bool fFullBuild) + { + throw new InvalidOperationException(); + } + } +} +#endif // MONO diff --git a/mcs/class/IKVM.Reflection/Impl/PdbWriter.cs b/mcs/class/IKVM.Reflection/Impl/PdbWriter.cs new file mode 100644 index 000000000000..aacc6c9d4950 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/PdbWriter.cs @@ -0,0 +1,1180 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Diagnostics.SymbolStore; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection.Impl +{ + [Guid("7dac8207-d3ae-4c75-9b67-92801a497d44")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + interface IMetaDataImport + { + void PlaceHolder_CloseEnum(); + void PlaceHolder_CountEnum(); + void PlaceHolder_ResetEnum(); + void PlaceHolder_EnumTypeDefs(); + void PlaceHolder_EnumInterfaceImpls(); + void PlaceHolder_EnumTypeRefs(); + void PlaceHolder_FindTypeDefByName(); + void PlaceHolder_GetScopeProps(); + void PlaceHolder_GetModuleFromScope(); + + void GetTypeDefProps( + int td, // [IN] TypeDef token for inquiry. + IntPtr szTypeDef, // [OUT] Put name here. + int cchTypeDef, // [IN] size of name buffer in wide chars. + IntPtr pchTypeDef, // [OUT] put size of name (wide chars) here. + IntPtr pdwTypeDefFlags, // [OUT] Put flags here. + IntPtr ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. + + void PlaceHolder_GetInterfaceImplProps(); + void PlaceHolder_GetTypeRefProps(); + void PlaceHolder_ResolveTypeRef(); + void PlaceHolder_EnumMembers(); + void PlaceHolder_EnumMembersWithName(); + void PlaceHolder_EnumMethods(); + void PlaceHolder_EnumMethodsWithName(); + void PlaceHolder_EnumFields(); + void PlaceHolder_EnumFieldsWithName(); + void PlaceHolder_EnumParams(); + void PlaceHolder_EnumMemberRefs(); + void PlaceHolder_EnumMethodImpls(); + void PlaceHolder_EnumPermissionSets(); + void PlaceHolder_FindMember(); + void PlaceHolder_FindMethod(); + void PlaceHolder_FindField(); + void PlaceHolder_FindMemberRef(); + + void GetMethodProps( + int mb, // The method for which to get props. + IntPtr pClass, // Put method's class here. + IntPtr szMethod, // Put method's name here. + int cchMethod, // Size of szMethod buffer in wide chars. + IntPtr pchMethod, // Put actual size here + IntPtr pdwAttr, // Put flags here. + IntPtr ppvSigBlob, // [OUT] point to the blob value of meta data + IntPtr pcbSigBlob, // [OUT] actual size of signature blob + IntPtr pulCodeRVA, // [OUT] codeRVA + IntPtr pdwImplFlags); // [OUT] Impl. Flags + + void PlaceHolder_GetMemberRefProps(); + void PlaceHolder_EnumProperties(); + void PlaceHolder_EnumEvents(); + void PlaceHolder_GetEventProps(); + void PlaceHolder_EnumMethodSemantics(); + void PlaceHolder_GetMethodSemantics(); + void PlaceHolder_GetClassLayout(); + void PlaceHolder_GetFieldMarshal(); + void PlaceHolder_GetRVA(); + void PlaceHolder_GetPermissionSetProps(); + void PlaceHolder_GetSigFromToken(); + void PlaceHolder_GetModuleRefProps(); + void PlaceHolder_EnumModuleRefs(); + void PlaceHolder_GetTypeSpecFromToken(); + void PlaceHolder_GetNameFromToken(); + void PlaceHolder_EnumUnresolvedMethods(); + void PlaceHolder_GetUserString(); + void PlaceHolder_GetPinvokeMap(); + void PlaceHolder_EnumSignatures(); + void PlaceHolder_EnumTypeSpecs(); + void PlaceHolder_EnumUserStrings(); + void PlaceHolder_GetParamForMethodIndex(); + void PlaceHolder_EnumCustomAttributes(); + void PlaceHolder_GetCustomAttributeProps(); + void PlaceHolder_FindTypeRef(); + void PlaceHolder_GetMemberProps(); + void PlaceHolder_GetFieldProps(); + void PlaceHolder_GetPropertyProps(); + void PlaceHolder_GetParamProps(); + void PlaceHolder_GetCustomAttributeByName(); + void PlaceHolder_IsValidToken(); + + void GetNestedClassProps( + int tdNestedClass, // [IN] NestedClass token. + IntPtr ptdEnclosingClass); // [OUT] EnclosingClass token. + + void PlaceHolder_GetNativeCallConvFromSig(); + void PlaceHolder_IsGlobal(); + } + + [Guid("ba3fee4c-ecb9-4e41-83b7-183fa41cd859")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + interface IMetaDataEmit + { + void PlaceHolder_SetModuleProps(); + void PlaceHolder_Save(); + void PlaceHolder_SaveToStream(); + void PlaceHolder_GetSaveSize(); + void PlaceHolder_DefineTypeDef(); + void PlaceHolder_DefineNestedType(); + void PlaceHolder_SetHandler(); + void PlaceHolder_DefineMethod(); + void PlaceHolder_DefineMethodImpl(); + void PlaceHolder_DefineTypeRefByName(); + void PlaceHolder_DefineImportType(); + void PlaceHolder_DefineMemberRef(); + void PlaceHolder_DefineImportMember(); + void PlaceHolder_DefineEvent(); + void PlaceHolder_SetClassLayout(); + void PlaceHolder_DeleteClassLayout(); + void PlaceHolder_SetFieldMarshal(); + void PlaceHolder_DeleteFieldMarshal(); + void PlaceHolder_DefinePermissionSet(); + void PlaceHolder_SetRVA(); + void PlaceHolder_GetTokenFromSig(); + void PlaceHolder_DefineModuleRef(); + void PlaceHolder_SetParent(); + void PlaceHolder_GetTokenFromTypeSpec(); + void PlaceHolder_SaveToMemory(); + void PlaceHolder_DefineUserString(); + void PlaceHolder_DeleteToken(); + void PlaceHolder_SetMethodProps(); + void PlaceHolder_SetTypeDefProps(); + void PlaceHolder_SetEventProps(); + void PlaceHolder_SetPermissionSetProps(); + void PlaceHolder_DefinePinvokeMap(); + void PlaceHolder_SetPinvokeMap(); + void PlaceHolder_DeletePinvokeMap(); + void PlaceHolder_DefineCustomAttribute(); + void PlaceHolder_SetCustomAttributeValue(); + void PlaceHolder_DefineField(); + void PlaceHolder_DefineProperty(); + void PlaceHolder_DefineParam(); + void PlaceHolder_SetFieldProps(); + void PlaceHolder_SetPropertyProps(); + void PlaceHolder_SetParamProps(); + void PlaceHolder_DefineSecurityAttributeSet(); + void PlaceHolder_ApplyEditAndContinue(); + void PlaceHolder_TranslateSigWithScope(); + void PlaceHolder_SetMethodImplFlags(); + void PlaceHolder_SetFieldRVA(); + void PlaceHolder_Merge(); + void PlaceHolder_MergeEnd(); + } + + [Guid("B01FAFEB-C450-3A4D-BEEC-B4CEEC01E006")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + internal interface ISymUnmanagedDocumentWriter { } + + [Guid("0b97726e-9e6d-4f05-9a26-424022093caa")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + [CoClass(typeof(CorSymWriterClass))] + interface ISymUnmanagedWriter2 + { + ISymUnmanagedDocumentWriter DefineDocument(string url, ref Guid language, ref Guid languageVendor, ref Guid documentType); + void PlaceHolder_SetUserEntryPoint(); + void OpenMethod(int method); + void CloseMethod(); + int OpenScope(int startOffset); + void CloseScope(int endOffset); + void PlaceHolder_SetScopeRange(); + void DefineLocalVariable(string name, int attributes, int cSig, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] signature, int addrKind, int addr1, int addr2, int startOffset, int endOffset); + void PlaceHolder_DefineParameter(); + void PlaceHolder_DefineField(); + void PlaceHolder_DefineGlobalVariable(); + void Close(); + void PlaceHolder_SetSymAttribute(); + void PlaceHolder_OpenNamespace(); + void PlaceHolder_CloseNamespace(); + void PlaceHolder_UsingNamespace(); + void PlaceHolder_SetMethodSourceRange(); + void Initialize([MarshalAs(UnmanagedType.IUnknown)] object emitter, string filename, [MarshalAs(UnmanagedType.IUnknown)] object pIStream, bool fFullBuild); + + void GetDebugInfo( + [In, Out] ref IMAGE_DEBUG_DIRECTORY pIDD, + [In] uint cData, + [Out] out uint pcData, + [Out, MarshalAs(UnmanagedType.LPArray)] byte[] data); + + void DefineSequencePoints(ISymUnmanagedDocumentWriter document, int spCount, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] offsets, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] lines, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] columns, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] endLines, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] endColumns); + + void RemapToken( + [In] int oldToken, + [In] int newToken); + + void PlaceHolder_Initialize2(); + void PlaceHolder_DefineConstant(); + void PlaceHolder_Abort(); + + void DefineLocalVariable2(string name, int attributes, int token, int addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset); + + void PlaceHolder_DefineGlobalVariable2(); + void PlaceHolder_DefineConstant2(); + } + + [Guid("108296c1-281e-11d3-bd22-0000f80849bd")] + [ComImport] + class CorSymWriterClass { } + + sealed class PdbWriter : ISymbolWriterImpl, IMetaDataEmit, IMetaDataImport + { + private readonly ModuleBuilder moduleBuilder; + private ISymUnmanagedWriter2 symUnmanagedWriter; + private readonly Dictionary documents = new Dictionary(); + private readonly List methods = new List(); + private readonly Dictionary remap = new Dictionary(); + private readonly Dictionary reversemap = new Dictionary(); + private Method currentMethod; + + internal PdbWriter(ModuleBuilder moduleBuilder) + { + this.moduleBuilder = moduleBuilder; + } + + private sealed class Document : ISymbolDocumentWriter + { + internal readonly string url; + private Guid language; + private Guid languageVendor; + private Guid documentType; + private ISymUnmanagedDocumentWriter unmanagedDocument; + + internal Document(string url, Guid language, Guid languageVendor, Guid documentType) + { + this.url = url; + this.language = language; + this.languageVendor = languageVendor; + this.documentType = documentType; + } + + public void SetCheckSum(Guid algorithmId, byte[] checkSum) + { + throw new NotImplementedException(); + } + + public void SetSource(byte[] source) + { + throw new NotImplementedException(); + } + + internal ISymUnmanagedDocumentWriter GetUnmanagedDocument(ISymUnmanagedWriter2 symUnmanagedWriter) + { + if (unmanagedDocument == null) + { + unmanagedDocument = symUnmanagedWriter.DefineDocument(url, ref language, ref languageVendor, ref documentType); + } + return unmanagedDocument; + } + + internal void Release() + { + if (unmanagedDocument != null) + { + Marshal.ReleaseComObject(unmanagedDocument); + unmanagedDocument = null; + } + } + } + + private sealed class LocalVar + { + internal readonly FieldAttributes attributes; + internal readonly int signature; + internal readonly SymAddressKind addrKind; + internal readonly int addr1; + internal readonly int addr2; + internal readonly int addr3; + internal readonly int startOffset; + internal readonly int endOffset; + + internal LocalVar(FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) + { + this.attributes = attributes; + this.signature = signature; + this.addrKind = addrKind; + this.addr1 = addr1; + this.addr2 = addr2; + this.addr3 = addr3; + this.startOffset = startOffset; + this.endOffset = endOffset; + } + } + + private sealed class Scope + { + internal readonly int startOffset; + internal int endOffset; + internal readonly List scopes = new List(); + internal readonly Dictionary locals = new Dictionary(); + + internal Scope(int startOffset) + { + this.startOffset = startOffset; + } + + internal void Do(ISymUnmanagedWriter2 symUnmanagedWriter) + { + symUnmanagedWriter.OpenScope(startOffset); + foreach (KeyValuePair kv in locals) + { + symUnmanagedWriter.DefineLocalVariable2(kv.Key, (int)kv.Value.attributes, kv.Value.signature, (int)kv.Value.addrKind, kv.Value.addr1, kv.Value.addr2, kv.Value.addr3, kv.Value.startOffset, kv.Value.endOffset); + } + foreach (Scope scope in scopes) + { + scope.Do(symUnmanagedWriter); + } + symUnmanagedWriter.CloseScope(endOffset); + } + } + + private sealed class Method + { + internal readonly int token; + internal Document document; + internal int[] offsets; + internal int[] lines; + internal int[] columns; + internal int[] endLines; + internal int[] endColumns; + internal readonly List scopes = new List(); + internal readonly Stack scopeStack = new Stack(); + + internal Method(int token) + { + this.token = token; + } + } + + public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) + { + Document doc; + if (!documents.TryGetValue(url, out doc)) + { + doc = new Document(url, language, languageVendor, documentType); + documents.Add(url, doc); + } + return doc; + } + + public void OpenMethod(SymbolToken method) + { + currentMethod = new Method(method.GetToken()); + } + + public void CloseMethod() + { + methods.Add(currentMethod); + currentMethod = null; + } + + public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) + { + currentMethod.document = (Document)document; + currentMethod.offsets = offsets; + currentMethod.lines = lines; + currentMethod.columns = columns; + currentMethod.endLines = endLines; + currentMethod.endColumns = endColumns; + } + + public int OpenScope(int startOffset) + { + Scope scope = new Scope(startOffset); + if (currentMethod.scopeStack.Count == 0) + { + currentMethod.scopes.Add(scope); + } + else + { + currentMethod.scopeStack.Peek().scopes.Add(scope); + } + currentMethod.scopeStack.Push(scope); + return 0; + } + + public void CloseScope(int endOffset) + { + currentMethod.scopeStack.Pop().endOffset = endOffset; + } + + public void DefineLocalVariable2(string name, FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) + { + currentMethod.scopeStack.Peek().locals[name] = new LocalVar(attributes, signature, addrKind, addr1, addr2, addr3, startOffset, endOffset); + } + + private void InitWriter() + { + if (symUnmanagedWriter == null) + { + string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb"); + // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what) + System.IO.File.Delete(fileName); + symUnmanagedWriter = new ISymUnmanagedWriter2(); + symUnmanagedWriter.Initialize(this, fileName, null, true); + } + } + + public byte[] GetDebugInfo(ref IMAGE_DEBUG_DIRECTORY idd) + { + InitWriter(); + uint cData; + symUnmanagedWriter.GetDebugInfo(ref idd, 0, out cData, null); + byte[] buf = new byte[cData]; + symUnmanagedWriter.GetDebugInfo(ref idd, (uint)buf.Length, out cData, buf); + return buf; + } + + public void RemapToken(int oldToken, int newToken) + { + remap.Add(oldToken, newToken); + reversemap.Add(newToken, oldToken); + } + + public void Close() + { + InitWriter(); + + foreach (Method method in methods) + { + int remappedToken = method.token; + remap.TryGetValue(remappedToken, out remappedToken); + symUnmanagedWriter.OpenMethod(remappedToken); + if (method.document != null) + { + ISymUnmanagedDocumentWriter doc = method.document.GetUnmanagedDocument(symUnmanagedWriter); + symUnmanagedWriter.DefineSequencePoints(doc, method.offsets.Length, method.offsets, method.lines, method.columns, method.endLines, method.endColumns); + } + foreach (Scope scope in method.scopes) + { + scope.Do(symUnmanagedWriter); + } + symUnmanagedWriter.CloseMethod(); + } + + foreach (Document doc in documents.Values) + { + doc.Release(); + } + + symUnmanagedWriter.Close(); + Marshal.ReleaseComObject(symUnmanagedWriter); + symUnmanagedWriter = null; + documents.Clear(); + methods.Clear(); + remap.Clear(); + reversemap.Clear(); + } + + public void DefineLocalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) + { + throw new NotImplementedException(); + } + + public void CloseNamespace() + { + throw new NotImplementedException(); + } + + public void DefineField(SymbolToken parent, string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + throw new NotImplementedException(); + } + + public void DefineGlobalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + throw new NotImplementedException(); + } + + public void DefineParameter(string name, System.Reflection.ParameterAttributes attributes, int sequence, SymAddressKind addrKind, int addr1, int addr2, int addr3) + { + throw new NotImplementedException(); + } + + public void Initialize(IntPtr emitter, string filename, bool fFullBuild) + { + throw new NotImplementedException(); + } + + public void OpenNamespace(string name) + { + throw new NotImplementedException(); + } + + public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) + { + throw new NotImplementedException(); + } + + public void SetScopeRange(int scopeID, int startOffset, int endOffset) + { + throw new NotImplementedException(); + } + + public void SetSymAttribute(SymbolToken parent, string name, byte[] data) + { + throw new NotImplementedException(); + } + + public void SetUnderlyingWriter(IntPtr underlyingWriter) + { + throw new NotImplementedException(); + } + + public void SetUserEntryPoint(SymbolToken entryMethod) + { + throw new NotImplementedException(); + } + + public void UsingNamespace(string fullName) + { + throw new NotImplementedException(); + } + + public void PlaceHolder_CloseEnum() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_CountEnum() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_ResetEnum() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumTypeDefs() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumInterfaceImpls() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumTypeRefs() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindTypeDefByName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetScopeProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetModuleFromScope() + { + throw new NotImplementedException(); + } + + private static void WriteString(IntPtr ptrString, IntPtr ptrLength, string str, int length) + { + if (ptrString != IntPtr.Zero) + { + for (int i = 0; i < Math.Min(length, str.Length); i++) + { + Marshal.WriteInt16(ptrString, i, str[i]); + } + } + if (ptrLength != IntPtr.Zero) + { + Marshal.WriteInt32(ptrLength, str.Length); + } + } + + private static void WriteToken(IntPtr ptr, MemberInfo member) + { + if (ptr != IntPtr.Zero) + { + Marshal.WriteInt32(ptr, member == null ? 0 : member.MetadataToken); + } + } + + private static void WriteInt32(IntPtr ptr, int value) + { + if (ptr != IntPtr.Zero) + { + Marshal.WriteInt32(ptr, value); + } + } + + public void GetTypeDefProps( + int td, // [IN] TypeDef token for inquiry. + IntPtr szTypeDef, // [OUT] Put name here. + int cchTypeDef, // [IN] size of name buffer in wide chars. + IntPtr pchTypeDef, // [OUT] put size of name (wide chars) here. + IntPtr pdwTypeDefFlags, // [OUT] Put flags here. + IntPtr ptkExtends) // [OUT] Put base class TypeDef/TypeRef here. + { + if (td == 0) + { + // why are we being called with an invalid token? + WriteString(szTypeDef, pchTypeDef, "", cchTypeDef); + WriteInt32(pdwTypeDefFlags, 0); + WriteToken(ptkExtends, null); + } + else + { + Type type = moduleBuilder.ResolveType(td); + WriteString(szTypeDef, pchTypeDef, type.FullName, cchTypeDef); + WriteInt32(pdwTypeDefFlags, (int)type.Attributes); + WriteToken(ptkExtends, type.BaseType); + } + } + + public void PlaceHolder_GetInterfaceImplProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetTypeRefProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_ResolveTypeRef() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMembers() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMembersWithName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMethods() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMethodsWithName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumFields() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumFieldsWithName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumParams() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMemberRefs() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMethodImpls() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumPermissionSets() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindMember() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindMethod() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindField() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindMemberRef() + { + throw new NotImplementedException(); + } + + public void GetMethodProps( + int mb, // The method for which to get props. + IntPtr pClass, // [OUT] Put method's class here. + IntPtr szMethod, // [OUT] Put method's name here. + int cchMethod, // Size of szMethod buffer in wide chars. + IntPtr pchMethod, // [OUT] Put actual size here + IntPtr pdwAttr, // [OUT] Put flags here. + IntPtr ppvSigBlob, // [OUT] point to the blob value of meta data + IntPtr pcbSigBlob, // [OUT] actual size of signature blob + IntPtr pulCodeRVA, // [OUT] codeRVA + IntPtr pdwImplFlags) // [OUT] Impl. Flags + { + if (pdwAttr != IntPtr.Zero || ppvSigBlob != IntPtr.Zero || pcbSigBlob != IntPtr.Zero || pulCodeRVA != IntPtr.Zero || pdwImplFlags != IntPtr.Zero) + { + throw new NotImplementedException(); + } + MethodBase method = moduleBuilder.ResolveMethod(reversemap[mb]); + WriteToken(pClass, method.DeclaringType); + WriteString(szMethod, pchMethod, method.Name, cchMethod); + } + + public void PlaceHolder_GetMemberRefProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumProperties() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumEvents() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetEventProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumMethodSemantics() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetMethodSemantics() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetClassLayout() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetFieldMarshal() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetRVA() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetPermissionSetProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetSigFromToken() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetModuleRefProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumModuleRefs() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetTypeSpecFromToken() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetNameFromToken() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumUnresolvedMethods() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetUserString() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetPinvokeMap() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumSignatures() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumTypeSpecs() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumUserStrings() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetParamForMethodIndex() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_EnumCustomAttributes() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetCustomAttributeProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_FindTypeRef() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetMemberProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetFieldProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetPropertyProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetParamProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetCustomAttributeByName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_IsValidToken() + { + throw new NotImplementedException(); + } + + public void GetNestedClassProps( + int tdNestedClass, // [IN] NestedClass token. + IntPtr ptdEnclosingClass) // [OUT] EnclosingClass token. + { + Type type = moduleBuilder.ResolveType(tdNestedClass); + WriteToken(ptdEnclosingClass, type.DeclaringType); + } + + public void PlaceHolder_GetNativeCallConvFromSig() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_IsGlobal() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetModuleProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_Save() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SaveToStream() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetSaveSize() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineTypeDef() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineNestedType() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetHandler() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineMethod() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineMethodImpl() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineTypeRefByName() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineImportType() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineMemberRef() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineImportMember() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineEvent() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetClassLayout() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DeleteClassLayout() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetFieldMarshal() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DeleteFieldMarshal() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefinePermissionSet() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetRVA() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetTokenFromSig() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineModuleRef() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetParent() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_GetTokenFromTypeSpec() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SaveToMemory() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineUserString() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DeleteToken() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetMethodProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetTypeDefProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetEventProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetPermissionSetProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefinePinvokeMap() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetPinvokeMap() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DeletePinvokeMap() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineCustomAttribute() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetCustomAttributeValue() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineField() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineProperty() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineParam() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetFieldProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetPropertyProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetParamProps() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_DefineSecurityAttributeSet() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_ApplyEditAndContinue() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_TranslateSigWithScope() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetMethodImplFlags() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_SetFieldRVA() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_Merge() + { + throw new NotImplementedException(); + } + + public void PlaceHolder_MergeEnd() + { + throw new NotImplementedException(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Impl/SymbolSupport.cs b/mcs/class/IKVM.Reflection/Impl/SymbolSupport.cs new file mode 100644 index 000000000000..945187ed0ea6 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Impl/SymbolSupport.cs @@ -0,0 +1,85 @@ +/* + Copyright (C) 2008, 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.InteropServices; +using System.Diagnostics.SymbolStore; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection.Impl +{ + [StructLayout(LayoutKind.Sequential)] + struct IMAGE_DEBUG_DIRECTORY + { + public uint Characteristics; + public uint TimeDateStamp; + public ushort MajorVersion; + public ushort MinorVersion; + public uint Type; + public uint SizeOfData; + public uint AddressOfRawData; + public uint PointerToRawData; + } + + interface ISymbolWriterImpl : ISymbolWriter + { + byte[] GetDebugInfo(ref IMAGE_DEBUG_DIRECTORY idd); + void RemapToken(int oldToken, int newToken); + void DefineLocalVariable2(string name, FieldAttributes attributes, int signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset); + } + + static class SymbolSupport + { + private static readonly bool runningOnMono = System.Type.GetType("Mono.Runtime") != null; + + internal static ISymbolWriterImpl CreateSymbolWriterFor(ModuleBuilder moduleBuilder) + { +#if !NO_SYMBOL_WRITER + throw new NotSupportedException ("IKVM.Reflection with no symbol writer support"); +#else + if (runningOnMono) + { +#if MONO + return new MdbWriter(moduleBuilder); +#else + throw new NotSupportedException("IKVM.Reflection must be compiled with MONO defined to support writing Mono debugging symbols."); +#endif + } + else + { + return new PdbWriter(moduleBuilder); + } +#endif + } + + internal static byte[] GetDebugInfo(ISymbolWriterImpl writer, ref IMAGE_DEBUG_DIRECTORY idd) + { + return writer.GetDebugInfo(ref idd); + } + + internal static void RemapToken(ISymbolWriterImpl writer, int oldToken, int newToken) + { + writer.RemapToken(oldToken, newToken); + } + } +} diff --git a/mcs/class/IKVM.Reflection/InterfaceMapping.cs b/mcs/class/IKVM.Reflection/InterfaceMapping.cs new file mode 100644 index 000000000000..f589cfe951dd --- /dev/null +++ b/mcs/class/IKVM.Reflection/InterfaceMapping.cs @@ -0,0 +1,35 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + public struct InterfaceMapping + { + public MethodInfo[] InterfaceMethods; + public Type InterfaceType; + public MethodInfo[] TargetMethods; + public Type TargetType; + } +} diff --git a/mcs/class/IKVM.Reflection/LocalVariableInfo.cs b/mcs/class/IKVM.Reflection/LocalVariableInfo.cs new file mode 100644 index 000000000000..a6875d9f0752 --- /dev/null +++ b/mcs/class/IKVM.Reflection/LocalVariableInfo.cs @@ -0,0 +1,56 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + public class LocalVariableInfo + { + private readonly int index; + private readonly Type type; + private readonly bool pinned; + + internal LocalVariableInfo(int index, Type type, bool pinned) + { + this.index = index; + this.type = type; + this.pinned = pinned; + } + + public virtual bool IsPinned + { + get { return pinned; } + } + + public virtual int LocalIndex + { + get { return index; } + } + + public virtual Type LocalType + { + get { return type; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/ManifestResourceInfo.cs b/mcs/class/IKVM.Reflection/ManifestResourceInfo.cs new file mode 100644 index 000000000000..a17b0d121471 --- /dev/null +++ b/mcs/class/IKVM.Reflection/ManifestResourceInfo.cs @@ -0,0 +1,91 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection +{ + public class ManifestResourceInfo + { + private readonly ModuleReader module; + private readonly int index; + + internal ManifestResourceInfo(ModuleReader module, int index) + { + this.module = module; + this.index = index; + } + + public ResourceLocation ResourceLocation + { + get + { + int implementation = module.ManifestResource.records[index].Implementation; + if ((implementation >> 24) == AssemblyRefTable.Index) + { + //return ResourceLocation.ContainedInAnotherAssembly; + throw new NotImplementedException(); + } + else if ((implementation >> 24) == FileTable.Index) + { + if ((implementation & 0xFFFFFF) == 0) + { + return ResourceLocation.ContainedInManifestFile | ResourceLocation.Embedded; + } + return 0; + } + else + { + throw new BadImageFormatException(); + } + } + } + + public Assembly ReferencedAssembly + { + get { throw new NotImplementedException(); } + } + + public string FileName + { + get + { + int implementation = module.ManifestResource.records[index].Implementation; + if ((implementation >> 24) == FileTable.Index) + { + if ((implementation & 0xFFFFFF) == 0) + { + return null; + } + else + { + return module.GetString(module.File.records[(implementation & 0xFFFFFF) - 1].Name); + } + } + throw new NotImplementedException(); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/MarshalSpec.cs b/mcs/class/IKVM.Reflection/MarshalSpec.cs new file mode 100644 index 000000000000..7078196d571f --- /dev/null +++ b/mcs/class/IKVM.Reflection/MarshalSpec.cs @@ -0,0 +1,299 @@ +/* + Copyright (C) 2008, 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection +{ + static class MarshalSpec + { + private const UnmanagedType NATIVE_TYPE_MAX = (UnmanagedType)0x50; + + internal static CustomAttributeData GetMarshalAsAttribute(Module module, int token) + { + // TODO use binary search? + for (int i = 0; i < module.FieldMarshal.records.Length; i++) + { + if (module.FieldMarshal.records[i].Parent == token) + { + ByteReader blob = module.GetBlob(module.FieldMarshal.records[i].NativeType); + UnmanagedType unmanagedType = (UnmanagedType)blob.ReadCompressedInt(); + UnmanagedType? arraySubType = null; + short? sizeParamIndex = null; + int? sizeConst = null; + VarEnum? safeArraySubType = null; + Type safeArrayUserDefinedSubType = null; + int? iidParameterIndex = null; + string marshalType = null; + string marshalCookie = null; + Type marshalTypeRef = null; + if (unmanagedType == UnmanagedType.LPArray) + { + arraySubType = (UnmanagedType)blob.ReadCompressedInt(); + if (arraySubType == NATIVE_TYPE_MAX) + { + arraySubType = null; + } + if (blob.Length != 0) + { + sizeParamIndex = (short)blob.ReadCompressedInt(); + if (blob.Length != 0) + { + sizeConst = blob.ReadCompressedInt(); + if (blob.Length != 0 && blob.ReadCompressedInt() == 0) + { + sizeParamIndex = null; + } + } + } + } + else if (unmanagedType == UnmanagedType.SafeArray) + { + if (blob.Length != 0) + { + safeArraySubType = (VarEnum)blob.ReadCompressedInt(); + if (blob.Length != 0) + { + safeArrayUserDefinedSubType = ReadType(module, blob); + } + } + } + else if (unmanagedType == UnmanagedType.ByValArray) + { + sizeConst = blob.ReadCompressedInt(); + if (blob.Length != 0) + { + arraySubType = (UnmanagedType)blob.ReadCompressedInt(); + } + } + else if (unmanagedType == UnmanagedType.ByValTStr) + { + sizeConst = blob.ReadCompressedInt(); + } + else if (unmanagedType == UnmanagedType.Interface + || unmanagedType == UnmanagedType.IDispatch + || unmanagedType == UnmanagedType.IUnknown) + { + if (blob.Length != 0) + { + iidParameterIndex = blob.ReadCompressedInt(); + } + } + else if (unmanagedType == UnmanagedType.CustomMarshaler) + { + blob.ReadCompressedInt(); + blob.ReadCompressedInt(); + marshalType = ReadString(blob); + marshalCookie = ReadString(blob); + marshalTypeRef = module.Assembly.GetType(marshalType) ?? module.universe.GetType(marshalType); + } + + Type typeofMarshalAs = module.universe.System_Runtime_InteropServices_MarshalAsAttribute; + Type typeofUnmanagedType = module.universe.System_Runtime_InteropServices_UnmanagedType; + Type typeofVarEnum = module.universe.System_Runtime_InteropServices_VarEnum; + Type typeofType = module.universe.System_Type; + List named = new List(); + if (arraySubType != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("ArraySubType"), new CustomAttributeTypedArgument(typeofUnmanagedType, arraySubType.Value))); + } + if (sizeParamIndex != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("SizeParamIndex"), new CustomAttributeTypedArgument(module.universe.System_Int16, sizeParamIndex.Value))); + } + if (sizeConst != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("SizeConst"), new CustomAttributeTypedArgument(module.universe.System_Int32, sizeConst.Value))); + } + if (safeArraySubType != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("SafeArraySubType"), new CustomAttributeTypedArgument(typeofVarEnum, safeArraySubType.Value))); + } + if (safeArrayUserDefinedSubType != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("SafeArrayUserDefinedSubType"), new CustomAttributeTypedArgument(typeofType, safeArrayUserDefinedSubType))); + } + if (iidParameterIndex != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("IidParameterIndex"), new CustomAttributeTypedArgument(module.universe.System_Int32, iidParameterIndex.Value))); + } + if (marshalType != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("MarshalType"), new CustomAttributeTypedArgument(module.universe.System_String, marshalType))); + } + if (marshalTypeRef != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("MarshalTypeRef"), new CustomAttributeTypedArgument(module.universe.System_Type, marshalTypeRef))); + } + if (marshalCookie != null) + { + named.Add(new CustomAttributeNamedArgument(typeofMarshalAs.GetField("MarshalCookie"), new CustomAttributeTypedArgument(module.universe.System_String, marshalCookie))); + } + ConstructorInfo constructor = typeofMarshalAs.GetConstructor(new Type[] { typeofUnmanagedType }); + return new CustomAttributeData(constructor, new object[] { unmanagedType }, named); + } + } + throw new BadImageFormatException(); + } + + internal static void SetMarshalAsAttribute(ModuleBuilder module, int token, CustomAttributeBuilder attribute) + { + attribute = attribute.DecodeBlob(module.Assembly); + FieldMarshalTable.Record rec = new FieldMarshalTable.Record(); + rec.Parent = token; + rec.NativeType = WriteMarshallingDescriptor(module, attribute); + module.FieldMarshal.AddRecord(rec); + } + + private static int WriteMarshallingDescriptor(ModuleBuilder module, CustomAttributeBuilder attribute) + { + UnmanagedType unmanagedType; + object val = attribute.GetConstructorArgument(0); + if (val is short) + { + unmanagedType = (UnmanagedType)(short)val; + } + else if (val is int) + { + unmanagedType = (UnmanagedType)(int)val; + } + else + { + unmanagedType = (UnmanagedType)val; + } + + ByteBuffer bb = new ByteBuffer(5); + bb.WriteCompressedInt((int)unmanagedType); + + if (unmanagedType == UnmanagedType.LPArray) + { + UnmanagedType arraySubType = attribute.GetFieldValue("ArraySubType") ?? NATIVE_TYPE_MAX; + bb.WriteCompressedInt((int)arraySubType); + int? sizeParamIndex = attribute.GetFieldValue("SizeParamIndex"); + int? sizeConst = attribute.GetFieldValue("SizeConst"); + if (sizeParamIndex != null) + { + bb.WriteCompressedInt(sizeParamIndex.Value); + if (sizeConst != null) + { + bb.WriteCompressedInt(sizeConst.Value); + bb.WriteCompressedInt(1); // flag that says that SizeParamIndex was specified + } + } + else if (sizeConst != null) + { + bb.WriteCompressedInt(0); // SizeParamIndex + bb.WriteCompressedInt(sizeConst.Value); + bb.WriteCompressedInt(0); // flag that says that SizeParamIndex was not specified + } + } + else if (unmanagedType == UnmanagedType.SafeArray) + { + VarEnum? safeArraySubType = attribute.GetFieldValue("SafeArraySubType"); + if (safeArraySubType != null) + { + bb.WriteCompressedInt((int)safeArraySubType); + Type safeArrayUserDefinedSubType = (Type)attribute.GetFieldValue("SafeArrayUserDefinedSubType"); + if (safeArrayUserDefinedSubType != null) + { + WriteType(module, bb, safeArrayUserDefinedSubType); + } + } + } + else if (unmanagedType == UnmanagedType.ByValArray) + { + bb.WriteCompressedInt(attribute.GetFieldValue("SizeConst") ?? 1); + UnmanagedType? arraySubType = attribute.GetFieldValue("ArraySubType"); + if (arraySubType != null) + { + bb.WriteCompressedInt((int)arraySubType); + } + } + else if (unmanagedType == UnmanagedType.ByValTStr) + { + bb.WriteCompressedInt(attribute.GetFieldValue("SizeConst").Value); + } + else if (unmanagedType == UnmanagedType.Interface + || unmanagedType == UnmanagedType.IDispatch + || unmanagedType == UnmanagedType.IUnknown) + { + int? iidParameterIndex = attribute.GetFieldValue("IidParameterIndex"); + if (iidParameterIndex != null) + { + bb.WriteCompressedInt(iidParameterIndex.Value); + } + } + else if (unmanagedType == UnmanagedType.CustomMarshaler) + { + bb.WriteCompressedInt(0); + bb.WriteCompressedInt(0); + string marshalType = (string)attribute.GetFieldValue("MarshalType"); + if (marshalType != null) + { + WriteString(bb, marshalType); + } + else + { + WriteType(module, bb, (Type)attribute.GetFieldValue("MarshalTypeRef")); + } + WriteString(bb, (string)attribute.GetFieldValue("MarshalCookie") ?? ""); + } + + return module.Blobs.Add(bb); + } + + private static Type ReadType(Module module, ByteReader br) + { + string str = ReadString(br); + if (str == "") + { + return null; + } + return module.Assembly.GetType(str) ?? module.universe.GetType(str, true); + } + + private static void WriteType(Module module, ByteBuffer bb, Type type) + { + WriteString(bb, type.Assembly == module.Assembly ? type.FullName : type.AssemblyQualifiedName); + } + + private static string ReadString(ByteReader br) + { + return Encoding.UTF8.GetString(br.ReadBytes(br.ReadCompressedInt())); + } + + private static void WriteString(ByteBuffer bb, string str) + { + byte[] buf = Encoding.UTF8.GetBytes(str); + bb.WriteCompressedInt(buf.Length); + bb.Write(buf); + } + } +} diff --git a/mcs/class/IKVM.Reflection/MemberInfo.cs b/mcs/class/IKVM.Reflection/MemberInfo.cs new file mode 100644 index 000000000000..5406c32d5100 --- /dev/null +++ b/mcs/class/IKVM.Reflection/MemberInfo.cs @@ -0,0 +1,81 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ +// disable warnings that complain about us having == and != operators without also overriding Equals/GetHashCode, +// this is intentional because most subtypes use reference equality +#pragma warning disable 660, 661 + public abstract class MemberInfo : ICustomAttributeProvider + { + public abstract string Name { get; } + public abstract Type DeclaringType { get; } + public abstract MemberTypes MemberType { get; } + + public virtual int MetadataToken + { + get { throw new NotSupportedException(); } + } + + public abstract Module Module + { + get; + } + + public bool IsDefined(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0; + } + + public IList __GetCustomAttributes(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit); + } + + public static bool operator ==(MemberInfo m1, MemberInfo m2) + { + return ReferenceEquals(m1, m2) || (!ReferenceEquals(m1, null) && m1.Equals(m2)); + } + + public static bool operator !=(MemberInfo m1, MemberInfo m2) + { + return !(m1 == m2); + } + + internal virtual IList GetCustomAttributesData(Type attributeType) + { + return this.Module.GetCustomAttributes(this.MetadataToken, attributeType); + } + + internal static bool BindingFlagsMatch(bool state, BindingFlags flags, BindingFlags trueFlag, BindingFlags falseFlag) + { + return (state && (flags & trueFlag) == trueFlag) + || (!state && (flags & falseFlag) == falseFlag); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Metadata/CliHeader.cs b/mcs/class/IKVM.Reflection/Metadata/CliHeader.cs new file mode 100644 index 000000000000..90258c336f5a --- /dev/null +++ b/mcs/class/IKVM.Reflection/Metadata/CliHeader.cs @@ -0,0 +1,92 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System.IO; + +namespace IKVM.Reflection.Metadata +{ + sealed class CliHeader + { + internal const uint COMIMAGE_FLAGS_ILONLY = 0x00000001; + internal const uint COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002; + internal const uint COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008; + internal const uint COMIMAGE_FLAGS_NATIVE_ENTRYPOINT = 0x00000010; + + internal uint Cb = 0x48; + internal ushort MajorRuntimeVersion; + internal ushort MinorRuntimeVersion; + internal uint MetaDataRVA; + internal uint MetaDataSize; + internal uint Flags; + internal uint EntryPointToken; + internal uint ResourcesRVA; + internal uint ResourcesSize; + internal uint StrongNameSignatureRVA; + internal uint StrongNameSignatureSize; + internal ulong CodeManagerTable; + internal uint VTableFixupsRVA; + internal uint VTableFixupsSize; + internal ulong ExportAddressTableJumps; + internal ulong ManagedNativeHeader; + + internal void Read(BinaryReader br) + { + Cb = br.ReadUInt32(); + MajorRuntimeVersion = br.ReadUInt16(); + MinorRuntimeVersion = br.ReadUInt16(); + MetaDataRVA = br.ReadUInt32(); + MetaDataSize = br.ReadUInt32(); + Flags = br.ReadUInt32(); + EntryPointToken = br.ReadUInt32(); + ResourcesRVA = br.ReadUInt32(); + ResourcesSize = br.ReadUInt32(); + StrongNameSignatureRVA = br.ReadUInt32(); + StrongNameSignatureSize = br.ReadUInt32(); + CodeManagerTable = br.ReadUInt32(); + VTableFixupsRVA = br.ReadUInt32(); + VTableFixupsSize = br.ReadUInt32(); + ExportAddressTableJumps = br.ReadUInt32(); + ManagedNativeHeader = br.ReadUInt32(); + } + + internal void Write(IKVM.Reflection.Writer.MetadataWriter mw) + { + mw.Write(Cb); + mw.Write(MajorRuntimeVersion); + mw.Write(MinorRuntimeVersion); + mw.Write(MetaDataRVA); + mw.Write(MetaDataSize); + mw.Write(Flags); + mw.Write(EntryPointToken); + mw.Write(ResourcesRVA); + mw.Write(ResourcesSize); + mw.Write(StrongNameSignatureRVA); + mw.Write(StrongNameSignatureSize); + mw.Write(CodeManagerTable); + mw.Write(VTableFixupsRVA); + mw.Write(VTableFixupsSize); + mw.Write(ExportAddressTableJumps); + mw.Write(ManagedNativeHeader); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Metadata/MetadataRW.cs b/mcs/class/IKVM.Reflection/Metadata/MetadataRW.cs new file mode 100644 index 000000000000..d03c8d628977 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Metadata/MetadataRW.cs @@ -0,0 +1,101 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection.Metadata +{ + // base class for MetadataReader and MetadataWriter + abstract class MetadataRW + { + internal readonly bool bigStrings; + internal readonly bool bigGuids; + internal readonly bool bigBlobs; + internal readonly bool bigResolutionScope; + internal readonly bool bigTypeDefOrRef; + internal readonly bool bigMemberRefParent; + internal readonly bool bigHasCustomAttribute; + internal readonly bool bigCustomAttributeType; + internal readonly bool bigMethodDefOrRef; + internal readonly bool bigHasConstant; + internal readonly bool bigHasSemantics; + internal readonly bool bigHasFieldMarshal; + internal readonly bool bigHasDeclSecurity; + internal readonly bool bigTypeOrMethodDef; + internal readonly bool bigMemberForwarded; + internal readonly bool bigImplementation; + internal readonly bool bigField; + internal readonly bool bigMethodDef; + internal readonly bool bigParam; + internal readonly bool bigTypeDef; + internal readonly bool bigProperty; + internal readonly bool bigEvent; + internal readonly bool bigGenericParam; + internal readonly bool bigModuleRef; + + protected MetadataRW(Module module, bool bigStrings, bool bigGuids, bool bigBlobs) + { + this.bigStrings = bigStrings; + this.bigGuids = bigGuids; + this.bigBlobs = bigBlobs; + this.bigField = module.Field.IsBig; + this.bigMethodDef = module.MethodDef.IsBig; + this.bigParam = module.Param.IsBig; + this.bigTypeDef = module.TypeDef.IsBig; + this.bigProperty = module.Property.IsBig; + this.bigEvent = module.Event.IsBig; + this.bigGenericParam = module.GenericParam.IsBig; + this.bigModuleRef = module.ModuleRef.IsBig; + this.bigResolutionScope = IsBig(2, module.ModuleTable, module.ModuleRef, module.AssemblyRef, module.TypeRef); + this.bigTypeDefOrRef = IsBig(2, module.TypeDef, module.TypeRef, module.TypeSpec); + this.bigMemberRefParent = IsBig(3, module.TypeDef, module.TypeRef, module.ModuleRef, module.MethodDef, module.TypeSpec); + this.bigMethodDefOrRef = IsBig(1, module.MethodDef, module.MemberRef); + this.bigHasCustomAttribute = IsBig(5, module.MethodDef, module.Field, module.TypeRef, module.TypeDef, module.Param, module.InterfaceImpl, module.MemberRef, + module.ModuleTable, /*module.Permission,*/ module.Property, module.Event, module.StandAloneSig, module.ModuleRef, module.TypeSpec, module.AssemblyTable, + module.AssemblyRef, module.File, module.ExportedType, module.ManifestResource); + this.bigCustomAttributeType = IsBig(3, module.MethodDef, module.MemberRef); + this.bigHasConstant = IsBig(2, module.Field, module.Param, module.Property); + this.bigHasSemantics = IsBig(1, module.Event, module.Property); + this.bigHasFieldMarshal = IsBig(1, module.Field, module.Param); + this.bigHasDeclSecurity = IsBig(2, module.TypeDef, module.MethodDef, module.AssemblyTable); + this.bigTypeOrMethodDef = IsBig(1, module.TypeDef, module.MethodDef); + this.bigMemberForwarded = IsBig(1, module.Field, module.MethodDef); + this.bigImplementation = IsBig(2, module.File, module.AssemblyRef, module.ExportedType); + } + + private static bool IsBig(int bitsUsed, params Table[] tables) + { + int limit = 1 << (16 - bitsUsed); + foreach (Table table in tables) + { + if (table.RowCount >= limit) + { + return true; + } + } + return false; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Metadata/Tables.cs b/mcs/class/IKVM.Reflection/Metadata/Tables.cs new file mode 100644 index 000000000000..d734330a48cf --- /dev/null +++ b/mcs/class/IKVM.Reflection/Metadata/Tables.cs @@ -0,0 +1,2483 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection.Metadata +{ + internal abstract class Table + { + internal bool IsBig + { + get { return RowCount > 65535; } + } + + internal abstract int RowCount { get; set; } + + internal abstract void Write(MetadataWriter mw); + internal abstract void Read(MetadataReader mr); + + internal int GetLength(MetadataWriter md) + { + return RowCount * GetRowSize(new RowSizeCalc(md)); + } + + protected abstract int GetRowSize(RowSizeCalc rsc); + + protected sealed class RowSizeCalc + { + private readonly MetadataWriter mw; + private int size; + + internal RowSizeCalc(MetadataWriter mw) + { + this.mw = mw; + } + + internal RowSizeCalc AddFixed(int size) + { + this.size += size; + return this; + } + + internal RowSizeCalc WriteStringIndex() + { + if (mw.bigStrings) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteGuidIndex() + { + if (mw.bigGuids) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteBlobIndex() + { + if (mw.bigBlobs) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteTypeDefOrRef() + { + if (mw.bigTypeDefOrRef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteField() + { + if (mw.bigField) + { + size += 4; + } + else + { + size += 2; + } + return this; + } + + internal RowSizeCalc WriteMethodDef() + { + if (mw.bigMethodDef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteParam() + { + if (mw.bigParam) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteResolutionScope() + { + if (mw.bigResolutionScope) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteMemberRefParent() + { + if (mw.bigMemberRefParent) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteHasCustomAttribute() + { + if (mw.bigHasCustomAttribute) + { + size += 4; + } + else + { + size += 2; + } + return this; + } + + internal RowSizeCalc WriteCustomAttributeType() + { + if (mw.bigCustomAttributeType) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteHasConstant() + { + if (mw.bigHasConstant) + { + size += 4; + } + else + { + size += 2; + } + return this; + } + + internal RowSizeCalc WriteTypeDef() + { + if (mw.bigTypeDef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteMethodDefOrRef() + { + if (mw.bigMethodDefOrRef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteEvent() + { + if (mw.bigEvent) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteProperty() + { + if (mw.bigProperty) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteHasSemantics() + { + if (mw.bigHasSemantics) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteImplementation() + { + if (mw.bigImplementation) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteTypeOrMethodDef() + { + if (mw.bigTypeOrMethodDef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteGenericParam() + { + if (mw.bigGenericParam) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteHasDeclSecurity() + { + if (mw.bigHasDeclSecurity) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteMemberForwarded() + { + if (mw.bigMemberForwarded) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteModuleRef() + { + if (mw.bigModuleRef) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal RowSizeCalc WriteHasFieldMarshal() + { + if (mw.bigHasFieldMarshal) + { + this.size += 4; + } + else + { + this.size += 2; + } + return this; + } + + internal int Value + { + get { return size; } + } + } + } + + abstract class Table : Table + { + internal T[] records = new T[1]; + protected int rowCount; + + internal sealed override int RowCount + { + get { return rowCount; } + set { rowCount = value; records = new T[value]; } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + throw new InvalidOperationException(); + } + + internal int AddRecord(T newRecord) + { + if (rowCount == records.Length) + { + T[] newarr = new T[records.Length * 2]; + Array.Copy(records, newarr, records.Length); + records = newarr; + } + records[rowCount++] = newRecord; + return rowCount; + } + + internal int AddVirtualRecord() + { + return ++rowCount; + } + + internal override void Write(MetadataWriter mw) + { + throw new InvalidOperationException(); + } + } + + sealed class ModuleTable : Table + { + internal const int Index = 0x00; + + internal struct Record + { + internal short Generation; + internal int Name; // -> StringHeap + internal int Mvid; // -> GuidHeap + internal int EncId; // -> GuidHeap + internal int EncBaseId; // -> GuidHeap + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Generation = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + records[i].Mvid = mr.ReadGuidIndex(); + records[i].EncId = mr.ReadGuidIndex(); + records[i].EncBaseId = mr.ReadGuidIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Generation); + mw.WriteStringIndex(records[i].Name); + mw.WriteGuidIndex(records[i].Mvid); + mw.WriteGuidIndex(records[i].EncId); + mw.WriteGuidIndex(records[i].EncBaseId); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteStringIndex() + .WriteGuidIndex() + .WriteGuidIndex() + .WriteGuidIndex() + .Value; + } + + internal void Add(short generation, int name, int mvid, int encid, int encbaseid) + { + Record record = new Record(); + record.Generation = generation; + record.Name = name; + record.Mvid = mvid; + record.EncId = encid; + record.EncBaseId = encbaseid; + AddRecord(record); + } + } + + sealed class TypeRefTable : Table + { + internal const int Index = 0x01; + + internal struct Record + { + internal int ResolutionScope; + internal int TypeName; + internal int TypeNameSpace; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].ResolutionScope = mr.ReadResolutionScope(); + records[i].TypeName = mr.ReadStringIndex(); + records[i].TypeNameSpace = mr.ReadStringIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteResolutionScope(records[i].ResolutionScope); + mw.WriteStringIndex(records[i].TypeName); + mw.WriteStringIndex(records[i].TypeNameSpace); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteResolutionScope() + .WriteStringIndex() + .WriteStringIndex() + .Value; + } + } + + sealed class TypeDefTable : Table + { + internal const int Index = 0x02; + + internal struct Record + { + internal int Flags; + internal int TypeName; + internal int TypeNamespace; + internal int Extends; + internal int FieldList; + internal int MethodList; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt32(); + records[i].TypeName = mr.ReadStringIndex(); + records[i].TypeNamespace = mr.ReadStringIndex(); + records[i].Extends = mr.ReadTypeDefOrRef(); + records[i].FieldList = mr.ReadField(); + records[i].MethodList = mr.ReadMethodDef(); + } + } + + internal override void Write(MetadataWriter mw) + { + mw.ModuleBuilder.WriteTypeDefTable(mw); + } + + internal int AllocToken() + { + return 0x02000000 + AddVirtualRecord(); + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteStringIndex() + .WriteStringIndex() + .WriteTypeDefOrRef() + .WriteField() + .WriteMethodDef() + .Value; + } + } + + sealed class FieldTable : Table + { + internal const int Index = 0x04; + + internal struct Record + { + internal short Flags; + internal int Name; + internal int Signature; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + records[i].Signature = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + mw.ModuleBuilder.WriteFieldTable(mw); + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteStringIndex() + .WriteBlobIndex() + .Value; + } + } + + sealed class MethodDefTable : Table + { + internal const int Index = 0x06; + private int baseRVA; + + internal struct Record + { + internal int RVA; + internal short ImplFlags; + internal short Flags; + internal int Name; + internal int Signature; + internal int ParamList; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].RVA = mr.ReadInt32(); + records[i].ImplFlags = mr.ReadInt16(); + records[i].Flags = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + records[i].Signature = mr.ReadBlobIndex(); + records[i].ParamList = mr.ReadParam(); + } + } + + internal override void Write(MetadataWriter mw) + { + mw.ModuleBuilder.WriteMethodDefTable(baseRVA, mw); + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(8) + .WriteStringIndex() + .WriteBlobIndex() + .WriteParam() + .Value; + } + + internal void Fixup(TextSection code) + { + baseRVA = (int)code.MethodBodiesRVA; + } + } + + sealed class ParamTable : Table + { + internal const int Index = 0x08; + + internal struct Record + { + internal short Flags; + internal short Sequence; + internal int Name; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt16(); + records[i].Sequence = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + mw.ModuleBuilder.WriteParamTable(mw); + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteStringIndex() + .Value; + } + } + + sealed class InterfaceImplTable : Table, IComparer + { + internal const int Index = 0x09; + + internal struct Record + { + internal int Class; + internal int Interface; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Class = mr.ReadTypeDef(); + records[i].Interface = mr.ReadTypeDefOrRef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteTypeDef(records[i].Class); + mw.WriteEncodedTypeDefOrRef(records[i].Interface); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteTypeDef() + .WriteTypeDefOrRef() + .Value; + } + + internal void Fixup() + { + for (int i = 0; i < rowCount; i++) + { + int token = records[i].Interface; + switch (token >> 24) + { + case 0: + break; + case TypeDefTable.Index: + token = (token & 0xFFFFFF) << 2 | 0; + break; + case TypeRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 1; + break; + case TypeSpecTable.Index: + token = (token & 0xFFFFFF) << 2 | 2; + break; + default: + throw new InvalidOperationException(); + } + records[i].Interface = token; + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + if (x.Class == y.Class) + { + return x.Interface == y.Interface ? 0 : (x.Interface > y.Interface ? 1 : -1); + } + return x.Class > y.Class ? 1 : -1; + } + } + + sealed class MemberRefTable : Table + { + internal const int Index = 0x0A; + + internal struct Record + { + internal int Class; + internal int Name; + internal int Signature; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Class = mr.ReadMemberRefParent(); + records[i].Name = mr.ReadStringIndex(); + records[i].Signature = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteMemberRefParent(records[i].Class); + mw.WriteStringIndex(records[i].Name); + mw.WriteBlobIndex(records[i].Signature); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteMemberRefParent() + .WriteStringIndex() + .WriteBlobIndex() + .Value; + } + + internal int FindOrAddRecord(Record record) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i].Class == record.Class + && records[i].Name == record.Name + && records[i].Signature == record.Signature) + { + return i + 1; + } + } + return AddRecord(record); + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].Class)) + { + records[i].Class = moduleBuilder.ResolvePseudoToken(records[i].Class); + } + } + } + } + + sealed class ConstantTable : Table, IComparer + { + internal const int Index = 0x0B; + + internal struct Record + { + internal short Type; + internal int Parent; + internal int Value; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Type = mr.ReadInt16(); + records[i].Parent = mr.ReadHasConstant(); + records[i].Value = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Type); + mw.WriteHasConstant(records[i].Parent); + mw.WriteBlobIndex(records[i].Value); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteHasConstant() + .WriteBlobIndex() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + int token = records[i].Parent; + if (moduleBuilder.IsPseudoToken(token)) + { + token = moduleBuilder.ResolvePseudoToken(token); + } + // do the HasConstant encoding, so that we can sort the table + switch (token >> 24) + { + case FieldTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 2 | 0; + break; + case ParamTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 2 | 1; + break; + case PropertyTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 2 | 2; + break; + default: + throw new InvalidOperationException(); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Parent == y.Parent ? 0 : (x.Parent > y.Parent ? 1 : -1); + } + + internal object GetRawConstantValue(Module module, int parent) + { + // TODO use binary search (if sorted) + for (int i = 0; i < module.Constant.records.Length; i++) + { + if (module.Constant.records[i].Parent == parent) + { + ByteReader br = module.GetBlob(module.Constant.records[i].Value); + switch (module.Constant.records[i].Type) + { + // see ModuleBuilder.AddConstant for the encodings + case Signature.ELEMENT_TYPE_BOOLEAN: + return br.ReadByte() != 0; + case Signature.ELEMENT_TYPE_I1: + return br.ReadSByte(); + case Signature.ELEMENT_TYPE_I2: + return br.ReadInt16(); + case Signature.ELEMENT_TYPE_I4: + return br.ReadInt32(); + case Signature.ELEMENT_TYPE_I8: + return br.ReadInt64(); + case Signature.ELEMENT_TYPE_U1: + return br.ReadByte(); + case Signature.ELEMENT_TYPE_U2: + return br.ReadUInt16(); + case Signature.ELEMENT_TYPE_U4: + return br.ReadUInt32(); + case Signature.ELEMENT_TYPE_U8: + return br.ReadUInt64(); + case Signature.ELEMENT_TYPE_R4: + return br.ReadSingle(); + case Signature.ELEMENT_TYPE_R8: + return br.ReadDouble(); + case Signature.ELEMENT_TYPE_CHAR: + return br.ReadChar(); + case Signature.ELEMENT_TYPE_STRING: + { + char[] chars = new char[br.Length / 2]; + for (int j = 0; j < chars.Length; j++) + { + chars[j] = br.ReadChar(); + } + return new String(chars); + } + case Signature.ELEMENT_TYPE_CLASS: + if (br.ReadInt32() != 0) + { + throw new BadImageFormatException(); + } + return null; + default: + throw new BadImageFormatException(); + } + } + } + throw new InvalidOperationException(); + } + } + + sealed class CustomAttributeTable : Table, IComparer + { + internal const int Index = 0x0C; + + internal struct Record + { + internal int Parent; + internal int Type; + internal int Value; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Parent = mr.ReadHasCustomAttribute(); + records[i].Type = mr.ReadCustomAttributeType(); + records[i].Value = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteHasCustomAttribute(records[i].Parent); + mw.WriteCustomAttributeType(records[i].Type); + mw.WriteBlobIndex(records[i].Value); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteHasCustomAttribute() + .WriteCustomAttributeType() + .WriteBlobIndex() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + int[] genericParamFixup = moduleBuilder.GenericParam.GetIndexFixup(); + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].Type)) + { + records[i].Type = moduleBuilder.ResolvePseudoToken(records[i].Type); + } + int token = records[i].Parent; + if (moduleBuilder.IsPseudoToken(token)) + { + token = moduleBuilder.ResolvePseudoToken(token); + } + // do the HasCustomAttribute encoding, so that we can sort the table + switch (token >> 24) + { + case MethodDefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 0; + break; + case FieldTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 1; + break; + case TypeRefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 2; + break; + case TypeDefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 3; + break; + case ParamTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 4; + break; + case InterfaceImplTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 5; + break; + case MemberRefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 6; + break; + case ModuleTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 7; + break; + // Permission (8) table doesn't exist in the spec + case PropertyTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 9; + break; + case EventTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 10; + break; + case StandAloneSigTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 11; + break; + case ModuleRefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 12; + break; + case TypeSpecTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 13; + break; + case AssemblyTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 14; + break; + case AssemblyRefTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 15; + break; + case FileTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 16; + break; + case ExportedTypeTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 17; + break; + case ManifestResourceTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 5 | 18; + break; + case GenericParamTable.Index: + records[i].Parent = (genericParamFixup[(token & 0xFFFFFF) - 1] + 1) << 5 | 19; + break; + default: + throw new InvalidOperationException(); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Parent == y.Parent ? 0 : (x.Parent > y.Parent ? 1 : -1); + } + } + + sealed class FieldMarshalTable : Table, IComparer + { + internal const int Index = 0x0D; + + internal struct Record + { + internal int Parent; + internal int NativeType; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Parent = mr.ReadHasFieldMarshal(); + records[i].NativeType = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteHasFieldMarshal(records[i].Parent); + mw.WriteBlobIndex(records[i].NativeType); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteHasFieldMarshal() + .WriteBlobIndex() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + int token = moduleBuilder.ResolvePseudoToken(records[i].Parent); + // do the HasFieldMarshal encoding, so that we can sort the table + switch (token >> 24) + { + case FieldTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 1 | 0; + break; + case ParamTable.Index: + records[i].Parent = (token & 0xFFFFFF) << 1 | 1; + break; + default: + throw new InvalidOperationException(); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Parent == y.Parent ? 0 : (x.Parent > y.Parent ? 1 : -1); + } + } + + sealed class DeclSecurityTable : Table, IComparer + { + internal const int Index = 0x0E; + + internal struct Record + { + internal short Action; + internal int Parent; + internal int PermissionSet; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Action = mr.ReadInt16(); + records[i].Parent = mr.ReadHasDeclSecurity(); + records[i].PermissionSet = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Action); + mw.WriteHasDeclSecurity(records[i].Parent); + mw.WriteBlobIndex(records[i].PermissionSet); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteHasDeclSecurity() + .WriteBlobIndex() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + int token = records[i].Parent; + if (moduleBuilder.IsPseudoToken(token)) + { + token = moduleBuilder.ResolvePseudoToken(token); + } + // do the HasDeclSecurity encoding, so that we can sort the table + switch (token >> 24) + { + case TypeDefTable.Index: + token = (token & 0xFFFFFF) << 2 | 0; + break; + case MethodDefTable.Index: + token = (token & 0xFFFFFF) << 2 | 1; + break; + case AssemblyTable.Index: + token = (token & 0xFFFFFF) << 2 | 2; + break; + default: + throw new InvalidOperationException(); + } + records[i].Parent = token; + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Parent == y.Parent ? 0 : (x.Parent > y.Parent ? 1 : -1); + } + } + + sealed class ClassLayoutTable : Table, IComparer + { + internal const int Index = 0x0f; + + internal struct Record + { + internal short PackingSize; + internal int ClassSize; + internal int Parent; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].PackingSize = mr.ReadInt16(); + records[i].ClassSize = mr.ReadInt32(); + records[i].Parent = mr.ReadTypeDef(); + } + } + + internal override void Write(MetadataWriter mw) + { + Array.Sort(records, 0, rowCount, this); + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].PackingSize); + mw.Write(records[i].ClassSize); + mw.WriteTypeDef(records[i].Parent); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(6) + .WriteTypeDef() + .Value; + } + + int IComparer.Compare(Record x, Record y) + { + return x.Parent == y.Parent ? 0 : (x.Parent > y.Parent ? 1 : -1); + } + + internal void GetLayout(int token, ref int pack, ref int size) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i].Parent == token) + { + pack = records[i].PackingSize; + size = records[i].ClassSize; + break; + } + } + } + } + + sealed class FieldLayoutTable : Table, IComparer + { + internal const int Index = 0x10; + + internal struct Record + { + internal int Offset; + internal int Field; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Offset = mr.ReadInt32(); + records[i].Field = mr.ReadField(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Offset); + mw.WriteField(records[i].Field); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteField() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + records[i].Field = moduleBuilder.ResolvePseudoToken(records[i].Field); + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Field == y.Field ? 0 : (x.Field > y.Field ? 1 : -1); + } + } + + sealed class StandAloneSigTable : Table + { + internal const int Index = 0x11; + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i] = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteBlobIndex(records[i]); + } + } + + protected override int GetRowSize(Table.RowSizeCalc rsc) + { + return rsc.WriteBlobIndex().Value; + } + + internal int FindOrAddRecord(int blob) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i] == blob) + { + return i + 1; + } + } + return AddRecord(blob); + } + } + + sealed class EventMapTable : Table + { + internal const int Index = 0x12; + + internal struct Record + { + internal int Parent; + internal int EventList; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Parent = mr.ReadTypeDef(); + records[i].EventList = mr.ReadEvent(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteTypeDef(records[i].Parent); + mw.WriteEvent(records[i].EventList); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteTypeDef() + .WriteEvent() + .Value; + } + } + + sealed class EventTable : Table + { + internal const int Index = 0x14; + + internal struct Record + { + internal short EventFlags; + internal int Name; + internal int EventType; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].EventFlags = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + records[i].EventType = mr.ReadTypeDefOrRef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].EventFlags); + mw.WriteStringIndex(records[i].Name); + mw.WriteTypeDefOrRef(records[i].EventType); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteStringIndex() + .WriteTypeDefOrRef() + .Value; + } + } + + sealed class PropertyMapTable : Table + { + internal const int Index = 0x15; + + internal struct Record + { + internal int Parent; + internal int PropertyList; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Parent = mr.ReadTypeDef(); + records[i].PropertyList = mr.ReadProperty(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteTypeDef(records[i].Parent); + mw.WriteProperty(records[i].PropertyList); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteTypeDef() + .WriteProperty() + .Value; + } + } + + sealed class PropertyTable : Table + { + internal const int Index = 0x17; + + internal struct Record + { + internal short Flags; + internal int Name; + internal int Type; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt16(); + records[i].Name = mr.ReadStringIndex(); + records[i].Type = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Flags); + mw.WriteStringIndex(records[i].Name); + mw.WriteBlobIndex(records[i].Type); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteStringIndex() + .WriteBlobIndex() + .Value; + } + } + + sealed class MethodSemanticsTable : Table, IComparer + { + internal const int Index = 0x18; + + // semantics + internal const short Setter = 0x0001; + internal const short Getter = 0x0002; + internal const short Other = 0x0004; + internal const short AddOn = 0x0008; + internal const short RemoveOn = 0x0010; + internal const short Fire = 0x0020; + + internal struct Record + { + internal short Semantics; + internal int Method; + internal int Association; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Semantics = mr.ReadInt16(); + records[i].Method = mr.ReadMethodDef(); + records[i].Association = mr.ReadHasSemantics(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Semantics); + mw.WriteMethodDef(records[i].Method); + mw.WriteHasSemantics(records[i].Association); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteMethodDef() + .WriteHasSemantics() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].Method)) + { + records[i].Method = moduleBuilder.ResolvePseudoToken(records[i].Method); + } + int token = records[i].Association; + // do the HasSemantics encoding, so that we can sort the table + switch (token >> 24) + { + case EventTable.Index: + token = (token & 0xFFFFFF) << 1 | 0; + break; + case PropertyTable.Index: + token = (token & 0xFFFFFF) << 1 | 1; + break; + default: + throw new InvalidOperationException(); + } + records[i].Association = token; + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Association == y.Association ? 0 : (x.Association > y.Association ? 1 : -1); + } + + internal MethodInfo GetMethod(Module module, int token, bool nonPublic, short semantics) + { + int i = 0; + return GetNextMethod(module, token, nonPublic, semantics, ref i); + } + + internal MethodInfo[] GetMethods(Module module, int token, bool nonPublic, short semantics) + { + List methods = new List(); + MethodInfo method; + for (int i = 0; (method = GetNextMethod(module, token, nonPublic, semantics, ref i)) != null; ) + { + methods.Add(method); + } + return methods.ToArray(); + } + + private MethodInfo GetNextMethod(Module module, int token, bool nonPublic, short semantics, ref int i) + { + // TODO use binary search? + for (; i < records.Length; i++) + { + if (records[i].Association == token) + { + if ((records[i].Semantics & semantics) != 0) + { + MethodInfo method = (MethodInfo)module.ResolveMethod((MethodDefTable.Index << 24) + records[i].Method); + if (nonPublic || method.IsPublic) + { + i++; + return method; + } + } + } + } + return null; + } + + internal void ComputeFlags(Module module, int token, out bool isPublic, out bool isStatic) + { + isPublic = false; + isStatic = false; + MethodInfo method; + for (int i = 0; (method = GetNextMethod(module, token, true, -1, ref i)) != null; ) + { + if (method.IsPublic) + { + isPublic = true; + } + if (method.IsStatic) + { + isStatic = true; + } + } + } + } + + sealed class MethodImplTable : Table, IComparer + { + internal const int Index = 0x19; + + internal struct Record + { + internal int Class; + internal int MethodBody; + internal int MethodDeclaration; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Class = mr.ReadTypeDef(); + records[i].MethodBody = mr.ReadMethodDefOrRef(); + records[i].MethodDeclaration = mr.ReadMethodDefOrRef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteTypeDef(records[i].Class); + mw.WriteMethodDefOrRef(records[i].MethodBody); + mw.WriteMethodDefOrRef(records[i].MethodDeclaration); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteTypeDef() + .WriteMethodDefOrRef() + .WriteMethodDefOrRef() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].MethodBody)) + { + records[i].MethodBody = moduleBuilder.ResolvePseudoToken(records[i].MethodBody); + } + if (moduleBuilder.IsPseudoToken(records[i].MethodDeclaration)) + { + records[i].MethodDeclaration = moduleBuilder.ResolvePseudoToken(records[i].MethodDeclaration); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Class == y.Class ? 0 : (x.Class > y.Class ? 1 : -1); + } + } + + sealed class ModuleRefTable : Table + { + internal const int Index = 0x1A; + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i] = mr.ReadStringIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteStringIndex(records[i]); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteStringIndex() + .Value; + } + + internal int FindOrAddRecord(int str) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i] == str) + { + return i + 1; + } + } + return AddRecord(str); + } + } + + sealed class TypeSpecTable : Table + { + internal const int Index = 0x1B; + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i] = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteBlobIndex(records[i]); + } + } + + protected override int GetRowSize(Table.RowSizeCalc rsc) + { + return rsc.WriteBlobIndex().Value; + } + } + + sealed class ImplMapTable : Table, IComparer + { + internal const int Index = 0x1C; + + internal struct Record + { + internal short MappingFlags; + internal int MemberForwarded; + internal int ImportName; + internal int ImportScope; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].MappingFlags = mr.ReadInt16(); + records[i].MemberForwarded = mr.ReadMemberForwarded(); + records[i].ImportName = mr.ReadStringIndex(); + records[i].ImportScope = mr.ReadModuleRef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].MappingFlags); + mw.WriteMemberForwarded(records[i].MemberForwarded); + mw.WriteStringIndex(records[i].ImportName); + mw.WriteModuleRef(records[i].ImportScope); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(2) + .WriteMemberForwarded() + .WriteStringIndex() + .WriteModuleRef() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].MemberForwarded)) + { + records[i].MemberForwarded = moduleBuilder.ResolvePseudoToken(records[i].MemberForwarded); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.MemberForwarded == y.MemberForwarded ? 0 : (x.MemberForwarded > y.MemberForwarded ? 1 : -1); + } + } + + sealed class FieldRVATable : Table, IComparer + { + internal const int Index = 0x1D; + + internal struct Record + { + internal int RVA; + internal int Field; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].RVA = mr.ReadInt32(); + records[i].Field = mr.ReadField(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].RVA); + mw.WriteField(records[i].Field); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteField() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder, int sdataRVA) + { + for (int i = 0; i < rowCount; i++) + { + records[i].RVA += sdataRVA; + if (moduleBuilder.IsPseudoToken(records[i].Field)) + { + records[i].Field = moduleBuilder.ResolvePseudoToken(records[i].Field); + } + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Field == y.Field ? 0 : (x.Field > y.Field ? 1 : -1); + } + } + + sealed class AssemblyTable : Table + { + internal const int Index = 0x20; + + internal struct Record + { + internal int HashAlgId; + internal ushort MajorVersion; + internal ushort MinorVersion; + internal ushort BuildNumber; + internal ushort RevisionNumber; + internal int Flags; + internal int PublicKey; + internal int Name; + internal int Culture; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].HashAlgId = mr.ReadInt32(); + records[i].MajorVersion = mr.ReadUInt16(); + records[i].MinorVersion = mr.ReadUInt16(); + records[i].BuildNumber = mr.ReadUInt16(); + records[i].RevisionNumber = mr.ReadUInt16(); + records[i].Flags = mr.ReadInt32(); + records[i].PublicKey = mr.ReadBlobIndex(); + records[i].Name = mr.ReadStringIndex(); + records[i].Culture = mr.ReadStringIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].HashAlgId); + mw.Write(records[i].MajorVersion); + mw.Write(records[i].MinorVersion); + mw.Write(records[i].BuildNumber); + mw.Write(records[i].RevisionNumber); + mw.Write(records[i].Flags); + mw.WriteBlobIndex(records[i].PublicKey); + mw.WriteStringIndex(records[i].Name); + mw.WriteStringIndex(records[i].Culture); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(16) + .WriteBlobIndex() + .WriteStringIndex() + .WriteStringIndex() + .Value; + } + } + + sealed class AssemblyRefTable : Table + { + internal const int Index = 0x23; + + internal struct Record + { + internal ushort MajorVersion; + internal ushort MinorVersion; + internal ushort BuildNumber; + internal ushort RevisionNumber; + internal int Flags; + internal int PublicKeyOrToken; + internal int Name; + internal int Culture; + internal int HashValue; + } + + internal int FindOrAddRecord(Record rec) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i].Name == rec.Name + && records[i].MajorVersion == rec.MajorVersion + && records[i].MinorVersion == rec.MinorVersion + && records[i].BuildNumber == rec.BuildNumber + && records[i].RevisionNumber == rec.RevisionNumber + && records[i].Flags == rec.Flags + && records[i].PublicKeyOrToken == rec.PublicKeyOrToken + && records[i].Culture == rec.Culture + && records[i].HashValue == rec.HashValue + ) + { + return i + 1; + } + } + return AddRecord(rec); + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].MajorVersion = mr.ReadUInt16(); + records[i].MinorVersion = mr.ReadUInt16(); + records[i].BuildNumber = mr.ReadUInt16(); + records[i].RevisionNumber = mr.ReadUInt16(); + records[i].Flags = mr.ReadInt32(); + records[i].PublicKeyOrToken = mr.ReadBlobIndex(); + records[i].Name = mr.ReadStringIndex(); + records[i].Culture = mr.ReadStringIndex(); + records[i].HashValue = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].MajorVersion); + mw.Write(records[i].MinorVersion); + mw.Write(records[i].BuildNumber); + mw.Write(records[i].RevisionNumber); + mw.Write(records[i].Flags); + mw.WriteBlobIndex(records[i].PublicKeyOrToken); + mw.WriteStringIndex(records[i].Name); + mw.WriteStringIndex(records[i].Culture); + mw.WriteBlobIndex(records[i].HashValue); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(12) + .WriteBlobIndex() + .WriteStringIndex() + .WriteStringIndex() + .WriteBlobIndex() + .Value; + } + } + + sealed class FileTable : Table + { + internal const int Index = 0x26; + + internal struct Record + { + internal int Flags; + internal int Name; + internal int HashValue; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt32(); + records[i].Name = mr.ReadStringIndex(); + records[i].HashValue = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Flags); + mw.WriteStringIndex(records[i].Name); + mw.WriteBlobIndex(records[i].HashValue); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteStringIndex() + .WriteBlobIndex() + .Value; + } + } + + sealed class ExportedTypeTable : Table + { + internal const int Index = 0x27; + + internal struct Record + { + internal int Flags; + internal int TypeDefId; + internal int TypeName; + internal int TypeNamespace; + internal int Implementation; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Flags = mr.ReadInt32(); + records[i].TypeDefId = mr.ReadInt32(); + records[i].TypeName = mr.ReadStringIndex(); + records[i].TypeNamespace = mr.ReadStringIndex(); + records[i].Implementation = mr.ReadImplementation(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Flags); + mw.Write(records[i].TypeDefId); + mw.WriteStringIndex(records[i].TypeName); + mw.WriteStringIndex(records[i].TypeNamespace); + mw.WriteImplementation(records[i].Implementation); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(8) + .WriteStringIndex() + .WriteStringIndex() + .WriteImplementation() + .Value; + } + + internal int FindOrAddRecord(Record rec) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i].Implementation == rec.Implementation + && records[i].TypeName == rec.TypeName + && records[i].TypeNamespace == rec.TypeNamespace) + { + return i + 1; + } + } + return AddRecord(rec); + } + } + + sealed class ManifestResourceTable : Table + { + internal const int Index = 0x28; + + internal struct Record + { + internal int Offset; + internal int Flags; + internal int Name; + internal int Implementation; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Offset = mr.ReadInt32(); + records[i].Flags = mr.ReadInt32(); + records[i].Name = mr.ReadStringIndex(); + records[i].Implementation = mr.ReadImplementation(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Offset); + mw.Write(records[i].Flags); + mw.WriteStringIndex(records[i].Name); + mw.WriteImplementation(records[i].Implementation); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(8) + .WriteStringIndex() + .WriteImplementation() + .Value; + } + } + + sealed class NestedClassTable : Table + { + internal const int Index = 0x29; + + internal struct Record + { + internal int NestedClass; + internal int EnclosingClass; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].NestedClass = mr.ReadTypeDef(); + records[i].EnclosingClass = mr.ReadTypeDef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteTypeDef(records[i].NestedClass); + mw.WriteTypeDef(records[i].EnclosingClass); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteTypeDef() + .WriteTypeDef() + .Value; + } + + internal List GetNestedClasses(int enclosingClass) + { + List nestedClasses = new List(); + for (int i = 0; i < rowCount; i++) + { + if (records[i].EnclosingClass == enclosingClass) + { + nestedClasses.Add(records[i].NestedClass); + } + } + return nestedClasses; + } + } + + sealed class GenericParamTable : Table, IComparer + { + internal const int Index = 0x2A; + + internal struct Record + { + internal short Number; + internal short Flags; + internal int Owner; + internal int Name; + // not part of the table, we use it to be able to fixup the GenericParamConstraint table + internal int unsortedIndex; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Number = mr.ReadInt16(); + records[i].Flags = mr.ReadInt16(); + records[i].Owner = mr.ReadTypeOrMethodDef(); + records[i].Name = mr.ReadStringIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.Write(records[i].Number); + mw.Write(records[i].Flags); + mw.WriteTypeOrMethodDef(records[i].Owner); + mw.WriteStringIndex(records[i].Name); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .AddFixed(4) + .WriteTypeOrMethodDef() + .WriteStringIndex() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + int token = records[i].Owner; + if (moduleBuilder.IsPseudoToken(token)) + { + token = moduleBuilder.ResolvePseudoToken(token); + } + // do the TypeOrMethodDef encoding, so that we can sort the table + switch (token >> 24) + { + case TypeDefTable.Index: + records[i].Owner = (token & 0xFFFFFF) << 1 | 0; + break; + case MethodDefTable.Index: + records[i].Owner = (token & 0xFFFFFF) << 1 | 1; + break; + default: + throw new InvalidOperationException(); + } + records[i].unsortedIndex = i; + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + if (x.Owner == y.Owner) + { + return x.Number == y.Number ? 0 : (x.Number > y.Number ? 1 : -1); + } + return x.Owner > y.Owner ? 1 : -1; + } + + internal GenericParameterAttributes GetAttributes(int token) + { + return (GenericParameterAttributes)records[(token & 0xFFFFFF) - 1].Flags; + } + + internal void PatchAttribute(int token, GenericParameterAttributes genericParameterAttributes) + { + records[(token & 0xFFFFFF) - 1].Flags = (short)genericParameterAttributes; + } + + internal int[] GetIndexFixup() + { + int[] array = new int[rowCount]; + for (int i = 0; i < rowCount; i++) + { + array[records[i].unsortedIndex] = i; + } + return array; + } + + internal int FindFirstByOwner(int token) + { + // TODO use binary search (if sorted) + for (int i = 0; i < records.Length; i++) + { + if (records[i].Owner == token) + { + return i; + } + } + return -1; + } + } + + sealed class MethodSpecTable : Table + { + internal const int Index = 0x2B; + + internal struct Record + { + internal int Method; + internal int Instantiation; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Method = mr.ReadMethodDefOrRef(); + records[i].Instantiation = mr.ReadBlobIndex(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteMethodDefOrRef(records[i].Method); + mw.WriteBlobIndex(records[i].Instantiation); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteMethodDefOrRef() + .WriteBlobIndex() + .Value; + } + + internal int FindOrAddRecord(Record record) + { + for (int i = 0; i < rowCount; i++) + { + if (records[i].Method == record.Method + && records[i].Instantiation == record.Instantiation) + { + return i + 1; + } + } + return AddRecord(record); + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + for (int i = 0; i < rowCount; i++) + { + if (moduleBuilder.IsPseudoToken(records[i].Method)) + { + records[i].Method = moduleBuilder.ResolvePseudoToken(records[i].Method); + } + } + } + } + + sealed class GenericParamConstraintTable : Table, IComparer + { + internal const int Index = 0x2C; + + internal struct Record + { + internal int Owner; + internal int Constraint; + } + + internal override void Read(MetadataReader mr) + { + for (int i = 0; i < records.Length; i++) + { + records[i].Owner = mr.ReadGenericParam(); + records[i].Constraint = mr.ReadTypeDefOrRef(); + } + } + + internal override void Write(MetadataWriter mw) + { + for (int i = 0; i < rowCount; i++) + { + mw.WriteGenericParam(records[i].Owner); + mw.WriteTypeDefOrRef(records[i].Constraint); + } + } + + protected override int GetRowSize(RowSizeCalc rsc) + { + return rsc + .WriteGenericParam() + .WriteTypeDefOrRef() + .Value; + } + + internal void Fixup(ModuleBuilder moduleBuilder) + { + int[] fixups = moduleBuilder.GenericParam.GetIndexFixup(); + for (int i = 0; i < rowCount; i++) + { + records[i].Owner = fixups[records[i].Owner - 1] + 1; + } + Array.Sort(records, 0, rowCount, this); + } + + int IComparer.Compare(Record x, Record y) + { + return x.Owner == y.Owner ? 0 : (x.Owner > y.Owner ? 1 : -1); + } + } +} diff --git a/mcs/class/IKVM.Reflection/MethodBase.cs b/mcs/class/IKVM.Reflection/MethodBase.cs new file mode 100644 index 000000000000..b7e4b8527e10 --- /dev/null +++ b/mcs/class/IKVM.Reflection/MethodBase.cs @@ -0,0 +1,139 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + public abstract class MethodBase : MemberInfo + { + internal abstract MethodSignature MethodSignature { get; } + internal abstract int ParameterCount { get; } + public abstract ParameterInfo[] GetParameters(); + public abstract MethodAttributes Attributes { get; } + public abstract MethodImplAttributes GetMethodImplementationFlags(); + public abstract MethodBody GetMethodBody(); + public abstract CallingConventions CallingConvention { get; } + + public bool IsConstructor + { + get + { + if ((this.Attributes & MethodAttributes.RTSpecialName) != 0) + { + string name = this.Name; + return name == ConstructorInfo.ConstructorName || name == ConstructorInfo.TypeConstructorName; + } + return false; + } + } + + public bool IsStatic + { + get { return (Attributes & MethodAttributes.Static) != 0; } + } + + public bool IsVirtual + { + get { return (Attributes & MethodAttributes.Virtual) != 0; } + } + + public bool IsAbstract + { + get { return (Attributes & MethodAttributes.Abstract) != 0; } + } + + public bool IsFinal + { + get { return (Attributes & MethodAttributes.Final) != 0; } + } + + public bool IsPublic + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; } + } + + public bool IsFamily + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; } + } + + public bool IsFamilyOrAssembly + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; } + } + + public bool IsAssembly + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; } + } + + public bool IsFamilyAndAssembly + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; } + } + + public bool IsPrivate + { + get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; } + } + + public bool IsSpecialName + { + get { return (Attributes & MethodAttributes.SpecialName) != 0; } + } + + public bool IsHideBySig + { + get { return (Attributes & MethodAttributes.HideBySig) != 0; } + } + + public virtual Type[] GetGenericArguments() + { + return Type.EmptyTypes; + } + + public virtual bool IsGenericMethod + { + get { return false; } + } + + public virtual bool IsGenericMethodDefinition + { + get { return false; } + } + + public virtual bool ContainsGenericParameters + { + get { return IsGenericMethodDefinition; } + } + + // This goes to the (uninstantiated) MethodInfo on the (uninstantiated) Type. For constructors + // it also has the effect of removing the ConstructorInfo wrapper and returning the underlying MethodInfo. + internal abstract MethodInfo GetMethodOnTypeDefinition(); + + internal abstract int ImportTo(Emit.ModuleBuilder module); + + internal abstract MethodBase BindTypeParameters(Type type); + } +} diff --git a/mcs/class/IKVM.Reflection/MethodBody.cs b/mcs/class/IKVM.Reflection/MethodBody.cs new file mode 100644 index 000000000000..7e14992bbe0b --- /dev/null +++ b/mcs/class/IKVM.Reflection/MethodBody.cs @@ -0,0 +1,161 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using IKVM.Reflection.Reader; +using System.IO; + +namespace IKVM.Reflection +{ + public sealed class MethodBody + { + private readonly IList exceptionClauses; + private readonly IList locals; + private readonly bool initLocals; + private readonly int maxStack; + private readonly int localVarSigTok; + private byte[] body; + + internal MethodBody(ModuleReader module, int rva, IGenericContext context) + { + const byte CorILMethod_TinyFormat = 0x02; + const byte CorILMethod_FatFormat = 0x03; + const byte CorILMethod_MoreSects = 0x08; + const byte CorILMethod_InitLocals = 0x10; + const byte CorILMethod_Sect_EHTable = 0x01; + const byte CorILMethod_Sect_FatFormat = 0x40; + const byte CorILMethod_Sect_MoreSects = 0x80; + + List exceptionClauses = new List(); + List locals = new List(); + module.SeekRVA(rva); + BinaryReader br = new BinaryReader(module.stream); + byte b = br.ReadByte(); + if ((b & 3) == CorILMethod_TinyFormat) + { + initLocals = true; + body = br.ReadBytes(b >> 2); + } + else if ((b & 3) == CorILMethod_FatFormat) + { + initLocals = (b & CorILMethod_InitLocals) != 0; + short flagsAndSize = (short)(b | (br.ReadByte() << 8)); + if ((flagsAndSize >> 12) != 3) + { + throw new BadImageFormatException("Fat format method header size should be 3"); + } + maxStack = br.ReadUInt16(); + int codeLength = br.ReadInt32(); + localVarSigTok = br.ReadInt32(); + body = br.ReadBytes(codeLength); + if ((b & CorILMethod_MoreSects) != 0) + { + module.stream.Position = (module.stream.Position + 3) & ~3; + int hdr = br.ReadInt32(); + if ((hdr & CorILMethod_Sect_MoreSects) != 0 || (hdr & CorILMethod_Sect_EHTable) == 0) + { + throw new NotImplementedException(); + } + else if ((hdr & CorILMethod_Sect_FatFormat) != 0) + { + int count = ComputeExceptionCount((hdr >> 8) & 0xFFFFFF, 24); + for (int i = 0; i < count; i++) + { + int flags = br.ReadInt32(); + int tryOffset = br.ReadInt32(); + int tryLength = br.ReadInt32(); + int handlerOffset = br.ReadInt32(); + int handlerLength = br.ReadInt32(); + int classTokenOrFilterOffset = br.ReadInt32(); + exceptionClauses.Add(new ExceptionHandlingClause(module, flags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset, context)); + } + } + else + { + int count = ComputeExceptionCount((hdr >> 8) & 0xFF, 12); + for (int i = 0; i < count; i++) + { + int flags = br.ReadUInt16(); + int tryOffset = br.ReadUInt16(); + int tryLength = br.ReadByte(); + int handlerOffset = br.ReadUInt16(); + int handlerLength = br.ReadByte(); + int classTokenOrFilterOffset = br.ReadInt32(); + exceptionClauses.Add(new ExceptionHandlingClause(module, flags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset, context)); + } + } + } + if (localVarSigTok != 0) + { + ByteReader sig = module.ResolveSignature(localVarSigTok); + Signature.ReadLocalVarSig(module, sig, context, locals); + } + } + else + { + throw new BadImageFormatException(); + } + this.exceptionClauses = exceptionClauses.AsReadOnly(); + this.locals = locals.AsReadOnly(); + } + + private static int ComputeExceptionCount(int size, int itemLength) + { + // LAMESPEC according to the spec, the count should be calculated as "(size - 4) / itemLength", + // FXBUG but to workaround a VB compiler bug that specifies the size incorrectly, + // we do a truncating division instead. + return size / itemLength; + } + + public IList ExceptionHandlingClauses + { + get { return exceptionClauses; } + } + + public bool InitLocals + { + get { return initLocals; } + } + + public IList LocalVariables + { + get { return locals; } + } + + public byte[] GetILAsByteArray() + { + return body; + } + + public int LocalSignatureMetadataToken + { + get { return localVarSigTok; } + } + + public int MaxStackSize + { + get { return maxStack; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/MethodImplMap.cs b/mcs/class/IKVM.Reflection/MethodImplMap.cs new file mode 100644 index 000000000000..bab829f60c98 --- /dev/null +++ b/mcs/class/IKVM.Reflection/MethodImplMap.cs @@ -0,0 +1,36 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + public struct __MethodImplMap + { + public Type TargetType; + public MethodInfo[] MethodBodies; + public MethodInfo[][] MethodDeclarations; + } +} diff --git a/mcs/class/IKVM.Reflection/MethodInfo.cs b/mcs/class/IKVM.Reflection/MethodInfo.cs new file mode 100644 index 000000000000..6d8e997c1b80 --- /dev/null +++ b/mcs/class/IKVM.Reflection/MethodInfo.cs @@ -0,0 +1,146 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Text; + +namespace IKVM.Reflection +{ + public abstract class MethodInfo : MethodBase, IGenericContext, IGenericBinder + { + public sealed override MemberTypes MemberType + { + get { return MemberTypes.Method; } + } + + public abstract Type ReturnType { get; } + public abstract ParameterInfo ReturnParameter { get; } + + public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) + { + throw new NotSupportedException(this.GetType().FullName); + } + + public virtual MethodInfo GetGenericMethodDefinition() + { + throw new NotSupportedException(this.GetType().FullName); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(this.ReturnType.Name).Append(' ').Append(this.Name); + string sep; + if (this.IsGenericMethod) + { + sb.Append('['); + sep = ""; + foreach (Type arg in GetGenericArguments()) + { + sb.Append(sep).Append(arg); + sep = ", "; + } + sb.Append(']'); + } + sb.Append('('); + sep = ""; + foreach (ParameterInfo arg in GetParameters()) + { + sb.Append(sep).Append(arg.ParameterType); + sep = ", "; + } + sb.Append(')'); + return sb.ToString(); + } + + internal bool IsNewSlot + { + get { return (this.Attributes & MethodAttributes.NewSlot) != 0; } + } + + public MethodInfo GetBaseDefinition() + { + MethodInfo match = this; + if (match.IsVirtual) + { + for (Type type = this.DeclaringType.BaseType; type != null && !match.IsNewSlot; type = type.BaseType) + { + MethodInfo method = type.FindMethod(this.Name, this.MethodSignature) as MethodInfo; + if (method != null && method.IsVirtual) + { + match = method; + } + } + } + return match; + } + + Type IGenericContext.GetGenericTypeArgument(int index) + { + return this.DeclaringType.GetGenericTypeArgument(index); + } + + Type IGenericContext.GetGenericMethodArgument(int index) + { + return GetGenericMethodArgument(index); + } + + internal virtual Type GetGenericMethodArgument(int index) + { + throw new InvalidOperationException(); + } + + internal virtual int GetGenericMethodArgumentCount() + { + throw new InvalidOperationException(); + } + + internal override MethodInfo GetMethodOnTypeDefinition() + { + return this; + } + + Type IGenericBinder.BindTypeParameter(Type type) + { + return this.DeclaringType.GetGenericTypeArgument(type.GenericParameterPosition); + } + + Type IGenericBinder.BindMethodParameter(Type type) + { + return GetGenericMethodArgument(type.GenericParameterPosition); + } + + internal override MethodBase BindTypeParameters(Type type) + { + return new GenericMethodInstance(this.DeclaringType.BindTypeParameters(type), this, null); + } + + // This method is used by ILGenerator and exists to allow ArrayMethod to override it, + // because ArrayMethod doesn't have a working MethodAttributes property, so it needs + // to base the result of this on the CallingConvention. + internal virtual bool HasThis + { + get { return !IsStatic; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/MethodSignature.cs b/mcs/class/IKVM.Reflection/MethodSignature.cs new file mode 100644 index 000000000000..8db04bc8e299 --- /dev/null +++ b/mcs/class/IKVM.Reflection/MethodSignature.cs @@ -0,0 +1,492 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection +{ + sealed class MethodSignature : Signature + { + private readonly Type returnType; + private readonly Type[] parameterTypes; + private readonly Type[][][] modifiers; // see PackedCustomModifiers + private readonly CallingConventions callingConvention; + private readonly int genericParamCount; + + private MethodSignature(Type returnType, Type[] parameterTypes, Type[][][] modifiers, CallingConventions callingConvention, int genericParamCount) + { + this.returnType = returnType; + this.parameterTypes = parameterTypes; + this.modifiers = modifiers; + this.callingConvention = callingConvention; + this.genericParamCount = genericParamCount; + } + + public override bool Equals(object obj) + { + MethodSignature other = obj as MethodSignature; + return other != null + && other.callingConvention == callingConvention + && other.genericParamCount == genericParamCount + && other.returnType.Equals(returnType) + && Util.ArrayEquals(other.parameterTypes, parameterTypes) + && Util.ArrayEquals(other.modifiers, modifiers); + } + + public override int GetHashCode() + { + return genericParamCount ^ 77 * (int)callingConvention + ^ 3 * returnType.GetHashCode() + ^ Util.GetHashCode(parameterTypes) * 5 + ^ Util.GetHashCode(modifiers) * 55; + } + + private sealed class UnboundGenericMethodContext : IGenericContext + { + private readonly IGenericContext original; + + internal UnboundGenericMethodContext(IGenericContext original) + { + this.original = original; + } + + public Type GetGenericTypeArgument(int index) + { + return original.GetGenericTypeArgument(index); + } + + public Type GetGenericMethodArgument(int index) + { + return UnboundGenericMethodParameter.Make(index); + } + } + + internal static MethodSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context) + { + CallingConventions callingConvention; + int genericParamCount; + Type returnType; + Type[] parameterTypes; + byte flags = br.ReadByte(); + switch (flags & 7) + { + case DEFAULT: + callingConvention = CallingConventions.Standard; + break; + case VARARG: + callingConvention = CallingConventions.VarArgs; + break; + default: + throw new BadImageFormatException(); + } + if ((flags & HASTHIS) != 0) + { + callingConvention |= CallingConventions.HasThis; + } + if ((flags & EXPLICITTHIS) != 0) + { + callingConvention |= CallingConventions.ExplicitThis; + } + genericParamCount = 0; + if ((flags & GENERIC) != 0) + { + genericParamCount = br.ReadCompressedInt(); + context = new UnboundGenericMethodContext(context); + } + int paramCount = br.ReadCompressedInt(); + Type[][][] modifiers = null; + Type[] optionalCustomModifiers; + Type[] requiredCustomModifiers; + ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers); + returnType = ReadRetType(module, br, context); + parameterTypes = new Type[paramCount]; + PackedCustomModifiers.SetModifiers(ref modifiers, 0, 0, optionalCustomModifiers, paramCount + 1); + PackedCustomModifiers.SetModifiers(ref modifiers, 0, 1, requiredCustomModifiers, paramCount + 1); + for (int i = 0; i < parameterTypes.Length; i++) + { + if ((callingConvention & CallingConventions.VarArgs) != 0 && br.PeekByte() == SENTINEL) + { + Array.Resize(ref parameterTypes, i); + if (modifiers != null) + { + Array.Resize(ref modifiers, i + 1); + } + break; + } + ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers); + PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 0, optionalCustomModifiers, paramCount + 1); + PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 1, requiredCustomModifiers, paramCount + 1); + parameterTypes[i] = ReadParam(module, br, context); + } + return new MethodSignature(returnType, parameterTypes, modifiers, callingConvention, genericParamCount); + } + + internal static __StandAloneMethodSig ReadStandAloneMethodSig(ModuleReader module, ByteReader br, IGenericContext context) + { + CallingConventions callingConvention = 0; + System.Runtime.InteropServices.CallingConvention unmanagedCallingConvention = 0; + bool unmanaged; + byte flags = br.ReadByte(); + switch (flags & 7) + { + case DEFAULT: + callingConvention = CallingConventions.Standard; + unmanaged = false; + break; + case 0x01: // C + unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl; + unmanaged = true; + break; + case 0x02: // STDCALL + unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall; + unmanaged = true; + break; + case 0x03: // THISCALL + unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall; + unmanaged = true; + break; + case 0x04: // FASTCALL + unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.FastCall; + unmanaged = true; + break; + case VARARG: + callingConvention = CallingConventions.VarArgs; + unmanaged = false; + break; + default: + throw new BadImageFormatException(); + } + if ((flags & HASTHIS) != 0) + { + callingConvention |= CallingConventions.HasThis; + } + if ((flags & EXPLICITTHIS) != 0) + { + callingConvention |= CallingConventions.ExplicitThis; + } + if ((flags & GENERIC) != 0) + { + throw new BadImageFormatException(); + } + int paramCount = br.ReadCompressedInt(); + SkipCustomModifiers(br); + Type returnType = ReadRetType(module, br, context); + List parameterTypes = new List(); + List optionalParameterTypes = new List(); + List curr = parameterTypes; + for (int i = 0; i < paramCount; i++) + { + if (br.PeekByte() == SENTINEL) + { + br.ReadByte(); + curr = optionalParameterTypes; + } + SkipCustomModifiers(br); + curr.Add(ReadParam(module, br, context)); + } + return new __StandAloneMethodSig(unmanaged, unmanagedCallingConvention, callingConvention, returnType, parameterTypes.ToArray(), optionalParameterTypes.ToArray()); + } + + internal int GetParameterCount() + { + return parameterTypes.Length; + } + + internal Type GetParameterType(int index) + { + return parameterTypes[index]; + } + + internal Type GetReturnType(IGenericBinder binder) + { + return returnType.BindTypeParameters(binder); + } + + internal Type[] GetReturnTypeOptionalCustomModifiers(IGenericBinder binder) + { + return BindTypeParameters(binder, modifiers, 0, 0); + } + + internal Type[] GetReturnTypeRequiredCustomModifiers(IGenericBinder binder) + { + return BindTypeParameters(binder, modifiers, 0, 1); + } + + internal Type GetParameterType(IGenericBinder binder, int index) + { + return parameterTypes[index].BindTypeParameters(binder); + } + + internal Type[] GetParameterOptionalCustomModifiers(IGenericBinder binder, int index) + { + return BindTypeParameters(binder, modifiers, index + 1, 0); + } + + internal Type[] GetParameterRequiredCustomModifiers(IGenericBinder binder, int index) + { + return BindTypeParameters(binder, modifiers, index + 1, 1); + } + + internal CallingConventions CallingConvention + { + get { return callingConvention; } + } + + private sealed class Binder : IGenericBinder + { + private readonly Type declaringType; + private readonly Type[] methodArgs; + + internal Binder(Type declaringType, Type[] methodArgs) + { + this.declaringType = declaringType; + this.methodArgs = methodArgs; + } + + public Type BindTypeParameter(Type type) + { + return declaringType.GetGenericTypeArgument(type.GenericParameterPosition); + } + + public Type BindMethodParameter(Type type) + { + if (methodArgs == null) + { + return type; + } + return methodArgs[type.GenericParameterPosition]; + } + } + + internal MethodSignature Bind(Type type, Type[] methodArgs) + { + Binder binder = new Binder(type, methodArgs); + return new MethodSignature(returnType.BindTypeParameters(binder), + BindTypeParameters(binder, parameterTypes), + BindTypeParameters(binder, modifiers), + callingConvention, genericParamCount); + } + + private sealed class Unbinder : IGenericBinder + { + internal static readonly Unbinder Instance = new Unbinder(); + + private Unbinder() + { + } + + public Type BindTypeParameter(Type type) + { + return type; + } + + public Type BindMethodParameter(Type type) + { + return UnboundGenericMethodParameter.Make(type.GenericParameterPosition); + } + } + + internal static MethodSignature MakeFromBuilder(Type returnType, Type[] parameterTypes, Type[][][] modifiers, CallingConventions callingConvention, int genericParamCount) + { + if (genericParamCount > 0) + { + returnType = returnType.BindTypeParameters(Unbinder.Instance); + parameterTypes = BindTypeParameters(Unbinder.Instance, parameterTypes); + modifiers = BindTypeParameters(Unbinder.Instance, modifiers); + } + return new MethodSignature(returnType, parameterTypes, modifiers, callingConvention, genericParamCount); + } + + internal bool MatchParameterTypes(Type[] types) + { + if (types == parameterTypes) + { + return true; + } + if (types == null) + { + return parameterTypes.Length == 0; + } + if (parameterTypes == null) + { + return types.Length == 0; + } + if (types.Length == parameterTypes.Length) + { + for (int i = 0; i < types.Length; i++) + { + if (!Util.TypeEquals(types[i], parameterTypes[i])) + { + return false; + } + } + return true; + } + return false; + } + + internal override void WriteSig(ModuleBuilder module, ByteBuffer bb) + { + WriteSigImpl(module, bb, parameterTypes.Length); + } + + internal void WriteMethodRefSig(ModuleBuilder module, ByteBuffer bb, Type[] optionalParameterTypes) + { + WriteSigImpl(module, bb, parameterTypes.Length + optionalParameterTypes.Length); + if (optionalParameterTypes.Length > 0) + { + bb.Write(SENTINEL); + foreach (Type type in optionalParameterTypes) + { + WriteType(module, bb, type); + } + } + } + + private void WriteSigImpl(ModuleBuilder module, ByteBuffer bb, int parameterCount) + { + byte first; + if ((callingConvention & CallingConventions.Any) == CallingConventions.VarArgs) + { + Debug.Assert(genericParamCount == 0); + first = VARARG; + } + else if (genericParamCount > 0) + { + first = GENERIC; + } + else + { + first = DEFAULT; + } + if ((callingConvention & CallingConventions.HasThis) != 0) + { + first |= HASTHIS; + } + if ((callingConvention & CallingConventions.ExplicitThis) != 0) + { + first |= EXPLICITTHIS; + } + bb.Write(first); + if (genericParamCount > 0) + { + bb.WriteCompressedInt(genericParamCount); + } + bb.WriteCompressedInt(parameterCount); + // RetType + if (modifiers != null && modifiers[0] != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, modifiers[0][0]); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, modifiers[0][1]); + } + WriteType(module, bb, returnType); + // Param + for (int i = 0; i < parameterTypes.Length; i++) + { + if (modifiers != null && modifiers[i + 1] != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, modifiers[i + 1][0]); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, modifiers[i + 1][1]); + } + WriteType(module, bb, parameterTypes[i]); + } + } + } + + static class PackedCustomModifiers + { + // modifiers are packed in a very specific way (and required to be so, otherwise equality checks will fail) + // For modifiers[x][y][z]: + // x = parameter index, 0 = return type, 1 = first parameters, ... + // y = 0 = optional custom modifiers, 1 = required custom modifiers + // z = the custom modifiers + // At any level the reference can be null (and *must* be null, if there are no modifiers below that level). + // Empty arrays are not allowed at any level. + + // this can be used to "add" elements to the modifiers array (and the elements are assumed to already be in normalized form) + internal static void SetModifiers(ref Type[][][] modifiers, int index, int optOrReq, Type[] add, int count) + { + if (add != null) + { + if (modifiers == null) + { + modifiers = new Type[count][][]; + } + if (modifiers[index] == null) + { + modifiers[index] = new Type[2][]; + } + modifiers[index][optOrReq] = add; + } + } + + // this method make a copy of the incoming arrays (where necessary) and returns a normalized modifiers array + internal static Type[][][] CreateFromExternal(Type[] returnOptional, Type[] returnRequired, Type[][] parameterOptional, Type[][] parameterRequired, int parameterCount) + { + Type[][][] modifiers = null; + SetModifiers(ref modifiers, 0, 0, NormalizeAndCopy(returnOptional), parameterCount + 1); + SetModifiers(ref modifiers, 0, 1, NormalizeAndCopy(returnRequired), parameterCount + 1); + for (int i = 0; i < parameterCount; i++) + { + SetModifiers(ref modifiers, i + 1, 0, NormalizeAndCopy(parameterOptional, i), parameterCount + 1); + SetModifiers(ref modifiers, i + 1, 1, NormalizeAndCopy(parameterRequired, i), parameterCount + 1); + } + return modifiers; + } + + private static Type[] NormalizeAndCopy(Type[] array) + { + if (array == null || array.Length == 0) + { + return null; + } + Type[] copy = null; + for (int i = 0; i < array.Length; i++) + { + if (array[i] != null) + { + if (copy == null) + { + copy = new Type[array.Length]; + } + copy[i] = array[i]; + } + } + return copy; + } + + private static Type[] NormalizeAndCopy(Type[][] array, int index) + { + if (array == null || array.Length == 0) + { + return null; + } + return NormalizeAndCopy(array[index]); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Module.cs b/mcs/class/IKVM.Reflection/Module.cs new file mode 100644 index 000000000000..a481ae2383bd --- /dev/null +++ b/mcs/class/IKVM.Reflection/Module.cs @@ -0,0 +1,462 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using IKVM.Reflection.Metadata; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + public sealed class RawModule : IDisposable + { + private readonly ModuleReader module; + private readonly bool isManifestModule; + private bool imported; + + internal RawModule(ModuleReader module) + { + this.module = module; + this.isManifestModule = module.Assembly != null; + } + + public string Location + { + get { return module.FullyQualifiedName; } + } + + public bool IsManifestModule + { + get { return isManifestModule; } + } + + private void CheckManifestModule() + { + if (!IsManifestModule) + { + throw new BadImageFormatException("Module does not contain a manifest"); + } + } + + public AssemblyName GetAssemblyName() + { + CheckManifestModule(); + return module.Assembly.GetName(); + } + + public AssemblyName[] GetReferencedAssemblies() + { + return module.__GetReferencedAssemblies(); + } + + public void Dispose() + { + if (!imported) + { + module.stream.Dispose(); + } + } + + internal Assembly ToAssembly() + { + if (imported) + { + throw new InvalidOperationException(); + } + imported = true; + return module.Assembly; + } + + internal Module ToModule(Assembly assembly) + { + if (module.Assembly != null) + { + throw new InvalidOperationException(); + } + imported = true; + module.SetAssembly(assembly); + return module; + } + } + + public abstract class Module : ICustomAttributeProvider + { + internal readonly Universe universe; + internal readonly ModuleTable ModuleTable = new ModuleTable(); + internal readonly TypeRefTable TypeRef = new TypeRefTable(); + internal readonly TypeDefTable TypeDef = new TypeDefTable(); + internal readonly FieldTable Field = new FieldTable(); + internal readonly MemberRefTable MemberRef = new MemberRefTable(); + internal readonly ConstantTable Constant = new ConstantTable(); + internal readonly CustomAttributeTable CustomAttribute = new CustomAttributeTable(); + internal readonly FieldMarshalTable FieldMarshal = new FieldMarshalTable(); + internal readonly DeclSecurityTable DeclSecurity = new DeclSecurityTable(); + internal readonly ClassLayoutTable ClassLayout = new ClassLayoutTable(); + internal readonly FieldLayoutTable FieldLayout = new FieldLayoutTable(); + internal readonly ParamTable Param = new ParamTable(); + internal readonly InterfaceImplTable InterfaceImpl = new InterfaceImplTable(); + internal readonly StandAloneSigTable StandAloneSig = new StandAloneSigTable(); + internal readonly EventMapTable EventMap = new EventMapTable(); + internal readonly EventTable Event = new EventTable(); + internal readonly PropertyMapTable PropertyMap = new PropertyMapTable(); + internal readonly PropertyTable Property = new PropertyTable(); + internal readonly MethodSemanticsTable MethodSemantics = new MethodSemanticsTable(); + internal readonly MethodImplTable MethodImpl = new MethodImplTable(); + internal readonly ModuleRefTable ModuleRef = new ModuleRefTable(); + internal readonly TypeSpecTable TypeSpec = new TypeSpecTable(); + internal readonly ImplMapTable ImplMap = new ImplMapTable(); + internal readonly FieldRVATable FieldRVA = new FieldRVATable(); + internal readonly AssemblyTable AssemblyTable = new AssemblyTable(); + internal readonly AssemblyRefTable AssemblyRef = new AssemblyRefTable(); + internal readonly MethodDefTable MethodDef = new MethodDefTable(); + internal readonly NestedClassTable NestedClass = new NestedClassTable(); + internal readonly FileTable File = new FileTable(); + internal readonly ExportedTypeTable ExportedType = new ExportedTypeTable(); + internal readonly ManifestResourceTable ManifestResource = new ManifestResourceTable(); + internal readonly GenericParamTable GenericParam = new GenericParamTable(); + internal readonly MethodSpecTable MethodSpec = new MethodSpecTable(); + internal readonly GenericParamConstraintTable GenericParamConstraint = new GenericParamConstraintTable(); + + internal Module(Universe universe) + { + this.universe = universe; + } + + internal Table[] GetTables() + { + Table[] tables = new Table[64]; + tables[ModuleTable.Index] = ModuleTable; + tables[TypeRefTable.Index] = TypeRef; + tables[TypeDefTable.Index] = TypeDef; + tables[FieldTable.Index] = Field; + tables[MemberRefTable.Index] = MemberRef; + tables[ConstantTable.Index] = Constant; + tables[CustomAttributeTable.Index] = CustomAttribute; + tables[FieldMarshalTable.Index] = FieldMarshal; + tables[DeclSecurityTable.Index] = DeclSecurity; + tables[ClassLayoutTable.Index] = ClassLayout; + tables[FieldLayoutTable.Index] = FieldLayout; + tables[ParamTable.Index] = Param; + tables[InterfaceImplTable.Index] = InterfaceImpl; + tables[StandAloneSigTable.Index] = StandAloneSig; + tables[EventMapTable.Index] = EventMap; + tables[EventTable.Index] = Event; + tables[PropertyMapTable.Index] = PropertyMap; + tables[PropertyTable.Index] = Property; + tables[MethodSemanticsTable.Index] = MethodSemantics; + tables[MethodImplTable.Index] = MethodImpl; + tables[ModuleRefTable.Index] = ModuleRef; + tables[TypeSpecTable.Index] = TypeSpec; + tables[ImplMapTable.Index] = ImplMap; + tables[FieldRVATable.Index] = FieldRVA; + tables[AssemblyTable.Index] = AssemblyTable; + tables[AssemblyRefTable.Index] = AssemblyRef; + tables[MethodDefTable.Index] = MethodDef; + tables[NestedClassTable.Index] = NestedClass; + tables[FileTable.Index] = File; + tables[ExportedTypeTable.Index] = ExportedType; + tables[ManifestResourceTable.Index] = ManifestResource; + tables[GenericParamTable.Index] = GenericParam; + tables[MethodSpecTable.Index] = MethodSpec; + tables[GenericParamConstraintTable.Index] = GenericParamConstraint; + return tables; + } + + public virtual void __GetDataDirectoryEntry(int index, out int rva, out int length) + { + throw new NotSupportedException(); + } + + public virtual long __RelativeVirtualAddressToFileOffset(int rva) + { + throw new NotSupportedException(); + } + + public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) + { + throw new NotSupportedException(); + } + + public virtual int __Subsystem + { + get { throw new NotSupportedException(); } + } + + public FieldInfo GetField(string name) + { + return IsResource() ? null : GetModuleType().GetField(name); + } + + public FieldInfo GetField(string name, BindingFlags bindingFlags) + { + return IsResource() ? null : GetModuleType().GetField(name, bindingFlags); + } + + public FieldInfo[] GetFields() + { + return IsResource() ? Empty.Array : GetModuleType().GetFields(); + } + + public FieldInfo[] GetFields(BindingFlags bindingFlags) + { + return IsResource() ? Empty.Array : GetModuleType().GetFields(bindingFlags); + } + + public MethodInfo GetMethod(string name) + { + return IsResource() ? null : GetModuleType().GetMethod(name); + } + + public MethodInfo GetMethod(string name, Type[] types) + { + return IsResource() ? null : GetModuleType().GetMethod(name, types); + } + + public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) + { + return IsResource() ? null : GetModuleType().GetMethod(name, bindingAttr, binder, callConv, types, modifiers); + } + + public MethodInfo[] GetMethods() + { + return IsResource() ? Empty.Array : GetModuleType().GetMethods(); + } + + public MethodInfo[] GetMethods(BindingFlags bindingFlags) + { + return IsResource() ? Empty.Array : GetModuleType().GetMethods(bindingFlags); + } + + public ConstructorInfo __ModuleInitializer + { + get { return IsResource() ? null : GetModuleType().TypeInitializer; } + } + + public byte[] ResolveSignature(int metadataToken) + { + ModuleReader rdr = this as ModuleReader; + if (rdr != null) + { + ByteReader br = rdr.ResolveSignature(metadataToken); + return br.ReadBytes(br.Length); + } + throw new NotSupportedException(); + } + + public virtual __StandAloneMethodSig __ResolveStandAloneMethodSig(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotSupportedException(); + } + + public int MetadataToken + { + get { return IsResource() ? 0 : 1; } + } + + public abstract int MDStreamVersion { get ;} + public abstract Assembly Assembly { get; } + public abstract string FullyQualifiedName { get; } + public abstract string Name { get; } + public abstract Guid ModuleVersionId { get; } + public abstract Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments); + public abstract MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments); + public abstract FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments); + public abstract MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments); + + public abstract string ResolveString(int metadataToken); + public abstract Type[] __ResolveOptionalParameterTypes(int metadataToken); + public abstract string ScopeName { get; } + + internal abstract Type GetTypeImpl(string typeName); + internal abstract void GetTypesImpl(List list); + + public Type GetType(string className) + { + return GetType(className, false, false); + } + + public Type GetType(string className, bool ignoreCase) + { + return GetType(className, false, ignoreCase); + } + + public Type GetType(string className, bool throwOnError, bool ignoreCase) + { + if (ignoreCase) + { + throw new NotImplementedException(); + } + TypeNameParser parser = TypeNameParser.Parse(className, throwOnError); + if (parser.Error) + { + return null; + } + if (parser.AssemblyName != null) + { + if (throwOnError) + { + throw new ArgumentException("Type names passed to Module.GetType() must not specify an assembly."); + } + else + { + return null; + } + } + return parser.Expand(GetTypeImpl(parser.FirstNamePart), this.Assembly, throwOnError, className); + } + + public Type[] GetTypes() + { + List list = new List(); + GetTypesImpl(list); + return list.ToArray(); + } + + public Type[] FindTypes(TypeFilter filter, object filterCriteria) + { + List list = new List(); + foreach (Type type in GetTypes()) + { + if (filter(type, filterCriteria)) + { + list.Add(type); + } + } + return list.ToArray(); + } + + public virtual bool IsResource() + { + return false; + } + + public Type ResolveType(int metadataToken) + { + return ResolveType(metadataToken, null, null); + } + + public MethodBase ResolveMethod(int metadataToken) + { + return ResolveMethod(metadataToken, null, null); + } + + public FieldInfo ResolveField(int metadataToken) + { + return ResolveField(metadataToken, null, null); + } + + public MemberInfo ResolveMember(int metadataToken) + { + return ResolveMember(metadataToken, null, null); + } + + public bool IsDefined(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0; + } + + public IList __GetCustomAttributes(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit); + } + + public virtual IList __GetPlaceholderAssemblyCustomAttributes(bool multiple, bool security) + { + return Empty.Array; + } + + public abstract AssemblyName[] __GetReferencedAssemblies(); + + internal Type CanonicalizeType(Type type) + { + Type canon; + if (!universe.canonicalizedTypes.TryGetValue(type, out canon)) + { + canon = type; + universe.canonicalizedTypes.Add(canon, canon); + } + return canon; + } + + internal abstract Type GetModuleType(); + + internal abstract ByteReader GetBlob(int blobIndex); + + internal IList GetCustomAttributesData(Type attributeType) + { + return GetCustomAttributes(0x00000001, attributeType); + } + + internal List GetCustomAttributes(int metadataToken, Type attributeType) + { + List list = new List(); + // TODO use binary search? + for (int i = 0; i < CustomAttribute.records.Length; i++) + { + if (CustomAttribute.records[i].Parent == metadataToken) + { + if (attributeType == null) + { + list.Add(new CustomAttributeData(this, i)); + } + else + { + ConstructorInfo constructor = (ConstructorInfo)ResolveMethod(CustomAttribute.records[i].Type); + if (attributeType.IsAssignableFrom(constructor.DeclaringType)) + { + list.Add(new CustomAttributeData(this.Assembly, constructor, GetBlob(CustomAttribute.records[i].Value))); + } + } + } + } + return list; + } + + internal IList GetDeclarativeSecurity(int metadataToken) + { + List list = new List(); + // TODO use binary search? + for (int i = 0; i < DeclSecurity.records.Length; i++) + { + if (DeclSecurity.records[i].Parent == metadataToken) + { + int action = DeclSecurity.records[i].Action; + int permissionSet = DeclSecurity.records[i].PermissionSet; + CustomAttributeData.ReadDeclarativeSecurity(this.Assembly, list, action, GetBlob(permissionSet)); + } + } + return list; + } + + internal virtual void Dispose() + { + } + + internal virtual void ExportTypes(int fileToken, IKVM.Reflection.Emit.ModuleBuilder manifestModule) + { + } + } + + public delegate bool TypeFilter(Type m, object filterCriteria); + public delegate bool MemberFilter(MemberInfo m, object filterCriteria); +} diff --git a/mcs/class/IKVM.Reflection/ParameterInfo.cs b/mcs/class/IKVM.Reflection/ParameterInfo.cs new file mode 100644 index 000000000000..6bc2fff0564e --- /dev/null +++ b/mcs/class/IKVM.Reflection/ParameterInfo.cs @@ -0,0 +1,102 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System.Collections.Generic; + +namespace IKVM.Reflection +{ + public abstract class ParameterInfo : ICustomAttributeProvider + { + public sealed override bool Equals(object obj) + { + ParameterInfo other = obj as ParameterInfo; + return other != null && other.Member == this.Member && other.Position == this.Position; + } + + public sealed override int GetHashCode() + { + return this.Member.GetHashCode() * 1777 + this.Position; + } + + public static bool operator ==(ParameterInfo p1, ParameterInfo p2) + { + return ReferenceEquals(p1, p2) || (!ReferenceEquals(p1, null) && p1.Equals(p2)); + } + + public static bool operator !=(ParameterInfo p1, ParameterInfo p2) + { + return !(p1 == p2); + } + + public abstract string Name { get; } + public abstract Type ParameterType { get; } + public abstract ParameterAttributes Attributes { get; } + public abstract int Position { get; } + public abstract object RawDefaultValue { get; } + public abstract Type[] GetOptionalCustomModifiers(); + public abstract Type[] GetRequiredCustomModifiers(); + public abstract MemberInfo Member { get; } + public abstract int MetadataToken { get; } + internal abstract Module Module { get; } + + public bool IsIn + { + get { return (Attributes & ParameterAttributes.In) != 0; } + } + + public bool IsOut + { + get { return (Attributes & ParameterAttributes.Out) != 0; } + } + + public bool IsLcid + { + get { return (Attributes & ParameterAttributes.Lcid) != 0; } + } + + public bool IsRetval + { + get { return (Attributes & ParameterAttributes.Retval) != 0; } + } + + public bool IsOptional + { + get { return (Attributes & ParameterAttributes.Optional) != 0; } + } + + public bool IsDefined(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0; + } + + public IList __GetCustomAttributes(Type attributeType, bool inherit) + { + return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit); + } + + internal virtual IList GetCustomAttributesData(Type attributeType) + { + return this.Module.GetCustomAttributes(this.MetadataToken, attributeType); + } + } +} diff --git a/mcs/class/IKVM.Reflection/ParameterModifier.cs b/mcs/class/IKVM.Reflection/ParameterModifier.cs new file mode 100644 index 000000000000..605cca48fdcc --- /dev/null +++ b/mcs/class/IKVM.Reflection/ParameterModifier.cs @@ -0,0 +1,45 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + public struct ParameterModifier + { + private readonly bool[] values; + + public ParameterModifier(int parameterCount) + { + values = new bool[parameterCount]; + } + + public bool this[int index] + { + get { return values[index]; } + set { values[index] = value; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Properties/AssemblyInfo.cs b/mcs/class/IKVM.Reflection/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..6422e190d9c0 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("IKVM.NET Reflection")] +[assembly: AssemblyDescription("Managed (partial) Reflection implementation for use by ikvmc")] diff --git a/mcs/class/IKVM.Reflection/PropertyInfo.cs b/mcs/class/IKVM.Reflection/PropertyInfo.cs new file mode 100644 index 000000000000..de991aacdee3 --- /dev/null +++ b/mcs/class/IKVM.Reflection/PropertyInfo.cs @@ -0,0 +1,158 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; + +namespace IKVM.Reflection +{ + public abstract class PropertyInfo : MemberInfo + { + public sealed override MemberTypes MemberType + { + get { return MemberTypes.Property; } + } + + public abstract PropertyAttributes Attributes { get; } + public abstract bool CanRead { get; } + public abstract bool CanWrite { get; } + public abstract MethodInfo GetGetMethod(bool nonPublic); + public abstract MethodInfo GetSetMethod(bool nonPublic); + public abstract MethodInfo[] GetAccessors(bool nonPublic); + public abstract object GetRawConstantValue(); + internal abstract bool IsPublic { get; } + internal abstract bool IsStatic { get; } + internal abstract PropertySignature PropertySignature { get; } + + private sealed class ParameterInfoImpl : ParameterInfo + { + private readonly PropertyInfo property; + private readonly int parameter; + + internal ParameterInfoImpl(PropertyInfo property, int parameter) + { + this.property = property; + this.parameter = parameter; + } + + public override string Name + { + get { return null; } + } + + public override Type ParameterType + { + get { return property.PropertySignature.GetParameter(parameter); } + } + + public override ParameterAttributes Attributes + { + get { return ParameterAttributes.None; } + } + + public override int Position + { + get { return parameter; } + } + + public override object RawDefaultValue + { + get { throw new InvalidOperationException(); } + } + + public override Type[] GetOptionalCustomModifiers() + { + return property.PropertySignature.GetOptionalCustomModifiers(parameter); + } + + public override Type[] GetRequiredCustomModifiers() + { + return property.PropertySignature.GetRequiredCustomModifiers(parameter); + } + + public override MemberInfo Member + { + get { return property; } + } + + public override int MetadataToken + { + get { return 0x08000000; } + } + + internal override Module Module + { + get { return property.Module; } + } + } + + public ParameterInfo[] GetIndexParameters() + { + ParameterInfo[] parameters = new ParameterInfo[this.PropertySignature.ParameterCount]; + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = new ParameterInfoImpl(this, i); + } + return parameters; + } + + public Type PropertyType + { + get { return this.PropertySignature.PropertyType; } + } + + public Type[] GetRequiredCustomModifiers() + { + return this.PropertySignature.GetRequiredCustomModifiers(); + } + + public Type[] GetOptionalCustomModifiers() + { + return this.PropertySignature.GetOptionalCustomModifiers(); + } + + public bool IsSpecialName + { + get { return (Attributes & PropertyAttributes.SpecialName) != 0; } + } + + public MethodInfo GetGetMethod() + { + return GetGetMethod(false); + } + + public MethodInfo GetSetMethod() + { + return GetSetMethod(false); + } + + public MethodInfo[] GetAccessors() + { + return GetAccessors(false); + } + + internal virtual PropertyInfo BindTypeParameters(Type type) + { + return new GenericPropertyInfo(this.DeclaringType.BindTypeParameters(type), this); + } + } +} diff --git a/mcs/class/IKVM.Reflection/PropertySignature.cs b/mcs/class/IKVM.Reflection/PropertySignature.cs new file mode 100644 index 000000000000..4e19dca66af3 --- /dev/null +++ b/mcs/class/IKVM.Reflection/PropertySignature.cs @@ -0,0 +1,218 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + sealed class PropertySignature : Signature + { + private CallingConventions callingConvention; + private readonly Type propertyType; + private readonly Type[] optionalCustomModifiers; + private readonly Type[] requiredCustomModifiers; + private readonly Type[] parameterTypes; + private readonly Type[][] parameterOptionalCustomModifiers; + private readonly Type[][] parameterRequiredCustomModifiers; + + internal static PropertySignature Create(CallingConventions callingConvention, Type propertyType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeOptionalCustomModifiers, Type[][] parameterTypeRequiredCustomModifiers) + { + return new PropertySignature(callingConvention, propertyType, Util.Copy(optionalCustomModifiers), Util.Copy(requiredCustomModifiers), Util.Copy(parameterTypes), Util.Copy(parameterTypeOptionalCustomModifiers), Util.Copy(parameterTypeRequiredCustomModifiers)); + } + + private PropertySignature(CallingConventions callingConvention, Type propertyType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeOptionalCustomModifiers, Type[][] parameterTypeRequiredCustomModifiers) + { + this.callingConvention = callingConvention; + this.propertyType = propertyType; + this.optionalCustomModifiers = optionalCustomModifiers; + this.requiredCustomModifiers = requiredCustomModifiers; + this.parameterTypes = parameterTypes; + this.parameterOptionalCustomModifiers = parameterTypeOptionalCustomModifiers; + this.parameterRequiredCustomModifiers = parameterTypeRequiredCustomModifiers; + } + + public override bool Equals(object obj) + { + PropertySignature other = obj as PropertySignature; + return other != null + && other.propertyType.Equals(propertyType) + && Util.ArrayEquals(other.optionalCustomModifiers, optionalCustomModifiers) + && Util.ArrayEquals(other.requiredCustomModifiers, requiredCustomModifiers); + } + + public override int GetHashCode() + { + return propertyType.GetHashCode() ^ Util.GetHashCode(optionalCustomModifiers) ^ Util.GetHashCode(requiredCustomModifiers); + } + + internal int ParameterCount + { + get { return parameterTypes.Length; } + } + + internal bool HasThis + { + set + { + if (value) + { + callingConvention |= CallingConventions.HasThis; + } + else + { + callingConvention &= ~CallingConventions.HasThis; + } + } + } + + internal Type PropertyType + { + get { return propertyType; } + } + + internal Type[] GetOptionalCustomModifiers() + { + return Util.Copy(optionalCustomModifiers); + } + + internal Type[] GetRequiredCustomModifiers() + { + return Util.Copy(requiredCustomModifiers); + } + + internal PropertySignature ExpandTypeParameters(Type declaringType) + { + return new PropertySignature( + callingConvention, + propertyType.BindTypeParameters(declaringType), + BindTypeParameters(declaringType, optionalCustomModifiers), + BindTypeParameters(declaringType, requiredCustomModifiers), + BindTypeParameters(declaringType, parameterTypes), + BindTypeParameters(declaringType, parameterOptionalCustomModifiers), + BindTypeParameters(declaringType, parameterRequiredCustomModifiers)); + } + + internal override void WriteSig(ModuleBuilder module, ByteBuffer bb) + { + byte flags = PROPERTY; + if ((callingConvention & CallingConventions.HasThis) != 0) + { + flags |= HASTHIS; + } + if ((callingConvention & CallingConventions.ExplicitThis) != 0) + { + flags |= EXPLICITTHIS; + } + if ((callingConvention & CallingConventions.VarArgs) != 0) + { + flags |= VARARG; + } + bb.Write(flags); + bb.WriteCompressedInt(parameterTypes == null ? 0 : parameterTypes.Length); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, requiredCustomModifiers); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, optionalCustomModifiers); + WriteType(module, bb, propertyType); + if (parameterTypes != null) + { + for (int i = 0; i < parameterTypes.Length; i++) + { + if (parameterRequiredCustomModifiers != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, parameterRequiredCustomModifiers[i]); + } + if (parameterOptionalCustomModifiers != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, parameterOptionalCustomModifiers[i]); + } + WriteType(module, bb, parameterTypes[i]); + } + } + } + + internal Type GetParameter(int parameter) + { + return parameterTypes[parameter]; + } + + internal Type[] GetOptionalCustomModifiers(int parameter) + { + return parameterOptionalCustomModifiers == null ? Type.EmptyTypes : parameterOptionalCustomModifiers[parameter]; + } + + internal Type[] GetRequiredCustomModifiers(int parameter) + { + return parameterRequiredCustomModifiers == null ? Type.EmptyTypes : parameterRequiredCustomModifiers[parameter]; + } + + internal static PropertySignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context) + { + byte flags = br.ReadByte(); + if ((flags & PROPERTY) == 0) + { + throw new BadImageFormatException(); + } + CallingConventions callingConvention = CallingConventions.Standard; + if ((flags & HASTHIS) != 0) + { + callingConvention |= CallingConventions.HasThis; + } + if ((flags & EXPLICITTHIS) != 0) + { + callingConvention |= CallingConventions.ExplicitThis; + } + Type returnType; + Type[] returnTypeRequiredCustomModifiers; + Type[] returnTypeOptionalCustomModifiers; + Type[] parameterTypes; + Type[][] parameterRequiredCustomModifiers; + Type[][] parameterOptionalCustomModifiers; + int paramCount = br.ReadCompressedInt(); + ReadCustomModifiers(module, br, context, out returnTypeRequiredCustomModifiers, out returnTypeOptionalCustomModifiers); + returnType = ReadRetType(module, br, context); + parameterTypes = new Type[paramCount]; + parameterRequiredCustomModifiers = null; + parameterOptionalCustomModifiers = null; + for (int i = 0; i < parameterTypes.Length; i++) + { + if (IsCustomModifier(br.PeekByte())) + { + if (parameterOptionalCustomModifiers == null) + { + parameterOptionalCustomModifiers = new Type[parameterTypes.Length][]; + parameterRequiredCustomModifiers = new Type[parameterTypes.Length][]; + } + ReadCustomModifiers(module, br, context, out parameterRequiredCustomModifiers[i], out parameterOptionalCustomModifiers[i]); + } + parameterTypes[i] = ReadParam(module, br, context); + } + return new PropertySignature(callingConvention, returnType, returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers, + parameterTypes, parameterOptionalCustomModifiers, parameterRequiredCustomModifiers); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/AssemblyReader.cs b/mcs/class/IKVM.Reflection/Reader/AssemblyReader.cs new file mode 100644 index 000000000000..08d66ddf58c3 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/AssemblyReader.cs @@ -0,0 +1,255 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Configuration.Assemblies; +using System.IO; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class AssemblyReader : Assembly + { + private const int ContainsNoMetaData = 0x0001; + private readonly string location; + private readonly ModuleReader manifestModule; + private readonly Module[] externalModules; + + internal AssemblyReader(string location, ModuleReader manifestModule) + : base(manifestModule.universe) + { + this.location = location; + this.manifestModule = manifestModule; + externalModules = new Module[manifestModule.File.records.Length]; + } + + public override string Location + { + get { return location; } + } + + public override string FullName + { + get { return GetName().FullName; } + } + + public override AssemblyName GetName() + { + return GetNameImpl(ref manifestModule.AssemblyTable.records[0]); + } + + private AssemblyName GetNameImpl(ref AssemblyTable.Record rec) + { + AssemblyName name = new AssemblyName(); + name.Name = manifestModule.GetString(rec.Name); + name.Version = new Version(rec.MajorVersion, rec.MinorVersion, rec.BuildNumber, rec.RevisionNumber); + if (rec.PublicKey != 0) + { + name.SetPublicKey(manifestModule.GetBlobCopy(rec.PublicKey)); + } + else + { + name.SetPublicKey(Empty.Array); + } + if (rec.Culture != 0) + { + name.CultureInfo = new System.Globalization.CultureInfo(manifestModule.GetString(rec.Culture)); + } + else + { + name.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; + } + name.HashAlgorithm = (AssemblyHashAlgorithm)rec.HashAlgId; + name.CodeBase = this.CodeBase; + name.Flags = (AssemblyNameFlags)rec.Flags; + return name; + } + + public override Type[] GetTypes() + { + if (externalModules.Length == 0) + { + return manifestModule.GetTypes(); + } + + List list = new List(); + foreach (Module module in GetModules(false)) + { + list.AddRange(module.GetTypes()); + } + return list.ToArray(); + } + + internal override Type GetTypeImpl(string typeName) + { + Type type = manifestModule.GetType(typeName); + for (int i = 0; type == null && i < externalModules.Length; i++) + { + if ((manifestModule.File.records[i].Flags & ContainsNoMetaData) == 0) + { + type = GetModule(i).GetType(typeName); + } + } + return type; + } + + public override string ImageRuntimeVersion + { + get { return manifestModule.ImageRuntimeVersion; } + } + + public override Module ManifestModule + { + get { return manifestModule; } + } + + public override Module[] GetLoadedModules(bool getResourceModules) + { + List list = new List(); + list.Add(manifestModule); + foreach (Module m in externalModules) + { + if (m != null) + { + list.Add(m); + } + } + return list.ToArray(); + } + + public override Module[] GetModules(bool getResourceModules) + { + if (externalModules.Length == 0) + { + return new Module[] { manifestModule }; + } + else + { + List list = new List(); + list.Add(manifestModule); + for (int i = 0; i < manifestModule.File.records.Length; i++) + { + if (getResourceModules || (manifestModule.File.records[i].Flags & ContainsNoMetaData) == 0) + { + list.Add(GetModule(i)); + } + } + return list.ToArray(); + } + } + + public override Module GetModule(string name) + { + if (name.Equals(manifestModule.ScopeName, StringComparison.InvariantCultureIgnoreCase)) + { + return manifestModule; + } + int index = GetModuleIndex(name); + if (index != -1) + { + return GetModule(index); + } + return null; + } + + private int GetModuleIndex(string name) + { + for (int i = 0; i < manifestModule.File.records.Length; i++) + { + if (name.Equals(manifestModule.GetString(manifestModule.File.records[i].Name), StringComparison.InvariantCultureIgnoreCase)) + { + return i; + } + } + return -1; + } + + private Module GetModule(int index) + { + if (externalModules[index] != null) + { + return externalModules[index]; + } + // TODO add ModuleResolve event + string location = Path.Combine(Path.GetDirectoryName(this.location), manifestModule.GetString(manifestModule.File.records[index].Name)); + return LoadModule(index, File.ReadAllBytes(location), location); + } + + private Module LoadModule(int index, byte[] rawModule, string location) + { + if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0) + { + return externalModules[index] = new ResourceModule(this, manifestModule.GetString(manifestModule.File.records[index].Name), location); + } + else + { + return externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location); + } + } + + public override Module LoadModule(string moduleName, byte[] rawModule) + { + int index = GetModuleIndex(moduleName); + if (index == -1) + { + throw new ArgumentException(); + } + if (externalModules[index] != null) + { + return externalModules[index]; + } + return LoadModule(index, rawModule, null); + } + + public override MethodInfo EntryPoint + { + get { return manifestModule.GetEntryPoint(); } + } + + public override string[] GetManifestResourceNames() + { + return manifestModule.GetManifestResourceNames(); + } + + public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) + { + return manifestModule.GetManifestResourceInfo(resourceName); + } + + public override Stream GetManifestResourceStream(string resourceName) + { + return manifestModule.GetManifestResourceStream(resourceName); + } + + public override AssemblyName[] GetReferencedAssemblies() + { + return manifestModule.__GetReferencedAssemblies(); + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return manifestModule.GetCustomAttributes(0x20000001, attributeType); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/ByteReader.cs b/mcs/class/IKVM.Reflection/Reader/ByteReader.cs new file mode 100644 index 000000000000..edd1054323ba --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/ByteReader.cs @@ -0,0 +1,198 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection.Reader +{ + sealed class ByteReader + { + private byte[] buffer; + private int pos; + private int end; + + internal ByteReader(byte[] buffer, int offset, int length) + { + this.buffer = buffer; + this.pos = offset; + this.end = pos + length; + } + + internal static ByteReader FromBlob(byte[] blobHeap, int blob) + { + ByteReader br = new ByteReader(blobHeap, blob, 4); + int length = br.ReadCompressedInt(); + br.end = br.pos + length; + return br; + } + + internal int Length + { + get { return end - pos; } + } + + internal byte PeekByte() + { + if (pos == end) + throw new BadImageFormatException(); + return buffer[pos]; + } + + internal byte ReadByte() + { + if (pos == end) + throw new BadImageFormatException(); + return buffer[pos++]; + } + + internal byte[] ReadBytes(int count) + { + if (count < 0) + throw new BadImageFormatException(); + if (end - pos < count) + throw new BadImageFormatException(); + byte[] buf = new byte[count]; + Buffer.BlockCopy(buffer, pos, buf, 0, count); + pos += count; + return buf; + } + + internal int ReadCompressedInt() + { + byte b1 = ReadByte(); + if (b1 <= 0x7F) + { + return b1; + } + else if ((b1 & 0xC0) == 0x80) + { + byte b2 = ReadByte(); + return ((b1 & 0x3F) << 8) | b2; + } + else + { + byte b2 = ReadByte(); + byte b3 = ReadByte(); + byte b4 = ReadByte(); + return ((b1 & 0x3F) << 24) + (b2 << 16) + (b3 << 8) + b4; + } + } + + internal string ReadString() + { + if (PeekByte() == 0xFF) + { + pos++; + return null; + } + int length = ReadCompressedInt(); + string str = Encoding.UTF8.GetString(buffer, pos, length); + pos += length; + return str; + } + + internal char ReadChar() + { + return (char)ReadInt16(); + } + + internal sbyte ReadSByte() + { + return (sbyte)ReadByte(); + } + + internal short ReadInt16() + { + if (end - pos < 2) + throw new BadImageFormatException(); + byte b1 = buffer[pos++]; + byte b2 = buffer[pos++]; + return (short)(b1 | (b2 << 8)); + } + + internal ushort ReadUInt16() + { + return (ushort)ReadInt16(); + } + + internal int ReadInt32() + { + if (end - pos < 4) + throw new BadImageFormatException(); + byte b1 = buffer[pos++]; + byte b2 = buffer[pos++]; + byte b3 = buffer[pos++]; + byte b4 = buffer[pos++]; + return (int)(b1 | (b2 << 8) | (b3 << 16) | (b4 << 24)); + } + + internal uint ReadUInt32() + { + return (uint)ReadInt32(); + } + + internal long ReadInt64() + { + ulong lo = ReadUInt32(); + ulong hi = ReadUInt32(); + return (long)(lo | (hi << 32)); + } + + internal ulong ReadUInt64() + { + return (ulong)ReadInt64(); + } + + internal float ReadSingle() + { + if (end - pos < 4) + throw new BadImageFormatException(); + float value = BitConverter.ToSingle(buffer, pos); + pos += 4; + return value; + } + + internal double ReadDouble() + { + return BitConverter.Int64BitsToDouble(ReadInt64()); + } + + internal ByteReader Slice(int length) + { + if (end - pos < length) + throw new BadImageFormatException(); + ByteReader br = new ByteReader(buffer, pos, length); + pos += length; + return br; + } + + // NOTE this method only works if the original offset was aligned and for alignments that are a power of 2 + internal void Align(int alignment) + { + alignment--; + pos = (pos + alignment) & ~alignment; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/EventInfoImpl.cs b/mcs/class/IKVM.Reflection/Reader/EventInfoImpl.cs new file mode 100644 index 000000000000..82591b0be4c8 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/EventInfoImpl.cs @@ -0,0 +1,138 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class EventInfoImpl : EventInfo + { + private readonly ModuleReader module; + private readonly Type declaringType; + private readonly int index; + private bool isPublic; + private bool isStatic; + private bool flagsCached; + + internal EventInfoImpl(ModuleReader module, Type declaringType, int index) + { + this.module = module; + this.declaringType = declaringType; + this.index = index; + } + + public override bool Equals(object obj) + { + EventInfoImpl other = obj as EventInfoImpl; + return other != null && other.declaringType == declaringType && other.index == index; + } + + public override int GetHashCode() + { + return declaringType.GetHashCode() * 123 + index; + } + + public override EventAttributes Attributes + { + get { return (EventAttributes)module.Event.records[index].EventFlags; } + } + + public override MethodInfo GetAddMethod(bool nonPublic) + { + return module.MethodSemantics.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.AddOn); + } + + public override MethodInfo GetRaiseMethod(bool nonPublic) + { + return module.MethodSemantics.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Fire); + } + + public override MethodInfo GetRemoveMethod(bool nonPublic) + { + return module.MethodSemantics.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.RemoveOn); + } + + public override MethodInfo[] GetOtherMethods(bool nonPublic) + { + return module.MethodSemantics.GetMethods(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Other); + } + + public override Type EventHandlerType + { + get { return module.ResolveType(module.Event.records[index].EventType, declaringType); } + } + + public override string Name + { + get { return module.GetString(module.Event.records[index].Name); } + } + + public override Type DeclaringType + { + get { return declaringType; } + } + + public override Module Module + { + get { return module; } + } + + public override int MetadataToken + { + get { return (EventTable.Index << 24) + index + 1; } + } + + internal override bool IsPublic + { + get + { + if (!flagsCached) + { + ComputeFlags(); + } + return isPublic; + } + } + + internal override bool IsStatic + { + get + { + if (!flagsCached) + { + ComputeFlags(); + } + return isStatic; + } + } + + private void ComputeFlags() + { + module.MethodSemantics.ComputeFlags(module, this.MetadataToken, out isPublic, out isStatic); + flagsCached = true; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/Field.cs b/mcs/class/IKVM.Reflection/Reader/Field.cs new file mode 100644 index 000000000000..f9bcca6ed591 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/Field.cs @@ -0,0 +1,152 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class FieldDefImpl : FieldInfo + { + private readonly ModuleReader module; + private readonly TypeDefImpl declaringType; + private readonly int index; + private FieldSignature lazyFieldSig; + + internal FieldDefImpl(ModuleReader module, TypeDefImpl declaringType, int index) + { + this.module = module; + this.declaringType = declaringType; + this.index = index; + } + + public override FieldAttributes Attributes + { + get { return (FieldAttributes)module.Field.records[index].Flags; } + } + + public override Type DeclaringType + { + get { return declaringType.IsModulePseudoType ? null : declaringType; } + } + + public override string Name + { + get { return module.GetString(module.Field.records[index].Name); } + } + + public override string ToString() + { + return this.FieldType.Name + " " + this.Name; + } + + public override Module Module + { + get { return module; } + } + + public override int MetadataToken + { + get { return (FieldTable.Index << 24) + index + 1; } + } + + public override object GetRawConstantValue() + { + return module.Constant.GetRawConstantValue(module, this.MetadataToken); + } + + public override void __GetDataFromRVA(byte[] data, int offset, int length) + { + int rid = index + 1; + // TODO binary search? + for (int i = 0; i < module.FieldRVA.records.Length; i++) + { + if (module.FieldRVA.records[i].Field == rid) + { + int rva = module.FieldRVA.records[i].RVA; + if (rva == 0) + { + // C++ assemblies can have fields that have an RVA that is zero + Array.Clear(data, offset, length); + return; + } + module.SeekRVA(rva); + while (length > 0) + { + int read = module.stream.Read(data, offset, length); + if (read == 0) + { + // C++ assemblies can have fields that have an RVA that lies outside of the file + break; + } + offset += read; + length -= read; + } + return; + } + } + throw new InvalidOperationException(); + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + List list = module.GetCustomAttributes(this.MetadataToken, attributeType); + if ((this.Attributes & FieldAttributes.HasFieldMarshal) != 0 + && (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_MarshalAsAttribute))) + { + list.Add(MarshalSpec.GetMarshalAsAttribute(module, this.MetadataToken)); + } + if (declaringType.IsExplicitLayout + && (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_FieldOffsetAttribute))) + { + int rid = index + 1; + // TODO use binary search? + for (int i = 0; i < module.FieldLayout.records.Length; i++) + { + if (module.FieldLayout.records[i].Field == rid) + { + ConstructorInfo constructor = module.universe.System_Runtime_InteropServices_FieldOffsetAttribute.GetConstructor(new Type[] { module.universe.System_Int32 }); + list.Add(new CustomAttributeData(constructor, + new object[] { module.FieldLayout.records[i].Offset }, + null)); + break; + } + } + } + return list; + } + + internal override FieldSignature FieldSignature + { + get { return lazyFieldSig ?? (lazyFieldSig = FieldSignature.ReadSig(module, module.GetBlob(module.Field.records[index].Signature), declaringType)); } + } + + internal override int ImportTo(Emit.ModuleBuilder module) + { + return module.ImportMethodOrField(declaringType, this.Name, this.FieldSignature); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/GenericTypeParameter.cs b/mcs/class/IKVM.Reflection/Reader/GenericTypeParameter.cs new file mode 100644 index 000000000000..2f961f94d1c5 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/GenericTypeParameter.cs @@ -0,0 +1,380 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + abstract class TypeParameterType : Type + { + public sealed override string AssemblyQualifiedName + { + get { return null; } + } + + public sealed override bool IsValueType + { + get { return (this.GenericParameterAttributes & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0; } + } + + public sealed override Type BaseType + { + get + { + foreach (Type type in GetGenericParameterConstraints()) + { + if (!type.IsInterface && !type.IsGenericParameter) + { + return type; + } + } + return this.IsValueType ? this.Module.universe.System_ValueType : this.Module.universe.System_Object; + } + } + + public override Type[] __GetDeclaredInterfaces() + { + List list = new List(); + foreach (Type type in GetGenericParameterConstraints()) + { + if (type.IsInterface) + { + list.Add(type); + } + } + return list.ToArray(); + } + + public sealed override TypeAttributes Attributes + { + get { return TypeAttributes.Public; } + } + + public sealed override Type UnderlyingSystemType + { + get { return this; } + } + + public sealed override string FullName + { + get { return null; } + } + + public sealed override string ToString() + { + return this.Name; + } + + public sealed override bool IsGenericParameter + { + get { return true; } + } + } + + sealed class UnboundGenericMethodParameter : TypeParameterType + { + private static readonly DummyModule module = new DummyModule(); + private readonly int position; + + private sealed class DummyModule : Module + { + internal DummyModule() + : base(new Universe()) + { + } + + public override bool Equals(object obj) + { + throw new InvalidOperationException(); + } + + public override int GetHashCode() + { + throw new InvalidOperationException(); + } + + public override string ToString() + { + throw new InvalidOperationException(); + } + + public override int MDStreamVersion + { + get { throw new InvalidOperationException(); } + } + + public override Assembly Assembly + { + get { throw new InvalidOperationException(); } + } + + internal override Type GetTypeImpl(string typeName) + { + throw new InvalidOperationException(); + } + + internal override void GetTypesImpl(List list) + { + throw new InvalidOperationException(); + } + + public override string FullyQualifiedName + { + get { throw new InvalidOperationException(); } + } + + public override string Name + { + get { throw new InvalidOperationException(); } + } + + public override Guid ModuleVersionId + { + get { throw new InvalidOperationException(); } + } + + public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new InvalidOperationException(); + } + + public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new InvalidOperationException(); + } + + public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new InvalidOperationException(); + } + + public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new InvalidOperationException(); + } + + public override string ResolveString(int metadataToken) + { + throw new InvalidOperationException(); + } + + public override Type[] __ResolveOptionalParameterTypes(int metadataToken) + { + throw new InvalidOperationException(); + } + + public override string ScopeName + { + get { throw new InvalidOperationException(); } + } + + public override AssemblyName[] __GetReferencedAssemblies() + { + throw new InvalidOperationException(); + } + + internal override Type GetModuleType() + { + throw new InvalidOperationException(); + } + + internal override ByteReader GetBlob(int blobIndex) + { + throw new InvalidOperationException(); + } + } + + internal static Type Make(int position) + { + return module.CanonicalizeType(new UnboundGenericMethodParameter(position)); + } + + private UnboundGenericMethodParameter(int position) + { + this.position = position; + } + + public override bool Equals(object obj) + { + UnboundGenericMethodParameter other = obj as UnboundGenericMethodParameter; + return other != null && other.position == position; + } + + public override int GetHashCode() + { + return position; + } + + public override string Namespace + { + get { throw new InvalidOperationException(); } + } + + public override string Name + { + get { throw new InvalidOperationException(); } + } + + public override int MetadataToken + { + get { throw new InvalidOperationException(); } + } + + public override Module Module + { + get { return module; } + } + + public override int GenericParameterPosition + { + get { return position; } + } + + public override Type DeclaringType + { + get { return null; } + } + + public override MethodBase DeclaringMethod + { + get { throw new InvalidOperationException(); } + } + + public override Type[] GetGenericParameterConstraints() + { + throw new InvalidOperationException(); + } + + public override GenericParameterAttributes GenericParameterAttributes + { + get { throw new InvalidOperationException(); } + } + + internal override Type BindTypeParameters(IGenericBinder binder) + { + return binder.BindMethodParameter(this); + } + } + + sealed class GenericTypeParameter : TypeParameterType + { + private readonly ModuleReader module; + private readonly int index; + + internal GenericTypeParameter(ModuleReader module, int index) + { + this.module = module; + this.index = index; + } + + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public override string Namespace + { + get { return DeclaringType.Namespace; } + } + + public override string Name + { + get { return module.GetString(module.GenericParam.records[index].Name); } + } + + public override Module Module + { + get { return module; } + } + + public override int MetadataToken + { + get { return (GenericParamTable.Index << 24) + index + 1; } + } + + public override int GenericParameterPosition + { + get { return module.GenericParam.records[index].Number; } + } + + public override Type DeclaringType + { + get + { + int owner = module.GenericParam.records[index].Owner; + return (owner >> 24) == TypeDefTable.Index ? module.ResolveType(owner) : null; + } + } + + public override MethodBase DeclaringMethod + { + get + { + int owner = module.GenericParam.records[index].Owner; + return (owner >> 24) == MethodDefTable.Index ? module.ResolveMethod(owner) : null; + } + } + + public override Type[] GetGenericParameterConstraints() + { + IGenericContext context = (this.DeclaringMethod as IGenericContext) ?? this.DeclaringType; + List list = new List(); + int token = this.MetadataToken; + // TODO use binary search + for (int i = 0; i < module.GenericParamConstraint.records.Length; i++) + { + if (module.GenericParamConstraint.records[i].Owner == token) + { + list.Add(module.ResolveType(module.GenericParamConstraint.records[i].Constraint, context)); + } + } + return list.ToArray(); + } + + public override GenericParameterAttributes GenericParameterAttributes + { + get { return (GenericParameterAttributes)module.GenericParam.records[index].Flags; } + } + + internal override Type BindTypeParameters(IGenericBinder binder) + { + int owner = module.GenericParam.records[index].Owner; + if ((owner >> 24) == MethodDefTable.Index) + { + return binder.BindMethodParameter(this); + } + else + { + return binder.BindTypeParameter(this); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/MetadataReader.cs b/mcs/class/IKVM.Reflection/Reader/MetadataReader.cs new file mode 100644 index 000000000000..0bbe475a61de --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/MetadataReader.cs @@ -0,0 +1,522 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class MetadataReader : MetadataRW + { + private readonly BinaryReader br; + + internal MetadataReader(ModuleReader module, BinaryReader br, byte heapSizes) + : base(module, (heapSizes & 0x01) != 0, (heapSizes & 0x02) != 0, (heapSizes & 0x04) != 0) + { + this.br = br; + } + + internal short ReadInt16() + { + return br.ReadInt16(); + } + + internal ushort ReadUInt16() + { + return br.ReadUInt16(); + } + + internal int ReadInt32() + { + return br.ReadInt32(); + } + + internal int ReadStringIndex() + { + if (bigStrings) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadGuidIndex() + { + if (bigGuids) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadBlobIndex() + { + if (bigBlobs) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadResolutionScope() + { + int codedIndex; + if (bigResolutionScope) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 3) + { + case 0: + return (ModuleTable.Index << 24) + (codedIndex >> 2); + case 1: + return (ModuleRefTable.Index << 24) + (codedIndex >> 2); + case 2: + return (AssemblyRefTable.Index << 24) + (codedIndex >> 2); + case 3: + return (TypeRefTable.Index << 24) + (codedIndex >> 2); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadTypeDefOrRef() + { + int codedIndex; + if (bigTypeDefOrRef) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 3) + { + case 0: + return (TypeDefTable.Index << 24) + (codedIndex >> 2); + case 1: + return (TypeRefTable.Index << 24) + (codedIndex >> 2); + case 2: + return (TypeSpecTable.Index << 24) + (codedIndex >> 2); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadMemberRefParent() + { + int codedIndex; + if (bigMemberRefParent) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 7) + { + case 0: + return (TypeDefTable.Index << 24) + (codedIndex >> 3); + case 1: + return (TypeRefTable.Index << 24) + (codedIndex >> 3); + case 2: + return (ModuleRefTable.Index << 24) + (codedIndex >> 3); + case 3: + return (MethodDefTable.Index << 24) + (codedIndex >> 3); + case 4: + return (TypeSpecTable.Index << 24) + (codedIndex >> 3); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadHasCustomAttribute() + { + int codedIndex; + if (bigHasCustomAttribute) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 31) + { + case 0: + return (MethodDefTable.Index << 24) + (codedIndex >> 5); + case 1: + return (FieldTable.Index << 24) + (codedIndex >> 5); + case 2: + return (TypeRefTable.Index << 24) + (codedIndex >> 5); + case 3: + return (TypeDefTable.Index << 24) + (codedIndex >> 5); + case 4: + return (ParamTable.Index << 24) + (codedIndex >> 5); + case 5: + return (InterfaceImplTable.Index << 24) + (codedIndex >> 5); + case 6: + return (MemberRefTable.Index << 24) + (codedIndex >> 5); + case 7: + return (ModuleTable.Index << 24) + (codedIndex >> 5); + case 8: + throw new BadImageFormatException(); + case 9: + return (PropertyTable.Index << 24) + (codedIndex >> 5); + case 10: + return (EventTable.Index << 24) + (codedIndex >> 5); + case 11: + return (StandAloneSigTable.Index << 24) + (codedIndex >> 5); + case 12: + return (ModuleRefTable.Index << 24) + (codedIndex >> 5); + case 13: + return (TypeSpecTable.Index << 24) + (codedIndex >> 5); + case 14: + return (AssemblyTable.Index << 24) + (codedIndex >> 5); + case 15: + return (AssemblyRefTable.Index << 24) + (codedIndex >> 5); + case 16: + return (FileTable.Index << 24) + (codedIndex >> 5); + case 17: + return (ExportedTypeTable.Index << 24) + (codedIndex >> 5); + case 18: + return (ManifestResourceTable.Index << 24) + (codedIndex >> 5); + case 19: + return (GenericParamTable.Index << 24) + (codedIndex >> 5); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadCustomAttributeType() + { + int codedIndex; + if (bigCustomAttributeType) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 7) + { + case 2: + return (MethodDefTable.Index << 24) + (codedIndex >> 3); + case 3: + return (MemberRefTable.Index << 24) + (codedIndex >> 3); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadMethodDefOrRef() + { + int codedIndex; + if (bigMethodDefOrRef) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 1) + { + case 0: + return (MethodDefTable.Index << 24) + (codedIndex >> 1); + case 1: + return (MemberRefTable.Index << 24) + (codedIndex >> 1); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadHasConstant() + { + int codedIndex; + if (bigHasConstant) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 3) + { + case 0: + return (FieldTable.Index << 24) + (codedIndex >> 2); + case 1: + return (ParamTable.Index << 24) + (codedIndex >> 2); + case 2: + return (PropertyTable.Index << 24) + (codedIndex >> 2); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadHasSemantics() + { + int codedIndex; + if (bigHasSemantics) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 1) + { + case 0: + return (EventTable.Index << 24) + (codedIndex >> 1); + case 1: + return (PropertyTable.Index << 24) + (codedIndex >> 1); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadHasFieldMarshal() + { + int codedIndex; + if (bigHasFieldMarshal) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 1) + { + case 0: + return (FieldTable.Index << 24) + (codedIndex >> 1); + case 1: + return (ParamTable.Index << 24) + (codedIndex >> 1); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadHasDeclSecurity() + { + int codedIndex; + if (bigHasDeclSecurity) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 3) + { + case 0: + return (TypeDefTable.Index << 24) + (codedIndex >> 2); + case 1: + return (MethodDefTable.Index << 24) + (codedIndex >> 2); + case 2: + return (AssemblyTable.Index << 24) + (codedIndex >> 2); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadTypeOrMethodDef() + { + int codedIndex; + if (bigTypeOrMethodDef) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 1) + { + case 0: + return (TypeDefTable.Index << 24) + (codedIndex >> 1); + case 1: + return (MethodDefTable.Index << 24) + (codedIndex >> 1); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadMemberForwarded() + { + int codedIndex; + if (bigMemberForwarded) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 1) + { + case 0: + return (FieldTable.Index << 24) + (codedIndex >> 1); + case 1: + return (MethodDefTable.Index << 24) + (codedIndex >> 1); + default: + throw new BadImageFormatException(); + } + } + + internal int ReadImplementation() + { + int codedIndex; + if (bigImplementation) + { + codedIndex = br.ReadInt32(); + } + else + { + codedIndex = br.ReadUInt16(); + } + switch (codedIndex & 3) + { + case 0: + return (FileTable.Index << 24) + (codedIndex >> 2); + case 1: + return (AssemblyRefTable.Index << 24) + (codedIndex >> 2); + case 2: + return (ExportedTypeTable.Index << 24) + (codedIndex >> 2); + default: + throw new BadImageFormatException(); + } + } + + private int ReadToken(int table, bool big) + { + int rid; + if (big) + { + rid = br.ReadInt32(); + } + else + { + rid = br.ReadUInt16(); + } + return rid | (table << 24); + } + + internal int ReadField() + { + if (bigField) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadMethodDef() + { + if (bigMethodDef) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadParam() + { + if (bigParam) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadProperty() + { + if (bigProperty) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadEvent() + { + if (bigEvent) + { + return br.ReadInt32(); + } + else + { + return br.ReadUInt16(); + } + } + + internal int ReadTypeDef() + { + return ReadToken(TypeDefTable.Index, bigTypeDef); + } + + internal int ReadGenericParam() + { + return ReadToken(GenericParamTable.Index, bigGenericParam); + } + + internal int ReadModuleRef() + { + return ReadToken(ModuleRefTable.Index, bigModuleRef); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/Method.cs b/mcs/class/IKVM.Reflection/Reader/Method.cs new file mode 100644 index 000000000000..c3d77f5812dc --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/Method.cs @@ -0,0 +1,485 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class MethodDefImpl : MethodInfo + { + private readonly ModuleReader module; + private readonly int index; + private readonly TypeDefImpl declaringType; + private MethodSignature lazyMethodSignature; + private ParameterInfo returnParameter; + private ParameterInfo[] parameters; + private Type[] typeArgs; + + internal MethodDefImpl(ModuleReader module, TypeDefImpl declaringType, int index) + { + this.module = module; + this.index = index; + this.declaringType = declaringType; + } + + public override MethodBody GetMethodBody() + { + return GetMethodBody(this); + } + + internal MethodBody GetMethodBody(IGenericContext context) + { + if ((GetMethodImplementationFlags() & MethodImplAttributes.CodeTypeMask) != MethodImplAttributes.IL) + { + // method is not IL + return null; + } + int rva = module.MethodDef.records[index].RVA; + return rva == 0 ? null : new MethodBody(module, rva, context); + } + + public override CallingConventions CallingConvention + { + get { return this.MethodSignature.CallingConvention; } + } + + public override MethodAttributes Attributes + { + get { return (MethodAttributes)module.MethodDef.records[index].Flags; } + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return (MethodImplAttributes)module.MethodDef.records[index].ImplFlags; + } + + public override ParameterInfo[] GetParameters() + { + PopulateParameters(); + return (ParameterInfo[])parameters.Clone(); + } + + private void PopulateParameters() + { + if (parameters == null) + { + MethodSignature methodSignature = this.MethodSignature; + parameters = new ParameterInfo[methodSignature.GetParameterCount()]; + int parameter = module.MethodDef.records[index].ParamList - 1; + int end = module.MethodDef.records.Length > index + 1 ? module.MethodDef.records[index + 1].ParamList - 1 : module.Param.records.Length; + for (; parameter < end; parameter++) + { + int seq = module.Param.records[parameter].Sequence - 1; + if (seq == -1) + { + returnParameter = new ParameterInfoImpl(this, seq, parameter); + } + else + { + parameters[seq] = new ParameterInfoImpl(this, seq, parameter); + } + } + for (int i = 0; i < parameters.Length; i++) + { + if (parameters[i] == null) + { + parameters[i] = new ParameterInfoImpl(this, i, -1); + } + } + if (returnParameter == null) + { + returnParameter = new ParameterInfoImpl(this, -1, -1); + } + } + } + + internal override int ParameterCount + { + get { return this.MethodSignature.GetParameterCount(); } + } + + public override ParameterInfo ReturnParameter + { + get + { + PopulateParameters(); + return returnParameter; + } + } + + public override Type ReturnType + { + get + { + return this.ReturnParameter.ParameterType; + } + } + + public override Type DeclaringType + { + get { return declaringType.IsModulePseudoType ? null : declaringType; } + } + + public override string Name + { + get { return module.GetString(module.MethodDef.records[index].Name); } + } + + public override int MetadataToken + { + get { return (MethodDefTable.Index << 24) + index + 1; } + } + + public override bool IsGenericMethodDefinition + { + get + { + PopulateGenericArguments(); + return typeArgs.Length > 0; + } + } + + public override bool IsGenericMethod + { + get { return IsGenericMethodDefinition; } + } + + public override Type[] GetGenericArguments() + { + PopulateGenericArguments(); + return Util.Copy(typeArgs); + } + + private void PopulateGenericArguments() + { + if (typeArgs == null) + { + int token = this.MetadataToken; + int first = module.GenericParam.FindFirstByOwner(token); + if (first == -1) + { + typeArgs = Type.EmptyTypes; + } + else + { + List list = new List(); + int len = module.GenericParam.records.Length; + for (int i = first; i < len && module.GenericParam.records[i].Owner == token; i++) + { + list.Add(new GenericTypeParameter(module, i)); + } + typeArgs = list.ToArray(); + } + } + } + + internal override Type GetGenericMethodArgument(int index) + { + PopulateGenericArguments(); + return typeArgs[index]; + } + + internal override int GetGenericMethodArgumentCount() + { + PopulateGenericArguments(); + return typeArgs.Length; + } + + public override MethodInfo GetGenericMethodDefinition() + { + if (this.IsGenericMethodDefinition) + { + return this; + } + throw new InvalidOperationException(); + } + + public override MethodInfo MakeGenericMethod(params Type[] typeArguments) + { + return new GenericMethodInstance(declaringType, this, typeArguments); + } + + public override Module Module + { + get { return module; } + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + List list = module.GetCustomAttributes(this.MetadataToken, attributeType); + if ((this.Attributes & MethodAttributes.PinvokeImpl) != 0 + && (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_DllImportAttribute))) + { + CreateDllImportPseudoCustomAttribute(list); + } + return list; + } + + private void CreateDllImportPseudoCustomAttribute(List attribs) + { + int token = this.MetadataToken; + // TODO use binary search? + for (int i = 0; i < module.ImplMap.records.Length; i++) + { + if (module.ImplMap.records[i].MemberForwarded == token) + { + const short NoMangle = 0x0001; + const short CharSetMask = 0x0006; + const short CharSetNotSpec = 0x0000; + const short CharSetAnsi = 0x0002; + const short CharSetUnicode = 0x0004; + const short CharSetAuto = 0x0006; + const short SupportsLastError = 0x0040; + const short CallConvMask = 0x0700; + const short CallConvWinapi = 0x0100; + const short CallConvCdecl = 0x0200; + const short CallConvStdcall = 0x0300; + const short CallConvThiscall = 0x0400; + const short CallConvFastcall = 0x0500; + // non-standard flags + const short BestFitOn = 0x0010; + const short BestFitOff = 0x0020; + const short CharMapErrorOn = 0x1000; + const short CharMapErrorOff = 0x2000; + + Type type = module.universe.System_Runtime_InteropServices_DllImportAttribute; + ConstructorInfo constructor = type.GetConstructor(new Type[] { module.universe.System_String }); + List list = new List(); + int flags = module.ImplMap.records[i].MappingFlags; + string entryPoint = module.GetString(module.ImplMap.records[i].ImportName); + string dllName = module.GetString(module.ModuleRef.records[(module.ImplMap.records[i].ImportScope & 0xFFFFFF) - 1]); + System.Runtime.InteropServices.CharSet? charSet; + switch (flags & CharSetMask) + { + case CharSetAnsi: + charSet = System.Runtime.InteropServices.CharSet.Ansi; + break; + case CharSetUnicode: + charSet = System.Runtime.InteropServices.CharSet.Unicode; + break; + case CharSetAuto: + charSet = System.Runtime.InteropServices.CharSet.Auto; + break; + case CharSetNotSpec: + default: + charSet = null; + break; + } + System.Runtime.InteropServices.CallingConvention callingConvention; + switch (flags & CallConvMask) + { + case CallConvCdecl: + callingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl; + break; + case CallConvFastcall: + callingConvention = System.Runtime.InteropServices.CallingConvention.FastCall; + break; + case CallConvStdcall: + callingConvention = System.Runtime.InteropServices.CallingConvention.StdCall; + break; + case CallConvThiscall: + callingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall; + break; + case CallConvWinapi: + default: + callingConvention = System.Runtime.InteropServices.CallingConvention.Winapi; + break; + } + list.Add(MakeNamedArgument(type, "EntryPoint", entryPoint)); + list.Add(MakeNamedArgument(type, "ExactSpelling", flags, NoMangle)); + list.Add(MakeNamedArgument(type, "SetLastError", flags, SupportsLastError)); + list.Add(MakeNamedArgument(type, "PreserveSig", (int)GetMethodImplementationFlags(), (int)MethodImplAttributes.PreserveSig)); + list.Add(MakeNamedArgument(type, "CallingConvention", (int)callingConvention)); + if (charSet.HasValue) + { + list.Add(MakeNamedArgument(type, "CharSet", (int)charSet.Value)); + } + if ((flags & (BestFitOn | BestFitOff)) != 0) + { + list.Add(MakeNamedArgument(type, "BestFitMapping", flags, BestFitOn)); + } + if ((flags & (CharMapErrorOn | CharMapErrorOff)) != 0) + { + list.Add(MakeNamedArgument(type, "ThrowOnUnmappableChar", flags, CharMapErrorOn)); + } + attribs.Add(new CustomAttributeData(constructor, new object[] { dllName }, list)); + return; + } + } + } + + private static CustomAttributeNamedArgument MakeNamedArgument(Type type, string field, string value) + { + return new CustomAttributeNamedArgument(type.GetField(field), new CustomAttributeTypedArgument(type.Module.universe.System_String, value)); + } + + private static CustomAttributeNamedArgument MakeNamedArgument(Type type, string field, int value) + { + return new CustomAttributeNamedArgument(type.GetField(field), new CustomAttributeTypedArgument(type.Module.universe.System_Int32, value)); + } + + private static CustomAttributeNamedArgument MakeNamedArgument(Type type, string field, int flags, int flagMask) + { + return new CustomAttributeNamedArgument(type.GetField(field), new CustomAttributeTypedArgument(type.Module.universe.System_Boolean, (flags & flagMask) != 0)); + } + + internal override MethodSignature MethodSignature + { + get { return lazyMethodSignature ?? (lazyMethodSignature = MethodSignature.ReadSig(module, module.GetBlob(module.MethodDef.records[index].Signature), this)); } + } + + internal override int ImportTo(Emit.ModuleBuilder module) + { + return module.ImportMethodOrField(declaringType, this.Name, this.MethodSignature); + } + } + + sealed class ParameterInfoImpl : ParameterInfo + { + private readonly MethodDefImpl method; + private readonly int position; + private readonly int index; + + internal ParameterInfoImpl(MethodDefImpl method, int position, int index) + { + this.method = method; + this.position = position; + this.index = index; + } + + public override string Name + { + get { return index == -1 ? null : ((ModuleReader)this.Module).GetString(this.Module.Param.records[index].Name); } + } + + public override Type ParameterType + { + get { return position == -1 ? method.MethodSignature.GetReturnType(method) : method.MethodSignature.GetParameterType(method, position); } + } + + public override ParameterAttributes Attributes + { + get { return index == -1 ? ParameterAttributes.None : (ParameterAttributes)this.Module.Param.records[index].Flags; } + } + + public override int Position + { + get { return position; } + } + + public override object RawDefaultValue + { + get + { + if ((this.Attributes & ParameterAttributes.HasDefault) != 0) + { + return this.Module.Constant.GetRawConstantValue(this.Module, this.MetadataToken); + } + Universe universe = this.Module.universe; + if (this.ParameterType == universe.System_Decimal) + { + Type attr = universe.System_Runtime_CompilerServices_DecimalConstantAttribute; + if (attr != null) + { + foreach (CustomAttributeData cad in GetCustomAttributesData(attr)) + { + IList args = cad.ConstructorArguments; + if (args.Count == 5) + { + if (args[0].ArgumentType == universe.System_Byte + && args[1].ArgumentType == universe.System_Byte + && args[2].ArgumentType == universe.System_Int32 + && args[3].ArgumentType == universe.System_Int32 + && args[4].ArgumentType == universe.System_Int32) + { + return new Decimal((int)args[4].Value, (int)args[3].Value, (int)args[2].Value, (byte)args[1].Value != 0, (byte)args[0].Value); + } + else if (args[0].ArgumentType == universe.System_Byte + && args[1].ArgumentType == universe.System_Byte + && args[2].ArgumentType == universe.System_UInt32 + && args[3].ArgumentType == universe.System_UInt32 + && args[4].ArgumentType == universe.System_UInt32) + { + return new Decimal(unchecked((int)(uint)args[4].Value), unchecked((int)(uint)args[3].Value), unchecked((int)(uint)args[2].Value), (byte)args[1].Value != 0, (byte)args[0].Value); + } + } + } + } + } + if ((this.Attributes & ParameterAttributes.Optional) != 0) + { + return Missing.Value; + } + return null; + } + } + + public override Type[] GetRequiredCustomModifiers() + { + return Util.Copy(position == -1 ? method.MethodSignature.GetReturnTypeRequiredCustomModifiers(method) : method.MethodSignature.GetParameterRequiredCustomModifiers(method, position)); + } + + public override Type[] GetOptionalCustomModifiers() + { + return Util.Copy(position == -1 ? method.MethodSignature.GetReturnTypeOptionalCustomModifiers(method) : method.MethodSignature.GetParameterOptionalCustomModifiers(method, position)); + } + + public override MemberInfo Member + { + get + { + // return the right ConstructorInfo wrapper + return method.Module.ResolveMethod(method.MetadataToken); + } + } + + public override int MetadataToken + { + get + { + // for parameters that don't have a row in the Param table, we return 0x08000000 (because index is -1 in that case), + // just like .NET + return (ParamTable.Index << 24) + index + 1; + } + } + + internal override Module Module + { + get { return method.Module; } + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + IList list = base.GetCustomAttributesData(attributeType); + if ((this.Attributes & ParameterAttributes.HasFieldMarshal) != 0 + && (attributeType == null || attributeType.IsAssignableFrom(this.Module.universe.System_Runtime_InteropServices_MarshalAsAttribute))) + { + list.Add(MarshalSpec.GetMarshalAsAttribute(this.Module, this.MetadataToken)); + } + return list; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/ModuleReader.cs b/mcs/class/IKVM.Reflection/Reader/ModuleReader.cs new file mode 100644 index 000000000000..3f04d71562d5 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/ModuleReader.cs @@ -0,0 +1,1028 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using System.Text; +using System.Collections.Generic; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class StreamHeader + { + internal uint Offset; + internal uint Size; + internal string Name; + + internal void Read(BinaryReader br) + { + Offset = br.ReadUInt32(); + Size = br.ReadUInt32(); + byte[] buf = new byte[32]; + byte b; + int len = 0; + while ((b = br.ReadByte()) != 0) + { + buf[len++] = b; + } + Name = Encoding.UTF8.GetString(buf, 0, len); ; + int padding = -1 + ((len + 4) & ~3) - len; + br.BaseStream.Seek(padding, SeekOrigin.Current); + } + } + + sealed class ModuleReader : Module + { + internal readonly Stream stream; + private readonly string location; + private Assembly assembly; + private readonly PEReader peFile = new PEReader(); + private readonly CliHeader cliHeader = new CliHeader(); + private string imageRuntimeVersion; + private int metadataStreamVersion; + private byte[] stringHeap; + private byte[] blobHeap; + private byte[] userStringHeap; + private byte[] guidHeap; + private TypeDefImpl[] typeDefs; + private TypeDefImpl moduleType; + private Assembly[] assemblyRefs; + private Type[] typeRefs; + private Type[] typeSpecs; + private FieldInfo[] fields; + private MethodBase[] methods; + private MemberInfo[] memberRefs; + private Dictionary strings = new Dictionary(); + private Dictionary types = new Dictionary(); + private Dictionary forwardedTypes = new Dictionary(); + + private sealed class LazyForwardedType + { + private readonly int assemblyRef; + private Type type; + + internal LazyForwardedType(int assemblyRef) + { + this.assemblyRef = assemblyRef; + } + + internal Type GetType(ModuleReader module, string typeName) + { + if (type == null) + { + Assembly asm = module.ResolveAssemblyRef(assemblyRef); + type = asm.GetType(typeName, true); + } + return type; + } + } + + internal ModuleReader(AssemblyReader assembly, Universe universe, Stream stream, string location) + : base(universe) + { + this.stream = stream; + this.location = location; + Read(); + if (assembly == null && AssemblyTable.records.Length != 0) + { + assembly = new AssemblyReader(location, this); + } + this.assembly = assembly; + } + + private void Read() + { + BinaryReader br = new BinaryReader(stream); + peFile.Read(br); + stream.Seek(peFile.RvaToFileOffset(peFile.GetComDescriptorVirtualAddress()), SeekOrigin.Begin); + cliHeader.Read(br); + stream.Seek(peFile.RvaToFileOffset(cliHeader.MetaDataRVA), SeekOrigin.Begin); + foreach (StreamHeader sh in ReadStreamHeaders(br, out imageRuntimeVersion)) + { + switch (sh.Name) + { + case "#Strings": + stringHeap = ReadHeap(stream, sh); + break; + case "#Blob": + blobHeap = ReadHeap(stream, sh); + break; + case "#US": + userStringHeap = ReadHeap(stream, sh); + break; + case "#GUID": + guidHeap = ReadHeap(stream, sh); + break; + case "#~": + stream.Seek(peFile.RvaToFileOffset(cliHeader.MetaDataRVA + sh.Offset), SeekOrigin.Begin); + ReadTables(br); + break; + default: + throw new BadImageFormatException("Unsupported stream: " + sh.Name); + } + } + } + + internal void SetAssembly(Assembly assembly) + { + this.assembly = assembly; + } + + private static StreamHeader[] ReadStreamHeaders(BinaryReader br, out string Version) + { + uint Signature = br.ReadUInt32(); + if (Signature != 0x424A5342) + { + throw new BadImageFormatException("Invalid metadata signature"); + } + ushort MajorVersion = br.ReadUInt16(); + ushort MinorVersion = br.ReadUInt16(); + uint Reserved = br.ReadUInt32(); + uint Length = br.ReadUInt32(); + byte[] buf = br.ReadBytes((int)Length); + Version = Encoding.UTF8.GetString(buf).TrimEnd('\u0000'); + ushort Flags = br.ReadUInt16(); + ushort Streams = br.ReadUInt16(); + StreamHeader[] streamHeaders = new StreamHeader[Streams]; + for (int i = 0; i < streamHeaders.Length; i++) + { + streamHeaders[i] = new StreamHeader(); + streamHeaders[i].Read(br); + } + return streamHeaders; + } + + private void ReadTables(BinaryReader br) + { + Table[] tables = GetTables(); + uint Reserved0 = br.ReadUInt32(); + byte MajorVersion = br.ReadByte(); + byte MinorVersion = br.ReadByte(); + metadataStreamVersion = MajorVersion << 16 | MinorVersion; + byte HeapSizes = br.ReadByte(); + byte Reserved7 = br.ReadByte(); + ulong Valid = br.ReadUInt64(); + ulong Sorted = br.ReadUInt64(); + for (int i = 0; i < 64; i++) + { + if ((Valid & (1UL << i)) != 0) + { + tables[i].RowCount = br.ReadInt32(); + } + else if (tables[i] != null) + { + tables[i].RowCount = 0; + } + } + MetadataReader mr = new MetadataReader(this, br, HeapSizes); + for (int i = 0; i < 64; i++) + { + if ((Valid & (1UL << i)) != 0) + { + tables[i].Read(mr); + } + } + } + + private byte[] ReadHeap(Stream stream, StreamHeader sh) + { + byte[] buf = new byte[sh.Size]; + stream.Seek(peFile.RvaToFileOffset(cliHeader.MetaDataRVA + sh.Offset), SeekOrigin.Begin); + for (int pos = 0; pos < buf.Length; ) + { + int read = stream.Read(buf, pos, buf.Length - pos); + if (read == 0) + { + throw new BadImageFormatException(); + } + pos += read; + } + return buf; + } + + internal void SeekRVA(int rva) + { + stream.Seek(peFile.RvaToFileOffset((uint)rva), SeekOrigin.Begin); + } + + internal override void GetTypesImpl(List list) + { + PopulateTypeDef(); + foreach (TypeDefImpl type in typeDefs) + { + if (type != moduleType) + { + list.Add(type); + } + } + } + + private void PopulateTypeDef() + { + if (typeDefs == null) + { + typeDefs = new TypeDefImpl[TypeDef.records.Length]; + for (int i = 0; i < typeDefs.Length; i++) + { + TypeDefImpl type = new TypeDefImpl(this, i); + typeDefs[i] = type; + if (type.IsModulePseudoType) + { + moduleType = type; + } + else + { + types.Add(type.FullName, type); + } + } + // add forwarded types to forwardedTypes dictionary (because Module.GetType(string) should return them) + for (int i = 0; i < ExportedType.records.Length; i++) + { + int implementation = ExportedType.records[i].Implementation; + if (implementation >> 24 == AssemblyRefTable.Index) + { + string typeName = GetTypeName(ExportedType.records[i].TypeNamespace, ExportedType.records[i].TypeName); + forwardedTypes.Add(typeName, new LazyForwardedType((implementation & 0xFFFFFF) - 1)); + } + } + } + } + + internal string GetString(int index) + { + if (index == 0) + { + return null; + } + string str; + if (!strings.TryGetValue(index, out str)) + { + int len = 0; + while (stringHeap[index + len] != 0) + { + len++; + } + str = Encoding.UTF8.GetString(stringHeap, index, len); + strings.Add(index, str); + } + return str; + } + + private static int ReadCompressedInt(byte[] buffer, ref int offset) + { + byte b1 = buffer[offset++]; + if (b1 <= 0x7F) + { + return b1; + } + else if ((b1 & 0xC0) == 0x80) + { + byte b2 = buffer[offset++]; + return ((b1 & 0x3F) << 8) | b2; + } + else + { + byte b2 = buffer[offset++]; + byte b3 = buffer[offset++]; + byte b4 = buffer[offset++]; + return ((b1 & 0x3F) << 24) + (b2 << 16) + (b3 << 8) + b4; + } + } + + internal byte[] GetBlobCopy(int blobIndex) + { + int len = ReadCompressedInt(blobHeap, ref blobIndex); + byte[] buf = new byte[len]; + Buffer.BlockCopy(blobHeap, blobIndex, buf, 0, len); + return buf; + } + + internal override ByteReader GetBlob(int blobIndex) + { + return ByteReader.FromBlob(blobHeap, blobIndex); + } + + public override string ResolveString(int metadataToken) + { + string str; + if (!strings.TryGetValue(metadataToken, out str)) + { + if ((metadataToken >> 24) != 0x70) + { + throw new ArgumentOutOfRangeException(); + } + int index = metadataToken & 0xFFFFFF; + int len = ReadCompressedInt(userStringHeap, ref index) & ~1; + str = Encoding.Unicode.GetString(userStringHeap, index, len); + strings.Add(metadataToken, str); + } + return str; + } + + internal Type ResolveType(int metadataToken, IGenericContext context) + { + switch (metadataToken >> 24) + { + case TypeDefTable.Index: + PopulateTypeDef(); + return typeDefs[(metadataToken & 0xFFFFFF) - 1]; + case TypeRefTable.Index: + { + if (typeRefs == null) + { + typeRefs = new Type[TypeRef.records.Length]; + } + int index = (metadataToken & 0xFFFFFF) - 1; + if (typeRefs[index] == null) + { + int scope = TypeRef.records[index].ResolutionScope; + switch (scope >> 24) + { + case AssemblyRefTable.Index: + { + Assembly assembly = ResolveAssemblyRef((scope & 0xFFFFFF) - 1); + string typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName); + Type type = assembly.GetType(typeName); + if (type == null) + { + throw new TypeLoadException(String.Format("Type '{0}' not found in assembly '{1}'", typeName, assembly.FullName)); + } + typeRefs[index] = type; + break; + } + case TypeRefTable.Index: + { + Type outer = ResolveType(scope, null); + typeRefs[index] = outer.GetNestedType(GetString(TypeRef.records[index].TypeName), BindingFlags.Public | BindingFlags.NonPublic); + break; + } + case ModuleTable.Index: + if (scope != 0 && scope != 1) + { + throw new NotImplementedException("self reference scope?"); + } + typeRefs[index] = GetType(GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName)); + break; + case ModuleRefTable.Index: + { + Module module = ResolveModuleRef(ModuleRef.records[(scope & 0xFFFFFF) - 1]); + string typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName); + Type type = assembly.GetType(typeName); + if (type == null) + { + throw new TypeLoadException(String.Format("Type '{0}' not found in module '{1}'", typeName, module.Name)); + } + typeRefs[index] = type; + break; + } + default: + throw new NotImplementedException("ResolutionScope = " + scope.ToString("X")); + } + } + return typeRefs[index]; + } + case TypeSpecTable.Index: + { + if (typeSpecs == null) + { + typeSpecs = new Type[TypeSpec.records.Length]; + } + int index = (metadataToken & 0xFFFFFF) - 1; + Type type = typeSpecs[index]; + if (type == null) + { + TrackingGenericContext tc = context == null ? null : new TrackingGenericContext(context); + type = Signature.ReadTypeSpec(this, ByteReader.FromBlob(blobHeap, TypeSpec.records[index]), tc); + if (tc == null || !tc.IsUsed) + { + typeSpecs[index] = type; + } + } + return type; + } + default: + throw new NotImplementedException(String.Format("0x{0:X}", metadataToken)); + } + } + + private Module ResolveModuleRef(int moduleNameIndex) + { + string moduleName = GetString(moduleNameIndex); + Module module = assembly.GetModule(moduleName); + if (module == null) + { + throw new FileNotFoundException(moduleName); + } + return module; + } + + private sealed class TrackingGenericContext : IGenericContext + { + private readonly IGenericContext context; + private bool used; + + internal TrackingGenericContext(IGenericContext context) + { + this.context = context; + } + + internal bool IsUsed + { + get { return used; } + } + + public Type GetGenericTypeArgument(int index) + { + used = true; + return context.GetGenericTypeArgument(index); + } + + public Type GetGenericMethodArgument(int index) + { + used = true; + return context.GetGenericMethodArgument(index); + } + } + + public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if ((metadataToken >> 24) == TypeSpecTable.Index) + { + return ResolveType(metadataToken, new GenericContext(genericTypeArguments, genericMethodArguments)); + } + else + { + return ResolveType(metadataToken, null); + } + } + + private string GetTypeName(int typeNamespace, int typeName) + { + if (typeNamespace == 0) + { + return GetString(typeName); + } + else + { + return GetString(typeNamespace) + "." + GetString(typeName); + } + } + + private Assembly ResolveAssemblyRef(int index) + { + if (assemblyRefs == null) + { + assemblyRefs = new Assembly[AssemblyRef.RowCount]; + } + if (assemblyRefs[index] == null) + { + assemblyRefs[index] = ResolveAssemblyRefImpl(ref AssemblyRef.records[index]); + } + return assemblyRefs[index]; + } + + private Assembly ResolveAssemblyRefImpl(ref AssemblyRefTable.Record rec) + { + const int PublicKey = 0x0001; + string name = String.Format("{0}, Version={1}.{2}.{3}.{4}, Culture={5}, {6}={7}", + GetString(rec.Name), + rec.MajorVersion, + rec.MinorVersion, + rec.BuildNumber, + rec.RevisionNumber, + rec.Culture == 0 ? "neutral" : GetString(rec.Culture), + (rec.Flags & PublicKey) == 0 ? "PublicKeyToken" : "PublicKey", + PublicKeyOrTokenToString(rec.PublicKeyOrToken)); + return universe.Load(name, this.Assembly, true); + } + + private string PublicKeyOrTokenToString(int publicKeyOrToken) + { + if (publicKeyOrToken == 0) + { + return "null"; + } + ByteReader br = GetBlob(publicKeyOrToken); + if (br.Length == 0) + { + return "null"; + } + StringBuilder sb = new StringBuilder(br.Length * 2); + while (br.Length > 0) + { + sb.AppendFormat("{0:x2}", br.ReadByte()); + } + return sb.ToString(); + } + + public override Guid ModuleVersionId + { + get + { + byte[] buf = new byte[16]; + Buffer.BlockCopy(guidHeap, 16 * (ModuleTable.records[0].Mvid - 1), buf, 0, 16); + return new Guid(buf); + } + } + + public override string FullyQualifiedName + { + get { return location ?? ""; } + } + + public override string Name + { + get { return location == null ? "" : System.IO.Path.GetFileName(location); } + } + + public override Assembly Assembly + { + get { return assembly; } + } + + internal override Type GetTypeImpl(string typeName) + { + PopulateTypeDef(); + Type type; + if (!types.TryGetValue(typeName, out type)) + { + LazyForwardedType fw; + if (forwardedTypes.TryGetValue(typeName, out fw)) + { + return fw.GetType(this, typeName); + } + } + return type; + } + + public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + switch (metadataToken >> 24) + { + case FieldTable.Index: + return ResolveField(metadataToken, genericTypeArguments, genericMethodArguments); + case MemberRefTable.Index: + return GetMemberRef((metadataToken & 0xFFFFFF) - 1, genericTypeArguments, genericMethodArguments); + case MethodDefTable.Index: + case MethodSpecTable.Index: + return ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments); + } + throw new ArgumentOutOfRangeException(); + } + + internal FieldInfo GetFieldAt(TypeDefImpl owner, int index) + { + if (fields == null) + { + fields = new FieldInfo[Field.records.Length]; + } + if (fields[index] == null) + { + fields[index] = new FieldDefImpl(this, owner ?? FindFieldOwner(index), index); + } + return fields[index]; + } + + public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if ((metadataToken >> 24) == FieldTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + return GetFieldAt(null, index); + } + else if ((metadataToken >> 24) == MemberRefTable.Index) + { + FieldInfo field = GetMemberRef((metadataToken & 0xFFFFFF) - 1, genericTypeArguments, genericMethodArguments) as FieldInfo; + if (field != null) + { + return field; + } + } + throw new ArgumentOutOfRangeException(); + } + + private TypeDefImpl FindFieldOwner(int fieldIndex) + { + // TODO use binary search? + for (int i = 0; i < TypeDef.records.Length; i++) + { + int field = TypeDef.records[i].FieldList - 1; + int end = TypeDef.records.Length > i + 1 ? TypeDef.records[i + 1].FieldList - 1 : Field.records.Length; + if (field <= fieldIndex && fieldIndex < end) + { + PopulateTypeDef(); + return typeDefs[i]; + } + } + throw new InvalidOperationException(); + } + + internal MethodBase GetMethodAt(TypeDefImpl owner, int index) + { + if (methods == null) + { + methods = new MethodBase[MethodDef.records.Length]; + } + if (methods[index] == null) + { + MethodDefImpl method = new MethodDefImpl(this, owner ?? FindMethodOwner(index), index); + methods[index] = method.IsConstructor ? new ConstructorInfoImpl(method) : (MethodBase)method; + } + return methods[index]; + } + + private sealed class GenericContext : IGenericContext + { + private readonly Type[] genericTypeArguments; + private readonly Type[] genericMethodArguments; + + internal GenericContext(Type[] genericTypeArguments, Type[] genericMethodArguments) + { + this.genericTypeArguments = genericTypeArguments; + this.genericMethodArguments = genericMethodArguments; + } + + public Type GetGenericTypeArgument(int index) + { + return genericTypeArguments[index]; + } + + public Type GetGenericMethodArgument(int index) + { + return genericMethodArguments[index]; + } + } + + public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if ((metadataToken >> 24) == MethodDefTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + return GetMethodAt(null, index); + } + else if ((metadataToken >> 24) == MemberRefTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + MethodBase method = GetMemberRef(index, genericTypeArguments, genericMethodArguments) as MethodBase; + if (method != null) + { + return method; + } + } + else if ((metadataToken >> 24) == MethodSpecTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + MethodInfo method = (MethodInfo)ResolveMethod(MethodSpec.records[index].Method, genericTypeArguments, genericMethodArguments); + ByteReader instantiation = ByteReader.FromBlob(blobHeap, MethodSpec.records[index].Instantiation); + return method.MakeGenericMethod(Signature.ReadMethodSpec(this, instantiation, new GenericContext(genericTypeArguments, genericMethodArguments))); + } + throw new ArgumentOutOfRangeException(); + } + + public override Type[] __ResolveOptionalParameterTypes(int metadataToken) + { + if ((metadataToken >> 24) == MemberRefTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + int sig = MemberRef.records[index].Signature; + return Signature.ReadOptionalParameterTypes(this, GetBlob(sig)); + } + else if ((metadataToken >> 24) == MethodDefTable.Index) + { + // for convenience, we support passing a MethodDef token as well, because in some places + // it makes sense to have a vararg method that is referred to by its methoddef (e.g. ldftn). + // Note that MethodSpec doesn't make sense, because generic methods cannot be vararg. + return Type.EmptyTypes; + } + throw new ArgumentOutOfRangeException(); + } + + public override string ScopeName + { + get { return GetString(ModuleTable.records[0].Name); } + } + + private TypeDefImpl FindMethodOwner(int methodIndex) + { + // TODO use binary search? + for (int i = 0; i < TypeDef.records.Length; i++) + { + int method = TypeDef.records[i].MethodList - 1; + int end = TypeDef.records.Length > i + 1 ? TypeDef.records[i + 1].MethodList - 1 : MethodDef.records.Length; + if (method <= methodIndex && methodIndex < end) + { + PopulateTypeDef(); + return typeDefs[i]; + } + } + throw new InvalidOperationException(); + } + + private MemberInfo GetMemberRef(int index, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + if (memberRefs == null) + { + memberRefs = new MemberInfo[MemberRef.records.Length]; + } + if (memberRefs[index] == null) + { + int owner = MemberRef.records[index].Class; + int sig = MemberRef.records[index].Signature; + string name = GetString(MemberRef.records[index].Name); + switch (owner >> 24) + { + case MethodDefTable.Index: + return GetMethodAt(null, (owner & 0xFFFFFF) - 1); + case ModuleRefTable.Index: + memberRefs[index] = ResolveTypeMemberRef(ResolveModuleType(owner), name, ByteReader.FromBlob(blobHeap, sig), genericTypeArguments, genericMethodArguments); + break; + case TypeDefTable.Index: + case TypeRefTable.Index: + memberRefs[index] = ResolveTypeMemberRef(ResolveType(owner), name, ByteReader.FromBlob(blobHeap, sig), genericTypeArguments, genericMethodArguments); + break; + case TypeSpecTable.Index: + return ResolveTypeMemberRef(ResolveType(owner, genericTypeArguments, genericMethodArguments), name, ByteReader.FromBlob(blobHeap, sig), genericTypeArguments, genericMethodArguments); + default: + throw new BadImageFormatException(); + } + } + return memberRefs[index]; + } + + private Type ResolveModuleType(int token) + { + int index = (token & 0xFFFFFF) - 1; + string name = GetString(ModuleRef.records[index]); + Module module = assembly.GetModule(name); + if (module == null || module.IsResource()) + { + throw new BadImageFormatException(); + } + return module.GetModuleType(); + } + + private MemberInfo ResolveTypeMemberRef(Type type, string name, ByteReader sig, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + IGenericContext context; + if ((genericTypeArguments == null && genericMethodArguments == null) || type.IsGenericType) + { + context = type; + } + else + { + context = new GenericContext(genericTypeArguments, genericMethodArguments); + } + if (sig.PeekByte() == Signature.FIELD) + { + Type org = type; + FieldSignature fieldSig = FieldSignature.ReadSig(this, sig, context); + do + { + FieldInfo field = type.FindField(name, fieldSig); + if (field != null) + { + return field; + } + type = type.BaseType; + } while (type != null); + throw new MissingFieldException(org.ToString(), name); + } + else + { + Type org = type; + MethodSignature methodSig = MethodSignature.ReadSig(this, sig, context); + do + { + MethodBase method = type.FindMethod(name, methodSig); + if (method != null) + { + return method; + } + type = type.BaseType; + } while (type != null); + throw new MissingMethodException(org.ToString(), name); + } + } + + internal new ByteReader ResolveSignature(int metadataToken) + { + if ((metadataToken >> 24) == StandAloneSigTable.Index) + { + int index = (metadataToken & 0xFFFFFF) - 1; + return ByteReader.FromBlob(blobHeap, StandAloneSig.records[index]); + } + throw new ArgumentOutOfRangeException(); + } + + public override __StandAloneMethodSig __ResolveStandAloneMethodSig(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + return MethodSignature.ReadStandAloneMethodSig(this, ResolveSignature(metadataToken), new GenericContext(genericTypeArguments, genericMethodArguments)); + } + + internal MethodInfo GetEntryPoint() + { + if (cliHeader.EntryPointToken != 0 && (cliHeader.Flags & CliHeader.COMIMAGE_FLAGS_NATIVE_ENTRYPOINT) == 0) + { + return (MethodInfo)ResolveMethod((int)cliHeader.EntryPointToken); + } + return null; + } + + internal string[] GetManifestResourceNames() + { + string[] names = new string[ManifestResource.records.Length]; + for (int i = 0; i < ManifestResource.records.Length; i++) + { + names[i] = GetString(ManifestResource.records[i].Name); + } + return names; + } + + internal ManifestResourceInfo GetManifestResourceInfo(string resourceName) + { + for (int i = 0; i < ManifestResource.records.Length; i++) + { + if (resourceName == GetString(ManifestResource.records[i].Name)) + { + return new ManifestResourceInfo(this, i); + } + } + return null; + } + + internal Stream GetManifestResourceStream(string resourceName) + { + for (int i = 0; i < ManifestResource.records.Length; i++) + { + if (resourceName == GetString(ManifestResource.records[i].Name)) + { + if (ManifestResource.records[i].Implementation != 0x26000000) + { + throw new NotImplementedException(); + } + SeekRVA((int)cliHeader.ResourcesRVA + ManifestResource.records[i].Offset); + BinaryReader br = new BinaryReader(stream); + int length = br.ReadInt32(); + return new MemoryStream(br.ReadBytes(length)); + } + } + throw new FileNotFoundException(); + } + + public override AssemblyName[] __GetReferencedAssemblies() + { + List list = new List(); + for (int i = 0; i < AssemblyRef.records.Length; i++) + { + AssemblyName name = new AssemblyName(); + name.Name = GetString(AssemblyRef.records[i].Name); + name.Version = new Version( + AssemblyRef.records[i].MajorVersion, + AssemblyRef.records[i].MinorVersion, + AssemblyRef.records[i].BuildNumber, + AssemblyRef.records[i].RevisionNumber); + if (AssemblyRef.records[i].PublicKeyOrToken != 0) + { + byte[] keyOrToken = GetBlobCopy(AssemblyRef.records[i].PublicKeyOrToken); + const int PublicKey = 0x0001; + if ((AssemblyRef.records[i].Flags & PublicKey) != 0) + { + name.SetPublicKey(keyOrToken); + } + else + { + name.SetPublicKeyToken(keyOrToken); + } + } + if (AssemblyRef.records[i].Culture != 0) + { + name.CultureInfo = new System.Globalization.CultureInfo(GetString(AssemblyRef.records[i].Culture)); + } + else + { + name.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; + } + name.Flags = (AssemblyNameFlags)AssemblyRef.records[i].Flags; + list.Add(name); + } + return list.ToArray(); + } + + internal override Type GetModuleType() + { + PopulateTypeDef(); + return moduleType; + } + + internal string ImageRuntimeVersion + { + get { return imageRuntimeVersion; } + } + + public override int MDStreamVersion + { + get { return metadataStreamVersion; } + } + + public override void __GetDataDirectoryEntry(int index, out int rva, out int length) + { + peFile.GetDataDirectoryEntry(index, out rva, out length); + } + + public override long __RelativeVirtualAddressToFileOffset(int rva) + { + return peFile.RvaToFileOffset((uint)rva); + } + + public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) + { + peKind = 0; + if ((cliHeader.Flags & CliHeader.COMIMAGE_FLAGS_ILONLY) != 0) + { + peKind |= PortableExecutableKinds.ILOnly; + } + if ((cliHeader.Flags & CliHeader.COMIMAGE_FLAGS_32BITREQUIRED) != 0) + { + peKind |= PortableExecutableKinds.Required32Bit; + } + if (peFile.OptionalHeader.Magic == IMAGE_OPTIONAL_HEADER.IMAGE_NT_OPTIONAL_HDR64_MAGIC) + { + peKind |= PortableExecutableKinds.PE32Plus; + } + + machine = (ImageFileMachine)peFile.FileHeader.Machine; + } + + public override int __Subsystem + { + get { return peFile.OptionalHeader.Subsystem; } + } + + public override IList __GetPlaceholderAssemblyCustomAttributes(bool multiple, bool security) + { + string typeName; + switch ((multiple ? 1 : 0) + (security ? 2 : 0)) + { + case 0: + typeName = "System.Runtime.CompilerServices.AssemblyAttributesGoHere"; + break; + case 1: + typeName = "System.Runtime.CompilerServices.AssemblyAttributesGoHereM"; + break; + case 2: + typeName = "System.Runtime.CompilerServices.AssemblyAttributesGoHereS"; + break; + case 3: + default: + typeName = "System.Runtime.CompilerServices.AssemblyAttributesGoHereSM"; + break; + } + List list = new List(); + for (int i = 0; i < CustomAttribute.records.Length; i++) + { + if ((CustomAttribute.records[i].Parent >> 24) == TypeRefTable.Index) + { + int index = (CustomAttribute.records[i].Parent & 0xFFFFFF) - 1; + if (typeName == GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName)) + { + ConstructorInfo constructor = (ConstructorInfo)ResolveMethod(CustomAttribute.records[i].Type); + list.Add(new CustomAttributeData(this.Assembly, constructor, GetBlob(CustomAttribute.records[i].Value))); + } + } + } + return list; + } + + internal override void Dispose() + { + stream.Close(); + } + + internal override void ExportTypes(int fileToken, IKVM.Reflection.Emit.ModuleBuilder manifestModule) + { + PopulateTypeDef(); + manifestModule.ExportTypes(typeDefs, fileToken); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/PEReader.cs b/mcs/class/IKVM.Reflection/Reader/PEReader.cs new file mode 100644 index 000000000000..dcafcf00bee8 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/PEReader.cs @@ -0,0 +1,318 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using BYTE = System.Byte; +using WORD = System.UInt16; +using DWORD = System.UInt32; +using ULONGLONG = System.UInt64; +using System.IO; + +namespace IKVM.Reflection.Reader +{ + sealed class MSDOS_HEADER + { + internal const WORD MAGIC_MZ = 0x5A4D; + + internal WORD signature; // 'MZ' + // skip 58 bytes + internal DWORD peSignatureOffset; + } + + sealed class IMAGE_NT_HEADERS + { + public const DWORD MAGIC_SIGNATURE = 0x00004550; // "PE\0\0" + + public DWORD Signature; + public IMAGE_FILE_HEADER FileHeader = new IMAGE_FILE_HEADER(); + public IMAGE_OPTIONAL_HEADER OptionalHeader = new IMAGE_OPTIONAL_HEADER(); + + internal void Read(BinaryReader br) + { + Signature = br.ReadUInt32(); + if (Signature != IMAGE_NT_HEADERS.MAGIC_SIGNATURE) + { + throw new BadImageFormatException(); + } + FileHeader.Read(br); + OptionalHeader.Read(br); + } + } + + sealed class IMAGE_FILE_HEADER + { + public const WORD IMAGE_FILE_MACHINE_I386 = 0x014c; + public const WORD IMAGE_FILE_MACHINE_IA64 = 0x0200; + public const WORD IMAGE_FILE_MACHINE_AMD64 = 0x8664; + + public const WORD IMAGE_FILE_32BIT_MACHINE = 0x0100; + public const WORD IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002; + public const WORD IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020; + public const WORD IMAGE_FILE_DLL = 0x2000; + + public WORD Machine; + public WORD NumberOfSections; + public DWORD TimeDateStamp; + public DWORD PointerToSymbolTable; + public DWORD NumberOfSymbols; + public WORD SizeOfOptionalHeader; + public WORD Characteristics; + + internal void Read(BinaryReader br) + { + Machine = br.ReadUInt16(); + NumberOfSections = br.ReadUInt16(); + TimeDateStamp = br.ReadUInt32(); + PointerToSymbolTable = br.ReadUInt32(); + NumberOfSymbols = br.ReadUInt32(); + SizeOfOptionalHeader = br.ReadUInt16(); + Characteristics = br.ReadUInt16(); + } + } + + sealed class IMAGE_OPTIONAL_HEADER + { + public const WORD IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b; + public const WORD IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b; + + public const WORD IMAGE_SUBSYSTEM_WINDOWS_GUI = 2; + public const WORD IMAGE_SUBSYSTEM_WINDOWS_CUI = 3; + + public const WORD IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = 0x0040; + public const WORD IMAGE_DLLCHARACTERISTICS_NX_COMPAT = 0x0100; + public const WORD IMAGE_DLLCHARACTERISTICS_NO_SEH = 0x0400; + public const WORD IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000; + + public WORD Magic; + public BYTE MajorLinkerVersion; + public BYTE MinorLinkerVersion; + public DWORD SizeOfCode; + public DWORD SizeOfInitializedData; + public DWORD SizeOfUninitializedData; + public DWORD AddressOfEntryPoint; + public DWORD BaseOfCode; + public DWORD BaseOfData; + public ULONGLONG ImageBase; + public DWORD SectionAlignment; + public DWORD FileAlignment; + public WORD MajorOperatingSystemVersion; + public WORD MinorOperatingSystemVersion; + public WORD MajorImageVersion; + public WORD MinorImageVersion; + public WORD MajorSubsystemVersion; + public WORD MinorSubsystemVersion; + public DWORD Win32VersionValue; + public DWORD SizeOfImage; + public DWORD SizeOfHeaders; + public DWORD CheckSum; + public WORD Subsystem; + public WORD DllCharacteristics; + public ULONGLONG SizeOfStackReserve; + public ULONGLONG SizeOfStackCommit; + public ULONGLONG SizeOfHeapReserve; + public ULONGLONG SizeOfHeapCommit; + public DWORD LoaderFlags; + public DWORD NumberOfRvaAndSizes; + public IMAGE_DATA_DIRECTORY[] DataDirectory; + + internal void Read(BinaryReader br) + { + Magic = br.ReadUInt16(); + if (Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC && Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC) + { + throw new BadImageFormatException(); + } + MajorLinkerVersion = br.ReadByte(); + MinorLinkerVersion = br.ReadByte(); + SizeOfCode = br.ReadUInt32(); + SizeOfInitializedData = br.ReadUInt32(); + SizeOfUninitializedData = br.ReadUInt32(); + AddressOfEntryPoint = br.ReadUInt32(); + BaseOfCode = br.ReadUInt32(); + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + BaseOfData = br.ReadUInt32(); + ImageBase = br.ReadUInt32(); + } + else + { + ImageBase = br.ReadUInt64(); + } + SectionAlignment = br.ReadUInt32(); + FileAlignment = br.ReadUInt32(); + MajorOperatingSystemVersion = br.ReadUInt16(); + MinorOperatingSystemVersion = br.ReadUInt16(); + MajorImageVersion = br.ReadUInt16(); + MinorImageVersion = br.ReadUInt16(); + MajorSubsystemVersion = br.ReadUInt16(); + MinorSubsystemVersion = br.ReadUInt16(); + Win32VersionValue = br.ReadUInt32(); + SizeOfImage = br.ReadUInt32(); + SizeOfHeaders = br.ReadUInt32(); + CheckSum = br.ReadUInt32(); + Subsystem = br.ReadUInt16(); + DllCharacteristics = br.ReadUInt16(); + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + SizeOfStackReserve = br.ReadUInt32(); + SizeOfStackCommit = br.ReadUInt32(); + SizeOfHeapReserve = br.ReadUInt32(); + SizeOfHeapCommit = br.ReadUInt32(); + } + else + { + SizeOfStackReserve = br.ReadUInt64(); + SizeOfStackCommit = br.ReadUInt64(); + SizeOfHeapReserve = br.ReadUInt64(); + SizeOfHeapCommit = br.ReadUInt64(); + } + LoaderFlags = br.ReadUInt32(); + NumberOfRvaAndSizes = br.ReadUInt32(); + DataDirectory = new IMAGE_DATA_DIRECTORY[NumberOfRvaAndSizes]; + for (uint i = 0; i < NumberOfRvaAndSizes; i++) + { + DataDirectory[i] = new IMAGE_DATA_DIRECTORY(); + DataDirectory[i].Read(br); + } + } + } + + struct IMAGE_DATA_DIRECTORY + { + public DWORD VirtualAddress; + public DWORD Size; + + internal void Read(BinaryReader br) + { + VirtualAddress = br.ReadUInt32(); + Size = br.ReadUInt32(); + } + } + + class SectionHeader + { + public const DWORD IMAGE_SCN_CNT_CODE = 0x00000020; + public const DWORD IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040; + public const DWORD IMAGE_SCN_MEM_DISCARDABLE = 0x02000000; + public const DWORD IMAGE_SCN_MEM_EXECUTE = 0x20000000; + public const DWORD IMAGE_SCN_MEM_READ = 0x40000000; + public const DWORD IMAGE_SCN_MEM_WRITE = 0x80000000; + + public string Name; // 8 byte UTF8 encoded 0-padded + public DWORD VirtualSize; + public DWORD VirtualAddress; + public DWORD SizeOfRawData; + public DWORD PointerToRawData; + public DWORD PointerToRelocations; + public DWORD PointerToLinenumbers; + public WORD NumberOfRelocations; + public WORD NumberOfLinenumbers; + public DWORD Characteristics; + + internal void Read(BinaryReader br) + { + char[] name = new char[8]; + int len = 8; + for (int i = 0; i < 8; i++) + { + byte b = br.ReadByte(); + name[i] = (char)b; + if (b == 0 && len == 8) + { + len = i; + } + } + Name = new String(name, 0, len); + VirtualSize = br.ReadUInt32(); + VirtualAddress = br.ReadUInt32(); + SizeOfRawData = br.ReadUInt32(); + PointerToRawData = br.ReadUInt32(); + PointerToRelocations = br.ReadUInt32(); + PointerToLinenumbers = br.ReadUInt32(); + NumberOfRelocations = br.ReadUInt16(); + NumberOfLinenumbers = br.ReadUInt16(); + Characteristics = br.ReadUInt32(); + } + } + + sealed class PEReader + { + private MSDOS_HEADER msdos = new MSDOS_HEADER(); + private IMAGE_NT_HEADERS headers = new IMAGE_NT_HEADERS(); + private SectionHeader[] sections; + + internal void Read(BinaryReader br) + { + msdos.signature = br.ReadUInt16(); + br.BaseStream.Seek(58, SeekOrigin.Current); + msdos.peSignatureOffset = br.ReadUInt32(); + + if (msdos.signature != MSDOS_HEADER.MAGIC_MZ) + { + throw new BadImageFormatException(); + } + + br.BaseStream.Seek(msdos.peSignatureOffset, SeekOrigin.Begin); + headers.Read(br); + sections = new SectionHeader[headers.FileHeader.NumberOfSections]; + for (int i = 0; i < sections.Length; i++) + { + sections[i] = new SectionHeader(); + sections[i].Read(br); + } + } + + internal IMAGE_FILE_HEADER FileHeader + { + get { return headers.FileHeader; } + } + + internal IMAGE_OPTIONAL_HEADER OptionalHeader + { + get { return headers.OptionalHeader; } + } + + internal DWORD GetComDescriptorVirtualAddress() + { + return headers.OptionalHeader.DataDirectory[14].VirtualAddress; + } + + internal void GetDataDirectoryEntry(int index, out int rva, out int length) + { + rva = (int)headers.OptionalHeader.DataDirectory[index].VirtualAddress; + length = (int)headers.OptionalHeader.DataDirectory[index].Size; + } + + internal long RvaToFileOffset(DWORD rva) + { + for (int i = 0; i < sections.Length; i++) + { + if (rva >= sections[i].VirtualAddress && rva < sections[i].VirtualAddress + sections[i].VirtualSize) + { + return sections[i].PointerToRawData + rva - sections[i].VirtualAddress; + } + } + throw new BadImageFormatException(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/PropertyInfoImpl.cs b/mcs/class/IKVM.Reflection/Reader/PropertyInfoImpl.cs new file mode 100644 index 000000000000..ea95393f897b --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/PropertyInfoImpl.cs @@ -0,0 +1,156 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class PropertyInfoImpl : PropertyInfo + { + private readonly ModuleReader module; + private readonly Type declaringType; + private readonly int index; + private PropertySignature sig; + private bool isPublic; + private bool isStatic; + private bool flagsCached; + + internal PropertyInfoImpl(ModuleReader module, Type declaringType, int index) + { + this.module = module; + this.declaringType = declaringType; + this.index = index; + } + + public override bool Equals(object obj) + { + PropertyInfoImpl other = obj as PropertyInfoImpl; + return other != null && other.DeclaringType == declaringType && other.index == index; + } + + public override int GetHashCode() + { + return declaringType.GetHashCode() * 77 + index; + } + + internal override PropertySignature PropertySignature + { + get + { + if (sig == null) + { + sig = PropertySignature.ReadSig(module, module.GetBlob(module.Property.records[index].Type), declaringType); + } + return sig; + } + } + + public override PropertyAttributes Attributes + { + get { return (PropertyAttributes)module.Property.records[index].Flags; } + } + + public override object GetRawConstantValue() + { + return module.Constant.GetRawConstantValue(module, this.MetadataToken); + } + + public override bool CanRead + { + get { return GetGetMethod(true) != null; } + } + + public override bool CanWrite + { + get { return GetSetMethod(true) != null; } + } + + public override MethodInfo GetGetMethod(bool nonPublic) + { + return module.MethodSemantics.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Getter); + } + + public override MethodInfo GetSetMethod(bool nonPublic) + { + return module.MethodSemantics.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Setter); + } + + public override MethodInfo[] GetAccessors(bool nonPublic) + { + return module.MethodSemantics.GetMethods(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Getter | MethodSemanticsTable.Setter | MethodSemanticsTable.Other); + } + + public override Type DeclaringType + { + get { return declaringType; } + } + + public override Module Module + { + get { return module; } + } + + public override int MetadataToken + { + get { return (PropertyTable.Index << 24) + index + 1; } + } + + public override string Name + { + get { return module.GetString(module.Property.records[index].Name); } + } + + internal override bool IsPublic + { + get + { + if (!flagsCached) + { + ComputeFlags(); + } + return isPublic; + } + } + + internal override bool IsStatic + { + get + { + if (!flagsCached) + { + ComputeFlags(); + } + return isStatic; + } + } + + private void ComputeFlags() + { + module.MethodSemantics.ComputeFlags(module, this.MetadataToken, out isPublic, out isStatic); + flagsCached = true; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/ResourceModule.cs b/mcs/class/IKVM.Reflection/Reader/ResourceModule.cs new file mode 100644 index 000000000000..e80170d21811 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/ResourceModule.cs @@ -0,0 +1,132 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; + +namespace IKVM.Reflection.Reader +{ + sealed class ResourceModule : Module + { + private readonly Assembly assembly; + private readonly string scopeName; + private readonly string location; + + internal ResourceModule(Assembly assembly, string scopeName, string location) + : base(assembly.universe) + { + this.assembly = assembly; + this.scopeName = scopeName; + this.location = location; + } + + public override int MDStreamVersion + { + get { throw new NotSupportedException(); } + } + + public override bool IsResource() + { + return true; + } + + public override Assembly Assembly + { + get { return assembly; } + } + + public override string FullyQualifiedName + { + get { return location ?? ""; } + } + + public override string Name + { + get { return location == null ? "" : System.IO.Path.GetFileName(location); } + } + + public override string ScopeName + { + get { return scopeName; } + } + + public override Guid ModuleVersionId + { + get { throw new NotSupportedException(); } + } + + public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotSupportedException(); + } + + public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotSupportedException(); + } + + public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotSupportedException(); + } + + public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) + { + throw new NotSupportedException(); + } + + public override string ResolveString(int metadataToken) + { + throw new NotSupportedException(); + } + + public override Type[] __ResolveOptionalParameterTypes(int metadataToken) + { + throw new NotSupportedException(); + } + + public override AssemblyName[] __GetReferencedAssemblies() + { + throw new NotSupportedException(); + } + + internal override Type GetTypeImpl(string typeName) + { + return null; + } + + internal override void GetTypesImpl(List list) + { + } + + internal override Type GetModuleType() + { + throw new InvalidOperationException(); + } + + internal override ByteReader GetBlob(int blobIndex) + { + throw new InvalidOperationException(); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Reader/TypeDefImpl.cs b/mcs/class/IKVM.Reflection/Reader/TypeDefImpl.cs new file mode 100644 index 000000000000..ec6aba1bfdf0 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Reader/TypeDefImpl.cs @@ -0,0 +1,378 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Reader +{ + sealed class TypeDefImpl : Type + { + private readonly ModuleReader module; + private readonly int index; + private readonly string typeName; + private readonly string typeNamespace; + private Type[] typeArgs; + + internal TypeDefImpl(ModuleReader module, int index) + { + this.module = module; + this.index = index; + this.typeName = TypeNameParser.Escape(module.GetString(module.TypeDef.records[index].TypeName)); + this.typeNamespace = TypeNameParser.Escape(module.GetString(module.TypeDef.records[index].TypeNamespace)); + } + + public override Type BaseType + { + get + { + int extends = module.TypeDef.records[index].Extends; + if ((extends & 0xFFFFFF) == 0) + { + return null; + } + return module.ResolveType(extends, this); + } + } + + public override TypeAttributes Attributes + { + get { return (TypeAttributes)module.TypeDef.records[index].Flags; } + } + + public override EventInfo[] __GetDeclaredEvents() + { + int token = this.MetadataToken; + // TODO use binary search? + for (int i = 0; i < module.EventMap.records.Length; i++) + { + if (module.EventMap.records[i].Parent == token) + { + int evt = module.EventMap.records[i].EventList - 1; + int end = module.EventMap.records.Length > i + 1 ? module.EventMap.records[i + 1].EventList - 1 : module.Event.records.Length; + EventInfo[] events = new EventInfo[end - evt]; + for (int j = 0; evt < end; evt++, j++) + { + events[j] = new EventInfoImpl(module, this, evt); + } + return events; + } + } + return Empty.Array; + } + + public override FieldInfo[] __GetDeclaredFields() + { + int field = module.TypeDef.records[index].FieldList - 1; + int end = module.TypeDef.records.Length > index + 1 ? module.TypeDef.records[index + 1].FieldList - 1 : module.Field.records.Length; + FieldInfo[] fields = new FieldInfo[end - field]; + for (int i = 0; field < end; i++, field++) + { + fields[i] = module.GetFieldAt(this, field); + } + return fields; + } + + public override Type[] __GetDeclaredInterfaces() + { + int token = this.MetadataToken; + List list = new List(); + // TODO use binary search? + for (int i = 0; i < module.InterfaceImpl.records.Length; i++) + { + if (module.InterfaceImpl.records[i].Class == token) + { + list.Add(module.ResolveType(module.InterfaceImpl.records[i].Interface, this)); + } + } + return list.ToArray(); + } + + public override MethodBase[] __GetDeclaredMethods() + { + int method = module.TypeDef.records[index].MethodList - 1; + int end = module.TypeDef.records.Length > index + 1 ? module.TypeDef.records[index + 1].MethodList - 1 : module.MethodDef.records.Length; + MethodBase[] methods = new MethodBase[end - method]; + for (int i = 0; method < end; method++, i++) + { + methods[i] = module.GetMethodAt(this, method); + } + return methods; + } + + public override __MethodImplMap __GetMethodImplMap() + { + List bodies = new List(); + List> declarations = new List>(); + int token = this.MetadataToken; + // TODO use binary search? + for (int i = 0; i < module.MethodImpl.records.Length; i++) + { + if (module.MethodImpl.records[i].Class == token) + { + MethodInfo body = (MethodInfo)module.ResolveMethod(module.MethodImpl.records[i].MethodBody, typeArgs, null); + int index = bodies.IndexOf(body); + if (index == -1) + { + index = bodies.Count; + bodies.Add(body); + declarations.Add(new List()); + } + MethodInfo declaration = (MethodInfo)module.ResolveMethod(module.MethodImpl.records[i].MethodDeclaration, typeArgs, null); + declarations[index].Add(declaration); + } + } + __MethodImplMap map = new __MethodImplMap(); + map.TargetType = this; + map.MethodBodies = bodies.ToArray(); + map.MethodDeclarations = new MethodInfo[declarations.Count][]; + for (int i = 0; i < map.MethodDeclarations.Length; i++) + { + map.MethodDeclarations[i] = declarations[i].ToArray(); + } + return map; + } + + public override Type[] __GetDeclaredTypes() + { + int token = this.MetadataToken; + List list = new List(); + // TODO use binary search? + for (int i = 0; i < module.NestedClass.records.Length; i++) + { + if (module.NestedClass.records[i].EnclosingClass == token) + { + list.Add(module.ResolveType(module.NestedClass.records[i].NestedClass)); + } + } + return list.ToArray(); + } + + public override PropertyInfo[] __GetDeclaredProperties() + { + int token = this.MetadataToken; + // TODO use binary search? + for (int i = 0; i < module.PropertyMap.records.Length; i++) + { + if (module.PropertyMap.records[i].Parent == token) + { + int property = module.PropertyMap.records[i].PropertyList - 1; + int end = module.PropertyMap.records.Length > i + 1 ? module.PropertyMap.records[i + 1].PropertyList - 1 : module.Property.records.Length; + PropertyInfo[] properties = new PropertyInfo[end - property]; + for (int j = 0; property < end; property++, j++) + { + properties[j] = new PropertyInfoImpl(module, this, property); + } + return properties; + } + } + return Empty.Array; + } + + public override string Name + { + get { return typeName; } + } + + public override string Namespace + { + get { return typeNamespace; } + } + + public override Type UnderlyingSystemType + { + get { return this; } + } + + public override int MetadataToken + { + get { return (TypeDefTable.Index << 24) + index + 1; } + } + + public override Type[] GetGenericArguments() + { + PopulateGenericArguments(); + return Util.Copy(typeArgs); + } + + private void PopulateGenericArguments() + { + if (typeArgs == null) + { + int token = this.MetadataToken; + int first = module.GenericParam.FindFirstByOwner(token); + if (first == -1) + { + typeArgs = Type.EmptyTypes; + } + else + { + List list = new List(); + int len = module.GenericParam.records.Length; + for (int i = first; i < len && module.GenericParam.records[i].Owner == token; i++) + { + list.Add(new GenericTypeParameter(module, i)); + } + typeArgs = list.ToArray(); + } + } + } + + internal override Type GetGenericTypeArgument(int index) + { + PopulateGenericArguments(); + return typeArgs[index]; + } + + public override Type[][] __GetGenericArgumentsOptionalCustomModifiers() + { + PopulateGenericArguments(); + return Util.Copy(new Type[typeArgs.Length][]); + } + + public override Type[][] __GetGenericArgumentsRequiredCustomModifiers() + { + PopulateGenericArguments(); + return Util.Copy(new Type[typeArgs.Length][]); + } + + public override bool IsGenericType + { + get { return IsGenericTypeDefinition; } + } + + public override bool IsGenericTypeDefinition + { + get { return module.GenericParam.FindFirstByOwner(this.MetadataToken) != -1; } + } + + public override Type GetGenericTypeDefinition() + { + if (IsGenericTypeDefinition) + { + return this; + } + throw new InvalidOperationException(); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(this.FullName); + string sep = "["; + foreach (Type arg in GetGenericArguments()) + { + sb.Append(sep); + sb.Append(arg); + sep = ","; + } + if (sep != "[") + { + sb.Append(']'); + } + return sb.ToString(); + } + + public override Type DeclaringType + { + get + { + // note that we cannot use Type.IsNested for this, because that calls DeclaringType + if ((this.Attributes & TypeAttributes.VisibilityMask & ~TypeAttributes.Public) == 0) + { + return null; + } + // TODO use binary search (if sorted) + int token = this.MetadataToken; + for (int i = 0; i < module.NestedClass.records.Length; i++) + { + if (module.NestedClass.records[i].NestedClass == token) + { + return module.ResolveType(module.NestedClass.records[i].EnclosingClass, null, null); + } + } + throw new InvalidOperationException(); + } + } + + public override StructLayoutAttribute StructLayoutAttribute + { + get + { + StructLayoutAttribute layout; + switch (this.Attributes & TypeAttributes.LayoutMask) + { + case TypeAttributes.AutoLayout: + return null; + case TypeAttributes.SequentialLayout: + layout = new StructLayoutAttribute(LayoutKind.Sequential); + break; + case TypeAttributes.ExplicitLayout: + layout = new StructLayoutAttribute(LayoutKind.Explicit); + break; + default: + throw new BadImageFormatException(); + } + int token = this.MetadataToken; + // TODO use binary search? + for (int i = 0; i < module.ClassLayout.records.Length; i++) + { + if (module.ClassLayout.records[i].Parent == token) + { + layout.Pack = module.ClassLayout.records[i].PackingSize; + layout.Size = module.ClassLayout.records[i].ClassSize; + switch (this.Attributes & TypeAttributes.StringFormatMask) + { + case TypeAttributes.AnsiClass: + layout.CharSet = CharSet.Ansi; + break; + case TypeAttributes.UnicodeClass: + layout.CharSet = CharSet.Unicode; + break; + case TypeAttributes.AutoClass: + layout.CharSet = CharSet.Auto; + break; + default: + layout.CharSet = CharSet.None; + break; + } + return layout; + } + } + return null; + } + } + + public override Module Module + { + get { return module; } + } + + internal override bool IsModulePseudoType + { + get { return index == 0; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Signature.cs b/mcs/class/IKVM.Reflection/Signature.cs new file mode 100644 index 000000000000..7924c4f4d4e4 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Signature.cs @@ -0,0 +1,798 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; +using CallingConvention = System.Runtime.InteropServices.CallingConvention; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Writer; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection +{ + abstract class Signature + { + internal const byte DEFAULT = 0x00; + internal const byte VARARG = 0x05; + internal const byte GENERIC = 0x10; + internal const byte HASTHIS = 0x20; + internal const byte EXPLICITTHIS = 0x40; + internal const byte FIELD = 0x06; + internal const byte LOCAL_SIG = 0x07; + internal const byte PROPERTY = 0x08; + internal const byte GENERICINST = 0x0A; + internal const byte SENTINEL = 0x41; + internal const byte ELEMENT_TYPE_VOID = 0x01; + internal const byte ELEMENT_TYPE_BOOLEAN = 0x02; + internal const byte ELEMENT_TYPE_CHAR = 0x03; + internal const byte ELEMENT_TYPE_I1 = 0x04; + internal const byte ELEMENT_TYPE_U1 = 0x05; + internal const byte ELEMENT_TYPE_I2 = 0x06; + internal const byte ELEMENT_TYPE_U2 = 0x07; + internal const byte ELEMENT_TYPE_I4 = 0x08; + internal const byte ELEMENT_TYPE_U4 = 0x09; + internal const byte ELEMENT_TYPE_I8 = 0x0a; + internal const byte ELEMENT_TYPE_U8 = 0x0b; + internal const byte ELEMENT_TYPE_R4 = 0x0c; + internal const byte ELEMENT_TYPE_R8 = 0x0d; + internal const byte ELEMENT_TYPE_STRING = 0x0e; + internal const byte ELEMENT_TYPE_PTR = 0x0f; + internal const byte ELEMENT_TYPE_BYREF = 0x10; + internal const byte ELEMENT_TYPE_VALUETYPE = 0x11; + internal const byte ELEMENT_TYPE_CLASS = 0x12; + internal const byte ELEMENT_TYPE_VAR = 0x13; + internal const byte ELEMENT_TYPE_ARRAY = 0x14; + internal const byte ELEMENT_TYPE_GENERICINST = 0x15; + internal const byte ELEMENT_TYPE_TYPEDBYREF = 0x16; + internal const byte ELEMENT_TYPE_I = 0x18; + internal const byte ELEMENT_TYPE_U = 0x19; + internal const byte ELEMENT_TYPE_FNPTR = 0x1b; + internal const byte ELEMENT_TYPE_OBJECT = 0x1c; + internal const byte ELEMENT_TYPE_SZARRAY = 0x1d; + internal const byte ELEMENT_TYPE_MVAR = 0x1e; + internal const byte ELEMENT_TYPE_CMOD_REQD = 0x1f; + internal const byte ELEMENT_TYPE_CMOD_OPT = 0x20; + internal const byte ELEMENT_TYPE_PINNED = 0x45; + + internal abstract void WriteSig(ModuleBuilder module, ByteBuffer bb); + + private static Type ReadGenericInst(ModuleReader module, ByteReader br, IGenericContext context) + { + switch (br.ReadByte()) + { + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_VALUETYPE: + break; + default: + throw new BadImageFormatException(); + } + Type type = ReadTypeDefOrRefEncoded(module, br, context); + if (!type.IsGenericTypeDefinition) + { + throw new BadImageFormatException(); + } + int genArgCount = br.ReadCompressedInt(); + Type[] args = new Type[genArgCount]; + Type[][] reqmod = null; + Type[][] optmod = null; + for (int i = 0; i < genArgCount; i++) + { + // LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for genericinst, but C++ uses it, the verifier allows it and ildasm also supports it + CustomModifiers mods = ReadCustomModifiers(module, br, context); + if (mods.required != null || mods.optional != null) + { + if (reqmod == null) + { + reqmod = new Type[genArgCount][]; + optmod = new Type[genArgCount][]; + } + reqmod[i] = mods.required; + optmod[i] = mods.optional; + } + args[i] = ReadType(module, br, context); + } + return GenericTypeInstance.Make(type, args, reqmod, optmod); + } + + internal static Type ReadTypeSpec(ModuleReader module, ByteReader br, IGenericContext context) + { + // LAMESPEC a TypeSpec can contain custom modifiers (C++/CLI generates "newarr (TypeSpec with custom modifiers)") + SkipCustomModifiers(br); + // LAMESPEC anything can be adorned by (useless) custom modifiers + // also, VAR and MVAR are also used in TypeSpec (contrary to what the spec says) + return ReadType(module, br, context); + } + + private static Type ReadFunctionPointer(ModuleReader module, ByteReader br, IGenericContext context) + { + // TODO like .NET we return System.IntPtr here, but ideally we should fire an event in Universe that + // the user can hook to provide a custom type (or we simply should build in full support for function pointer types) + MethodSignature.ReadStandAloneMethodSig(module, br, context); + return module.universe.System_IntPtr; + } + + internal static Type[] ReadMethodSpec(ModuleReader module, ByteReader br, IGenericContext context) + { + if (br.ReadByte() != GENERICINST) + { + throw new BadImageFormatException(); + } + Type[] args = new Type[br.ReadCompressedInt()]; + for (int i = 0; i < args.Length; i++) + { + args[i] = ReadType(module, br, context); + } + return args; + } + + private static int ReadArrayShape(ByteReader br) + { + int rank = br.ReadCompressedInt(); + int numSizes = br.ReadCompressedInt(); + for (int i = 0; i < numSizes; i++) + { + br.ReadCompressedInt(); + } + int numLoBounds = br.ReadCompressedInt(); + for (int i = 0; i < numLoBounds; i++) + { + br.ReadCompressedInt(); + } + return rank; + } + + private static Type ReadTypeOrVoid(ModuleReader module, ByteReader br, IGenericContext context) + { + if (br.PeekByte() == ELEMENT_TYPE_VOID) + { + br.ReadByte(); + return module.universe.System_Void; + } + else + { + return ReadType(module, br, context); + } + } + + // see ECMA 335 CLI spec June 2006 section 23.2.12 for this production + protected static Type ReadType(ModuleReader module, ByteReader br, IGenericContext context) + { + CustomModifiers mods; + switch (br.ReadByte()) + { + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_VALUETYPE: + return ReadTypeDefOrRefEncoded(module, br, context); + case ELEMENT_TYPE_BOOLEAN: + return module.universe.System_Boolean; + case ELEMENT_TYPE_CHAR: + return module.universe.System_Char; + case ELEMENT_TYPE_I1: + return module.universe.System_SByte; + case ELEMENT_TYPE_U1: + return module.universe.System_Byte; + case ELEMENT_TYPE_I2: + return module.universe.System_Int16; + case ELEMENT_TYPE_U2: + return module.universe.System_UInt16; + case ELEMENT_TYPE_I4: + return module.universe.System_Int32; + case ELEMENT_TYPE_U4: + return module.universe.System_UInt32; + case ELEMENT_TYPE_I8: + return module.universe.System_Int64; + case ELEMENT_TYPE_U8: + return module.universe.System_UInt64; + case ELEMENT_TYPE_R4: + return module.universe.System_Single; + case ELEMENT_TYPE_R8: + return module.universe.System_Double; + case ELEMENT_TYPE_I: + return module.universe.System_IntPtr; + case ELEMENT_TYPE_U: + return module.universe.System_UIntPtr; + case ELEMENT_TYPE_STRING: + return module.universe.System_String; + case ELEMENT_TYPE_OBJECT: + return module.universe.System_Object; + case ELEMENT_TYPE_VAR: + return context.GetGenericTypeArgument(br.ReadCompressedInt()); + case ELEMENT_TYPE_MVAR: + return context.GetGenericMethodArgument(br.ReadCompressedInt()); + case ELEMENT_TYPE_GENERICINST: + return ReadGenericInst(module, br, context); + case ELEMENT_TYPE_SZARRAY: + mods = ReadCustomModifiers(module, br, context); + return ReadType(module, br, context).__MakeArrayType(mods.required, mods.optional); + case ELEMENT_TYPE_ARRAY: + mods = ReadCustomModifiers(module, br, context); + return ReadType(module, br, context).__MakeArrayType(ReadArrayShape(br), mods.required, mods.optional); + case ELEMENT_TYPE_PTR: + mods = ReadCustomModifiers(module, br, context); + return ReadTypeOrVoid(module, br, context).__MakePointerType(mods.required, mods.optional); + case ELEMENT_TYPE_FNPTR: + return ReadFunctionPointer(module, br, context); + default: + throw new BadImageFormatException(); + } + } + + internal static void ReadLocalVarSig(ModuleReader module, ByteReader br, IGenericContext context, List list) + { + if (br.Length < 2 || br.ReadByte() != LOCAL_SIG) + { + throw new BadImageFormatException("Invalid local variable signature"); + } + int count = br.ReadCompressedInt(); + for (int i = 0; i < count; i++) + { + if (br.PeekByte() == ELEMENT_TYPE_TYPEDBYREF) + { + br.ReadByte(); + list.Add(new LocalVariableInfo(i, module.universe.System_TypedReference, false)); + } + else + { + SkipCustomModifiers(br); + bool pinned = false; + if (br.PeekByte() == ELEMENT_TYPE_PINNED) + { + br.ReadByte(); + pinned = true; + } + SkipCustomModifiers(br); + Type type = ReadTypeOrByRef(module, br, context); + list.Add(new LocalVariableInfo(i, type, pinned)); + } + } + } + + private static Type ReadTypeOrByRef(ModuleReader module, ByteReader br, IGenericContext context) + { + if (br.PeekByte() == ELEMENT_TYPE_BYREF) + { + br.ReadByte(); + // LAMESPEC it is allowed (by C++/CLI, ilasm and peverify) to have custom modifiers after the BYREF + // (which makes sense, as it is analogous to pointers) + CustomModifiers mods = ReadCustomModifiers(module, br, context); + // C++/CLI generates void& local variables, so we need to use ReadTypeOrVoid here + return ReadTypeOrVoid(module, br, context).__MakeByRefType(mods.required, mods.optional); + } + else + { + return ReadType(module, br, context); + } + } + + protected static Type ReadRetType(ModuleReader module, ByteReader br, IGenericContext context) + { + switch (br.PeekByte()) + { + case ELEMENT_TYPE_VOID: + br.ReadByte(); + return module.universe.System_Void; + case ELEMENT_TYPE_TYPEDBYREF: + br.ReadByte(); + return module.universe.System_TypedReference; + default: + return ReadTypeOrByRef(module, br, context); + } + } + + protected static Type ReadParam(ModuleReader module, ByteReader br, IGenericContext context) + { + switch (br.PeekByte()) + { + case ELEMENT_TYPE_TYPEDBYREF: + br.ReadByte(); + return module.universe.System_TypedReference; + default: + return ReadTypeOrByRef(module, br, context); + } + } + + protected static void WriteType(ModuleBuilder module, ByteBuffer bb, Type type) + { + while (type.HasElementType) + { + if (type.__IsVector) + { + bb.Write(ELEMENT_TYPE_SZARRAY); + } + else if (type.IsArray) + { + int rank = type.GetArrayRank(); + bb.Write(ELEMENT_TYPE_ARRAY); + // LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for arrays, but the verifier allows it and ildasm also supports it + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, type.__GetRequiredCustomModifiers()); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, type.__GetOptionalCustomModifiers()); + WriteType(module, bb, type.GetElementType()); + bb.WriteCompressedInt(rank); + // since a Type doesn't contain the lower/upper bounds + // (they act like a custom modifier, so they are part of the signature, but not of the Type), + // we set them to the C# compatible values and hope for the best + bb.WriteCompressedInt(0); // boundsCount + bb.WriteCompressedInt(rank); // loCount + for (int i = 0; i < rank; i++) + { + bb.WriteCompressedInt(0); + } + return; + } + else if (type.IsByRef) + { + bb.Write(ELEMENT_TYPE_BYREF); + } + else if (type.IsPointer) + { + bb.Write(ELEMENT_TYPE_PTR); + } + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, type.__GetRequiredCustomModifiers()); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, type.__GetOptionalCustomModifiers()); + type = type.GetElementType(); + } + Universe u = module.universe; + if (type == u.System_Void) + { + bb.Write(ELEMENT_TYPE_VOID); + } + else if (type == u.System_Boolean) + { + bb.Write(ELEMENT_TYPE_BOOLEAN); + } + else if (type == u.System_Char) + { + bb.Write(ELEMENT_TYPE_CHAR); + } + else if (type == u.System_SByte) + { + bb.Write(ELEMENT_TYPE_I1); + } + else if (type == u.System_Byte) + { + bb.Write(ELEMENT_TYPE_U1); + } + else if (type == u.System_Int16) + { + bb.Write(ELEMENT_TYPE_I2); + } + else if (type == u.System_UInt16) + { + bb.Write(ELEMENT_TYPE_U2); + } + else if (type == u.System_Int32) + { + bb.Write(ELEMENT_TYPE_I4); + } + else if (type == u.System_UInt32) + { + bb.Write(ELEMENT_TYPE_U4); + } + else if (type == u.System_Int64) + { + bb.Write(ELEMENT_TYPE_I8); + } + else if (type == u.System_UInt64) + { + bb.Write(ELEMENT_TYPE_U8); + } + else if (type == u.System_Single) + { + bb.Write(ELEMENT_TYPE_R4); + } + else if (type == u.System_Double) + { + bb.Write(ELEMENT_TYPE_R8); + } + else if (type == u.System_String) + { + bb.Write(ELEMENT_TYPE_STRING); + } + else if (type == u.System_IntPtr) + { + bb.Write(ELEMENT_TYPE_I); + } + else if (type == u.System_UIntPtr) + { + bb.Write(ELEMENT_TYPE_U); + } + else if (type == u.System_TypedReference) + { + bb.Write(ELEMENT_TYPE_TYPEDBYREF); + } + else if (type == u.System_Object) + { + bb.Write(ELEMENT_TYPE_OBJECT); + } + else if (type.IsGenericParameter) + { + if (type is UnboundGenericMethodParameter || type.DeclaringMethod != null) + { + bb.Write(ELEMENT_TYPE_MVAR); + } + else + { + bb.Write(ELEMENT_TYPE_VAR); + } + bb.WriteCompressedInt(type.GenericParameterPosition); + } + else if (type.IsGenericType) + { + WriteGenericSignature(module, bb, type); + } + else + { + if (type.IsValueType) + { + bb.Write(ELEMENT_TYPE_VALUETYPE); + } + else + { + bb.Write(ELEMENT_TYPE_CLASS); + } + bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token); + } + } + + private static void WriteGenericSignature(ModuleBuilder module, ByteBuffer bb, Type type) + { + Type[] typeArguments = type.GetGenericArguments(); + Type[][] requiredCustomModifiers = type.__GetGenericArgumentsRequiredCustomModifiers(); + Type[][] optionalCustomModifiers = type.__GetGenericArgumentsOptionalCustomModifiers(); + if (!type.IsGenericTypeDefinition) + { + type = type.GetGenericTypeDefinition(); + } + bb.Write(ELEMENT_TYPE_GENERICINST); + if (type.IsValueType) + { + bb.Write(ELEMENT_TYPE_VALUETYPE); + } + else + { + bb.Write(ELEMENT_TYPE_CLASS); + } + bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token); + bb.WriteCompressedInt(typeArguments.Length); + for (int i = 0; i < typeArguments.Length; i++) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, requiredCustomModifiers[i]); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, optionalCustomModifiers[i]); + WriteType(module, bb, typeArguments[i]); + } + } + + protected static void WriteCustomModifiers(ModuleBuilder module, ByteBuffer bb, byte mod, Type[] modifiers) + { + if (modifiers != null) + { + foreach (Type type in modifiers) + { + bb.Write(mod); + bb.WriteTypeDefOrRefEncoded(module.GetTypeTokenForMemberRef(type)); + } + } + } + + protected static bool IsCustomModifier(byte b) + { + return b == ELEMENT_TYPE_CMOD_OPT || b == ELEMENT_TYPE_CMOD_REQD; + } + + struct CustomModifiers + { + internal Type[] required; + internal Type[] optional; + } + + private static CustomModifiers ReadCustomModifiers(ModuleReader module, ByteReader br, IGenericContext context) + { + CustomModifiers mods = new CustomModifiers(); + byte b = br.PeekByte(); + if (IsCustomModifier(b)) + { + List required = new List(); + List optional = new List(); + while (IsCustomModifier(b)) + { + bool req = br.ReadByte() == ELEMENT_TYPE_CMOD_REQD; + Type type = ReadTypeDefOrRefEncoded(module, br, context); + (req ? required : optional).Add(type); + b = br.PeekByte(); + } + mods.required = required.ToArray(); + mods.optional = optional.ToArray(); + } + return mods; + } + + protected static void SkipCustomModifiers(ByteReader br) + { + byte b = br.PeekByte(); + while (IsCustomModifier(b)) + { + br.ReadByte(); + br.ReadCompressedInt(); + b = br.PeekByte(); + } + } + + private static Type ReadTypeDefOrRefEncoded(ModuleReader module, ByteReader br, IGenericContext context) + { + int encoded = br.ReadCompressedInt(); + switch (encoded & 3) + { + case 0: + return module.ResolveType((TypeDefTable.Index << 24) + (encoded >> 2), null, null); + case 1: + return module.ResolveType((TypeRefTable.Index << 24) + (encoded >> 2), null, null); + case 2: + return module.ResolveType((TypeSpecTable.Index << 24) + (encoded >> 2), context); + default: + throw new BadImageFormatException(); + } + } + + protected static void ReadCustomModifiers(ModuleReader module, ByteReader br, IGenericContext context, out Type[] requiredCustomModifiers, out Type[] optionalCustomModifiers) + { + byte b = br.PeekByte(); + if (IsCustomModifier(b)) + { + List required = new List(); + List optional = new List(); + while (IsCustomModifier(b)) + { + br.ReadByte(); + Type type = ReadTypeDefOrRefEncoded(module, br, context); + if (b == ELEMENT_TYPE_CMOD_REQD) + { + required.Add(type); + } + else + { + optional.Add(type); + } + b = br.PeekByte(); + } + requiredCustomModifiers = required.ToArray(); + optionalCustomModifiers = optional.ToArray(); + } + else + { + requiredCustomModifiers = null; + optionalCustomModifiers = null; + } + } + + // unmanaged calling convention + internal static void WriteStandAloneMethodSig(ModuleBuilder module, ByteBuffer bb, CallingConvention callingConvention, Type returnType, Type[] parameterTypes) + { + switch (callingConvention) + { + case CallingConvention.Cdecl: + bb.Write((byte)0x01); // C + break; + case CallingConvention.StdCall: + case CallingConvention.Winapi: + bb.Write((byte)0x02); // STDCALL + break; + case CallingConvention.ThisCall: + bb.Write((byte)0x03); // THISCALL + break; + case CallingConvention.FastCall: + bb.Write((byte)0x04); // FASTCALL + break; + default: + throw new ArgumentOutOfRangeException("callingConvention"); + } + bb.WriteCompressedInt(parameterTypes.Length); + WriteType(module, bb, returnType); + foreach (Type t in parameterTypes) + { + WriteType(module, bb, t); + } + } + + // managed calling convention + internal static void WriteStandAloneMethodSig(ModuleBuilder module, ByteBuffer bb, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) + { + byte flags = 0; + if ((callingConvention & CallingConventions.HasThis) != 0) + { + flags |= HASTHIS; + } + if ((callingConvention & CallingConventions.ExplicitThis) != 0) + { + flags |= EXPLICITTHIS; + } + if ((callingConvention & CallingConventions.VarArgs) != 0) + { + flags |= VARARG; + } + bb.Write(flags); + bb.WriteCompressedInt(parameterTypes.Length + optionalParameterTypes.Length); + WriteType(module, bb, returnType); + foreach (Type t in parameterTypes) + { + WriteType(module, bb, t); + } + if (optionalParameterTypes.Length > 0) + { + bb.Write(SENTINEL); + foreach (Type t in optionalParameterTypes) + { + WriteType(module, bb, t); + } + } + } + + internal static void WriteLocalVarSig(ModuleBuilder module, ByteBuffer bb, IList locals) + { + bb.Write(LOCAL_SIG); + bb.WriteCompressedInt(locals.Count); + foreach (LocalBuilder local in locals) + { + if (local.IsPinned) + { + bb.Write(ELEMENT_TYPE_PINNED); + } + WriteType(module, bb, local.LocalType); + } + } + + internal static void WritePropertySig(ModuleBuilder module, ByteBuffer bb, CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) + { + byte flags = PROPERTY; + if ((callingConvention & CallingConventions.HasThis) != 0) + { + flags |= HASTHIS; + } + if ((callingConvention & CallingConventions.ExplicitThis) != 0) + { + flags |= EXPLICITTHIS; + } + if ((callingConvention & CallingConventions.VarArgs) != 0) + { + flags |= VARARG; + } + bb.Write(flags); + bb.WriteCompressedInt(parameterTypes == null ? 0 : parameterTypes.Length); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, returnTypeRequiredCustomModifiers); + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, returnTypeOptionalCustomModifiers); + WriteType(module, bb, returnType); + if (parameterTypes != null) + { + for (int i = 0; i < parameterTypes.Length; i++) + { + if (parameterTypeRequiredCustomModifiers != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, parameterTypeRequiredCustomModifiers[i]); + } + if (parameterTypeOptionalCustomModifiers != null) + { + WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, parameterTypeOptionalCustomModifiers[i]); + } + WriteType(module, bb, parameterTypes[i]); + } + } + } + + internal static void WriteTypeSpec(ModuleBuilder module, ByteBuffer bb, Type type) + { + WriteType(module, bb, type); + } + + internal static void WriteMethodSpec(ModuleBuilder module, ByteBuffer bb, Type[] genArgs) + { + bb.Write(GENERICINST); + bb.WriteCompressedInt(genArgs.Length); + foreach (Type arg in genArgs) + { + WriteType(module, bb, arg); + } + } + + // this reads just the optional parameter types, from a MethodRefSig + internal static Type[] ReadOptionalParameterTypes(ModuleReader module, ByteReader br) + { + br.ReadByte(); + int paramCount = br.ReadCompressedInt(); + SkipCustomModifiers(br); + ReadRetType(module, br, null); + for (int i = 0; i < paramCount; i++) + { + if (br.PeekByte() == SENTINEL) + { + br.ReadByte(); + Type[] types = new Type[paramCount - i]; + for (int j = 0; j < types.Length; j++) + { + SkipCustomModifiers(br); + types[j] = ReadType(module, br, null); + } + return types; + } + SkipCustomModifiers(br); + ReadType(module, br, null); + } + return Type.EmptyTypes; + } + + protected static Type[] BindTypeParameters(IGenericBinder binder, Type[] types) + { + if (types == null || types.Length == 0) + { + return Type.EmptyTypes; + } + Type[] expanded = new Type[types.Length]; + for (int i = 0; i < types.Length; i++) + { + expanded[i] = types[i].BindTypeParameters(binder); + } + return expanded; + } + + protected static Type[][] BindTypeParameters(IGenericBinder binder, Type[][] types) + { + if (types == null) + { + return null; + } + Type[][] expanded = new Type[types.Length][]; + for (int i = 0; i < types.Length; i++) + { + expanded[i] = BindTypeParameters(binder, types[i]); + } + return expanded; + } + + protected static Type[][][] BindTypeParameters(IGenericBinder binder, Type[][][] types) + { + if (types == null) + { + return null; + } + Type[][][] expanded = new Type[types.Length][][]; + for (int i = 0; i < types.Length; i++) + { + expanded[i] = BindTypeParameters(binder, types[i]); + } + return expanded; + } + + protected static Type[] BindTypeParameters(IGenericBinder binder, Type[][][] types, int index, int optOrReq) + { + if (types == null || types[index] == null) + { + return null; + } + return BindTypeParameters(binder, types[index][optOrReq]); + } + } +} diff --git a/mcs/class/IKVM.Reflection/StandAloneMethodSig.cs b/mcs/class/IKVM.Reflection/StandAloneMethodSig.cs new file mode 100644 index 000000000000..007e5757ad6a --- /dev/null +++ b/mcs/class/IKVM.Reflection/StandAloneMethodSig.cs @@ -0,0 +1,79 @@ +/* + Copyright (C) 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.InteropServices; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection +{ + public sealed class __StandAloneMethodSig + { + private readonly bool unmanaged; + private readonly CallingConvention unmanagedCallingConvention; + private readonly CallingConventions callingConvention; + private readonly Type returnType; + private readonly Type[] parameterTypes; + private readonly Type[] optionalParameterTypes; + + internal __StandAloneMethodSig(bool unmanaged, CallingConvention unmanagedCallingConvention, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) + { + this.unmanaged = unmanaged; + this.unmanagedCallingConvention = unmanagedCallingConvention; + this.callingConvention = callingConvention; + this.returnType = returnType; + this.parameterTypes = parameterTypes; + this.optionalParameterTypes = optionalParameterTypes; + } + + public bool IsUnmanaged + { + get { return unmanaged; } + } + + public CallingConventions CallingConvention + { + get { return callingConvention; } + } + + public CallingConvention UnmanagedCallingConvention + { + get { return unmanagedCallingConvention; } + } + + public Type ReturnType + { + get { return returnType; } + } + + public Type[] ParameterTypes + { + get { return Util.Copy(parameterTypes); } + } + + public Type[] OptionalParameterTypes + { + get { return Util.Copy(optionalParameterTypes); } + } + } +} diff --git a/mcs/class/IKVM.Reflection/StrongNameKeyPair.cs b/mcs/class/IKVM.Reflection/StrongNameKeyPair.cs new file mode 100644 index 000000000000..6ea6f7e9d9eb --- /dev/null +++ b/mcs/class/IKVM.Reflection/StrongNameKeyPair.cs @@ -0,0 +1,59 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + public class StrongNameKeyPair + { + internal readonly System.Reflection.StrongNameKeyPair keyPair; + + internal StrongNameKeyPair(System.Reflection.StrongNameKeyPair keyPair) + { + this.keyPair = keyPair; + } + + public StrongNameKeyPair(string keyPairContainer) + { + this.keyPair = new System.Reflection.StrongNameKeyPair(keyPairContainer); + } + + public StrongNameKeyPair(byte[] keyPairArray) + { + this.keyPair = new System.Reflection.StrongNameKeyPair(keyPairArray); + } + + public StrongNameKeyPair(System.IO.FileStream fs) + { + this.keyPair = new System.Reflection.StrongNameKeyPair(fs); + } + + public byte[] PublicKey + { + get { return keyPair.PublicKey; } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Type.cs b/mcs/class/IKVM.Reflection/Type.cs new file mode 100644 index 000000000000..43ed271e3701 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Type.cs @@ -0,0 +1,2398 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Runtime.InteropServices; +using System.Text; +using System.Collections.Generic; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection +{ + interface IGenericContext + { + Type GetGenericTypeArgument(int index); + Type GetGenericMethodArgument(int index); + } + + interface IGenericBinder + { + Type BindTypeParameter(Type type); + Type BindMethodParameter(Type type); + } + + public abstract class Type : MemberInfo, IGenericContext, IGenericBinder + { + public static readonly Type[] EmptyTypes = Empty.Array; + + public static Binder DefaultBinder + { + get { return null; } + } + + public sealed override MemberTypes MemberType + { + get { return IsNested ? MemberTypes.NestedType : MemberTypes.TypeInfo; } + } + + public virtual string AssemblyQualifiedName + { + // NOTE the assembly name is not escaped here, only when used in a generic type instantiation + get { return this.FullName + ", " + this.Assembly.FullName; } + } + + public abstract Type BaseType + { + get; + } + + public abstract TypeAttributes Attributes + { + get; + } + + public virtual Type GetElementType() + { + return null; + } + + internal virtual void CheckBaked() + { + } + + public virtual Type[] __GetDeclaredTypes() + { + return Type.EmptyTypes; + } + + public virtual Type[] __GetDeclaredInterfaces() + { + return Type.EmptyTypes; + } + + public virtual MethodBase[] __GetDeclaredMethods() + { + return Empty.Array; + } + + public virtual __MethodImplMap __GetMethodImplMap() + { + throw new NotSupportedException(); + } + + public virtual FieldInfo[] __GetDeclaredFields() + { + return Empty.Array; + } + + public virtual EventInfo[] __GetDeclaredEvents() + { + return Empty.Array; + } + + public virtual PropertyInfo[] __GetDeclaredProperties() + { + return Empty.Array; + } + + public virtual Type[] __GetRequiredCustomModifiers() + { + return Type.EmptyTypes; + } + + public virtual Type[] __GetOptionalCustomModifiers() + { + return Type.EmptyTypes; + } + + public virtual bool HasElementType + { + get { return false; } + } + + public virtual bool IsArray + { + get { return false; } + } + + public virtual bool __IsVector + { + get { return false; } + } + + public virtual bool IsByRef + { + get { return false; } + } + + public virtual bool IsPointer + { + get { return false; } + } + + public virtual bool IsValueType + { + get + { + Type baseType = this.BaseType; + return baseType == this.Module.universe.System_Enum + || (baseType == this.Module.universe.System_ValueType && this != this.Module.universe.System_Enum); + } + } + + public virtual bool IsGenericParameter + { + get { return false; } + } + + public virtual int GenericParameterPosition + { + get { throw new NotSupportedException(); } + } + + public virtual MethodBase DeclaringMethod + { + get { return null; } + } + + public virtual Type UnderlyingSystemType + { + get { return this; } + } + + public override Type DeclaringType + { + get { return null; } + } + + public override string Name + { + get + { + string fullname = FullName; + return fullname.Substring(fullname.LastIndexOf('.') + 1); + } + } + + public virtual string Namespace + { + get + { + if (IsNested) + { + return null; + } + string fullname = FullName; + int index = fullname.LastIndexOf('.'); + return index < 0 ? null : fullname.Substring(0, index); + } + } + + internal virtual int GetModuleBuilderToken() + { + throw new InvalidOperationException(); + } + + public bool Equals(Type type) + { + return !ReferenceEquals(type, null) && ReferenceEquals(type.UnderlyingSystemType, this.UnderlyingSystemType); + } + + public override bool Equals(object obj) + { + return Equals(obj as Type); + } + + public override int GetHashCode() + { + Type type = this.UnderlyingSystemType; + return ReferenceEquals(type, this) ? base.GetHashCode() : type.GetHashCode(); + } + + public virtual Type[] GetGenericArguments() + { + return Type.EmptyTypes; + } + + public virtual Type[][] __GetGenericArgumentsRequiredCustomModifiers() + { + return Empty.Array; + } + + public virtual Type[][] __GetGenericArgumentsOptionalCustomModifiers() + { + return Empty.Array; + } + + public virtual Type GetGenericTypeDefinition() + { + throw new InvalidOperationException(); + } + + public virtual StructLayoutAttribute StructLayoutAttribute + { + get { return null; } + } + + public virtual bool IsGenericType + { + get { return false; } + } + + public virtual bool IsGenericTypeDefinition + { + get { return false; } + } + + public virtual bool ContainsGenericParameters + { + get + { + if (this.IsGenericParameter) + { + return true; + } + foreach (Type arg in this.GetGenericArguments()) + { + if (arg.ContainsGenericParameters) + { + return true; + } + } + return false; + } + } + + public virtual Type[] GetGenericParameterConstraints() + { + throw new InvalidOperationException(); + } + + public virtual GenericParameterAttributes GenericParameterAttributes + { + get { throw new InvalidOperationException(); } + } + + public virtual int GetArrayRank() + { + throw new NotSupportedException(); + } + + // .NET 4.0 API + public virtual Type GetEnumUnderlyingType() + { + if (!this.IsEnum) + { + throw new ArgumentException(); + } + CheckBaked(); + return GetEnumUnderlyingTypeImpl(); + } + + internal Type GetEnumUnderlyingTypeImpl() + { + foreach (FieldInfo field in __GetDeclaredFields()) + { + if (!field.IsStatic) + { + // the CLR assumes that an enum has only one instance field, so we can do the same + return field.FieldType; + } + } + throw new InvalidOperationException(); + } + + public override string ToString() + { + return FullName; + } + + public virtual string FullName + { + get + { + Type decl = this.DeclaringType; + string ns = this.Namespace; + if (ns == null) + { + if (decl == null) + { + return this.Name; + } + else + { + return decl.FullName + "+" + this.Name; + } + } + else + { + if (decl == null) + { + return ns + "." + this.Name; + } + else + { + return decl.FullName + "+" + ns + "." + this.Name; + } + } + } + } + + internal virtual bool IsModulePseudoType + { + get { return false; } + } + + internal virtual Type GetGenericTypeArgument(int index) + { + throw new InvalidOperationException(); + } + + public MemberInfo[] GetDefaultMembers() + { + Type defaultMemberAttribute = this.Module.universe.Import(typeof(System.Reflection.DefaultMemberAttribute)); + foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(this)) + { + if (cad.Constructor.DeclaringType.Equals(defaultMemberAttribute)) + { + return GetMember((string)cad.ConstructorArguments[0].Value); + } + } + return Empty.Array; + } + + public MemberInfo[] GetMember(string name) + { + return GetMember(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public MemberInfo[] GetMember(string name, BindingFlags bindingAttr) + { + return GetMember(name, MemberTypes.All, bindingAttr); + } + + public MemberInfo[] GetMembers() + { + return GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public MemberInfo[] GetMembers(BindingFlags bindingAttr) + { + List members = new List(); + members.AddRange(GetConstructors(bindingAttr)); + members.AddRange(GetMethods(bindingAttr)); + members.AddRange(GetFields(bindingAttr)); + members.AddRange(GetProperties(bindingAttr)); + members.AddRange(GetEvents(bindingAttr)); + members.AddRange(GetNestedTypes(bindingAttr)); + return members.ToArray(); + } + + public MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) + { + MemberFilter filter = delegate(MemberInfo member, object filterCriteria) { return member.Name.Equals(filterCriteria); }; + return FindMembers(type, bindingAttr, filter, name); + } + + private static void AddMembers(List list, MemberFilter filter, object filterCriteria, MemberInfo[] members) + { + foreach (MemberInfo member in members) + { + if (filter == null || filter(member, filterCriteria)) + { + list.Add(member); + } + } + } + + public MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria) + { + List members = new List(); + if ((memberType & MemberTypes.Constructor) != 0) + { + AddMembers(members, filter, filterCriteria, GetConstructors(bindingAttr)); + } + if ((memberType & MemberTypes.Method) != 0) + { + AddMembers(members, filter, filterCriteria, GetMethods(bindingAttr)); + } + if ((memberType & MemberTypes.Field) != 0) + { + AddMembers(members, filter, filterCriteria, GetFields(bindingAttr)); + } + if ((memberType & MemberTypes.Property) != 0) + { + AddMembers(members, filter, filterCriteria, GetProperties(bindingAttr)); + } + if ((memberType & MemberTypes.Event) != 0) + { + AddMembers(members, filter, filterCriteria, GetEvents(bindingAttr)); + } + if ((memberType & MemberTypes.NestedType) != 0) + { + AddMembers(members, filter, filterCriteria, GetNestedTypes(bindingAttr)); + } + return members.ToArray(); + } + + public EventInfo GetEvent(string name) + { + return GetEvent(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public EventInfo GetEvent(string name, BindingFlags bindingAttr) + { + foreach (EventInfo evt in GetEvents(bindingAttr)) + { + if (evt.Name == name) + { + return evt; + } + } + return null; + } + + public EventInfo[] GetEvents() + { + return GetEvents(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public EventInfo[] GetEvents(BindingFlags bindingAttr) + { + List list = new List(); + Type type = this; + while (type != null) + { + type.CheckBaked(); + foreach (EventInfo evt in type.__GetDeclaredEvents()) + { + if (BindingFlagsMatch(evt.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(evt.IsStatic, bindingAttr, BindingFlags.Static, BindingFlags.Instance)) + { + list.Add(evt); + } + } + if ((bindingAttr & BindingFlags.DeclaredOnly) == 0) + { + if ((bindingAttr & BindingFlags.FlattenHierarchy) == 0) + { + bindingAttr &= ~BindingFlags.Static; + } + type = type.BaseType; + } + else + { + break; + } + } + return list.ToArray(); + } + + public FieldInfo GetField(string name) + { + return GetField(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public FieldInfo GetField(string name, BindingFlags bindingAttr) + { + foreach (FieldInfo field in GetFields(bindingAttr)) + { + if (field.Name == name) + { + return field; + } + } + return null; + } + + public FieldInfo[] GetFields() + { + return GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); + } + + public FieldInfo[] GetFields(BindingFlags bindingAttr) + { + List list = new List(); + CheckBaked(); + foreach (FieldInfo field in __GetDeclaredFields()) + { + if (BindingFlagsMatch(field.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(field.IsStatic, bindingAttr, BindingFlags.Static, BindingFlags.Instance)) + { + list.Add(field); + } + } + if ((bindingAttr & BindingFlags.DeclaredOnly) == 0) + { + for (Type type = this.BaseType; type != null; type = type.BaseType) + { + type.CheckBaked(); + foreach (FieldInfo field in type.__GetDeclaredFields()) + { + if ((field.Attributes & FieldAttributes.FieldAccessMask) > FieldAttributes.Private + && BindingFlagsMatch(field.IsStatic, bindingAttr, BindingFlags.Static | BindingFlags.FlattenHierarchy, BindingFlags.Instance)) + { + list.Add(field); + } + } + } + } + return list.ToArray(); + } + + public Type[] GetInterfaces() + { + List list = new List(); + for (Type type = this; type != null; type = type.BaseType) + { + AddInterfaces(list, type); + } + return list.ToArray(); + } + + private static void AddInterfaces(List list, Type type) + { + type.CheckBaked(); + foreach (Type iface in type.__GetDeclaredInterfaces()) + { + if (!list.Contains(iface)) + { + list.Add(iface); + AddInterfaces(list, iface); + } + } + } + + public MethodInfo[] GetMethods(BindingFlags bindingAttr) + { + CheckBaked(); + List list = new List(); + foreach (MethodBase mb in __GetDeclaredMethods()) + { + MethodInfo mi = mb as MethodInfo; + if (mi != null + && BindingFlagsMatch(mi.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(mi.IsStatic, bindingAttr, BindingFlags.Static, BindingFlags.Instance)) + { + list.Add(mi); + } + } + if ((bindingAttr & BindingFlags.DeclaredOnly) == 0) + { + for (Type type = this.BaseType; type != null; type = type.BaseType) + { + type.CheckBaked(); + foreach (MethodBase mb in type.__GetDeclaredMethods()) + { + MethodInfo mi = mb as MethodInfo; + if (mi != null + && (mi.Attributes & MethodAttributes.MemberAccessMask) > MethodAttributes.Private + && BindingFlagsMatch(mi.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(mi.IsStatic, bindingAttr, BindingFlags.Static | BindingFlags.FlattenHierarchy, BindingFlags.Instance) + && !FindMethod(list, mi)) + { + list.Add(mi); + } + } + } + } + return list.ToArray(); + } + + private static bool FindMethod(List methods, MethodInfo method) + { + foreach (MethodInfo m in methods) + { + if (m.Name == method.Name && m.MethodSignature.Equals(method.MethodSignature)) + { + return true; + } + } + return false; + } + + public MethodInfo[] GetMethods() + { + return GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); + } + + public MethodInfo GetMethod(string name) + { + return GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); + } + + public MethodInfo GetMethod(string name, BindingFlags bindingAttr) + { + MethodInfo found = null; + foreach (MethodInfo method in GetMethods(bindingAttr)) + { + if (method.Name == name) + { + if (found != null) + { + throw new AmbiguousMatchException(); + } + found = method; + } + } + return found; + } + + public MethodInfo GetMethod(string name, Type[] types) + { + return GetMethod(name, types, null); + } + + public MethodInfo GetMethod(string name, Type[] types, ParameterModifier[] modifiers) + { + return GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, types, modifiers); + } + + public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers) + { + MethodInfo found = null; + foreach (MethodInfo method in GetMethods(bindingAttr)) + { + if (method.Name == name && method.MethodSignature.MatchParameterTypes(types)) + { + if (found != null) + { + throw new AmbiguousMatchException(); + } + found = method; + } + } + return found; + } + + public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) + { + // FXBUG callConvention seems to be ignored + return GetMethod(name, bindingAttr, binder, types, modifiers); + } + + public ConstructorInfo[] GetConstructors() + { + return GetConstructors(BindingFlags.Public | BindingFlags.Instance); + } + + public ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) + { + CheckBaked(); + List list = new List(); + foreach (MethodBase mb in __GetDeclaredMethods()) + { + ConstructorInfo constructor = mb as ConstructorInfo; + if (constructor != null + && BindingFlagsMatch(constructor.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(constructor.IsStatic, bindingAttr, BindingFlags.Static, BindingFlags.Instance)) + { + list.Add(constructor); + } + } + return list.ToArray(); + } + + public ConstructorInfo GetConstructor(Type[] types) + { + return GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, CallingConventions.Standard, types, null); + } + + public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers) + { + foreach (ConstructorInfo constructor in GetConstructors(bindingAttr)) + { + if (constructor.MethodSignature.MatchParameterTypes(types)) + { + return constructor; + } + } + return null; + } + + public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callingConvention, Type[] types, ParameterModifier[] modifiers) + { + // FXBUG callConvention seems to be ignored + return GetConstructor(bindingAttr, binder, types, modifiers); + } + + public Type GetNestedType(string name) + { + return GetNestedType(name, BindingFlags.Public); + } + + public Type GetNestedType(string name, BindingFlags bindingAttr) + { + foreach (Type type in GetNestedTypes(bindingAttr)) + { + if (type.Name == name) + { + return type; + } + } + return null; + } + + public Type[] GetNestedTypes() + { + return GetNestedTypes(BindingFlags.Public); + } + + public Type[] GetNestedTypes(BindingFlags bindingAttr) + { + CheckBaked(); + List list = new List(); + foreach (Type type in __GetDeclaredTypes()) + { + if (BindingFlagsMatch(type.IsNestedPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic)) + { + list.Add(type); + } + } + return list.ToArray(); + } + + public PropertyInfo[] GetProperties() + { + return GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public PropertyInfo[] GetProperties(BindingFlags bindingAttr) + { + List list = new List(); + Type type = this; + while (type != null) + { + type.CheckBaked(); + foreach (PropertyInfo property in type.__GetDeclaredProperties()) + { + if (BindingFlagsMatch(property.IsPublic, bindingAttr, BindingFlags.Public, BindingFlags.NonPublic) + && BindingFlagsMatch(property.IsStatic, bindingAttr, BindingFlags.Static, BindingFlags.Instance)) + { + list.Add(property); + } + } + if ((bindingAttr & BindingFlags.DeclaredOnly) == 0) + { + if ((bindingAttr & BindingFlags.FlattenHierarchy) == 0) + { + bindingAttr &= ~BindingFlags.Static; + } + type = type.BaseType; + } + else + { + break; + } + } + return list.ToArray(); + } + + public PropertyInfo GetProperty(string name) + { + return GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + } + + public PropertyInfo GetProperty(string name, BindingFlags bindingAttr) + { + foreach (PropertyInfo prop in GetProperties(bindingAttr)) + { + if (prop.Name == name) + { + return prop; + } + } + return null; + } + + public PropertyInfo GetProperty(string name, Type returnType) + { + PropertyInfo found = null; + foreach (PropertyInfo prop in GetProperties()) + { + if (prop.Name == name && prop.PropertyType.Equals(returnType)) + { + if (found != null) + { + throw new AmbiguousMatchException(); + } + found = prop; + } + } + return found; + } + + public PropertyInfo GetProperty(string name, Type[] types) + { + PropertyInfo found = null; + foreach (PropertyInfo prop in GetProperties()) + { + if (prop.Name == name && MatchParameterTypes(prop.GetIndexParameters(), types)) + { + if (found != null) + { + throw new AmbiguousMatchException(); + } + found = prop; + } + } + return found; + } + + private static bool MatchParameterTypes(ParameterInfo[] parameters, Type[] types) + { + if (parameters.Length == types.Length) + { + for (int i = 0; i < parameters.Length; i++) + { + if (!parameters[i].ParameterType.Equals(types[i])) + { + return false; + } + } + return true; + } + return false; + } + + public PropertyInfo GetProperty(string name, Type returnType, Type[] types) + { + return GetProperty(name, returnType, types, null); + } + + public PropertyInfo GetProperty(string name, Type returnType, Type[] types, ParameterModifier[] modifiers) + { + return GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static, null, returnType, types, modifiers); + } + + public PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) + { + PropertyInfo found = null; + foreach (PropertyInfo prop in GetProperties(bindingAttr)) + { + if (prop.Name == name && prop.PropertyType.Equals(returnType) && MatchParameterTypes(prop.GetIndexParameters(), types)) + { + if (found != null) + { + throw new AmbiguousMatchException(); + } + found = prop; + } + } + return found; + } + + public Type GetInterface(string name) + { + return GetInterface(name, false); + } + + public Type GetInterface(string name, bool ignoreCase) + { + if (ignoreCase) + { + throw new NotImplementedException(); + } + foreach (Type type in GetInterfaces()) + { + if (type.FullName == name) + { + return type; + } + } + return null; + } + + public Type[] FindInterfaces(TypeFilter filter, object filterCriteria) + { + List list = new List(); + foreach (Type type in GetInterfaces()) + { + if (filter(type, filterCriteria)) + { + list.Add(type); + } + } + return list.ToArray(); + } + + public ConstructorInfo TypeInitializer + { + get { return GetConstructor(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); } + } + + public bool IsPrimitive + { + get + { + Universe u = this.Module.universe; + return this == u.System_Boolean + || this == u.System_Byte + || this == u.System_SByte + || this == u.System_Int16 + || this == u.System_UInt16 + || this == u.System_Int32 + || this == u.System_UInt32 + || this == u.System_Int64 + || this == u.System_UInt64 + || this == u.System_IntPtr + || this == u.System_UIntPtr + || this == u.System_Char + || this == u.System_Double + || this == u.System_Single + ; + } + } + + public bool IsEnum + { + get { return this.BaseType == this.Module.universe.System_Enum; } + } + + public bool IsSealed + { + get { return (Attributes & TypeAttributes.Sealed) != 0; } + } + + public bool IsAbstract + { + get { return (Attributes & TypeAttributes.Abstract) != 0; } + } + + private bool CheckVisibility(TypeAttributes access) + { + return (Attributes & TypeAttributes.VisibilityMask) == access; + } + + public bool IsPublic + { + get { return CheckVisibility(TypeAttributes.Public); } + } + + public bool IsNestedPublic + { + get { return CheckVisibility(TypeAttributes.NestedPublic); } + } + + public bool IsNestedPrivate + { + get { return CheckVisibility(TypeAttributes.NestedPrivate); } + } + + public bool IsNestedFamily + { + get { return CheckVisibility(TypeAttributes.NestedFamily); } + } + + public bool IsNestedAssembly + { + get { return CheckVisibility(TypeAttributes.NestedAssembly); } + } + + public bool IsNestedFamANDAssem + { + get { return CheckVisibility(TypeAttributes.NestedFamANDAssem); } + } + + public bool IsNestedFamORAssem + { + get { return CheckVisibility(TypeAttributes.NestedFamORAssem); } + } + + public bool IsNotPublic + { + get { return CheckVisibility(TypeAttributes.NotPublic); } + } + + public bool IsImport + { + get { return (Attributes & TypeAttributes.Import) != 0; } + } + + public bool IsCOMObject + { + get { return IsClass && IsImport; } + } + + public bool IsContextful + { + get { return IsSubclassOf(this.Module.universe.Import(typeof(ContextBoundObject))); } + } + + public bool IsMarshalByRef + { + get { return IsSubclassOf(this.Module.universe.Import(typeof(MarshalByRefObject))); } + } + + public virtual bool IsVisible + { + get { return IsPublic || (IsNestedPublic && this.DeclaringType.IsVisible); } + } + + public bool IsAnsiClass + { + get { return (Attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AnsiClass; } + } + + public bool IsUnicodeClass + { + get { return (Attributes & TypeAttributes.StringFormatMask) == TypeAttributes.UnicodeClass; } + } + + public bool IsAutoClass + { + get { return (Attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AutoClass; } + } + + public bool IsAutoLayout + { + get { return (Attributes & TypeAttributes.LayoutMask) == TypeAttributes.AutoLayout; } + } + + public bool IsLayoutSequential + { + get { return (Attributes & TypeAttributes.LayoutMask) == TypeAttributes.SequentialLayout; } + } + + public bool IsExplicitLayout + { + get { return (Attributes & TypeAttributes.LayoutMask) == TypeAttributes.ExplicitLayout; } + } + + public bool IsSpecialName + { + get { return (Attributes & TypeAttributes.SpecialName) != 0; } + } + + public bool IsSerializable + { + get { return (Attributes & TypeAttributes.Serializable) != 0; } + } + + public bool IsClass + { + get { return !IsInterface && !IsValueType; } + } + + public bool IsInterface + { + get { return (Attributes & TypeAttributes.Interface) != 0; } + } + + public bool IsNested + { + // FXBUG we check the declaring type (like .NET) and this results + // in IsNested returning true for a generic type parameter + get { return this.DeclaringType != null; } + } + + public Type MakeArrayType() + { + return ArrayType.Make(this, null, null); + } + + public Type __MakeArrayType(Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return ArrayType.Make(this, Util.Copy(requiredCustomModifiers), Util.Copy(optionalCustomModifiers)); + } + + public Type MakeArrayType(int rank) + { + return MultiArrayType.Make(this, rank, null, null); + } + + public Type __MakeArrayType(int rank, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return MultiArrayType.Make(this, rank, Util.Copy(requiredCustomModifiers), Util.Copy(optionalCustomModifiers)); + } + + public Type MakeByRefType() + { + return ByRefType.Make(this, null, null); + } + + public Type __MakeByRefType(Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return ByRefType.Make(this, Util.Copy(requiredCustomModifiers), Util.Copy(optionalCustomModifiers)); + } + + public Type MakePointerType() + { + return PointerType.Make(this, null, null); + } + + public Type __MakePointerType(Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return PointerType.Make(this, Util.Copy(requiredCustomModifiers), Util.Copy(optionalCustomModifiers)); + } + + public Type MakeGenericType(params Type[] typeArguments) + { + return __MakeGenericType(typeArguments, null, null); + } + + public Type __MakeGenericType(Type[] typeArguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) + { + if (!this.IsGenericTypeDefinition) + { + throw new InvalidOperationException(); + } + return GenericTypeInstance.Make(this, Util.Copy(typeArguments), Util.Copy(requiredCustomModifiers), Util.Copy(optionalCustomModifiers)); + } + + public static System.Type __GetSystemType(TypeCode typeCode) + { + switch (typeCode) + { + case TypeCode.Boolean: + return typeof(System.Boolean); + case TypeCode.Byte: + return typeof(System.Byte); + case TypeCode.Char: + return typeof(System.Char); + case TypeCode.DBNull: + return typeof(System.DBNull); + case TypeCode.DateTime: + return typeof(System.DateTime); + case TypeCode.Decimal: + return typeof(System.Decimal); + case TypeCode.Double: + return typeof(System.Double); + case TypeCode.Empty: + return null; + case TypeCode.Int16: + return typeof(System.Int16); + case TypeCode.Int32: + return typeof(System.Int32); + case TypeCode.Int64: + return typeof(System.Int64); + case TypeCode.Object: + return typeof(System.Object); + case TypeCode.SByte: + return typeof(System.SByte); + case TypeCode.Single: + return typeof(System.Single); + case TypeCode.String: + return typeof(System.String); + case TypeCode.UInt16: + return typeof(System.UInt16); + case TypeCode.UInt32: + return typeof(System.UInt32); + case TypeCode.UInt64: + return typeof(System.UInt64); + default: + throw new ArgumentOutOfRangeException(); + } + } + + public static TypeCode GetTypeCode(Type type) + { + if (type == null) + { + return TypeCode.Empty; + } + if (type.IsEnum) + { + type = type.GetEnumUnderlyingType(); + } + Universe u = type.Module.universe; + if (type == u.System_Boolean) + { + return TypeCode.Boolean; + } + else if (type == u.System_Char) + { + return TypeCode.Char; + } + else if (type == u.System_SByte) + { + return TypeCode.SByte; + } + else if (type == u.System_Byte) + { + return TypeCode.Byte; + } + else if (type == u.System_Int16) + { + return TypeCode.Int16; + } + else if (type == u.System_UInt16) + { + return TypeCode.UInt16; + } + else if (type == u.System_Int32) + { + return TypeCode.Int32; + } + else if (type == u.System_UInt32) + { + return TypeCode.UInt32; + } + else if (type == u.System_Int64) + { + return TypeCode.Int64; + } + else if (type == u.System_UInt64) + { + return TypeCode.UInt64; + } + else if (type == u.System_Single) + { + return TypeCode.Single; + } + else if (type == u.System_Double) + { + return TypeCode.Double; + } + else if (type == u.System_DateTime) + { + return TypeCode.DateTime; + } + else if (type == u.System_DBNull) + { + return TypeCode.DBNull; + } + else if (type == u.System_Decimal) + { + return TypeCode.Decimal; + } + else if (type == u.System_String) + { + return TypeCode.String; + } + else + { + return TypeCode.Object; + } + } + + public Assembly Assembly + { + get { return Module.Assembly; } + } + + // note that interface/delegate co- and contravariance is not considered + public bool IsAssignableFrom(Type type) + { + if (this.Equals(type)) + { + return true; + } + else if (type == null) + { + return false; + } + else if (this.IsArray && type.IsArray) + { + if (this.GetArrayRank() != type.GetArrayRank()) + { + return false; + } + else if (this.__IsVector && !type.__IsVector) + { + return false; + } + Type e1 = this.GetElementType(); + Type e2 = type.GetElementType(); + return e1.IsValueType == e2.IsValueType && e1.IsAssignableFrom(e2); + } + else if (this.IsSealed) + { + return false; + } + else if (this.IsInterface) + { + return Array.IndexOf(type.GetInterfaces(), this) != -1; + } + else if (type.IsInterface) + { + return this == this.Module.universe.System_Object; + } + else if (type.IsPointer) + { + return this == this.Module.universe.System_Object || this == this.Module.universe.System_ValueType; + } + else + { + return type.IsSubclassOf(this); + } + } + + public bool IsSubclassOf(Type type) + { + Type thisType = this.BaseType; + while (thisType != null) + { + if (thisType.Equals(type)) + { + return true; + } + thisType = thisType.BaseType; + } + return false; + } + + // This returns true if this type directly (i.e. not inherited from the base class) implements the interface. + // Note that a complicating factor is that the interface itself can be implemented by an interface that extends it. + private bool IsDirectlyImplementedInterface(Type interfaceType) + { + foreach (Type iface in __GetDeclaredInterfaces()) + { + if (interfaceType.IsAssignableFrom(iface)) + { + return true; + } + } + return false; + } + + public InterfaceMapping GetInterfaceMap(Type interfaceType) + { + CheckBaked(); + InterfaceMapping map = new InterfaceMapping(); + if (!IsDirectlyImplementedInterface(interfaceType)) + { + Type baseType = this.BaseType; + if (baseType == null) + { + throw new ArgumentException(); + } + else + { + map = baseType.GetInterfaceMap(interfaceType); + } + } + else + { + map.InterfaceMethods = interfaceType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); + map.InterfaceType = interfaceType; + map.TargetMethods = new MethodInfo[map.InterfaceMethods.Length]; + FillInExplicitInterfaceMethods(map.InterfaceMethods, map.TargetMethods); + MethodInfo[] methods = GetMethods(BindingFlags.Instance | BindingFlags.Public); + for (int i = 0; i < map.TargetMethods.Length; i++) + { + if (map.TargetMethods[i] == null) + { + // TODO use proper method resolution (also take into account that no implicit base class implementation is used across assembly boundaries) + for (int j = 0; j < methods.Length; j++) + { + if (methods[j].Name == map.InterfaceMethods[i].Name + && methods[j].MethodSignature.Equals(map.InterfaceMethods[i].MethodSignature)) + { + map.TargetMethods[i] = methods[j]; + } + } + } + } + for (Type baseType = this.BaseType; baseType != null && interfaceType.IsAssignableFrom(baseType); baseType = baseType.BaseType) + { + baseType.FillInExplicitInterfaceMethods(map.InterfaceMethods, map.TargetMethods); + } + } + map.TargetType = this; + return map; + } + + internal void FillInExplicitInterfaceMethods(MethodInfo[] interfaceMethods, MethodInfo[] targetMethods) + { + __MethodImplMap impl = __GetMethodImplMap(); + for (int i = 0; i < impl.MethodDeclarations.Length; i++) + { + for (int j = 0; j < impl.MethodDeclarations[i].Length; j++) + { + int index = Array.IndexOf(interfaceMethods, impl.MethodDeclarations[i][j]); + if (index != -1 && targetMethods[index] == null) + { + targetMethods[index] = impl.MethodBodies[i]; + } + } + } + } + + Type IGenericContext.GetGenericTypeArgument(int index) + { + return GetGenericTypeArgument(index); + } + + Type IGenericContext.GetGenericMethodArgument(int index) + { + throw new BadImageFormatException(); + } + + Type IGenericBinder.BindTypeParameter(Type type) + { + return GetGenericTypeArgument(type.GenericParameterPosition); + } + + Type IGenericBinder.BindMethodParameter(Type type) + { + throw new BadImageFormatException(); + } + + internal virtual Type BindTypeParameters(IGenericBinder binder) + { + if (IsGenericTypeDefinition) + { + Type[] args = GetGenericArguments(); + Type.InplaceBindTypeParameters(binder, args); + return GenericTypeInstance.Make(this, args, null, null); + } + else + { + return this; + } + } + + internal static void InplaceBindTypeParameters(IGenericBinder binder, Type[] types) + { + for (int i = 0; i < types.Length; i++) + { + types[i] = types[i].BindTypeParameters(binder); + } + } + + internal MethodBase FindMethod(string name, MethodSignature signature) + { + foreach (MethodBase method in __GetDeclaredMethods()) + { + if (method.Name == name && method.MethodSignature.Equals(signature)) + { + return method; + } + } + return null; + } + + internal FieldInfo FindField(string name, FieldSignature signature) + { + foreach (FieldInfo field in __GetDeclaredFields()) + { + if (field.Name == name && field.FieldSignature.Equals(signature)) + { + return field; + } + } + return null; + } + + internal bool IsAllowMultipleCustomAttribute + { + get + { + IList cad = GetCustomAttributesData(this.Module.universe.System_AttributeUsageAttribute); + if (cad.Count == 1) + { + foreach (CustomAttributeNamedArgument arg in cad[0].NamedArguments) + { + if (arg.MemberInfo.Name == "AllowMultiple") + { + return (bool)arg.TypedValue.Value; + } + } + } + return false; + } + } + + internal bool IsPseudoCustomAttribute + { + get + { + Universe u = this.Module.universe; + return this == u.System_NonSerializedAttribute + || this == u.System_SerializableAttribute + || this == u.System_Runtime_InteropServices_DllImportAttribute + || this == u.System_Runtime_InteropServices_FieldOffsetAttribute + || this == u.System_Runtime_InteropServices_InAttribute + || this == u.System_Runtime_InteropServices_MarshalAsAttribute + || this == u.System_Runtime_InteropServices_OutAttribute + || this == u.System_Runtime_InteropServices_StructLayoutAttribute + || this == u.System_Runtime_InteropServices_OptionalAttribute + || this == u.System_Runtime_InteropServices_PreserveSigAttribute + || this == u.System_Runtime_InteropServices_ComImportAttribute + || this == u.System_Runtime_CompilerServices_SpecialNameAttribute + || this == u.System_Runtime_CompilerServices_MethodImplAttribute + ; + } + } + } + + abstract class ElementHolderType : Type + { + protected readonly Type elementType; + private int token; + private readonly Type[] requiredCustomModifiers; + private readonly Type[] optionalCustomModifiers; + + protected ElementHolderType(Type elementType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + this.elementType = elementType; + this.requiredCustomModifiers = requiredCustomModifiers; + this.optionalCustomModifiers = optionalCustomModifiers; + } + + protected bool EqualsHelper(ElementHolderType other) + { + return other != null + && other.elementType.Equals(elementType) + && Util.ArrayEquals(other.requiredCustomModifiers, requiredCustomModifiers) + && Util.ArrayEquals(other.optionalCustomModifiers, optionalCustomModifiers); + } + + public override Type[] __GetRequiredCustomModifiers() + { + return Util.Copy(requiredCustomModifiers); + } + + public override Type[] __GetOptionalCustomModifiers() + { + return Util.Copy(optionalCustomModifiers); + } + + public sealed override string Name + { + get { return elementType.Name + GetSuffix(); } + } + + public sealed override string FullName + { + get { return elementType.FullName + GetSuffix(); } + } + + public sealed override string ToString() + { + return elementType.ToString() + GetSuffix(); + } + + public sealed override Type GetElementType() + { + return elementType; + } + + public sealed override bool HasElementType + { + get { return true; } + } + + public sealed override Module Module + { + get { return elementType.Module; } + } + + internal sealed override int GetModuleBuilderToken() + { + if (token == 0) + { + token = ((ModuleBuilder)elementType.Module).ImportType(this); + } + return token; + } + + public sealed override bool ContainsGenericParameters + { + get + { + Type type = elementType; + while (type.HasElementType) + { + type = type.GetElementType(); + } + return type.ContainsGenericParameters; + } + } + + internal sealed override Type BindTypeParameters(IGenericBinder binder) + { + Type type = elementType.BindTypeParameters(binder); + Type[] req = BindArray(requiredCustomModifiers, binder); + Type[] opt = BindArray(optionalCustomModifiers, binder); + if (ReferenceEquals(type, elementType) + && ReferenceEquals(req, requiredCustomModifiers) + && ReferenceEquals(opt, optionalCustomModifiers)) + { + return this; + } + return Wrap(type, req, opt); + } + + internal override void CheckBaked() + { + elementType.CheckBaked(); + } + + private static Type[] BindArray(Type[] array, IGenericBinder binder) + { + if (array ==null || array.Length == 0) + { + return array; + } + Type[] result = array; + for (int i = 0; i < array.Length; i++) + { + Type type = array[i].BindTypeParameters(binder); + if (!ReferenceEquals(type, array[i])) + { + if (result == array) + { + result = (Type[])array.Clone(); + } + result[i] = type; + } + } + return result; + } + + internal sealed override IList GetCustomAttributesData(Type attributeType) + { + return CustomAttributeData.EmptyList; + } + + protected abstract string GetSuffix(); + + protected abstract Type Wrap(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers); + } + + sealed class ArrayType : ElementHolderType + { + internal static Type Make(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return type.Module.CanonicalizeType(new ArrayType(type, requiredCustomModifiers, optionalCustomModifiers)); + } + + private ArrayType(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + : base(type, requiredCustomModifiers, optionalCustomModifiers) + { + } + + public override Type BaseType + { + get { return elementType.Module.universe.System_Array; } + } + + public override Type[] __GetDeclaredInterfaces() + { + return new Type[] { + this.Module.universe.Import(typeof(IList<>)).MakeGenericType(elementType), + this.Module.universe.Import(typeof(ICollection<>)).MakeGenericType(elementType), + this.Module.universe.Import(typeof(IEnumerable<>)).MakeGenericType(elementType) + }; + } + + public override MethodBase[] __GetDeclaredMethods() + { + Type[] int32 = new Type[] { this.Module.universe.System_Int32 }; + List list = new List(); + list.Add(new BuiltinArrayMethod(this.Module, this, "Set", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, new Type[] { this.Module.universe.System_Int32, elementType })); + list.Add(new BuiltinArrayMethod(this.Module, this, "Address", CallingConventions.Standard | CallingConventions.HasThis, elementType.MakeByRefType(), int32)); + list.Add(new BuiltinArrayMethod(this.Module, this, "Get", CallingConventions.Standard | CallingConventions.HasThis, elementType, int32)); + list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, int32))); + for (Type type = elementType; type.__IsVector; type = type.GetElementType()) + { + Array.Resize(ref int32, int32.Length + 1); + int32[int32.Length - 1] = int32[0]; + list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, int32))); + } + return list.ToArray(); + } + + public override TypeAttributes Attributes + { + get { return TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; } + } + + public override bool IsArray + { + get { return true; } + } + + public override bool __IsVector + { + get { return true; } + } + + public override int GetArrayRank() + { + return 1; + } + + public override bool Equals(object o) + { + return EqualsHelper(o as ArrayType); + } + + public override int GetHashCode() + { + return elementType.GetHashCode() * 5; + } + + protected override string GetSuffix() + { + return "[]"; + } + + protected override Type Wrap(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return Make(type, requiredCustomModifiers, optionalCustomModifiers); + } + } + + sealed class MultiArrayType : ElementHolderType + { + private readonly int rank; + + internal static Type Make(Type type, int rank, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return type.Module.CanonicalizeType(new MultiArrayType(type, rank, requiredCustomModifiers, optionalCustomModifiers)); + } + + private MultiArrayType(Type type, int rank, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + : base(type, requiredCustomModifiers, optionalCustomModifiers) + { + this.rank = rank; + } + + public override Type BaseType + { + get { return elementType.Module.universe.System_Array; } + } + + public override MethodBase[] __GetDeclaredMethods() + { + Type int32 = this.Module.universe.System_Int32; + Type[] setArgs = new Type[rank + 1]; + Type[] getArgs = new Type[rank]; + Type[] ctorArgs = new Type[rank * 2]; + for (int i = 0; i < rank; i++) + { + setArgs[i] = int32; + getArgs[i] = int32; + ctorArgs[i * 2 + 0] = int32; + ctorArgs[i * 2 + 1] = int32; + } + setArgs[rank] = elementType; + return new MethodBase[] { + new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, getArgs)), + new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, ctorArgs)), + new BuiltinArrayMethod(this.Module, this, "Set", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, setArgs), + new BuiltinArrayMethod(this.Module, this, "Address", CallingConventions.Standard | CallingConventions.HasThis, elementType.MakeByRefType(), getArgs), + new BuiltinArrayMethod(this.Module, this, "Get", CallingConventions.Standard | CallingConventions.HasThis, elementType, getArgs), + }; + } + + public override TypeAttributes Attributes + { + get { return TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; } + } + + public override bool IsArray + { + get { return true; } + } + + public override int GetArrayRank() + { + return rank; + } + + public override bool Equals(object o) + { + MultiArrayType at = o as MultiArrayType; + return EqualsHelper(at) && at.rank == rank; + } + + public override int GetHashCode() + { + return elementType.GetHashCode() * 9 + rank; + } + + protected override string GetSuffix() + { + if (rank == 1) + { + return "[*]"; + } + else + { + return "[" + new String(',', rank - 1) + "]"; + } + } + + protected override Type Wrap(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return Make(type, rank, requiredCustomModifiers, optionalCustomModifiers); + } + } + + sealed class BuiltinArrayMethod : ArrayMethod + { + internal BuiltinArrayMethod(Module module, Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) + : base(module, arrayClass, methodName, callingConvention, returnType, parameterTypes) + { + } + + public override MethodAttributes Attributes + { + get { return this.Name == ".ctor" ? MethodAttributes.RTSpecialName | MethodAttributes.Public : MethodAttributes.Public; } + } + + public override MethodImplAttributes GetMethodImplementationFlags() + { + return MethodImplAttributes.IL; + } + + public override int MetadataToken + { + get { return 0x06000000; } + } + + public override MethodBody GetMethodBody() + { + return null; + } + + public override ParameterInfo[] GetParameters() + { + ParameterInfo[] parameterInfos = new ParameterInfo[parameterTypes.Length]; + for (int i = 0; i < parameterInfos.Length; i++) + { + parameterInfos[i] = new ParameterInfoImpl(this, parameterTypes[i], i); + } + return parameterInfos; + } + + public override ParameterInfo ReturnParameter + { + get { return new ParameterInfoImpl(this, this.ReturnType, -1); } + } + + private sealed class ParameterInfoImpl : ParameterInfo + { + private readonly MethodInfo method; + private readonly Type type; + private readonly int pos; + + internal ParameterInfoImpl(MethodInfo method, Type type, int pos) + { + this.method = method; + this.type = type; + this.pos = pos; + } + + public override Type ParameterType + { + get { return type; } + } + + public override string Name + { + get { return null; } + } + + public override ParameterAttributes Attributes + { + get { return ParameterAttributes.None; } + } + + public override int Position + { + get { return pos; } + } + + public override object RawDefaultValue + { + get { return null; } + } + + public override Type[] GetOptionalCustomModifiers() + { + return Empty.Array; + } + + public override Type[] GetRequiredCustomModifiers() + { + return Empty.Array; + } + + public override MemberInfo Member + { + get { return method.IsConstructor ? (MethodBase)new ConstructorInfoImpl(method) : method; } + } + + public override int MetadataToken + { + get { return 0x8000000; } + } + + internal override Module Module + { + get { return method.Module; } + } + } + } + + sealed class ByRefType : ElementHolderType + { + internal static Type Make(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return type.Module.CanonicalizeType(new ByRefType(type, requiredCustomModifiers, optionalCustomModifiers)); + } + + private ByRefType(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + : base(type, requiredCustomModifiers, optionalCustomModifiers) + { + } + + public override bool Equals(object o) + { + return EqualsHelper(o as ByRefType); + } + + public override int GetHashCode() + { + return elementType.GetHashCode() * 3; + } + + public override Type BaseType + { + get { return null; } + } + + public override TypeAttributes Attributes + { + get { return 0; } + } + + public override bool IsByRef + { + get { return true; } + } + + protected override string GetSuffix() + { + return "&"; + } + + protected override Type Wrap(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return Make(type, requiredCustomModifiers, optionalCustomModifiers); + } + } + + sealed class PointerType : ElementHolderType + { + internal static Type Make(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return type.Module.CanonicalizeType(new PointerType(type, requiredCustomModifiers, optionalCustomModifiers)); + } + + private PointerType(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + : base(type, requiredCustomModifiers, optionalCustomModifiers) + { + } + + public override bool Equals(object o) + { + return EqualsHelper(o as PointerType); + } + + public override int GetHashCode() + { + return elementType.GetHashCode() * 7; + } + + public override Type BaseType + { + get { return null; } + } + + public override TypeAttributes Attributes + { + get { return 0; } + } + + public override bool IsPointer + { + get { return true; } + } + + protected override string GetSuffix() + { + return "*"; + } + + protected override Type Wrap(Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) + { + return Make(type, requiredCustomModifiers, optionalCustomModifiers); + } + } + + sealed class GenericTypeInstance : Type + { + private readonly Type type; + private readonly Type[] args; + private readonly Type[][] requiredCustomModifiers; + private readonly Type[][] optionalCustomModifiers; + private Type baseType; + private int token; + + internal static Type Make(Type type, Type[] typeArguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) + { + bool identity = true; + if (type is TypeBuilder || type is BakedType) + { + // a TypeBuiler identity must be instantiated + identity = false; + } + else + { + // we must not instantiate the identity instance, because typeof(Foo<>).MakeGenericType(typeof(Foo<>).GetGenericArguments()) == typeof(Foo<>) + for (int i = 0; i < typeArguments.Length; i++) + { + if (typeArguments[i] != type.GetGenericTypeArgument(i) + || !IsEmpty(requiredCustomModifiers, i) + || !IsEmpty(optionalCustomModifiers, i)) + { + identity = false; + break; + } + } + } + if (identity) + { + return type; + } + else + { + return type.Module.CanonicalizeType(new GenericTypeInstance(type, typeArguments, requiredCustomModifiers, optionalCustomModifiers)); + } + } + + private static bool IsEmpty(Type[][] mods, int i) + { + // we need to be extra careful, because mods doesn't not need to be in canonical format + // (Signature.ReadGenericInst() calls Make() directly, without copying the modifier arrays) + return mods == null || mods[i] == null || mods[i].Length == 0; + } + + private GenericTypeInstance(Type type, Type[] args, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) + { + this.type = type; + this.args = args; + this.requiredCustomModifiers = requiredCustomModifiers; + this.optionalCustomModifiers = optionalCustomModifiers; + } + + public override bool Equals(object o) + { + GenericTypeInstance gt = o as GenericTypeInstance; + return gt != null && gt.type.Equals(type) && Util.ArrayEquals(gt.args, args) + && Util.ArrayEquals(gt.requiredCustomModifiers, requiredCustomModifiers) + && Util.ArrayEquals(gt.optionalCustomModifiers, optionalCustomModifiers); + } + + public override int GetHashCode() + { + return type.GetHashCode() * 3 ^ Util.GetHashCode(args); + } + + public override string AssemblyQualifiedName + { + get + { + string fn = FullName; + return fn == null ? null : fn + ", " + type.Assembly.FullName; + } + } + + public override Type BaseType + { + get + { + if (baseType == null) + { + Type rawBaseType = type.BaseType; + if (rawBaseType == null) + { + baseType = rawBaseType; + } + else + { + baseType = rawBaseType.BindTypeParameters(this); + } + } + return baseType; + } + } + + public override bool IsValueType + { + get { return type.IsValueType; } + } + + public override bool IsVisible + { + get + { + if (base.IsVisible) + { + foreach (Type arg in args) + { + if (!arg.IsVisible) + { + return false; + } + } + return true; + } + return false; + } + } + + public override Type DeclaringType + { + get { return type.DeclaringType; } + } + + public override TypeAttributes Attributes + { + get { return type.Attributes; } + } + + internal override void CheckBaked() + { + type.CheckBaked(); + } + + public override FieldInfo[] __GetDeclaredFields() + { + FieldInfo[] fields = type.__GetDeclaredFields(); + for (int i = 0; i < fields.Length; i++) + { + fields[i] = fields[i].BindTypeParameters(this); + } + return fields; + } + + public override Type[] __GetDeclaredInterfaces() + { + Type[] interfaces = type.__GetDeclaredInterfaces(); + for (int i = 0; i < interfaces.Length; i++) + { + interfaces[i] = interfaces[i].BindTypeParameters(this); + } + return interfaces; + } + + public override MethodBase[] __GetDeclaredMethods() + { + MethodBase[] methods = type.__GetDeclaredMethods(); + for (int i = 0; i < methods.Length; i++) + { + methods[i] = methods[i].BindTypeParameters(this); + } + return methods; + } + + public override Type[] __GetDeclaredTypes() + { + return type.__GetDeclaredTypes(); + } + + public override EventInfo[] __GetDeclaredEvents() + { + EventInfo[] events = type.__GetDeclaredEvents(); + for (int i = 0; i < events.Length; i++) + { + events[i] = events[i].BindTypeParameters(this); + } + return events; + } + + public override PropertyInfo[] __GetDeclaredProperties() + { + PropertyInfo[] properties = type.__GetDeclaredProperties(); + for (int i = 0; i < properties.Length; i++) + { + properties[i] = properties[i].BindTypeParameters(this); + } + return properties; + } + + public override __MethodImplMap __GetMethodImplMap() + { + __MethodImplMap map = type.__GetMethodImplMap(); + map.TargetType = this; + for (int i = 0; i < map.MethodBodies.Length; i++) + { + map.MethodBodies[i] = (MethodInfo)map.MethodBodies[i].BindTypeParameters(this); + for (int j = 0; j < map.MethodDeclarations[i].Length; j++) + { + Type interfaceType = map.MethodDeclarations[i][j].DeclaringType; + if (interfaceType.IsGenericType) + { + map.MethodDeclarations[i][j] = (MethodInfo)map.MethodDeclarations[i][j].BindTypeParameters(this); + } + } + } + return map; + } + + public override string Namespace + { + get { return type.Namespace; } + } + + public override Type UnderlyingSystemType + { + get { return this; } + } + + public override string Name + { + get { return type.Name; } + } + + public override string FullName + { + get + { + if (this.ContainsGenericParameters) + { + return null; + } + StringBuilder sb = new StringBuilder(base.FullName); + sb.Append('['); + foreach (Type type in args) + { + sb.Append('[').Append(type.AssemblyQualifiedName.Replace("]", "\\]")).Append(']'); + } + sb.Append(']'); + return sb.ToString(); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(type.FullName); + sb.Append('['); + string sep = ""; + foreach (Type arg in args) + { + sb.Append(sep); + sb.Append(arg); + sep = ","; + } + sb.Append(']'); + return sb.ToString(); + } + + public override Module Module + { + get { return type.Module; } + } + + public override bool IsGenericType + { + get { return true; } + } + + public override Type GetGenericTypeDefinition() + { + return type; + } + + public override Type[] GetGenericArguments() + { + return Util.Copy(args); + } + + public override Type[][] __GetGenericArgumentsRequiredCustomModifiers() + { + return Util.Copy(requiredCustomModifiers ?? new Type[args.Length][]); + } + + public override Type[][] __GetGenericArgumentsOptionalCustomModifiers() + { + return Util.Copy(optionalCustomModifiers ?? new Type[args.Length][]); + } + + internal override Type GetGenericTypeArgument(int index) + { + return args[index]; + } + + public override bool ContainsGenericParameters + { + get + { + foreach (Type type in args) + { + if (type.ContainsGenericParameters) + { + return true; + } + } + return false; + } + } + + public override StructLayoutAttribute StructLayoutAttribute + { + get { return type.StructLayoutAttribute; } + } + + internal override int GetModuleBuilderToken() + { + if (token == 0) + { + token = ((ModuleBuilder)type.Module).ImportType(this); + } + return token; + } + + internal override Type BindTypeParameters(IGenericBinder binder) + { + for (int i = 0; i < args.Length; i++) + { + Type xarg = args[i].BindTypeParameters(binder); + if (!ReferenceEquals(xarg, args[i])) + { + Type[] xargs = new Type[args.Length]; + Array.Copy(args, xargs, i); + xargs[i++] = xarg; + for (; i < args.Length; i++) + { + xargs[i] = args[i].BindTypeParameters(binder); + } + return Make(type, xargs, null, null); + } + } + return this; + } + + internal override IList GetCustomAttributesData(Type attributeType) + { + return type.GetCustomAttributesData(attributeType); + } + } +} diff --git a/mcs/class/IKVM.Reflection/TypeNameParser.cs b/mcs/class/IKVM.Reflection/TypeNameParser.cs new file mode 100644 index 000000000000..d6c18ee9172c --- /dev/null +++ b/mcs/class/IKVM.Reflection/TypeNameParser.cs @@ -0,0 +1,458 @@ +/* + Copyright (C) 2009 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IKVM.Reflection +{ + struct TypeNameParser + { + private const string SpecialChars = "\\+,[]*&"; + private const short SZARRAY = -1; + private const short BYREF = -2; + private const short POINTER = -3; + private readonly string name; + private readonly string[] nested; + private readonly string assemblyName; + private readonly short[] modifiers; + private readonly TypeNameParser[] genericParameters; + + internal static string Escape(string name) + { + if (name == null) + { + return null; + } + StringBuilder sb = null; + for (int pos = 0; pos < name.Length; pos++) + { + char c = name[pos]; + if (SpecialChars.IndexOf(c) != -1) + { + if (sb == null) + { + sb = new StringBuilder(name, 0, pos, name.Length + 3); + } + sb.Append('\\').Append(c); + } + else if (sb != null) + { + sb.Append(c); + } + } + return sb != null ? sb.ToString() : name; + } + + internal static string Unescape(string name) + { + int pos = name.IndexOf('\\'); + if (pos == -1) + { + return name; + } + StringBuilder sb = new StringBuilder(name, 0, pos, name.Length - 1); + for (; pos < name.Length; pos++) + { + char c = name[pos]; + if (c == '\\') + { + c = name[++pos]; + } + sb.Append(c); + } + return sb.ToString(); + } + + internal static TypeNameParser Parse(string typeName, bool throwOnError) + { + if (throwOnError) + { + Parser parser = new Parser(typeName); + return new TypeNameParser(ref parser, true); + } + else + { + try + { + Parser parser = new Parser(typeName); + return new TypeNameParser(ref parser, true); + } + catch (ArgumentException) + { + return new TypeNameParser(); + } + } + } + + private TypeNameParser(ref Parser parser, bool withAssemblyName) + { + bool genericParameter = parser.pos != 0; + name = parser.NextNamePart(); + nested = null; + parser.ParseNested(ref nested); + genericParameters = null; + parser.ParseGenericParameters(ref genericParameters); + modifiers = null; + parser.ParseModifiers(ref modifiers); + assemblyName = null; + if (withAssemblyName) + { + parser.ParseAssemblyName(genericParameter, ref assemblyName); + } + } + + internal bool Error + { + get { return name == null; } + } + + internal string FirstNamePart + { + get { return name; } + } + + internal string AssemblyName + { + get { return assemblyName; } + } + + private struct Parser + { + private readonly string typeName; + internal int pos; + + internal Parser(string typeName) + { + this.typeName = typeName; + this.pos = 0; + } + + private void Check(bool condition) + { + if (!condition) + { + throw new ArgumentException("Invalid type name '" + typeName + "'"); + } + } + + private void Consume(char c) + { + Check(pos < typeName.Length && typeName[pos++] == c); + } + + private bool TryConsume(char c) + { + if (pos < typeName.Length && typeName[pos] == c) + { + pos++; + return true; + } + else + { + return false; + } + } + + internal string NextNamePart() + { + SkipWhiteSpace(); + int start = pos; + for (; pos < typeName.Length; pos++) + { + char c = typeName[pos]; + if (c == '\\') + { + pos++; + Check(pos < typeName.Length && SpecialChars.IndexOf(typeName[pos]) != -1); + } + else if (SpecialChars.IndexOf(c) != -1) + { + break; + } + } + Check(pos - start != 0); + if (start == 0 && pos == typeName.Length) + { + return typeName; + } + else + { + return typeName.Substring(start, pos - start); + } + } + + internal void ParseNested(ref string[] nested) + { + while (TryConsume('+')) + { + Add(ref nested, NextNamePart()); + } + } + + internal void ParseGenericParameters(ref TypeNameParser[] genericParameters) + { + int saved = pos; + if (TryConsume('[')) + { + SkipWhiteSpace(); + if (TryConsume(']') || TryConsume('*') || TryConsume(',')) + { + // it's not a generic parameter list, but an array instead + pos = saved; + return; + } + do + { + SkipWhiteSpace(); + if (TryConsume('[')) + { + Add(ref genericParameters, new TypeNameParser(ref this, true)); + Consume(']'); + } + else + { + Add(ref genericParameters, new TypeNameParser(ref this, false)); + } + } + while (TryConsume(',')); + Consume(']'); + SkipWhiteSpace(); + } + } + + internal void ParseModifiers(ref short[] modifiers) + { + while (pos < typeName.Length) + { + switch (typeName[pos]) + { + case '*': + pos++; + Add(ref modifiers, POINTER); + break; + case '&': + pos++; + Add(ref modifiers, BYREF); + break; + case '[': + pos++; + Add(ref modifiers, ParseArray()); + Consume(']'); + break; + default: + return; + } + SkipWhiteSpace(); + } + } + + internal void ParseAssemblyName(bool genericParameter, ref string assemblyName) + { + if (pos < typeName.Length) + { + if (typeName[pos] == ']' && genericParameter) + { + // ok + } + else + { + Consume(','); + SkipWhiteSpace(); + if (genericParameter) + { + int start = pos; + while (pos < typeName.Length) + { + char c = typeName[pos]; + if (c == '\\') + { + pos++; + // a backslash itself is not legal in an assembly name, so we don't need to check for an escaped backslash + Check(pos < typeName.Length && typeName[pos++] == ']'); + } + else if (c == ']') + { + break; + } + else + { + pos++; + } + } + Check(pos < typeName.Length && typeName[pos] == ']'); + assemblyName = typeName.Substring(start, pos - start).Replace("\\]", "]"); + } + else + { + // only when an assembly name is used in a generic type parameter, will it be escaped + assemblyName = typeName.Substring(pos); + } + Check(assemblyName.Length != 0); + } + } + else + { + Check(!genericParameter); + } + } + + private short ParseArray() + { + SkipWhiteSpace(); + Check(pos < typeName.Length); + char c = typeName[pos]; + if (c == ']') + { + return SZARRAY; + } + else if (c == '*') + { + pos++; + SkipWhiteSpace(); + return 1; + } + else + { + short rank = 1; + while (TryConsume(',')) + { + Check(rank < short.MaxValue); + rank++; + SkipWhiteSpace(); + } + return rank; + } + } + + private void SkipWhiteSpace() + { + while (pos < typeName.Length && Char.IsWhiteSpace(typeName[pos])) + { + pos++; + } + } + + private static void Add(ref T[] array, T elem) + { + if (array == null) + { + array = new T[] { elem }; + return; + } + Array.Resize(ref array, array.Length + 1); + array[array.Length - 1] = elem; + } + } + + internal Type GetType(Universe universe, Assembly context, bool throwOnError, string originalName) + { + Type type; + if (assemblyName != null) + { + Assembly asm = universe.Load(assemblyName, context, throwOnError); + if (asm == null) + { + return null; + } + type = asm.GetTypeImpl(name); + } + else if (context == null) + { + type = universe.Mscorlib.GetTypeImpl(name); + } + else + { + type = context.GetTypeImpl(name); + if (type == null && context != universe.Mscorlib) + { + type = universe.Mscorlib.GetTypeImpl(name); + } + } + return Expand(type, context, throwOnError, originalName); + } + + internal Type Expand(Type type, Assembly context, bool throwOnError, string originalName) + { + if (type == null) + { + if (throwOnError) + { + throw new TypeLoadException(originalName); + } + return null; + } + if (nested != null) + { + foreach (string nest in nested) + { + type = type.GetNestedType(nest, BindingFlags.Public | BindingFlags.NonPublic); + if (type == null) + { + if (throwOnError) + { + throw new TypeLoadException(originalName); + } + return null; + } + } + } + if (genericParameters != null) + { + Type[] typeArgs = new Type[genericParameters.Length]; + for (int i = 0; i < typeArgs.Length; i++) + { + typeArgs[i] = genericParameters[i].GetType(type.Assembly.universe, context, throwOnError, originalName); + if (typeArgs[i] == null) + { + return null; + } + } + type = type.MakeGenericType(typeArgs); + } + if (modifiers != null) + { + foreach (short modifier in modifiers) + { + switch (modifier) + { + case SZARRAY: + type = type.MakeArrayType(); + break; + case BYREF: + type = type.MakeByRefType(); + break; + case POINTER: + type = type.MakePointerType(); + break; + default: + type = type.MakeArrayType(modifier); + break; + } + } + } + return type; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Universe.cs b/mcs/class/IKVM.Reflection/Universe.cs new file mode 100644 index 000000000000..ab6318303afc --- /dev/null +++ b/mcs/class/IKVM.Reflection/Universe.cs @@ -0,0 +1,795 @@ +/* + Copyright (C) 2009-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Security; +using System.Text; +using System.Diagnostics; +using IKVM.Reflection.Reader; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection +{ + public class ResolveEventArgs : EventArgs + { + private readonly string name; + private readonly Assembly requestingAssembly; + + public ResolveEventArgs(string name) + : this(name, null) + { + } + + public ResolveEventArgs(string name, Assembly requestingAssembly) + { + this.name = name; + this.requestingAssembly = requestingAssembly; + } + + public string Name + { + get { return name; } + } + + public Assembly RequestingAssembly + { + get { return requestingAssembly; } + } + } + + public enum AssemblyComparisonResult + { + Unknown = 0, + EquivalentFullMatch = 1, + EquivalentWeakNamed = 2, + EquivalentFXUnified = 3, + EquivalentUnified = 4, + NonEquivalentVersion = 5, + NonEquivalent = 6, + EquivalentPartialMatch = 7, + EquivalentPartialWeakNamed = 8, + EquivalentPartialUnified = 9, + EquivalentPartialFXUnified = 10, + NonEquivalentPartialVersion = 11, + } + + public delegate Assembly ResolveEventHandler(object sender, ResolveEventArgs args); + + public sealed class Universe : IDisposable + { + internal readonly Dictionary canonicalizedTypes = new Dictionary(); + private readonly List assemblies = new List(); + private readonly List dynamicAssemblies = new List(); + private readonly Dictionary assembliesByName = new Dictionary(); + private readonly Dictionary importedTypes = new Dictionary(); + private Type typeof_System_Object; + private Type typeof_System_ValueType; + private Type typeof_System_Enum; + private Type typeof_System_Void; + private Type typeof_System_Boolean; + private Type typeof_System_Char; + private Type typeof_System_SByte; + private Type typeof_System_Byte; + private Type typeof_System_Int16; + private Type typeof_System_UInt16; + private Type typeof_System_Int32; + private Type typeof_System_UInt32; + private Type typeof_System_Int64; + private Type typeof_System_UInt64; + private Type typeof_System_Single; + private Type typeof_System_Double; + private Type typeof_System_String; + private Type typeof_System_IntPtr; + private Type typeof_System_UIntPtr; + private Type typeof_System_TypedReference; + private Type typeof_System_Type; + private Type typeof_System_Array; + private Type typeof_System_DateTime; + private Type typeof_System_DBNull; + private Type typeof_System_Decimal; + private Type typeof_System_NonSerializedAttribute; + private Type typeof_System_SerializableAttribute; + private Type typeof_System_AttributeUsageAttribute; + private Type typeof_System_Reflection_AssemblyCultureAttribute; + private Type typeof_System_Runtime_InteropServices_DllImportAttribute; + private Type typeof_System_Runtime_InteropServices_FieldOffsetAttribute; + private Type typeof_System_Runtime_InteropServices_InAttribute; + private Type typeof_System_Runtime_InteropServices_MarshalAsAttribute; + private Type typeof_System_Runtime_InteropServices_UnmanagedType; + private Type typeof_System_Runtime_InteropServices_VarEnum; + private Type typeof_System_Runtime_InteropServices_OutAttribute; + private Type typeof_System_Runtime_InteropServices_StructLayoutAttribute; + private Type typeof_System_Runtime_InteropServices_OptionalAttribute; + private Type typeof_System_Runtime_InteropServices_PreserveSigAttribute; + private Type typeof_System_Runtime_InteropServices_ComImportAttribute; + private Type typeof_System_Runtime_CompilerServices_DecimalConstantAttribute; + private Type typeof_System_Runtime_CompilerServices_SpecialNameAttribute; + private Type typeof_System_Runtime_CompilerServices_MethodImplAttribute; + private Type typeof_System_Security_SuppressUnmanagedCodeSecurityAttribute; + private Type typeof_System_Reflection_AssemblyCopyrightAttribute; + private Type typeof_System_Reflection_AssemblyTrademarkAttribute; + private Type typeof_System_Reflection_AssemblyProductAttribute; + private Type typeof_System_Reflection_AssemblyCompanyAttribute; + private Type typeof_System_Reflection_AssemblyDescriptionAttribute; + private Type typeof_System_Reflection_AssemblyTitleAttribute; + private Type typeof_System_Reflection_AssemblyInformationalVersionAttribute; + private Type typeof_System_Reflection_AssemblyFileVersionAttribute; + private Type typeof_System_Security_Permissions_CodeAccessSecurityAttribute; + private Type typeof_System_Security_Permissions_HostProtectionAttribute; + private Type typeof_System_Security_Permissions_PermissionSetAttribute; + private Type typeof_System_Security_Permissions_SecurityAction; + private List resolvers = new List(); + + internal Assembly Mscorlib + { + get { return Load("mscorlib"); } + } + + private Type ImportMscorlibType(System.Type type) + { + return Mscorlib.GetTypeImpl(type.FullName); + } + + internal Type System_Object + { + get { return typeof_System_Object ?? (typeof_System_Object = ImportMscorlibType(typeof(System.Object))); } + } + + internal Type System_ValueType + { + get { return typeof_System_ValueType ?? (typeof_System_ValueType = ImportMscorlibType(typeof(System.ValueType))); } + } + + internal Type System_Enum + { + get { return typeof_System_Enum ?? (typeof_System_Enum = ImportMscorlibType(typeof(System.Enum))); } + } + + internal Type System_Void + { + get { return typeof_System_Void ?? (typeof_System_Void = ImportMscorlibType(typeof(void))); } + } + + internal Type System_Boolean + { + get { return typeof_System_Boolean ?? (typeof_System_Boolean = ImportMscorlibType(typeof(System.Boolean))); } + } + + internal Type System_Char + { + get { return typeof_System_Char ?? (typeof_System_Char = ImportMscorlibType(typeof(System.Char))); } + } + + internal Type System_SByte + { + get { return typeof_System_SByte ?? (typeof_System_SByte = ImportMscorlibType(typeof(System.SByte))); } + } + + internal Type System_Byte + { + get { return typeof_System_Byte ?? (typeof_System_Byte = ImportMscorlibType(typeof(System.Byte))); } + } + + internal Type System_Int16 + { + get { return typeof_System_Int16 ?? (typeof_System_Int16 = ImportMscorlibType(typeof(System.Int16))); } + } + + internal Type System_UInt16 + { + get { return typeof_System_UInt16 ?? (typeof_System_UInt16 = ImportMscorlibType(typeof(System.UInt16))); } + } + + internal Type System_Int32 + { + get { return typeof_System_Int32 ?? (typeof_System_Int32 = ImportMscorlibType(typeof(System.Int32))); } + } + + internal Type System_UInt32 + { + get { return typeof_System_UInt32 ?? (typeof_System_UInt32 = ImportMscorlibType(typeof(System.UInt32))); } + } + + internal Type System_Int64 + { + get { return typeof_System_Int64 ?? (typeof_System_Int64 = ImportMscorlibType(typeof(System.Int64))); } + } + + internal Type System_UInt64 + { + get { return typeof_System_UInt64 ?? (typeof_System_UInt64 = ImportMscorlibType(typeof(System.UInt64))); } + } + + internal Type System_Single + { + get { return typeof_System_Single ?? (typeof_System_Single = ImportMscorlibType(typeof(System.Single))); } + } + + internal Type System_Double + { + get { return typeof_System_Double ?? (typeof_System_Double = ImportMscorlibType(typeof(System.Double))); } + } + + internal Type System_String + { + get { return typeof_System_String ?? (typeof_System_String = ImportMscorlibType(typeof(System.String))); } + } + + internal Type System_IntPtr + { + get { return typeof_System_IntPtr ?? (typeof_System_IntPtr = ImportMscorlibType(typeof(System.IntPtr))); } + } + + internal Type System_UIntPtr + { + get { return typeof_System_UIntPtr ?? (typeof_System_UIntPtr = ImportMscorlibType(typeof(System.UIntPtr))); } + } + + internal Type System_TypedReference + { + get { return typeof_System_TypedReference ?? (typeof_System_TypedReference = ImportMscorlibType(typeof(System.TypedReference))); } + } + + internal Type System_Type + { + get { return typeof_System_Type ?? (typeof_System_Type = ImportMscorlibType(typeof(System.Type))); } + } + + internal Type System_Array + { + get { return typeof_System_Array ?? (typeof_System_Array = ImportMscorlibType(typeof(System.Array))); } + } + + internal Type System_DateTime + { + get { return typeof_System_DateTime ?? (typeof_System_DateTime = ImportMscorlibType(typeof(System.DateTime))); } + } + + internal Type System_DBNull + { + get { return typeof_System_DBNull ?? (typeof_System_DBNull = ImportMscorlibType(typeof(System.DBNull))); } + } + + internal Type System_Decimal + { + get { return typeof_System_Decimal ?? (typeof_System_Decimal = ImportMscorlibType(typeof(System.Decimal))); } + } + + internal Type System_NonSerializedAttribute + { + get { return typeof_System_NonSerializedAttribute ?? (typeof_System_NonSerializedAttribute = ImportMscorlibType(typeof(System.NonSerializedAttribute))); } + } + + internal Type System_SerializableAttribute + { + get { return typeof_System_SerializableAttribute ?? (typeof_System_SerializableAttribute = ImportMscorlibType(typeof(System.SerializableAttribute))); } + } + + internal Type System_AttributeUsageAttribute + { + get { return typeof_System_AttributeUsageAttribute ?? (typeof_System_AttributeUsageAttribute = ImportMscorlibType(typeof(System.AttributeUsageAttribute))); } + } + + internal Type System_Reflection_AssemblyCultureAttribute + { + get { return typeof_System_Reflection_AssemblyCultureAttribute ?? (typeof_System_Reflection_AssemblyCultureAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyCultureAttribute))); } + } + + internal Type System_Runtime_InteropServices_DllImportAttribute + { + get { return typeof_System_Runtime_InteropServices_DllImportAttribute ?? (typeof_System_Runtime_InteropServices_DllImportAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.DllImportAttribute))); } + } + + internal Type System_Runtime_InteropServices_FieldOffsetAttribute + { + get { return typeof_System_Runtime_InteropServices_FieldOffsetAttribute ?? (typeof_System_Runtime_InteropServices_FieldOffsetAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.FieldOffsetAttribute))); } + } + + internal Type System_Runtime_InteropServices_InAttribute + { + get { return typeof_System_Runtime_InteropServices_InAttribute ?? (typeof_System_Runtime_InteropServices_InAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.InAttribute))); } + } + + internal Type System_Runtime_InteropServices_MarshalAsAttribute + { + get { return typeof_System_Runtime_InteropServices_MarshalAsAttribute ?? (typeof_System_Runtime_InteropServices_MarshalAsAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.MarshalAsAttribute))); } + } + + internal Type System_Runtime_InteropServices_UnmanagedType + { + get { return typeof_System_Runtime_InteropServices_UnmanagedType ?? (typeof_System_Runtime_InteropServices_UnmanagedType = ImportMscorlibType(typeof(System.Runtime.InteropServices.UnmanagedType))); } + } + + internal Type System_Runtime_InteropServices_VarEnum + { + get { return typeof_System_Runtime_InteropServices_VarEnum ?? (typeof_System_Runtime_InteropServices_VarEnum = ImportMscorlibType(typeof(System.Runtime.InteropServices.VarEnum))); } + } + + internal Type System_Runtime_InteropServices_OutAttribute + { + get { return typeof_System_Runtime_InteropServices_OutAttribute ?? (typeof_System_Runtime_InteropServices_OutAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.OutAttribute))); } + } + + internal Type System_Runtime_InteropServices_StructLayoutAttribute + { + get { return typeof_System_Runtime_InteropServices_StructLayoutAttribute ?? (typeof_System_Runtime_InteropServices_StructLayoutAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.StructLayoutAttribute))); } + } + + internal Type System_Runtime_InteropServices_OptionalAttribute + { + get { return typeof_System_Runtime_InteropServices_OptionalAttribute ?? (typeof_System_Runtime_InteropServices_OptionalAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.OptionalAttribute))); } + } + + internal Type System_Runtime_InteropServices_PreserveSigAttribute + { + get { return typeof_System_Runtime_InteropServices_PreserveSigAttribute ?? (typeof_System_Runtime_InteropServices_PreserveSigAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.PreserveSigAttribute))); } + } + + internal Type System_Runtime_InteropServices_ComImportAttribute + { + get { return typeof_System_Runtime_InteropServices_ComImportAttribute ?? (typeof_System_Runtime_InteropServices_ComImportAttribute = ImportMscorlibType(typeof(System.Runtime.InteropServices.ComImportAttribute))); } + } + + internal Type System_Runtime_CompilerServices_DecimalConstantAttribute + { + get { return typeof_System_Runtime_CompilerServices_DecimalConstantAttribute ?? (typeof_System_Runtime_CompilerServices_DecimalConstantAttribute = ImportMscorlibType(typeof(System.Runtime.CompilerServices.DecimalConstantAttribute))); } + } + + internal Type System_Runtime_CompilerServices_SpecialNameAttribute + { + get { return typeof_System_Runtime_CompilerServices_SpecialNameAttribute ?? (typeof_System_Runtime_CompilerServices_SpecialNameAttribute = ImportMscorlibType(typeof(System.Runtime.CompilerServices.SpecialNameAttribute))); } + } + + internal Type System_Runtime_CompilerServices_MethodImplAttribute + { + get { return typeof_System_Runtime_CompilerServices_MethodImplAttribute ?? (typeof_System_Runtime_CompilerServices_MethodImplAttribute = ImportMscorlibType(typeof(System.Runtime.CompilerServices.MethodImplAttribute))); } + } + + internal Type System_Security_SuppressUnmanagedCodeSecurityAttribute + { + get { return typeof_System_Security_SuppressUnmanagedCodeSecurityAttribute ?? (typeof_System_Security_SuppressUnmanagedCodeSecurityAttribute = ImportMscorlibType(typeof(System.Security.SuppressUnmanagedCodeSecurityAttribute))); } + } + + internal Type System_Reflection_AssemblyCopyrightAttribute + { + get { return typeof_System_Reflection_AssemblyCopyrightAttribute ?? (typeof_System_Reflection_AssemblyCopyrightAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyCopyrightAttribute))); } + } + + internal Type System_Reflection_AssemblyTrademarkAttribute + { + get { return typeof_System_Reflection_AssemblyTrademarkAttribute ?? (typeof_System_Reflection_AssemblyTrademarkAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyTrademarkAttribute))); } + } + + internal Type System_Reflection_AssemblyProductAttribute + { + get { return typeof_System_Reflection_AssemblyProductAttribute ?? (typeof_System_Reflection_AssemblyProductAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyProductAttribute))); } + } + + internal Type System_Reflection_AssemblyCompanyAttribute + { + get { return typeof_System_Reflection_AssemblyCompanyAttribute ?? (typeof_System_Reflection_AssemblyCompanyAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyCompanyAttribute))); } + } + + internal Type System_Reflection_AssemblyDescriptionAttribute + { + get { return typeof_System_Reflection_AssemblyDescriptionAttribute ?? (typeof_System_Reflection_AssemblyDescriptionAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyDescriptionAttribute))); } + } + + internal Type System_Reflection_AssemblyTitleAttribute + { + get { return typeof_System_Reflection_AssemblyTitleAttribute ?? (typeof_System_Reflection_AssemblyTitleAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyTitleAttribute))); } + } + + internal Type System_Reflection_AssemblyInformationalVersionAttribute + { + get { return typeof_System_Reflection_AssemblyInformationalVersionAttribute ?? (typeof_System_Reflection_AssemblyInformationalVersionAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyInformationalVersionAttribute))); } + } + + internal Type System_Reflection_AssemblyFileVersionAttribute + { + get { return typeof_System_Reflection_AssemblyFileVersionAttribute ?? (typeof_System_Reflection_AssemblyFileVersionAttribute = ImportMscorlibType(typeof(System.Reflection.AssemblyFileVersionAttribute))); } + } + + internal Type System_Security_Permissions_CodeAccessSecurityAttribute + { + get { return typeof_System_Security_Permissions_CodeAccessSecurityAttribute ?? (typeof_System_Security_Permissions_CodeAccessSecurityAttribute = ImportMscorlibType(typeof(System.Security.Permissions.CodeAccessSecurityAttribute))); } + } + + internal Type System_Security_Permissions_HostProtectionAttribute + { + get { return typeof_System_Security_Permissions_HostProtectionAttribute ?? (typeof_System_Security_Permissions_HostProtectionAttribute = ImportMscorlibType(typeof(System.Security.Permissions.HostProtectionAttribute))); } + } + + internal Type System_Security_Permissions_PermissionSetAttribute + { + get { return typeof_System_Security_Permissions_PermissionSetAttribute ?? (typeof_System_Security_Permissions_PermissionSetAttribute = ImportMscorlibType(typeof(System.Security.Permissions.PermissionSetAttribute))); } + } + + internal Type System_Security_Permissions_SecurityAction + { + get { return typeof_System_Security_Permissions_SecurityAction ?? (typeof_System_Security_Permissions_SecurityAction = ImportMscorlibType(typeof(System.Security.Permissions.SecurityAction))); } + } + + internal bool HasMscorlib + { + get { return GetLoadedAssembly("mscorlib") != null; } + } + + public event ResolveEventHandler AssemblyResolve + { + add { resolvers.Add(value); } + remove { resolvers.Remove(value); } + } + + public Type Import(System.Type type) + { + Type imported; + if (!importedTypes.TryGetValue(type, out imported)) + { + imported = ImportImpl(type); + if (imported != null) + { + importedTypes.Add(type, imported); + } + } + return imported; + } + + private Type ImportImpl(System.Type type) + { + if (type.Assembly == typeof(IKVM.Reflection.Type).Assembly) + { + throw new ArgumentException("Did you really want to import " + type.FullName + "?"); + } + if (type.HasElementType) + { + if (type.IsArray) + { + if (type.Name.EndsWith("[]")) + { + return Import(type.GetElementType()).MakeArrayType(); + } + else + { + return Import(type.GetElementType()).MakeArrayType(type.GetArrayRank()); + } + } + else if (type.IsByRef) + { + return Import(type.GetElementType()).MakeByRefType(); + } + else if (type.IsPointer) + { + return Import(type.GetElementType()).MakePointerType(); + } + else + { + throw new InvalidOperationException(); + } + } + else if (type.IsGenericParameter) + { + if (type.DeclaringMethod != null) + { + throw new NotImplementedException(); + } + else + { + return Import(type.DeclaringType).GetGenericArguments()[type.GenericParameterPosition]; + } + } + else if (type.IsGenericType && !type.IsGenericTypeDefinition) + { + System.Type[] args = type.GetGenericArguments(); + Type[] importedArgs = new Type[args.Length]; + for (int i = 0; i < args.Length; i++) + { + importedArgs[i] = Import(args[i]); + } + return Import(type.GetGenericTypeDefinition()).MakeGenericType(importedArgs); + } + else + { + return Import(type.Assembly).GetType(type.FullName); + } + } + + private Assembly Import(System.Reflection.Assembly asm) + { + return Load(asm.FullName); + } + + public RawModule OpenRawModule(string path) + { + path = Path.GetFullPath(path); + return OpenRawModule(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), path); + } + + public RawModule OpenRawModule(Stream stream, string location) + { + if (!stream.CanRead || !stream.CanSeek) + { + throw new NotSupportedException(); + } + return new RawModule(new ModuleReader(null, this, stream, location)); + } + + public Assembly LoadAssembly(RawModule module) + { + string refname = module.GetAssemblyName().FullName; + Assembly asm = GetLoadedAssembly(refname); + if (asm == null) + { + asm = module.ToAssembly(); + assemblies.Add(asm); + } + return asm; + } + + public Assembly LoadFile(string path) + { + try + { + using (RawModule module = OpenRawModule(path)) + { + return LoadAssembly(module); + } + } + catch (IOException x) + { + throw new FileNotFoundException(x.Message, x); + } + catch (UnauthorizedAccessException x) + { + throw new FileNotFoundException(x.Message, x); + } + } + + private Assembly GetLoadedAssembly(string refname) + { + Assembly asm; + if (!assembliesByName.TryGetValue(refname, out asm)) + { + for (int i = 0; i < assemblies.Count; i++) + { + AssemblyComparisonResult result; + // We won't allow FX unification here, because our own (non-Fusion) implementation of CompareAssemblyIdentity doesn't support it and + // we don't want to create a fundamental functional difference based on that. + if (CompareAssemblyIdentity(refname, false, assemblies[i].FullName, false, out result) && result != AssemblyComparisonResult.EquivalentFXUnified) + { + asm = assemblies[i]; + assembliesByName.Add(refname, asm); + break; + } + } + } + return asm; + } + + private Assembly GetDynamicAssembly(string refname) + { + foreach (AssemblyBuilder asm in dynamicAssemblies) + { + AssemblyComparisonResult result; + // We won't allow FX unification here, because our own (non-Fusion) implementation of CompareAssemblyIdentity doesn't support it and + // we don't want to create a fundamental functional difference based on that. + if (CompareAssemblyIdentity(refname, false, asm.FullName, false, out result) && result != AssemblyComparisonResult.EquivalentFXUnified) + { + return asm; + } + } + return null; + } + + public Assembly Load(string refname) + { + return Load(refname, null, true); + } + + internal Assembly Load(string refname, Assembly requestingAssembly, bool throwOnError) + { + Assembly asm = GetLoadedAssembly(refname); + if (asm != null) + { + return asm; + } + if (resolvers.Count == 0) + { + asm = DefaultResolver(refname, throwOnError); + } + else + { + ResolveEventArgs args = new ResolveEventArgs(refname, requestingAssembly); + foreach (ResolveEventHandler evt in resolvers) + { + asm = evt(this, args); + if (asm != null) + { + break; + } + } + if (asm == null) + { + asm = GetDynamicAssembly(refname); + } + } + if (asm != null) + { + string defname = asm.FullName; + if (refname != defname) + { + assembliesByName.Add(refname, asm); + } + return asm; + } + if (throwOnError) + { + throw new FileNotFoundException(refname); + } + return null; + } + + private Assembly DefaultResolver(string refname, bool throwOnError) + { + Assembly asm = GetDynamicAssembly(refname); + if (asm != null) + { + return asm; + } + string fileName; + if (throwOnError) + { + try + { + fileName = System.Reflection.Assembly.ReflectionOnlyLoad(refname).Location; + } + catch (System.BadImageFormatException x) + { + throw new BadImageFormatException(x.Message, x); + } + } + else + { + try + { + fileName = System.Reflection.Assembly.ReflectionOnlyLoad(refname).Location; + } + catch (System.BadImageFormatException x) + { + throw new BadImageFormatException(x.Message, x); + } + catch (FileNotFoundException) + { + // we intentionally only swallow the FileNotFoundException, if the file exists but isn't a valid assembly, + // we should throw an exception + return null; + } + } + return LoadFile(fileName); + } + + public Type GetType(string assemblyQualifiedTypeName) + { + // to be more compatible with Type.GetType(), we could call Assembly.GetCallingAssembly(), + // import that assembly and pass it as the context, but implicitly importing is considered evil + return GetType(null, assemblyQualifiedTypeName, false); + } + + public Type GetType(string assemblyQualifiedTypeName, bool throwOnError) + { + // to be more compatible with Type.GetType(), we could call Assembly.GetCallingAssembly(), + // import that assembly and pass it as the context, but implicitly importing is considered evil + return GetType(null, assemblyQualifiedTypeName, throwOnError); + } + + // note that context is slightly different from the calling assembly (System.Type.GetType), + // because context is passed to the AssemblyResolve event as the RequestingAssembly + public Type GetType(Assembly context, string assemblyQualifiedTypeName, bool throwOnError) + { + TypeNameParser parser = TypeNameParser.Parse(assemblyQualifiedTypeName, throwOnError); + if (parser.Error) + { + return null; + } + return parser.GetType(this, context, throwOnError, assemblyQualifiedTypeName); + } + + public Assembly[] GetAssemblies() + { + Assembly[] array = new Assembly[assemblies.Count + dynamicAssemblies.Count]; + assemblies.CopyTo(array); + for (int i = 0, j = assemblies.Count; j < array.Length; i++, j++) + { + array[j] = dynamicAssemblies[i]; + } + return array; + } + + // this is equivalent to the Fusion CompareAssemblyIdentity API + public bool CompareAssemblyIdentity(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result) + { + return Fusion.CompareAssemblyIdentity(assemblyIdentity1, unified1, assemblyIdentity2, unified2, out result); + } + + public AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) + { + return DefineDynamicAssemblyImpl(name, access, null, null, null, null); + } + + public AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir) + { + return DefineDynamicAssemblyImpl(name, access, dir, null, null, null); + } + +#if NET_4_0 + [Obsolete] +#endif + public AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions) + { + return DefineDynamicAssemblyImpl(name, access, dir, requiredPermissions, optionalPermissions, refusedPermissions); + } + + private AssemblyBuilder DefineDynamicAssemblyImpl(AssemblyName name, AssemblyBuilderAccess access, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions) + { + AssemblyBuilder asm = new AssemblyBuilder(this, name, dir, requiredPermissions, optionalPermissions, refusedPermissions); + dynamicAssemblies.Add(asm); + return asm; + } + + internal void RenameAssembly(Assembly assembly, AssemblyName oldName) + { + List remove = new List(); + foreach (KeyValuePair kv in assembliesByName) + { + if (kv.Value == assembly) + { + remove.Add(kv.Key); + } + } + foreach (string key in remove) + { + assembliesByName.Remove(key); + } + } + + public void Dispose() + { + foreach (Assembly asm in assemblies) + { + foreach (Module mod in asm.GetLoadedModules()) + { + mod.Dispose(); + } + } + foreach (AssemblyBuilder asm in dynamicAssemblies) + { + foreach (Module mod in asm.GetLoadedModules()) + { + mod.Dispose(); + } + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Util.cs b/mcs/class/IKVM.Reflection/Util.cs new file mode 100644 index 000000000000..a471eedd705d --- /dev/null +++ b/mcs/class/IKVM.Reflection/Util.cs @@ -0,0 +1,268 @@ +/* + Copyright (C) 2008-2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace IKVM.Reflection +{ + public interface ICustomAttributeProvider + { + bool IsDefined(Type attributeType, bool inherit); + IList __GetCustomAttributes(Type attributeType, bool inherit); + } + + [Serializable] + public sealed class FileFormatLimitationExceededException : InvalidOperationException + { + public const int META_E_STRINGSPACE_FULL = unchecked((int)0x80131198); + + public FileFormatLimitationExceededException(string message, int hresult) + : base(message) + { + this.HResult = hresult; + } + + private FileFormatLimitationExceededException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) + : base(info, context) + { + } + + public int ErrorCode + { + get { return this.HResult; } + } + } + + [Serializable] + public sealed class Missing : ISerializable + { + public static readonly Missing Value = new Missing(); + + private Missing() { } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + info.SetType(typeof(SingletonSerializationHelper)); + } + + [Serializable] + private sealed class SingletonSerializationHelper : IObjectReference + { + public object GetRealObject(StreamingContext context) + { + return Value; + } + } + } + + static class Empty + { + internal static readonly T[] Array = new T[0]; + } + + static class Util + { + internal static Type[] Copy(Type[] array) + { + if (array == null || array.Length == 0) + { + return Type.EmptyTypes; + } + Type[] copy = new Type[array.Length]; + Array.Copy(array, copy, array.Length); + return copy; + } + + internal static Type[][] Copy(Type[][] types) + { + if (types == null || types.Length == 0) + { + return types; + } + Type[][] newArray = new Type[types.Length][]; + for (int i = 0; i < newArray.Length; i++) + { + newArray[i] = Copy(types[i]); + } + return newArray; + } + + internal static T[] ToArray(List list, T[] empty) where V : T + { + if (list == null || list.Count == 0) + { + return empty; + } + T[] array = new T[list.Count]; + for (int i = 0; i < array.Length; i++) + { + array[i] = list[i]; + } + return array; + } + + // note that an empty array matches a null reference + internal static bool ArrayEquals(Type[] t1, Type[] t2) + { + if (t1 == t2) + { + return true; + } + if (t1 == null) + { + return t2.Length == 0; + } + else if (t2 == null) + { + return t1.Length == 0; + } + if (t1.Length == t2.Length) + { + for (int i = 0; i < t1.Length; i++) + { + if (!TypeEquals(t1[i], t2[i])) + { + return false; + } + } + return true; + } + return false; + } + + internal static bool ArrayEquals(Type[][] t1, Type[][] t2) + { + if (t1 == t2) + { + return true; + } + if (t1 == null) + { + return t2.Length == 0; + } + else if (t2 == null) + { + return t1.Length == 0; + } + if (t1.Length == t2.Length) + { + for (int i = 0; i < t1.Length; i++) + { + if (!ArrayEquals(t1[i], t2[i])) + { + return false; + } + } + return true; + } + return false; + } + + internal static bool ArrayEquals(Type[][][] t1, Type[][][] t2) + { + if (t1 == t2) + { + return true; + } + if (t1 == null) + { + return t2.Length == 0; + } + else if (t2 == null) + { + return t1.Length == 0; + } + if (t1.Length == t2.Length) + { + for (int i = 0; i < t1.Length; i++) + { + if (!ArrayEquals(t1[i], t2[i])) + { + return false; + } + } + return true; + } + return false; + } + + internal static bool TypeEquals(Type t1, Type t2) + { + if (t1 == t2) + { + return true; + } + if (t1 == null) + { + return false; + } + return t1.Equals(t2); + } + + internal static int GetHashCode(Type[] types) + { + if (types == null) + { + return 0; + } + int h = 0; + foreach (Type t in types) + { + if (t != null) + { + h *= 3; + h ^= t.GetHashCode(); + } + } + return h; + } + + internal static int GetHashCode(Type[][] types) + { + int h = 0; + if (types != null) + { + foreach (Type[] array in types) + { + h ^= GetHashCode(array); + } + } + return h; + } + + internal static int GetHashCode(Type[][][] types) + { + int h = 0; + if (types != null) + { + foreach (Type[][] array in types) + { + h ^= GetHashCode(array); + } + } + return h; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/ByteBuffer.cs b/mcs/class/IKVM.Reflection/Writer/ByteBuffer.cs new file mode 100644 index 000000000000..6b06a7d3b832 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/ByteBuffer.cs @@ -0,0 +1,311 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Writer +{ + sealed class ByteBuffer + { + private byte[] buffer; + private int pos; + private int __length; // __length is only valid if > pos, otherwise pos is the current length + + internal ByteBuffer(int initialCapacity) + { + buffer = new byte[initialCapacity]; + } + + private ByteBuffer(byte[] wrap, int length) + { + this.buffer = wrap; + this.pos = length; + } + + internal int Position + { + get { return pos; } + set + { + if (value > this.Length || value > buffer.Length) + throw new ArgumentOutOfRangeException(); + __length = Math.Max(__length, pos); + pos = value; + } + } + + internal int Length + { + get { return Math.Max(pos, __length); } + } + + private void Grow(int minGrow) + { + byte[] newbuf = new byte[Math.Max(buffer.Length + minGrow, buffer.Length * 2)]; + Buffer.BlockCopy(buffer, 0, newbuf, 0, buffer.Length); + buffer = newbuf; + } + + // NOTE this does not advance the position + internal int GetInt32AtCurrentPosition() + { + return buffer[pos] + + (buffer[pos + 1] << 8) + + (buffer[pos + 2] << 16) + + (buffer[pos + 3] << 24); + } + + // NOTE this does not advance the position + internal byte GetByteAtCurrentPosition() + { + return buffer[pos]; + } + + internal void Write(byte[] value) + { + if (pos + value.Length > buffer.Length) + Grow(value.Length); + Buffer.BlockCopy(value, 0, buffer, pos, value.Length); + pos += value.Length; + } + + internal void Write(byte value) + { + if (pos == buffer.Length) + Grow(1); + buffer[pos++] = value; + } + + internal void Write(sbyte value) + { + Write((byte)value); + } + + internal void Write(ushort value) + { + Write((short)value); + } + + internal void Write(short value) + { + if (pos + 2 > buffer.Length) + Grow(2); + buffer[pos++] = (byte)value; + buffer[pos++] = (byte)(value >> 8); + } + + internal void Write(uint value) + { + Write((int)value); + } + + internal void Write(int value) + { + if (pos + 4 > buffer.Length) + Grow(4); + buffer[pos++] = (byte)value; + buffer[pos++] = (byte)(value >> 8); + buffer[pos++] = (byte)(value >> 16); + buffer[pos++] = (byte)(value >> 24); + } + + internal void Write(ulong value) + { + Write((long)value); + } + + internal void Write(long value) + { + if (pos + 8 > buffer.Length) + Grow(8); + buffer[pos++] = (byte)value; + buffer[pos++] = (byte)(value >> 8); + buffer[pos++] = (byte)(value >> 16); + buffer[pos++] = (byte)(value >> 24); + buffer[pos++] = (byte)(value >> 32); + buffer[pos++] = (byte)(value >> 40); + buffer[pos++] = (byte)(value >> 48); + buffer[pos++] = (byte)(value >> 56); + } + + internal void Write(float value) + { + Write(BitConverter.GetBytes(value)); + } + + internal void Write(double value) + { + Write(BitConverter.DoubleToInt64Bits(value)); + } + + internal void Write(string str) + { + if (str == null) + { + Write((byte)0xFF); + } + else + { + byte[] buf = Encoding.UTF8.GetBytes(str); + WriteCompressedInt(buf.Length); + Write(buf); + } + } + + internal void WriteCompressedInt(int value) + { + if (value <= 0x7F) + { + Write((byte)value); + } + else if (value <= 0x3FFF) + { + Write((byte)(0x80 | (value >> 8))); + Write((byte)value); + } + else + { + Write((byte)(0xC0 | (value >> 24))); + Write((byte)(value >> 16)); + Write((byte)(value >> 8)); + Write((byte)value); + } + } + + internal void Write(ByteBuffer bb) + { + if (pos + bb.Length > buffer.Length) + Grow(bb.Length); + Buffer.BlockCopy(bb.buffer, 0, buffer, pos, bb.Length); + pos += bb.Length; + } + + internal void WriteTo(System.IO.Stream stream) + { + stream.Write(buffer, 0, this.Length); + } + + internal void Clear() + { + pos = 0; + __length = 0; + } + + internal void Align(int alignment) + { + if (pos + alignment > buffer.Length) + Grow(alignment); + int newpos = (pos + alignment - 1) & ~(alignment - 1); + while (pos < newpos) + buffer[pos++] = 0; + } + + internal void WriteTypeDefOrRefEncoded(int token) + { + switch (token >> 24) + { + case TypeDefTable.Index: + WriteCompressedInt((token & 0xFFFFFF) << 2 | 0); + break; + case TypeRefTable.Index: + WriteCompressedInt((token & 0xFFFFFF) << 2 | 1); + break; + case TypeSpecTable.Index: + WriteCompressedInt((token & 0xFFFFFF) << 2 | 2); + break; + default: + throw new InvalidOperationException(); + } + } + + internal void Write(System.IO.Stream stream) + { + const int chunkSize = 8192; + for (; ; ) + { + if (pos + chunkSize > buffer.Length) + Grow(chunkSize); + int read = stream.Read(buffer, pos, chunkSize); + if (read <= 0) + { + break; + } + pos += read; + } + } + + internal byte[] ToArray() + { + byte[] buf = new byte[pos]; + Buffer.BlockCopy(buffer, 0, buf, 0, pos); + return buf; + } + + internal static ByteBuffer Wrap(byte[] buf) + { + return new ByteBuffer(buf, buf.Length); + } + + internal static ByteBuffer Wrap(byte[] buf, int length) + { + return new ByteBuffer(buf, length); + } + + internal bool Match(int pos, ByteBuffer bb2, int pos2, int len) + { + for (int i = 0; i < len; i++) + { + if (buffer[pos + i] != bb2.buffer[pos2 + i]) + { + return false; + } + } + return true; + } + + internal int Hash() + { + int hash = 0; + int len = this.Length; + for (int i = 0; i < len; i++) + { + hash *= 37; + hash ^= buffer[i]; + } + return hash; + } + + internal IKVM.Reflection.Reader.ByteReader GetBlob(int offset) + { + return IKVM.Reflection.Reader.ByteReader.FromBlob(buffer, offset); + } + + internal void Patch(int offset, byte b) + { + buffer[offset] = b; + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/Heaps.cs b/mcs/class/IKVM.Reflection/Writer/Heaps.cs new file mode 100644 index 000000000000..b8764d29a488 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/Heaps.cs @@ -0,0 +1,382 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Writer +{ + abstract class Heap + { + protected bool frozen; + protected int unalignedlength; + + internal void Write(MetadataWriter mw) + { + int pos = mw.Position; + WriteImpl(mw); + Debug.Assert(mw.Position == pos + unalignedlength); + int align = Length - unalignedlength; + for (int i = 0; i < align; i++) + { + mw.Write((byte)0); + } + } + + internal bool IsBig + { + get { return Length > 65535; } + } + + internal int Length + { + get + { + if (!frozen) + throw new InvalidOperationException(); + return (unalignedlength + 3) & ~3; + } + } + + protected abstract void WriteImpl(MetadataWriter mw); + } + + abstract class SimpleHeap : Heap + { + internal void Freeze() + { + if (frozen) + throw new InvalidOperationException(); + frozen = true; + unalignedlength = GetLength(); + } + + protected abstract int GetLength(); + } + + sealed class TableHeap : Heap + { + internal void Freeze(MetadataWriter mw) + { + if (frozen) + throw new InvalidOperationException(); + frozen = true; + unalignedlength = GetLength(mw); + } + + protected override void WriteImpl(MetadataWriter mw) + { + Table[] tables = mw.ModuleBuilder.GetTables(); + // Header + mw.Write(0); // Reserved + int ver = mw.ModuleBuilder.MDStreamVersion; + mw.Write((byte)(ver >> 16)); // MajorVersion + mw.Write((byte)ver); // MinorVersion + byte heapSizes = 0; + if (mw.ModuleBuilder.Strings.IsBig) + { + heapSizes |= 0x01; + } + if (mw.ModuleBuilder.Guids.IsBig) + { + heapSizes |= 0x02; + } + if (mw.ModuleBuilder.Blobs.IsBig) + { + heapSizes |= 0x04; + } + mw.Write(heapSizes);// HeapSizes + // LAMESPEC spec says reserved, but .NET 2.0 Ref.Emit sets it to 0x10 + mw.Write((byte)0x10); // Reserved + long bit = 1; + long valid = 0; + foreach (Table table in tables) + { + if (table != null && table.RowCount > 0) + { + valid |= bit; + } + bit <<= 1; + } + mw.Write(valid); // Valid + mw.Write(0x0016003301FA00L); // Sorted + // Rows + foreach (Table table in tables) + { + if (table != null && table.RowCount > 0) + { + mw.Write(table.RowCount); + } + } + // Tables + foreach (Table table in tables) + { + if (table != null && table.RowCount > 0) + { + int pos = mw.Position; + table.Write(mw); + Debug.Assert(mw.Position - pos == table.GetLength(mw)); + } + } + // unexplained extra padding + mw.Write((byte)0); + } + + private int GetLength(MetadataWriter mw) + { + int len = 4 + 4 + 8 + 8; + foreach (Table table in mw.ModuleBuilder.GetTables()) + { + if (table != null && table.RowCount > 0) + { + len += 4; // row count + len += table.GetLength(mw); + } + } + // note that we pad one extra (unexplained) byte + return len + 1; + } + } + + sealed class StringHeap : SimpleHeap + { + private List list = new List(); + private Dictionary strings = new Dictionary(); + private int nextOffset; + + internal StringHeap() + { + Add(""); + } + + internal int Add(string str) + { + Debug.Assert(!frozen); + int offset; + if (!strings.TryGetValue(str, out offset)) + { + offset = nextOffset; + nextOffset += System.Text.Encoding.UTF8.GetByteCount(str) + 1; + list.Add(str); + strings.Add(str, offset); + } + return offset; + } + + protected override int GetLength() + { + return nextOffset; + } + + protected override void WriteImpl(MetadataWriter mw) + { + foreach (string str in list) + { + mw.Write(System.Text.Encoding.UTF8.GetBytes(str)); + mw.Write((byte)0); + } + } + } + + sealed class UserStringHeap : SimpleHeap + { + private List list = new List(); + private Dictionary strings = new Dictionary(); + private int nextOffset; + + internal UserStringHeap() + { + nextOffset = 1; + } + + internal bool IsEmpty + { + get { return nextOffset == 1; } + } + + internal int Add(string str) + { + Debug.Assert(!frozen); + int offset; + if (!strings.TryGetValue(str, out offset)) + { + int length = str.Length * 2 + 1 + MetadataWriter.GetCompressedIntLength(str.Length * 2 + 1); + if (nextOffset + length > 0xFFFFFF) + { + throw new FileFormatLimitationExceededException("No logical space left to create more user strings.", FileFormatLimitationExceededException.META_E_STRINGSPACE_FULL); + } + offset = nextOffset; + nextOffset += length; + list.Add(str); + strings.Add(str, offset); + } + return offset; + } + + protected override int GetLength() + { + return nextOffset; + } + + protected override void WriteImpl(MetadataWriter mw) + { + mw.Write((byte)0); + foreach (string str in list) + { + mw.WriteCompressedInt(str.Length * 2 + 1); + byte hasSpecialChars = 0; + foreach (char ch in str) + { + mw.Write((ushort)ch); + if (hasSpecialChars == 0 && (ch < 0x20 || ch > 0x7E)) + { + if (ch > 0x7E + || (ch >= 0x01 && ch <= 0x08) + || (ch >= 0x0E && ch <= 0x1F) + || ch == 0x27 + || ch == 0x2D) + { + hasSpecialChars = 1; + } + } + } + mw.Write(hasSpecialChars); + } + } + } + + sealed class GuidHeap : SimpleHeap + { + private List list = new List(); + + internal GuidHeap() + { + } + + internal int Add(Guid guid) + { + Debug.Assert(!frozen); + list.Add(guid); + return list.Count; + } + + protected override int GetLength() + { + return list.Count * 16; + } + + protected override void WriteImpl(MetadataWriter mw) + { + foreach (Guid guid in list) + { + mw.Write(guid.ToByteArray()); + } + } + } + + sealed class BlobHeap : SimpleHeap + { + private Key[] map = new Key[8179]; + private readonly ByteBuffer buf = new ByteBuffer(32); + + private struct Key + { + internal Key[] next; + internal int len; + internal int hash; + internal int offset; + } + + internal BlobHeap() + { + buf.Write((byte)0); + } + + internal int Add(ByteBuffer bb) + { + Debug.Assert(!frozen); + if (bb.Length == 0) + { + return 0; + } + int lenlen = MetadataWriter.GetCompressedIntLength(bb.Length); + int hash = bb.Hash(); + int index = (hash & 0x7FFFFFFF) % map.Length; + Key[] keys = map; + int last = index; + while (keys[index].offset != 0) + { + if (keys[index].hash == hash + && keys[index].len == bb.Length + && buf.Match(keys[index].offset + lenlen, bb, 0, bb.Length)) + { + return keys[index].offset; + } + if (index == last) + { + if (keys[index].next == null) + { + keys[index].next = new Key[4]; + keys = keys[index].next; + index = 0; + break; + } + keys = keys[index].next; + index = -1; + last = keys.Length - 1; + } + index++; + } + int offset = buf.Position; + buf.WriteCompressedInt(bb.Length); + buf.Write(bb); + keys[index].len = bb.Length; + keys[index].hash = hash; + keys[index].offset = offset; + return offset; + } + + protected override int GetLength() + { + return buf.Position; + } + + protected override void WriteImpl(MetadataWriter mw) + { + mw.Write(buf); + } + + internal bool IsEmpty + { + get { return buf.Position == 1; } + } + + internal IKVM.Reflection.Reader.ByteReader GetBlob(int blobIndex) + { + return buf.GetBlob(blobIndex); + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/MetadataWriter.cs b/mcs/class/IKVM.Reflection/Writer/MetadataWriter.cs new file mode 100644 index 000000000000..1f17b3815ec2 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/MetadataWriter.cs @@ -0,0 +1,565 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Writer +{ + sealed class MetadataWriter : MetadataRW + { + private readonly ModuleBuilder moduleBuilder; + private readonly Stream stream; + private readonly byte[] buffer = new byte[8]; + + internal MetadataWriter(ModuleBuilder module, Stream stream) + : base(module, module.Strings.IsBig, module.Guids.IsBig, module.Blobs.IsBig) + { + this.moduleBuilder = module; + this.stream = stream; + } + + internal ModuleBuilder ModuleBuilder + { + get { return moduleBuilder; } + } + + internal int Position + { + get { return (int)stream.Position; } + } + + internal void Write(ByteBuffer bb) + { + bb.WriteTo(stream); + } + + internal void Write(byte[] value) + { + stream.Write(value, 0, value.Length); + } + + internal void Write(byte value) + { + stream.WriteByte(value); + } + + internal void Write(ushort value) + { + Write((short)value); + } + + internal void Write(short value) + { + buffer[0] = (byte)value; + buffer[1] = (byte)(value >> 8); + stream.Write(buffer, 0, 2); + } + + internal void Write(uint value) + { + Write((int)value); + } + + internal void Write(int value) + { + buffer[0] = (byte)value; + buffer[1] = (byte)(value >> 8); + buffer[2] = (byte)(value >> 16); + buffer[3] = (byte)(value >> 24); + stream.Write(buffer, 0, 4); + } + + internal void Write(ulong value) + { + Write((long)value); + } + + internal void Write(long value) + { + buffer[0] = (byte)value; + buffer[1] = (byte)(value >> 8); + buffer[2] = (byte)(value >> 16); + buffer[3] = (byte)(value >> 24); + buffer[4] = (byte)(value >> 32); + buffer[5] = (byte)(value >> 40); + buffer[6] = (byte)(value >> 48); + buffer[7] = (byte)(value >> 56); + stream.Write(buffer, 0, 8); + } + + internal void WriteCompressedInt(int value) + { + if (value <= 0x7F) + { + Write((byte)value); + } + else if (value <= 0x3FFF) + { + Write((byte)(0x80 | (value >> 8))); + Write((byte)value); + } + else + { + Write((byte)(0xC0 | (value >> 24))); + Write((byte)(value >> 16)); + Write((byte)(value >> 8)); + Write((byte)value); + } + } + + internal static int GetCompressedIntLength(int value) + { + if (value <= 0x7F) + { + return 1; + } + else if (value <= 0x3FFF) + { + return 2; + } + else + { + return 4; + } + } + + internal void WriteStringIndex(int index) + { + if (bigStrings) + { + Write(index); + } + else + { + Write((short)index); + } + } + + internal void WriteGuidIndex(int index) + { + if (bigGuids) + { + Write(index); + } + else + { + Write((short)index); + } + } + + internal void WriteBlobIndex(int index) + { + if (bigBlobs) + { + Write(index); + } + else + { + Write((short)index); + } + } + + internal void WriteTypeDefOrRef(int token) + { + switch (token >> 24) + { + case 0: + break; + case TypeDefTable.Index: + token = (token & 0xFFFFFF) << 2 | 0; + break; + case TypeRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 1; + break; + case TypeSpecTable.Index: + token = (token & 0xFFFFFF) << 2 | 2; + break; + default: + throw new InvalidOperationException(); + } + if (bigTypeDefOrRef) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteEncodedTypeDefOrRef(int encodedToken) + { + if (bigTypeDefOrRef) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteHasCustomAttribute(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigHasCustomAttribute) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteCustomAttributeType(int token) + { + switch (token >> 24) + { + case MethodDefTable.Index: + token = (token & 0xFFFFFF) << 3 | 2; + break; + case MemberRefTable.Index: + token = (token & 0xFFFFFF) << 3 | 3; + break; + default: + throw new InvalidOperationException(); + } + if (bigCustomAttributeType) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteField(int index) + { + if (bigField) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteMethodDef(int index) + { + if (bigMethodDef) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteParam(int index) + { + if (bigParam) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteTypeDef(int index) + { + if (bigTypeDef) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteEvent(int index) + { + if (bigEvent) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteProperty(int index) + { + if (bigProperty) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteGenericParam(int index) + { + if (bigGenericParam) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteModuleRef(int index) + { + if (bigModuleRef) + { + Write(index & 0xFFFFFF); + } + else + { + Write((short)index); + } + } + + internal void WriteResolutionScope(int token) + { + switch (token >> 24) + { + case ModuleTable.Index: + token = (token & 0xFFFFFF) << 2 | 0; + break; + case ModuleRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 1; + break; + case AssemblyRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 2; + break; + case TypeRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 3; + break; + default: + throw new InvalidOperationException(); + } + if (bigResolutionScope) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteMemberRefParent(int token) + { + switch (token >> 24) + { + case TypeDefTable.Index: + token = (token & 0xFFFFFF) << 3 | 0; + break; + case TypeRefTable.Index: + token = (token & 0xFFFFFF) << 3 | 1; + break; + case ModuleRefTable.Index: + token = (token & 0xFFFFFF) << 3 | 2; + break; + case MethodDefTable.Index: + token = (token & 0xFFFFFF) << 3 | 3; + break; + case TypeSpecTable.Index: + token = (token & 0xFFFFFF) << 3 | 4; + break; + default: + throw new InvalidOperationException(); + } + if (bigMemberRefParent) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteMethodDefOrRef(int token) + { + switch (token >> 24) + { + case MethodDefTable.Index: + token = (token & 0xFFFFFF) << 1 | 0; + break; + case MemberRefTable.Index: + token = (token & 0xFFFFFF) << 1 | 1; + break; + default: + throw new InvalidOperationException(); + } + if (bigMethodDefOrRef) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteHasConstant(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigHasConstant) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteHasSemantics(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigHasSemantics) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteImplementation(int token) + { + switch (token >> 24) + { + case 0: + break; + case FileTable.Index: + token = (token & 0xFFFFFF) << 2 | 0; + break; + case AssemblyRefTable.Index: + token = (token & 0xFFFFFF) << 2 | 1; + break; + case ExportedTypeTable.Index: + token = (token & 0xFFFFFF) << 2 | 2; + break; + default: + throw new InvalidOperationException(); + } + if (bigImplementation) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteTypeOrMethodDef(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigTypeOrMethodDef) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteHasDeclSecurity(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigHasDeclSecurity) + { + Write(encodedToken); + } + else + { + Write((short)encodedToken); + } + } + + internal void WriteMemberForwarded(int token) + { + switch (token >> 24) + { + case FieldTable.Index: + token = (token & 0xFFFFFF) << 1 | 0; + break; + case MethodDefTable.Index: + token = (token & 0xFFFFFF) << 1 | 1; + break; + default: + throw new InvalidOperationException(); + } + if (bigMemberForwarded) + { + Write(token); + } + else + { + Write((short)token); + } + } + + internal void WriteHasFieldMarshal(int encodedToken) + { + // NOTE because we've already had to do the encoding (to be able to sort the table) + // here we simple write the value + if (bigHasFieldMarshal) + { + Write(encodedToken & 0xFFFFFF); + } + else + { + Write((short)encodedToken); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/ModuleWriter.cs b/mcs/class/IKVM.Reflection/Writer/ModuleWriter.cs new file mode 100644 index 000000000000..c4208f8fb163 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/ModuleWriter.cs @@ -0,0 +1,382 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Security.Cryptography; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Impl; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Writer +{ + static class ModuleWriter + { + internal static void WriteModule(StrongNameKeyPair keyPair, byte[] publicKey, ModuleBuilder moduleBuilder, + PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine, + ResourceSection resources, int entryPointToken) + { + moduleBuilder.FixupMethodBodyTokens(); + + moduleBuilder.ModuleTable.Add(0, moduleBuilder.Strings.Add(moduleBuilder.moduleName), moduleBuilder.Guids.Add(moduleBuilder.ModuleVersionId), 0, 0); + + if (moduleBuilder.UserStrings.IsEmpty) + { + // for compat with Ref.Emit, if there aren't any user strings, we add one + moduleBuilder.UserStrings.Add(" "); + } + + if (resources != null) + { + resources.Finish(); + } + + using (FileStream fs = new FileStream(moduleBuilder.FullyQualifiedName, FileMode.Create)) + { + PEWriter writer = new PEWriter(fs); + switch (imageFileMachine) + { + case ImageFileMachine.I386: + writer.Headers.FileHeader.Machine = IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386; + writer.Headers.FileHeader.Characteristics |= IMAGE_FILE_HEADER.IMAGE_FILE_32BIT_MACHINE; + break; + case ImageFileMachine.AMD64: + writer.Headers.FileHeader.Machine = IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_AMD64; + writer.Headers.FileHeader.Characteristics |= IMAGE_FILE_HEADER.IMAGE_FILE_LARGE_ADDRESS_AWARE; + writer.Headers.FileHeader.SizeOfOptionalHeader = 0xF0; + writer.Headers.OptionalHeader.Magic = IMAGE_OPTIONAL_HEADER.IMAGE_NT_OPTIONAL_HDR64_MAGIC; + writer.Headers.OptionalHeader.SizeOfStackReserve = 0x400000; + writer.Headers.OptionalHeader.SizeOfStackCommit = 0x4000; + writer.Headers.OptionalHeader.SizeOfHeapCommit = 0x2000; + break; + case ImageFileMachine.IA64: + writer.Headers.FileHeader.Machine = IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_IA64; + writer.Headers.FileHeader.Characteristics |= IMAGE_FILE_HEADER.IMAGE_FILE_LARGE_ADDRESS_AWARE; + writer.Headers.FileHeader.SizeOfOptionalHeader = 0xF0; + writer.Headers.OptionalHeader.Magic = IMAGE_OPTIONAL_HEADER.IMAGE_NT_OPTIONAL_HDR64_MAGIC; + writer.Headers.OptionalHeader.SizeOfStackReserve = 0x400000; + writer.Headers.OptionalHeader.SizeOfStackCommit = 0x4000; + writer.Headers.OptionalHeader.SizeOfHeapCommit = 0x2000; + break; + default: + throw new ArgumentOutOfRangeException("imageFileMachine"); + } + if (fileKind == PEFileKinds.Dll) + { + writer.Headers.FileHeader.Characteristics |= IMAGE_FILE_HEADER.IMAGE_FILE_DLL; + } + + switch (fileKind) + { + case PEFileKinds.WindowApplication: + writer.Headers.OptionalHeader.Subsystem = IMAGE_OPTIONAL_HEADER.IMAGE_SUBSYSTEM_WINDOWS_GUI; + break; + default: + writer.Headers.OptionalHeader.Subsystem = IMAGE_OPTIONAL_HEADER.IMAGE_SUBSYSTEM_WINDOWS_CUI; + break; + } + writer.Headers.OptionalHeader.DllCharacteristics = + IMAGE_OPTIONAL_HEADER.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE | + IMAGE_OPTIONAL_HEADER.IMAGE_DLLCHARACTERISTICS_NO_SEH | + IMAGE_OPTIONAL_HEADER.IMAGE_DLLCHARACTERISTICS_NX_COMPAT | + IMAGE_OPTIONAL_HEADER.IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE; + + CliHeader cliHeader = new CliHeader(); + cliHeader.Cb = 0x48; + cliHeader.MajorRuntimeVersion = 2; + cliHeader.MinorRuntimeVersion = moduleBuilder.MDStreamVersion < 0x20000 ? (ushort)0 : (ushort)5; + if ((portableExecutableKind & PortableExecutableKinds.ILOnly) != 0) + { + cliHeader.Flags |= CliHeader.COMIMAGE_FLAGS_ILONLY; + } + if ((portableExecutableKind & PortableExecutableKinds.Required32Bit) != 0) + { + cliHeader.Flags |= CliHeader.COMIMAGE_FLAGS_32BITREQUIRED; + } + if (keyPair != null) + { + cliHeader.Flags |= CliHeader.COMIMAGE_FLAGS_STRONGNAMESIGNED; + } + if (moduleBuilder.IsPseudoToken(entryPointToken)) + { + entryPointToken = moduleBuilder.ResolvePseudoToken(entryPointToken); + } + cliHeader.EntryPointToken = (uint)entryPointToken; + + moduleBuilder.Strings.Freeze(); + moduleBuilder.UserStrings.Freeze(); + moduleBuilder.Guids.Freeze(); + moduleBuilder.Blobs.Freeze(); + MetadataWriter mw = new MetadataWriter(moduleBuilder, fs); + moduleBuilder.Tables.Freeze(mw); + TextSection code = new TextSection(writer, cliHeader, moduleBuilder, ComputeStrongNameSignatureLength(publicKey)); + + // Import Directory + writer.Headers.OptionalHeader.DataDirectory[1].VirtualAddress = code.ImportDirectoryRVA; + writer.Headers.OptionalHeader.DataDirectory[1].Size = code.ImportDirectoryLength; + + // Import Address Table Directory + writer.Headers.OptionalHeader.DataDirectory[12].VirtualAddress = code.ImportAddressTableRVA; + writer.Headers.OptionalHeader.DataDirectory[12].Size = code.ImportAddressTableLength; + + // COM Descriptor Directory + writer.Headers.OptionalHeader.DataDirectory[14].VirtualAddress = code.ComDescriptorRVA; + writer.Headers.OptionalHeader.DataDirectory[14].Size = code.ComDescriptorLength; + + // Debug Directory + if (code.DebugDirectoryLength != 0) + { + writer.Headers.OptionalHeader.DataDirectory[6].VirtualAddress = code.DebugDirectoryRVA; + writer.Headers.OptionalHeader.DataDirectory[6].Size = code.DebugDirectoryLength; + } + + writer.Headers.FileHeader.NumberOfSections = 2; + + if (moduleBuilder.initializedData.Length != 0) + { + writer.Headers.FileHeader.NumberOfSections++; + } + + if (resources != null && resources.Length != 0) + { + writer.Headers.FileHeader.NumberOfSections++; + } + + SectionHeader text = new SectionHeader(); + text.Name = ".text"; + text.VirtualAddress = code.BaseRVA; + text.VirtualSize = (uint)code.Length; + text.PointerToRawData = code.PointerToRawData; + text.SizeOfRawData = writer.ToFileAlignment((uint)code.Length); + text.Characteristics = SectionHeader.IMAGE_SCN_CNT_CODE | SectionHeader.IMAGE_SCN_MEM_EXECUTE | SectionHeader.IMAGE_SCN_MEM_READ; + + SectionHeader sdata = new SectionHeader(); + sdata.Name = ".sdata"; + sdata.VirtualAddress = text.VirtualAddress + writer.ToSectionAlignment(text.VirtualSize); + sdata.VirtualSize = (uint)moduleBuilder.initializedData.Length; + sdata.PointerToRawData = text.PointerToRawData + text.SizeOfRawData; + sdata.SizeOfRawData = writer.ToFileAlignment((uint)moduleBuilder.initializedData.Length); + sdata.Characteristics = SectionHeader.IMAGE_SCN_CNT_INITIALIZED_DATA | SectionHeader.IMAGE_SCN_MEM_READ | SectionHeader.IMAGE_SCN_MEM_WRITE; + + SectionHeader rsrc = new SectionHeader(); + rsrc.Name = ".rsrc"; + rsrc.VirtualAddress = sdata.VirtualAddress + writer.ToSectionAlignment(sdata.VirtualSize); + rsrc.PointerToRawData = sdata.PointerToRawData + sdata.SizeOfRawData; + rsrc.VirtualSize = resources == null ? 0 : (uint)resources.Length; + rsrc.SizeOfRawData = writer.ToFileAlignment(rsrc.VirtualSize); + rsrc.Characteristics = SectionHeader.IMAGE_SCN_MEM_READ | SectionHeader.IMAGE_SCN_CNT_INITIALIZED_DATA; + + if (rsrc.SizeOfRawData != 0) + { + // Resource Directory + writer.Headers.OptionalHeader.DataDirectory[2].VirtualAddress = rsrc.VirtualAddress; + writer.Headers.OptionalHeader.DataDirectory[2].Size = rsrc.VirtualSize; + } + + SectionHeader reloc = new SectionHeader(); + reloc.Name = ".reloc"; + reloc.VirtualAddress = rsrc.VirtualAddress + writer.ToSectionAlignment(rsrc.VirtualSize); + reloc.VirtualSize = 12; + reloc.PointerToRawData = rsrc.PointerToRawData + rsrc.SizeOfRawData; + reloc.SizeOfRawData = writer.ToFileAlignment(reloc.VirtualSize); + reloc.Characteristics = SectionHeader.IMAGE_SCN_MEM_READ | SectionHeader.IMAGE_SCN_CNT_INITIALIZED_DATA | SectionHeader.IMAGE_SCN_MEM_DISCARDABLE; + + // Base Relocation Directory + writer.Headers.OptionalHeader.DataDirectory[5].VirtualAddress = reloc.VirtualAddress; + writer.Headers.OptionalHeader.DataDirectory[5].Size = reloc.VirtualSize; + + writer.Headers.OptionalHeader.SizeOfCode = text.SizeOfRawData; + writer.Headers.OptionalHeader.SizeOfInitializedData = sdata.SizeOfRawData + rsrc.SizeOfRawData + reloc.SizeOfRawData; + writer.Headers.OptionalHeader.SizeOfUninitializedData = 0; + writer.Headers.OptionalHeader.SizeOfImage = reloc.VirtualAddress + writer.ToSectionAlignment(reloc.VirtualSize); + writer.Headers.OptionalHeader.SizeOfHeaders = text.PointerToRawData; + writer.Headers.OptionalHeader.BaseOfCode = code.BaseRVA; + writer.Headers.OptionalHeader.BaseOfData = sdata.VirtualAddress; + writer.Headers.OptionalHeader.ImageBase = (ulong)moduleBuilder.__ImageBase; + + if (imageFileMachine == ImageFileMachine.IA64) + { + // apparently for IA64 AddressOfEntryPoint points to the address of the entry point + // (i.e. there is an additional layer of indirection), so we add the offset to the pointer + writer.Headers.OptionalHeader.AddressOfEntryPoint = code.StartupStubRVA + 0x20; + } + else + { + writer.Headers.OptionalHeader.AddressOfEntryPoint = code.StartupStubRVA; + } + + writer.WritePEHeaders(); + writer.WriteSectionHeader(text); + if (sdata.SizeOfRawData != 0) + { + writer.WriteSectionHeader(sdata); + } + if (rsrc.SizeOfRawData != 0) + { + writer.WriteSectionHeader(rsrc); + } + writer.WriteSectionHeader(reloc); + + fs.Seek(text.PointerToRawData, SeekOrigin.Begin); + code.Write(mw, (int)sdata.VirtualAddress); + + fs.Seek(sdata.PointerToRawData, SeekOrigin.Begin); + mw.Write(moduleBuilder.initializedData); + + if (rsrc.SizeOfRawData != 0) + { + fs.Seek(rsrc.PointerToRawData, SeekOrigin.Begin); + resources.Write(mw, rsrc.VirtualAddress); + } + + fs.Seek(reloc.PointerToRawData, SeekOrigin.Begin); + // .reloc section + uint relocAddress = code.StartupStubRVA; + switch (imageFileMachine) + { + case ImageFileMachine.I386: + case ImageFileMachine.AMD64: + relocAddress += 2; + break; + case ImageFileMachine.IA64: + relocAddress += 0x20; + break; + } + uint pageRVA = relocAddress & ~0xFFFU; + mw.Write(pageRVA); // PageRVA + mw.Write(0x000C); // Block Size + if (imageFileMachine == ImageFileMachine.I386) + { + mw.Write(0x3000 + relocAddress - pageRVA); // Type / Offset + } + else if (imageFileMachine == ImageFileMachine.AMD64) + { + mw.Write(0xA000 + relocAddress - pageRVA); // Type / Offset + } + else if (imageFileMachine == ImageFileMachine.IA64) + { + // on IA64 the StartupStubRVA is 16 byte aligned, so these two addresses won't cross a page boundary + mw.Write((short)(0xA000 + relocAddress - pageRVA)); // Type / Offset + mw.Write((short)(0xA000 + relocAddress - pageRVA + 8)); // Type / Offset + } + + // file alignment + mw.Write(new byte[writer.Headers.OptionalHeader.FileAlignment - reloc.VirtualSize]); + + // do the strong naming + if (keyPair != null) + { + StrongName(fs, keyPair, writer.HeaderSize, text.PointerToRawData, code.StrongNameSignatureRVA - text.VirtualAddress + text.PointerToRawData, code.StrongNameSignatureLength); + } + } + + if (moduleBuilder.symbolWriter != null) + { + moduleBuilder.WriteSymbolTokenMap(); + moduleBuilder.symbolWriter.Close(); + } + } + + private static int ComputeStrongNameSignatureLength(byte[] publicKey) + { + if (publicKey == null) + { + return 0; + } + else if (publicKey.Length == 16) + { + // it must be the ECMA pseudo public key, we don't know the key size of the real key, but currently both Mono and Microsoft use a 1024 bit key size + return 128; + } + else + { + // for the supported strong naming algorithms, the signature size is the same as the key size + // (we have to subtract 32 for the header) + return publicKey.Length - 32; + } + } + + private static void StrongName(FileStream fs, StrongNameKeyPair keyPair, uint headerLength, uint textSectionFileOffset, uint strongNameSignatureFileOffset, uint strongNameSignatureLength) + { + SHA1Managed hash = new SHA1Managed(); + using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write)) + { + fs.Seek(0, SeekOrigin.Begin); + byte[] buf = new byte[8192]; + HashChunk(fs, cs, buf, (int)headerLength); + fs.Seek(textSectionFileOffset, SeekOrigin.Begin); + HashChunk(fs, cs, buf, (int)(strongNameSignatureFileOffset - textSectionFileOffset)); + fs.Seek(strongNameSignatureLength, SeekOrigin.Current); + HashChunk(fs, cs, buf, (int)(fs.Length - (strongNameSignatureFileOffset + strongNameSignatureLength))); + } + using (RSA rsa = CryptoHack.CreateRSA(keyPair)) + { + RSAPKCS1SignatureFormatter sign = new RSAPKCS1SignatureFormatter(rsa); + byte[] signature = sign.CreateSignature(hash); + Array.Reverse(signature); + if (signature.Length != strongNameSignatureLength) + { + throw new InvalidOperationException("Signature length mismatch"); + } + fs.Seek(strongNameSignatureFileOffset, SeekOrigin.Begin); + fs.Write(signature, 0, signature.Length); + } + + // compute the PE checksum + fs.Seek(0, SeekOrigin.Begin); + int count = (int)fs.Length / 4; + BinaryReader br = new BinaryReader(fs); + long sum = 0; + for (int i = 0; i < count; i++) + { + sum += br.ReadUInt32(); + int carry = (int)(sum >> 32); + sum &= 0xFFFFFFFFU; + sum += carry; + } + while ((sum >> 16) != 0) + { + sum = (sum & 0xFFFF) + (sum >> 16); + } + sum += fs.Length; + + // write the PE checksum, note that it is always at offset 0xD8 in the file + ByteBuffer bb = new ByteBuffer(4); + bb.Write((int)sum); + fs.Seek(0xD8, SeekOrigin.Begin); + bb.WriteTo(fs); + } + + internal static void HashChunk(FileStream fs, CryptoStream cs, byte[] buf, int length) + { + while (length > 0) + { + int read = fs.Read(buf, 0, Math.Min(buf.Length, length)); + cs.Write(buf, 0, read); + length -= read; + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/PEWriter.cs b/mcs/class/IKVM.Reflection/Writer/PEWriter.cs new file mode 100644 index 000000000000..3ddd20be6b49 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/PEWriter.cs @@ -0,0 +1,303 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using BYTE = System.Byte; +using WORD = System.UInt16; +using DWORD = System.UInt32; +using ULONGLONG = System.UInt64; + +namespace IKVM.Reflection.Writer +{ + sealed class PEWriter + { + private readonly BinaryWriter bw; + private readonly IMAGE_NT_HEADERS hdr = new IMAGE_NT_HEADERS(); + + internal PEWriter(Stream stream) + { + bw = new BinaryWriter(stream); + WriteMSDOSHeader(); + } + + public IMAGE_NT_HEADERS Headers + { + get { return hdr; } + } + + public uint HeaderSize + { + get + { + return (uint) + ((8 * 16) + // MSDOS header + 4 + // signature + 20 + // IMAGE_FILE_HEADER + hdr.FileHeader.SizeOfOptionalHeader + + hdr.FileHeader.NumberOfSections * 40); + } + } + + private void WriteMSDOSHeader() + { + bw.Write(new byte[] { + 0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, + 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x0E, 0x1F, 0xBA, 0x0E, 0x00, 0xB4, 0x09, 0xCD, + 0x21, 0xB8, 0x01, 0x4C, 0xCD, 0x21, 0x54, 0x68, + 0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, + 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F, + 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, + 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20, + 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0D, 0x0A, + 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }); + } + + internal void WritePEHeaders() + { + bw.Write(hdr.Signature); + + // IMAGE_FILE_HEADER + bw.Write(hdr.FileHeader.Machine); + bw.Write(hdr.FileHeader.NumberOfSections); + bw.Write(hdr.FileHeader.TimeDateStamp); + bw.Write(hdr.FileHeader.PointerToSymbolTable); + bw.Write(hdr.FileHeader.NumberOfSymbols); + bw.Write(hdr.FileHeader.SizeOfOptionalHeader); + bw.Write(hdr.FileHeader.Characteristics); + + // IMAGE_OPTIONAL_HEADER + hdr.OptionalHeader.Write(bw); + } + + internal void WriteSectionHeader(SectionHeader sectionHeader) + { + byte[] name = new byte[8]; + System.Text.Encoding.UTF8.GetBytes(sectionHeader.Name, 0, sectionHeader.Name.Length, name, 0); + bw.Write(name); + bw.Write(sectionHeader.VirtualSize); + bw.Write(sectionHeader.VirtualAddress); + bw.Write(sectionHeader.SizeOfRawData); + bw.Write(sectionHeader.PointerToRawData); + bw.Write(sectionHeader.PointerToRelocations); + bw.Write(sectionHeader.PointerToLinenumbers); + bw.Write(sectionHeader.NumberOfRelocations); + bw.Write(sectionHeader.NumberOfLinenumbers); + bw.Write(sectionHeader.Characteristics); + } + + internal uint ToFileAlignment(uint p) + { + return (p + (Headers.OptionalHeader.FileAlignment - 1)) & ~(Headers.OptionalHeader.FileAlignment - 1); + } + + internal uint ToSectionAlignment(uint p) + { + return (p + (Headers.OptionalHeader.SectionAlignment - 1)) & ~(Headers.OptionalHeader.SectionAlignment - 1); + } + } + + sealed class IMAGE_NT_HEADERS + { + public DWORD Signature = 0x00004550; // "PE\0\0" + public IMAGE_FILE_HEADER FileHeader = new IMAGE_FILE_HEADER(); + public IMAGE_OPTIONAL_HEADER OptionalHeader = new IMAGE_OPTIONAL_HEADER(); + } + + sealed class IMAGE_FILE_HEADER + { + public const WORD IMAGE_FILE_MACHINE_I386 = 0x014c; + public const WORD IMAGE_FILE_MACHINE_IA64 = 0x0200; + public const WORD IMAGE_FILE_MACHINE_AMD64 = 0x8664; + + public const WORD IMAGE_FILE_32BIT_MACHINE = 0x0100; + public const WORD IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002; + public const WORD IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020; + public const WORD IMAGE_FILE_DLL = 0x2000; + + public WORD Machine; + public WORD NumberOfSections; + public DWORD TimeDateStamp = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; + public DWORD PointerToSymbolTable = 0; + public DWORD NumberOfSymbols = 0; + public WORD SizeOfOptionalHeader = 0xE0; + public WORD Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE; + } + + sealed class IMAGE_OPTIONAL_HEADER + { + public const WORD IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b; + public const WORD IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b; + + public const WORD IMAGE_SUBSYSTEM_WINDOWS_GUI = 2; + public const WORD IMAGE_SUBSYSTEM_WINDOWS_CUI = 3; + + public const WORD IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = 0x0040; + public const WORD IMAGE_DLLCHARACTERISTICS_NX_COMPAT = 0x0100; + public const WORD IMAGE_DLLCHARACTERISTICS_NO_SEH = 0x0400; + public const WORD IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000; + + public WORD Magic = IMAGE_NT_OPTIONAL_HDR32_MAGIC; + public BYTE MajorLinkerVersion = 8; + public BYTE MinorLinkerVersion = 0; + public DWORD SizeOfCode; + public DWORD SizeOfInitializedData; + public DWORD SizeOfUninitializedData; + public DWORD AddressOfEntryPoint; + public DWORD BaseOfCode; + public DWORD BaseOfData; + public ULONGLONG ImageBase; + public DWORD SectionAlignment = 0x2000; + public DWORD FileAlignment = 0x200; + public WORD MajorOperatingSystemVersion = 4; + public WORD MinorOperatingSystemVersion = 0; + public WORD MajorImageVersion = 0; + public WORD MinorImageVersion = 0; + public WORD MajorSubsystemVersion = 4; + public WORD MinorSubsystemVersion = 0; + public DWORD Win32VersionValue = 0; + public DWORD SizeOfImage; + public DWORD SizeOfHeaders; + public DWORD CheckSum = 0; + public WORD Subsystem; + public WORD DllCharacteristics; + public ULONGLONG SizeOfStackReserve = 0x100000; + public ULONGLONG SizeOfStackCommit = 0x1000; + public ULONGLONG SizeOfHeapReserve = 0x100000; + public ULONGLONG SizeOfHeapCommit = 0x1000; + public DWORD LoaderFlags = 0; + public DWORD NumberOfRvaAndSizes = 16; + public IMAGE_DATA_DIRECTORY[] DataDirectory = new IMAGE_DATA_DIRECTORY[16]; + + internal void Write(BinaryWriter bw) + { + bw.Write(Magic); + bw.Write(MajorLinkerVersion); + bw.Write(MinorLinkerVersion); + bw.Write(SizeOfCode); + bw.Write(SizeOfInitializedData); + bw.Write(SizeOfUninitializedData); + bw.Write(AddressOfEntryPoint); + bw.Write(BaseOfCode); + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + bw.Write(BaseOfData); + bw.Write((DWORD)ImageBase); + } + else + { + bw.Write(ImageBase); + } + bw.Write(SectionAlignment); + bw.Write(FileAlignment); + bw.Write(MajorOperatingSystemVersion); + bw.Write(MinorOperatingSystemVersion); + bw.Write(MajorImageVersion); + bw.Write(MinorImageVersion); + bw.Write(MajorSubsystemVersion); + bw.Write(MinorSubsystemVersion); + bw.Write(Win32VersionValue); + bw.Write(SizeOfImage); + bw.Write(SizeOfHeaders); + bw.Write(CheckSum); + bw.Write(Subsystem); + bw.Write(DllCharacteristics); + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + bw.Write((DWORD)SizeOfStackReserve); + } + else + { + bw.Write(SizeOfStackReserve); + } + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + bw.Write((DWORD)SizeOfStackCommit); + } + else + { + bw.Write(SizeOfStackCommit); + } + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + bw.Write((DWORD)SizeOfHeapReserve); + } + else + { + bw.Write(SizeOfHeapReserve); + } + if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + bw.Write((DWORD)SizeOfHeapCommit); + } + else + { + bw.Write(SizeOfHeapCommit); + } + bw.Write(LoaderFlags); + bw.Write(NumberOfRvaAndSizes); + for (int i = 0; i < DataDirectory.Length; i++) + { + bw.Write(DataDirectory[i].VirtualAddress); + bw.Write(DataDirectory[i].Size); + } + } + } + + struct IMAGE_DATA_DIRECTORY + { + public DWORD VirtualAddress; + public DWORD Size; + } + + class SectionHeader + { + public const DWORD IMAGE_SCN_CNT_CODE = 0x00000020; + public const DWORD IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040; + public const DWORD IMAGE_SCN_MEM_DISCARDABLE = 0x02000000; + public const DWORD IMAGE_SCN_MEM_EXECUTE = 0x20000000; + public const DWORD IMAGE_SCN_MEM_READ = 0x40000000; + public const DWORD IMAGE_SCN_MEM_WRITE = 0x80000000; + + public string Name; // 8 byte UTF8 encoded 0-padded + public DWORD VirtualSize; + public DWORD VirtualAddress; + public DWORD SizeOfRawData; + public DWORD PointerToRawData; +#pragma warning disable 649 // the follow fields are never assigned to + public DWORD PointerToRelocations; + public DWORD PointerToLinenumbers; + public WORD NumberOfRelocations; + public WORD NumberOfLinenumbers; +#pragma warning restore 649 + public DWORD Characteristics; + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/ResourceSection.cs b/mcs/class/IKVM.Reflection/Writer/ResourceSection.cs new file mode 100644 index 000000000000..81941e246bc9 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/ResourceSection.cs @@ -0,0 +1,372 @@ +/* + Copyright (C) 2010 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using IKVM.Reflection.Reader; + +namespace IKVM.Reflection.Writer +{ + sealed class ResourceSection + { + private const int RT_ICON = 3; + private const int RT_GROUP_ICON = 14; + private const int RT_VERSION = 16; + private ResourceDirectoryEntry root = new ResourceDirectoryEntry(new OrdinalOrName("root")); + private ByteBuffer bb; + private List linkOffsets; + + internal void AddVersionInfo(ByteBuffer versionInfo) + { + root[new OrdinalOrName(RT_VERSION)][new OrdinalOrName(1)][new OrdinalOrName(0)].Data = versionInfo; + } + + internal void AddIcon(byte[] iconFile) + { + BinaryReader br = new BinaryReader(new MemoryStream(iconFile)); + ushort idReserved = br.ReadUInt16(); + ushort idType = br.ReadUInt16(); + ushort idCount = br.ReadUInt16(); + if (idReserved != 0 || idType != 1) + { + throw new ArgumentException("The supplied byte array is not a valid .ico file."); + } + ByteBuffer group = new ByteBuffer(6 + 14 * idCount); + group.Write(idReserved); + group.Write(idType); + group.Write(idCount); + for (int i = 0; i < idCount; i++) + { + byte bWidth = br.ReadByte(); + byte bHeight = br.ReadByte(); + byte bColorCount = br.ReadByte(); + byte bReserved = br.ReadByte(); + ushort wPlanes = br.ReadUInt16(); + ushort wBitCount = br.ReadUInt16(); + uint dwBytesInRes = br.ReadUInt32(); + uint dwImageOffset = br.ReadUInt32(); + + // we start the icon IDs at 2 + ushort id = (ushort)(2 + i); + + group.Write(bWidth); + group.Write(bHeight); + group.Write(bColorCount); + group.Write(bReserved); + group.Write(wPlanes); + group.Write(wBitCount); + group.Write(dwBytesInRes); + group.Write(id); + + byte[] icon = new byte[dwBytesInRes]; + Buffer.BlockCopy(iconFile, (int)dwImageOffset, icon, 0, icon.Length); + root[new OrdinalOrName(RT_ICON)][new OrdinalOrName(id)][new OrdinalOrName(0)].Data = ByteBuffer.Wrap(icon); + } + root[new OrdinalOrName(RT_GROUP_ICON)][new OrdinalOrName(32512)][new OrdinalOrName(0)].Data = group; + } + + internal void ExtractResources(byte[] buf) + { + ByteReader br = new ByteReader(buf, 0, buf.Length); + while (br.Length >= 32) + { + br.Align(4); + RESOURCEHEADER hdr = new RESOURCEHEADER(br); + if (hdr.DataSize != 0) + { + root[hdr.TYPE][hdr.NAME][new OrdinalOrName(hdr.LanguageId)].Data = ByteBuffer.Wrap(br.ReadBytes(hdr.DataSize)); + } + } + } + + internal void Finish() + { + if (bb != null) + { + throw new InvalidOperationException(); + } + bb = new ByteBuffer(1024); + linkOffsets = new List(); + root.Write(bb, linkOffsets); + root = null; + } + + internal int Length + { + get { return bb.Length; } + } + + internal void Write(MetadataWriter mw, uint rva) + { + foreach (int offset in linkOffsets) + { + bb.Position = offset; + bb.Write(bb.GetInt32AtCurrentPosition() + (int)rva); + } + mw.Write(bb); + } + } + + sealed class ResourceDirectoryEntry + { + internal readonly OrdinalOrName OrdinalOrName; + internal ByteBuffer Data; + private int namedEntries; + private readonly List entries = new List(); + + internal ResourceDirectoryEntry(OrdinalOrName id) + { + this.OrdinalOrName = id; + } + + internal ResourceDirectoryEntry this[OrdinalOrName id] + { + get + { + foreach (ResourceDirectoryEntry entry in entries) + { + if (entry.OrdinalOrName.Ordinal == id.Ordinal && entry.OrdinalOrName.Name == id.Name) + { + return entry; + } + } + ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id); + if (id.Name == null) + { + entries.Add(newEntry); + } + else + { + entries.Insert(namedEntries++, newEntry); + } + return newEntry; + } + } + + private int DirectoryLength + { + get + { + if (Data != null) + { + return 16; + } + else + { + int length = 16 + entries.Count * 8; + foreach (ResourceDirectoryEntry entry in entries) + { + length += entry.DirectoryLength; + } + return length; + } + } + } + + internal void Write(ByteBuffer bb, List linkOffsets) + { + if (entries.Count != 0) + { + int stringTableOffset = this.DirectoryLength; + Dictionary strings = new Dictionary(); + ByteBuffer stringTable = new ByteBuffer(16); + int offset = 16 + entries.Count * 8; + for (int pass = 0; pass < 3; pass++) + { + Write(bb, pass, 0, ref offset, strings, ref stringTableOffset, stringTable); + } + // the pecoff spec says that the string table is between the directory entries and the data entries, + // but the windows linker puts them after the data entries, so we do too. + stringTable.Align(4); + offset += stringTable.Length; + WriteResourceDataEntries(bb, linkOffsets, ref offset); + bb.Write(stringTable); + WriteData(bb); + } + } + + private void WriteResourceDataEntries(ByteBuffer bb, List linkOffsets, ref int offset) + { + foreach (ResourceDirectoryEntry entry in entries) + { + if (entry.Data != null) + { + linkOffsets.Add(bb.Position); + bb.Write(offset); + bb.Write(entry.Data.Length); + bb.Write(0); // code page + bb.Write(0); // reserved + offset += (entry.Data.Length + 3) & ~3; + } + else + { + entry.WriteResourceDataEntries(bb, linkOffsets, ref offset); + } + } + } + + private void WriteData(ByteBuffer bb) + { + foreach (ResourceDirectoryEntry entry in entries) + { + if (entry.Data != null) + { + bb.Write(entry.Data); + bb.Align(4); + } + else + { + entry.WriteData(bb); + } + } + } + + private void Write(ByteBuffer bb, int writeDepth, int currentDepth, ref int offset, Dictionary strings, ref int stringTableOffset, ByteBuffer stringTable) + { + if (currentDepth == writeDepth) + { + // directory header + bb.Write(0); // Characteristics + bb.Write(0); // Time/Date Stamp + bb.Write(0); // Version (Major / Minor) + bb.Write((ushort)namedEntries); + bb.Write((ushort)(entries.Count - namedEntries)); + } + foreach (ResourceDirectoryEntry entry in entries) + { + if (currentDepth == writeDepth) + { + entry.WriteEntry(bb, ref offset, strings, ref stringTableOffset, stringTable); + } + else + { + entry.Write(bb, writeDepth, currentDepth + 1, ref offset, strings, ref stringTableOffset, stringTable); + } + } + } + + private void WriteEntry(ByteBuffer bb, ref int offset, Dictionary strings, ref int stringTableOffset, ByteBuffer stringTable) + { + WriteNameOrOrdinal(bb, OrdinalOrName, strings, ref stringTableOffset, stringTable); + if (Data == null) + { + bb.Write(0x80000000U | (uint)offset); + } + else + { + bb.Write(offset); + } + offset += 16 + entries.Count * 8; + } + + private static void WriteNameOrOrdinal(ByteBuffer bb, OrdinalOrName id, Dictionary strings, ref int stringTableOffset, ByteBuffer stringTable) + { + if (id.Name == null) + { + bb.Write((int)id.Ordinal); + } + else + { + int stringOffset; + if (!strings.TryGetValue(id.Name, out stringOffset)) + { + stringOffset = stringTableOffset; + strings.Add(id.Name, stringOffset); + stringTableOffset += id.Name.Length * 2 + 2; + stringTable.Write((ushort)id.Name.Length); + foreach (char c in id.Name) + { + stringTable.Write((short)c); + } + } + bb.Write(0x80000000U | (uint)stringOffset); + } + } + } + + struct OrdinalOrName + { + internal readonly ushort Ordinal; + internal readonly string Name; + + internal OrdinalOrName(ushort value) + { + Ordinal = value; + Name = null; + } + + internal OrdinalOrName(string value) + { + Ordinal = 0xFFFF; + Name = value; + } + } + + struct RESOURCEHEADER + { + internal int DataSize; + internal int HeaderSize; + internal OrdinalOrName TYPE; + internal OrdinalOrName NAME; + internal int DataVersion; + internal ushort MemoryFlags; + internal ushort LanguageId; + internal int Version; + internal int Characteristics; + + internal RESOURCEHEADER(ByteReader br) + { + DataSize = br.ReadInt32(); + HeaderSize = br.ReadInt32(); + TYPE = ReadOrdinalOrName(br); + NAME = ReadOrdinalOrName(br); + br.Align(4); + DataVersion = br.ReadInt32(); + MemoryFlags = br.ReadUInt16(); + LanguageId = br.ReadUInt16(); + Version = br.ReadInt32(); + Characteristics = br.ReadInt32(); + } + + private static OrdinalOrName ReadOrdinalOrName(ByteReader br) + { + char c = br.ReadChar(); + if (c == 0xFFFF) + { + return new OrdinalOrName(br.ReadUInt16()); + } + else + { + StringBuilder sb = new StringBuilder(); + while (c != 0) + { + sb.Append(c); + c = br.ReadChar(); + } + return new OrdinalOrName(sb.ToString()); + } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/TextSection.cs b/mcs/class/IKVM.Reflection/Writer/TextSection.cs new file mode 100644 index 000000000000..9b4a7eecbc25 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/TextSection.cs @@ -0,0 +1,445 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Diagnostics; +using System.IO; +using System.Collections.Generic; +using System.Text; +using IKVM.Reflection.Emit; +using IKVM.Reflection.Impl; +using IKVM.Reflection.Metadata; + +namespace IKVM.Reflection.Writer +{ + sealed class TextSection + { + private readonly PEWriter peWriter; + private readonly CliHeader cliHeader; + private readonly ModuleBuilder moduleBuilder; + private readonly uint strongNameSignatureLength; + + internal TextSection(PEWriter peWriter, CliHeader cliHeader, ModuleBuilder moduleBuilder, int strongNameSignatureLength) + { + this.peWriter = peWriter; + this.cliHeader = cliHeader; + this.moduleBuilder = moduleBuilder; + this.strongNameSignatureLength = (uint)strongNameSignatureLength; + } + + internal uint PointerToRawData + { + get { return peWriter.ToFileAlignment(peWriter.HeaderSize); } + } + + internal uint BaseRVA + { + get { return 0x2000; } + } + + internal uint ImportAddressTableRVA + { + get { return BaseRVA; } + } + + internal uint ImportAddressTableLength + { + get + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386) + { + return 8; + } + else + { + return 16; + } + } + } + + internal uint ComDescriptorRVA + { + get { return ImportAddressTableRVA + ImportAddressTableLength; } + } + + internal uint ComDescriptorLength + { + get { return cliHeader.Cb; } + } + + internal uint MethodBodiesRVA + { + get { return (ComDescriptorRVA + ComDescriptorLength + 7) & ~7U; } + } + + private uint MethodBodiesLength + { + get { return (uint)moduleBuilder.methodBodies.Length; } + } + + private uint ResourcesRVA + { + get + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386) + { + return (MethodBodiesRVA + MethodBodiesLength + 3) & ~3U; + } + else + { + return (MethodBodiesRVA + MethodBodiesLength + 15) & ~15U; + } + } + } + + private uint ResourcesLength + { + get { return (uint)moduleBuilder.manifestResources.Length; } + } + + internal uint StrongNameSignatureRVA + { + get + { + return (ResourcesRVA + ResourcesLength + 3) & ~3U; + } + } + + internal uint StrongNameSignatureLength + { + get + { + return strongNameSignatureLength; + } + } + + private uint MetadataRVA + { + get + { + return (StrongNameSignatureRVA + StrongNameSignatureLength + 3) & ~3U; + } + } + + private uint MetadataLength + { + get { return (uint)moduleBuilder.MetadataLength; } + } + + internal uint DebugDirectoryRVA + { + get { return MetadataRVA + MetadataLength; } + } + + internal uint DebugDirectoryLength + { + get + { + if (DebugDirectoryContentsLength != 0) + { + return 28; + } + return 0; + } + } + + private uint DebugDirectoryContentsLength + { + get + { + if (moduleBuilder.symbolWriter != null) + { + IMAGE_DEBUG_DIRECTORY idd = new IMAGE_DEBUG_DIRECTORY(); + return (uint)SymbolSupport.GetDebugInfo(moduleBuilder.symbolWriter, ref idd).Length; + } + return 0; + } + } + + internal uint ImportDirectoryRVA + { + // on AMD64 (and probably IA64) the import directory needs to be 16 byte aligned (on I386 4 byte alignment is sufficient) + get { return (DebugDirectoryRVA + DebugDirectoryLength + DebugDirectoryContentsLength + 15) & ~15U; } + } + + internal uint ImportDirectoryLength + { + get { return (ImportHintNameTableRVA - ImportDirectoryRVA) + 27; } + } + + private uint ImportHintNameTableRVA + { + get + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386) + { + return (ImportDirectoryRVA + 48 + 15) & ~15U; + } + else + { + return (ImportDirectoryRVA + 48 + 4 + 15) & ~15U; + } + } + } + + internal uint StartupStubRVA + { + get + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_IA64) + { + // note that the alignment is driven by the requirement that the two relocation fixups are in a single page + return (ImportDirectoryRVA + ImportDirectoryLength + 15U) & ~15U; + } + else + { + // the additional 2 bytes padding are to align the address in the jump (which is a relocation fixup) + return 2 + ((ImportDirectoryRVA + ImportDirectoryLength + 3U) & ~3U); + } + } + } + + internal uint StartupStubLength + { + get + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_AMD64) + { + return 12; + } + else if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_IA64) + { + return 48; + } + else + { + return 6; + } + } + } + + private void WriteRVA(MetadataWriter mw, uint rva) + { + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386) + { + mw.Write(rva); + } + else + { + mw.Write((ulong)rva); + } + } + + internal void Write(MetadataWriter mw, int sdataRVA) + { + // Now that we're ready to start writing, we need to do some fix ups + moduleBuilder.MethodDef.Fixup(this); + moduleBuilder.MethodImpl.Fixup(moduleBuilder); + moduleBuilder.MethodSemantics.Fixup(moduleBuilder); + moduleBuilder.InterfaceImpl.Fixup(); + moduleBuilder.MemberRef.Fixup(moduleBuilder); + moduleBuilder.Constant.Fixup(moduleBuilder); + moduleBuilder.FieldMarshal.Fixup(moduleBuilder); + moduleBuilder.DeclSecurity.Fixup(moduleBuilder); + moduleBuilder.GenericParam.Fixup(moduleBuilder); + moduleBuilder.CustomAttribute.Fixup(moduleBuilder); + moduleBuilder.FieldLayout.Fixup(moduleBuilder); + moduleBuilder.FieldRVA.Fixup(moduleBuilder, sdataRVA); + moduleBuilder.ImplMap.Fixup(moduleBuilder); + moduleBuilder.MethodSpec.Fixup(moduleBuilder); + moduleBuilder.GenericParamConstraint.Fixup(moduleBuilder); + + // Import Address Table + AssertRVA(mw, ImportAddressTableRVA); + WriteRVA(mw, ImportHintNameTableRVA); + WriteRVA(mw, 0); + + // CLI Header + AssertRVA(mw, ComDescriptorRVA); + cliHeader.MetaDataRVA = MetadataRVA; + cliHeader.MetaDataSize = MetadataLength; + if (ResourcesLength != 0) + { + cliHeader.ResourcesRVA = ResourcesRVA; + cliHeader.ResourcesSize = ResourcesLength; + } + if (StrongNameSignatureLength != 0) + { + cliHeader.StrongNameSignatureRVA = StrongNameSignatureRVA; + cliHeader.StrongNameSignatureSize = StrongNameSignatureLength; + } + cliHeader.Write(mw); + + // alignment padding + for (int i = (int)(MethodBodiesRVA - (ComDescriptorRVA + ComDescriptorLength)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Method Bodies + mw.Write(moduleBuilder.methodBodies); + + // alignment padding + for (int i = (int)(ResourcesRVA - (MethodBodiesRVA + MethodBodiesLength)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Resources + mw.Write(moduleBuilder.manifestResources); + + // The strong name signature live here (if it exists), but it will written later + // and the following alignment padding will take care of reserving the space. + + // alignment padding + for (int i = (int)(MetadataRVA - (ResourcesRVA + ResourcesLength)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Metadata + AssertRVA(mw, MetadataRVA); + moduleBuilder.WriteMetadata(mw); + + // Debug Directory + AssertRVA(mw, DebugDirectoryRVA); + WriteDebugDirectory(mw); + + // alignment padding + for (int i = (int)(ImportDirectoryRVA - (DebugDirectoryRVA + DebugDirectoryLength + DebugDirectoryContentsLength)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Import Directory + AssertRVA(mw, ImportDirectoryRVA); + WriteImportDirectory(mw); + + // alignment padding + for (int i = (int)(StartupStubRVA - (ImportDirectoryRVA + ImportDirectoryLength)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Startup Stub + AssertRVA(mw, StartupStubRVA); + if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_AMD64) + { + /* + * 48 A1 00 20 40 00 00 00 00 00 mov rax,qword ptr [0000000000402000h] + * FF E0 jmp rax + */ + mw.Write((ushort)0xA148); + mw.Write(peWriter.Headers.OptionalHeader.ImageBase + ImportAddressTableRVA); + mw.Write((ushort)0xE0FF); + } + else if (peWriter.Headers.FileHeader.Machine == IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_IA64) + { + mw.Write(new byte[] { + 0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00 + }); + mw.Write(peWriter.Headers.OptionalHeader.ImageBase + StartupStubRVA); + mw.Write(peWriter.Headers.OptionalHeader.ImageBase + BaseRVA); + } + else + { + mw.Write((ushort)0x25FF); + mw.Write((uint)peWriter.Headers.OptionalHeader.ImageBase + ImportAddressTableRVA); + } + } + + [Conditional("DEBUG")] + private void AssertRVA(MetadataWriter mw, uint rva) + { + Debug.Assert(mw.Position - PointerToRawData + BaseRVA == rva); + } + + private void WriteDebugDirectory(MetadataWriter mw) + { + if (DebugDirectoryLength != 0) + { + IMAGE_DEBUG_DIRECTORY idd = new IMAGE_DEBUG_DIRECTORY(); + idd.Characteristics = 0; + idd.TimeDateStamp = peWriter.Headers.FileHeader.TimeDateStamp; + byte[] buf = SymbolSupport.GetDebugInfo(moduleBuilder.symbolWriter, ref idd); + idd.PointerToRawData = (DebugDirectoryRVA - BaseRVA) + DebugDirectoryLength + PointerToRawData; + mw.Write(idd.Characteristics); + mw.Write(idd.TimeDateStamp); + mw.Write(idd.MajorVersion); + mw.Write(idd.MinorVersion); + mw.Write(idd.Type); + mw.Write(idd.SizeOfData); + mw.Write(idd.AddressOfRawData); + mw.Write(idd.PointerToRawData); + mw.Write(buf); + } + } + + private void WriteImportDirectory(MetadataWriter mw) + { + mw.Write(ImportDirectoryRVA + 40); // ImportLookupTable + mw.Write(0); // DateTimeStamp + mw.Write(0); // ForwarderChain + mw.Write(ImportHintNameTableRVA + 14); // Name + mw.Write(ImportAddressTableRVA); + mw.Write(new byte[20]); + // Import Lookup Table + mw.Write(ImportHintNameTableRVA); // Hint/Name Table RVA + int size = 48; + if (peWriter.Headers.FileHeader.Machine != IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_I386) + { + size += 4; + mw.Write(0); + } + mw.Write(0); + + // alignment padding + for (int i = (int)(ImportHintNameTableRVA - (ImportDirectoryRVA + size)); i > 0; i--) + { + mw.Write((byte)0); + } + + // Hint/Name Table + AssertRVA(mw, ImportHintNameTableRVA); + mw.Write((ushort)0); // Hint + if ((peWriter.Headers.FileHeader.Characteristics & IMAGE_FILE_HEADER.IMAGE_FILE_DLL) != 0) + { + mw.Write(System.Text.Encoding.ASCII.GetBytes("_CorDllMain")); + } + else + { + mw.Write(System.Text.Encoding.ASCII.GetBytes("_CorExeMain")); + } + mw.Write((byte)0); + // Name + mw.Write(System.Text.Encoding.ASCII.GetBytes("mscoree.dll")); + mw.Write((ushort)0); + } + + internal int Length + { + get { return (int)(StartupStubRVA - BaseRVA + StartupStubLength); } + } + } +} diff --git a/mcs/class/IKVM.Reflection/Writer/VersionInfo.cs b/mcs/class/IKVM.Reflection/Writer/VersionInfo.cs new file mode 100644 index 000000000000..bfcc00b94c65 --- /dev/null +++ b/mcs/class/IKVM.Reflection/Writer/VersionInfo.cs @@ -0,0 +1,280 @@ +/* + Copyright (C) 2008 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.Globalization; +using IKVM.Reflection.Emit; + +namespace IKVM.Reflection.Writer +{ + sealed class VersionInfo + { + private AssemblyName name; + private string fileName; + internal string copyright; + internal string trademark; + internal string product; + internal string company; + private string description; + private string title; + internal string informationalVersion; + private string culture; + private string fileVersion; + + internal void SetName(AssemblyName name) + { + this.name = name; + } + + internal void SetFileName(string assemblyFileName) + { + this.fileName = assemblyFileName; + } + + internal void SetAttribute(CustomAttributeBuilder cab) + { + Universe u = cab.Constructor.Module.universe; + Type type = cab.Constructor.DeclaringType; + if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute) + { + copyright = (string)cab.GetConstructorArgument(0); + } + else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute) + { + trademark = (string)cab.GetConstructorArgument(0); + } + else if (product == null && type == u.System_Reflection_AssemblyProductAttribute) + { + product = (string)cab.GetConstructorArgument(0); + } + else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute) + { + company = (string)cab.GetConstructorArgument(0); + } + else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute) + { + description = (string)cab.GetConstructorArgument(0); + } + else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute) + { + title = (string)cab.GetConstructorArgument(0); + } + else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute) + { + informationalVersion = (string)cab.GetConstructorArgument(0); + } + else if (culture == null && type == u.System_Reflection_AssemblyCultureAttribute) + { + culture = (string)cab.GetConstructorArgument(0); + } + else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute) + { + fileVersion = (string)cab.GetConstructorArgument(0); + } + } + + internal void Write(ByteBuffer bb) + { + if (fileVersion == null) + { + if (name.Version != null) + { + fileVersion = name.Version.ToString(); + } + else + { + fileVersion = "0.0.0.0"; + } + } + + int codepage = 1200; // Unicode codepage + int lcid = 0x7f; + if (name.CultureInfo != null) + { + lcid = name.CultureInfo.LCID; + } + if (culture != null) + { + lcid = new CultureInfo(culture).LCID; + } + + Version filever = ParseVersionRobust(fileVersion); + int fileVersionMajor = filever.Major; + int fileVersionMinor = filever.Minor; + int fileVersionBuild = filever.Build; + int fileVersionRevision = filever.Revision; + + int productVersionMajor = fileVersionMajor; + int productVersionMinor = fileVersionMinor; + int productVersionBuild = fileVersionBuild; + int productVersionRevision = fileVersionRevision; + if (informationalVersion != null) + { + Version productver = ParseVersionRobust(informationalVersion); + productVersionMajor = productver.Major; + productVersionMinor = productver.Minor; + productVersionBuild = productver.Build; + productVersionRevision = productver.Revision; + } + + ByteBuffer stringTable = new ByteBuffer(512); + stringTable.Write((short)0); // wLength (placeholder) + stringTable.Write((short)0); // wValueLength + stringTable.Write((short)1); // wType + WriteUTF16Z(stringTable, string.Format("{0:x4}{1:x4}", lcid, codepage)); + stringTable.Align(4); + + WriteString(stringTable, "Comments", description); + WriteString(stringTable, "CompanyName", company); + WriteString(stringTable, "FileDescription", title); + WriteString(stringTable, "FileVersion", fileVersion); + WriteString(stringTable, "InternalName", name.Name); + WriteString(stringTable, "LegalCopyright", copyright); + WriteString(stringTable, "LegalTrademarks", trademark); + WriteString(stringTable, "OriginalFilename", fileName); + WriteString(stringTable, "ProductName", product); + WriteString(stringTable, "ProductVersion", informationalVersion); + + stringTable.Position = 0; + stringTable.Write((short)stringTable.Length); + + ByteBuffer stringFileInfo = new ByteBuffer(512); + stringFileInfo.Write((short)0); // wLength (placeholder) + stringFileInfo.Write((short)0); // wValueLength + stringFileInfo.Write((short)1); // wType + WriteUTF16Z(stringFileInfo, "StringFileInfo"); + stringFileInfo.Align(4); + stringFileInfo.Write(stringTable); + stringFileInfo.Position = 0; + stringFileInfo.Write((short)stringFileInfo.Length); + + byte[] preamble1 = new byte[] { + // VS_VERSIONINFO (platform SDK) + 0x34, 0x00, // wValueLength + 0x00, 0x00, // wType + 0x56, 0x00, 0x53, 0x00, 0x5F, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00, 0x53, 0x00, 0x49, 0x00, 0x4F, 0x00, 0x4E, 0x00, 0x5F, 0x00, 0x49, 0x00, 0x4E, 0x00, 0x46, 0x00, 0x4F, 0x00, 0x00, 0x00, // "VS_VERSION_INFO\0" + 0x00, 0x00, // Padding1 (32 bit alignment) + // VS_FIXEDFILEINFO starts + 0xBD, 0x04, 0xEF, 0xFE, // dwSignature (0xFEEF04BD) + 0x00, 0x00, 0x01, 0x00, // dwStrucVersion + }; + byte[] preamble2 = new byte[] { + 0x3F, 0x00, 0x00, 0x00, // dwFileFlagsMask (??) + 0x00, 0x00, 0x00, 0x00, // dwFileFlags (??) + 0x04, 0x00, 0x00, 0x00, // dwFileOS + 0x02, 0x00, 0x00, 0x00, // dwFileType + 0x00, 0x00, 0x00, 0x00, // dwFileSubtype + 0x00, 0x00, 0x00, 0x00, // dwFileDateMS + 0x00, 0x00, 0x00, 0x00, // dwFileDateLS + // Padding2 (32 bit alignment) + // VarFileInfo + 0x44, 0x00, // wLength + 0x00, 0x00, // wValueLength + 0x01, 0x00, // wType + 0x56, 0x00, 0x61, 0x00, 0x72, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x49, 0x00, 0x6E, 0x00, 0x66, 0x00, 0x6F, 0x00, 0x00, 0x00, // "VarFileInfo\0" + 0x00, 0x00, // Padding + // Var + 0x24, 0x00, // wLength + 0x04, 0x00, // wValueLength + 0x00, 0x00, // wType + 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x00, 0x00, // "Translation\0" + 0x00, 0x00, // Padding (32 bit alignment) + }; + bb.Write((short)(2 + preamble1.Length + 8 + 8 + preamble2.Length + 4 + stringFileInfo.Length)); + bb.Write(preamble1); + bb.Write((short)fileVersionMinor); + bb.Write((short)fileVersionMajor); + bb.Write((short)fileVersionRevision); + bb.Write((short)fileVersionBuild); + bb.Write((short)productVersionMinor); + bb.Write((short)productVersionMajor); + bb.Write((short)productVersionRevision); + bb.Write((short)productVersionBuild); + bb.Write(preamble2); + bb.Write((short)lcid); + bb.Write((short)codepage); + bb.Write(stringFileInfo); + } + + private static void WriteUTF16Z(ByteBuffer bb, string str) + { + foreach (char c in str) + { + bb.Write((short)c); + } + bb.Write((short)0); + } + + private static void WriteString(ByteBuffer bb, string name, string value) + { + value = value ?? " "; + int pos = bb.Position; + bb.Write((short)0); // wLength (placeholder) + bb.Write((short)(value.Length + 1));// wValueLength + bb.Write((short)1); // wType + WriteUTF16Z(bb, name); + bb.Align(4); + WriteUTF16Z(bb, value); + bb.Align(4); + int savedPos = bb.Position; + bb.Position = pos; + bb.Write((short)(savedPos - pos)); + bb.Position = savedPos; + } + + private static Version ParseVersionRobust(string ver) + { + int index = 0; + ushort major = ParseVersionPart(ver, ref index); + ushort minor = ParseVersionPart(ver, ref index); + ushort build = ParseVersionPart(ver, ref index); + ushort revision = ParseVersionPart(ver, ref index); + return new Version(major, minor, build, revision); + } + + private static ushort ParseVersionPart(string str, ref int pos) + { + ushort value = 0; + while (pos < str.Length) + { + char c = str[pos]; + if (c == '.') + { + pos++; + break; + } + else if (c >= '0' && c <= '9') + { + value *= 10; + value += (ushort)(c - '0'); + pos++; + } + else + { + break; + } + } + return value; + } + } +} diff --git a/mcs/class/IKVM.Reflection/reflect.build b/mcs/class/IKVM.Reflection/reflect.build new file mode 100644 index 000000000000..972aacceff7c --- /dev/null +++ b/mcs/class/IKVM.Reflection/reflect.build @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f9d82bd990d1fe8a9f8b266f6dc66b45de96ac1f Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 09:30:32 +0000 Subject: [PATCH 40/93] dist IKVM.Reflection --- mcs/class/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index cf2d076dc35e..a052f7ab977c 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -199,7 +199,7 @@ include ../build/rules.make SUBDIRS = $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) $(moonlight_dirs) $(mobile_dirs) $(net_4_0_dirs) -DIST_ONLY_SUBDIRS = dlr +DIST_ONLY_SUBDIRS = dlr IKVM.Reflection # No new makefiles for: System.Messaging, System.Web.Mobile, # System.ServiceProcess From 49b0253a7fb0cc7bc3500727d028bf6712b09bfb Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 09:59:39 +0000 Subject: [PATCH 41/93] Switch to single mcs compiler for all managed code build --- mcs/Makefile | 34 ++-- mcs/build/profiles/monodroid.make | 12 +- mcs/build/profiles/monotouch.make | 12 +- mcs/build/profiles/moonlight_raw.make | 12 +- mcs/build/profiles/net_2_0.make | 8 +- mcs/build/profiles/net_3_5.make | 7 +- mcs/build/profiles/net_4_0.make | 13 +- mcs/build/rules.make | 8 +- mcs/class/Makefile | 29 +-- .../Makefile | 2 +- mcs/class/System.Core/Makefile | 9 +- .../System.Web.Extensions.Design_1.0/Makefile | 3 +- mcs/class/System.XML/Makefile | 4 - mcs/class/aot-compiler/Makefile | 13 +- mcs/class/corlib/Makefile | 11 +- mcs/mcs/Makefile | 11 +- mcs/mcs/mcs.csproj | 176 ++++++++++++++++++ mcs/mcs/mcs.exe.sources | 67 +++++++ 18 files changed, 307 insertions(+), 124 deletions(-) create mode 100644 mcs/mcs/mcs.csproj create mode 100644 mcs/mcs/mcs.exe.sources diff --git a/mcs/Makefile b/mcs/Makefile index bc2ce2139e3c..99d143abf372 100644 --- a/mcs/Makefile +++ b/mcs/Makefile @@ -3,18 +3,13 @@ thisdir := . SUBDIRS := build jay mcs class nunit24 ilasm tools tests errors docs basic_SUBDIRS := build jay mcs class tools -net_2_0_bootstrap_SUBDIRS := build tools -net_2_0_SUBDIRS := build mcs class nunit24 ilasm tools tests errors -moonlight_bootstrap_SUBDIRS := build mcs class -moonlight_raw_SUBDIRS := build mcs class tools -moonlight_SUBDIRS := tools tests errors -monodroid_bootstrap_SUBDIRS := build mcs class -monodroid_SUBDIRS := build mcs class -monotouch_bootstrap_SUBDIRS := build mcs class -monotouch_SUBDIRS := build mcs class +net_2_0_SUBDIRS := build class nunit24 ilasm tools tests errors mcs +moonlight_raw_SUBDIRS := build class tools mcs +moonlight_SUBDIRS := tools +monodroid_SUBDIRS := build class mcs +monotouch_SUBDIRS := build class mcs net_3_5_SUBDIRS := build class tools/xbuild -net_4_0_bootstrap_SUBDIRS := build mcs class tools -net_4_0_SUBDIRS := build mcs class nunit24 ilasm tools tests errors docs +net_4_0_SUBDIRS := build class nunit24 ilasm tools tests errors docs mcs # List of test subdirs that should pass 100% centum_tests := \ @@ -105,18 +100,13 @@ profiles-do--run-test: # Orchestrate the bootstrap here. _boot_ = all clean install -$(_boot_:%=profile-do--net_4_0--%): profile-do--net_4_0--%: profile-do--net_4_0_bootstrap--% -$(_boot_:%=profile-do--net_4_0_bootstrap--%): profile-do--net_4_0_bootstrap--%: profile-do--net_2_0--% +$(_boot_:%=profile-do--net_4_0--%): profile-do--net_4_0--%: profile-do--basic--% $(_boot_:%=profile-do--net_3_5--%): profile-do--net_3_5--%: profile-do--net_2_0--% -$(_boot_:%=profile-do--moonlight--%): profile-do--moonlight--%: profile-do--moonlight_raw--% -$(_boot_:%=profile-do--monodroid--%): profile-do--monodroid--%: profile-do--monodroid_bootstrap--% -$(_boot_:%=profile-do--monodroid_bootstrap--%): profile-do--monodroid_bootstrap--%: profile-do--net_2_0--% -$(_boot_:%=profile-do--monotouch--%): profile-do--monotouch--%: profile-do--monotouch_bootstrap--% -$(_boot_:%=profile-do--monotouch_bootstrap--%): profile-do--monotouch_bootstrap--%: profile-do--net_2_0--% -$(_boot_:%=profile-do--moonlight_raw--%): profile-do--moonlight_raw--%: profile-do--moonlight_bootstrap--% -$(_boot_:%=profile-do--moonlight_bootstrap--%): profile-do--moonlight_bootstrap--%: profile-do--basic--% -$(_boot_:%=profile-do--net_2_0--%): profile-do--net_2_0--%: profile-do--net_2_0_bootstrap--% -$(_boot_:%=profile-do--net_2_0_bootstrap--%): profile-do--net_2_0_bootstrap--%: profile-do--basic--% +$(_boot_:%=profile-do--moonlight--%): profile-do--moonlight--%: profile-do--moonlight_raw--% +$(_boot_:%=profile-do--monodroid--%): profile-do--monodroid--%: profile-do--basic--% +$(_boot_:%=profile-do--monotouch--%): profile-do--monotouch--%: profile-do--basic--% +$(_boot_:%=profile-do--moonlight_raw--%): profile-do--moonlight_raw--%: profile-do--basic--% +$(_boot_:%=profile-do--net_2_0--%): profile-do--net_2_0--%: profile-do--basic--% testcorlib: @cd class/corlib && $(MAKE) test run-test diff --git a/mcs/build/profiles/monodroid.make b/mcs/build/profiles/monodroid.make index b4cb827d2909..533af51b6851 100644 --- a/mcs/build/profiles/monodroid.make +++ b/mcs/build/profiles/monodroid.make @@ -1,17 +1,15 @@ #! -*- makefile -*- -my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack -INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe +BOOTSTRAP_PROFILE = basic -BOOTSTRAP_PROFILE = monodroid_bootstrap - -BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS) +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONODROID +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONODROID -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) FRAMEWORK_VERSION = 2.1 NO_TEST = yes diff --git a/mcs/build/profiles/monotouch.make b/mcs/build/profiles/monotouch.make index 6fcbf98da853..31dce07bacec 100644 --- a/mcs/build/profiles/monotouch.make +++ b/mcs/build/profiles/monotouch.make @@ -1,17 +1,15 @@ #! -*- makefile -*- -my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack -INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe +BOOTSTRAP_PROFILE = basic -BOOTSTRAP_PROFILE = monotouch_bootstrap - -BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS) +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONOTOUCH +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONOTOUCH -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) FRAMEWORK_VERSION = 2.1 NO_TEST = yes diff --git a/mcs/build/profiles/moonlight_raw.make b/mcs/build/profiles/moonlight_raw.make index f3aba438b8f5..1c530545ec54 100644 --- a/mcs/build/profiles/moonlight_raw.make +++ b/mcs/build/profiles/moonlight_raw.make @@ -1,17 +1,15 @@ #! -*- makefile -*- -my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack -INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe +BOOTSTRAP_PROFILE = basic -BOOTSTRAP_PROFILE = moonlight_bootstrap - -BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS) +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) FRAMEWORK_VERSION = 2.1 NO_TEST = yes diff --git a/mcs/build/profiles/net_2_0.make b/mcs/build/profiles/net_2_0.make index 03ce4e94f7f1..796c78290e6e 100644 --- a/mcs/build/profiles/net_2_0.make +++ b/mcs/build/profiles/net_2_0.make @@ -1,14 +1,16 @@ # -*- makefile -*- BOOTSTRAP_PROFILE = basic -BUILD_TOOLS_PROFILE = net_2_0_bootstrap +BUILD_TOOLS_PROFILE = net_2_0 BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) # nuttzing! profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -nowarn:1699 +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) + FRAMEWORK_VERSION = 2.0 diff --git a/mcs/build/profiles/net_3_5.make b/mcs/build/profiles/net_3_5.make index 07248ff39c66..71b8b60ad6a0 100644 --- a/mcs/build/profiles/net_3_5.make +++ b/mcs/build/profiles/net_3_5.make @@ -1,14 +1,15 @@ # -*- makefile -*- -INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/net_2_0/gmcs.exe +MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) # nuttzing! profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_5 +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_5 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) -lib:$(topdir)/class/lib/net_2_0 $(DEFAULT_REFERENCES) + FRAMEWORK_VERSION = 3.5 TEST_HARNESS = $(topdir)/class/lib/net_2_0/nunit-console.exe diff --git a/mcs/build/profiles/net_4_0.make b/mcs/build/profiles/net_4_0.make index dd9dab464ea6..4574b47a0906 100644 --- a/mcs/build/profiles/net_4_0.make +++ b/mcs/build/profiles/net_4_0.make @@ -1,17 +1,16 @@ # -*- makefile -*- -INTERNAL_DMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/dmcs.exe +BOOTSTRAP_PROFILE = basic -BOOTSTRAP_PROFILE = net_4_0_bootstrap - -BOOTSTAP_DMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/dmcs.exe -BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(BOOTSTAP_DMCS) -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_DMCS) +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) # nuttzing! profile-check: @: -PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 +DEFAULT_REFERENCES = -r:mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) + FRAMEWORK_VERSION = 4.0 diff --git a/mcs/build/rules.make b/mcs/build/rules.make index b9a1d3e4be46..5ba5d649d791 100644 --- a/mcs/build/rules.make +++ b/mcs/build/rules.make @@ -36,9 +36,8 @@ INSTALL_DATA = $(INSTALL) -c -m 644 INSTALL_BIN = $(INSTALL) -c -m 755 INSTALL_LIB = $(INSTALL_BIN) MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs -INTERNAL_MCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/mcs.exe INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe -INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/gmcs.exe +INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/basic/mcs.exe INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe corlib = mscorlib.dll @@ -197,11 +196,6 @@ dist-default: $(MKINSTALLDIRS) $(@D) touch $@ -# Useful - -withmcs: - $(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all - ## Documentation stuff Q_MDOC =$(if $(V),,@echo "MDOC [$(PROFILE)] $(notdir $(@))";) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index a052f7ab977c..f8680aebb35a 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -1,19 +1,8 @@ thisdir = class -bootstrap_dirs := \ - corlib \ - Mono.CompilerServices.SymbolWriter \ - System \ - System.XML \ - Mono.Security \ - System.Security \ - System.Configuration \ - System - - # Note that Mono.Security and System.Security aren't listed. # We may have to add those if 'mcs' starts using them. -basic_SUBDIRS := corlib System System.XML System Mono.Security Mono.CompilerServices.SymbolWriter System.Core +basic_SUBDIRS := corlib System System.XML System Mono.Security Mono.CompilerServices.SymbolWriter System.Core aot-compiler net_1_1_java_SUBDIRS = \ System.Xml \ @@ -37,7 +26,6 @@ common_dirs := \ System.Configuration \ System \ System.XML \ - aot-compiler \ I18N \ System.Drawing \ System.Transactions \ @@ -124,17 +112,11 @@ net_2_0_only_dirs := \ System.Web.Extensions.Design_1.0 \ Compat.ICSharpCode.SharpZipLib -net_2_1_bootstrap_dirs := \ - corlib \ - System \ - Mono.CompilerServices.SymbolWriter \ - System.Core - moonlight_dirs := \ corlib \ + System \ Mono.CompilerServices.SymbolWriter \ System.Core \ - System \ System.XML \ System.Net \ System.Xml.Linq \ @@ -145,9 +127,9 @@ moonlight_dirs := \ mobile_dirs := \ corlib \ + System \ Mono.CompilerServices.SymbolWriter \ System.Core \ - System \ System.XML \ Mono.Security \ System \ @@ -183,16 +165,11 @@ net_4_0_dirs := \ System.Runtime.DurableInstancing \ Mono.CodeContracts -net_2_0_bootstrap_SUBDIRS := $(bootstrap_dirs) net_2_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) -moonlight_bootstrap_SUBDIRS := $(net_2_1_bootstrap_dirs) moonlight_raw_SUBDIRS := $(moonlight_dirs) -monodroid_bootstrap_SUBDIRS := $(net_2_1_bootstrap_dirs) monodroid_SUBDIRS := $(mobile_dirs) -monotouch_bootstrap_SUBDIRS := $(net_2_1_bootstrap_dirs) monotouch_SUBDIRS := $(mobile_dirs) net_3_5_SUBDIRS := $(net_3_5_only_dirs) -net_4_0_bootstrap_SUBDIRS := $(bootstrap_dirs) Mono.Posix System.Core net_4_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_4_0_dirs) include ../build/rules.make diff --git a/mcs/class/Mono.CompilerServices.SymbolWriter/Makefile b/mcs/class/Mono.CompilerServices.SymbolWriter/Makefile index 4e8f2ab38911..db8e873762e6 100644 --- a/mcs/class/Mono.CompilerServices.SymbolWriter/Makefile +++ b/mcs/class/Mono.CompilerServices.SymbolWriter/Makefile @@ -5,7 +5,7 @@ include ../../build/rules.make LIBRARY = Mono.CompilerServices.SymbolWriter.dll LIBRARY_USE_INTERMEDIATE_FILE = yes -LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll +LIB_MCS_FLAGS = /r:System.dll NO_TEST = yes ifneq (basic, $(PROFILE)) diff --git a/mcs/class/System.Core/Makefile b/mcs/class/System.Core/Makefile index b58458bd527f..ffc843a60ba7 100644 --- a/mcs/class/System.Core/Makefile +++ b/mcs/class/System.Core/Makefile @@ -4,7 +4,7 @@ include ../../build/rules.make LIBRARY = System.Core.dll -LIB_MCS_FLAGS = -d:INSIDE_SYSCORE -d:LIBC /r:$(corlib) /r:System +LIB_MCS_FLAGS = -d:INSIDE_SYSCORE -d:LIBC /r:$(corlib) /r:System.dll ifneq (2.1, $(FRAMEWORK_VERSION)) LIB_MCS_FLAGS += -d:NET_3_5 -nowarn:1720 @@ -18,17 +18,12 @@ ifeq (4.0, $(FRAMEWORK_VERSION)) LIB_MCS_FLAGS += -d:CODEPLEX_40 endif -FULL_PROFILE := $(filter net_2_0 net_4_0 moonlight_raw monotouch monodroid, $(PROFILE)) -ifdef FULL_PROFILE -LIBRARY_COMPILE = $(BOOT_COMPILE) -endif - ifneq (basic, $(PROFILE)) CLR_PROFILE := $(filter 2.0 4.0, $(FRAMEWORK_VERSION)) endif ifdef CLR_PROFILE -LIB_MCS_FLAGS += -r:../lib/$(PROFILE)/Mono.Posix -unsafe +LIB_MCS_FLAGS += -r:Mono.Posix.dll -unsafe endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Web.Extensions.Design_1.0/Makefile b/mcs/class/System.Web.Extensions.Design_1.0/Makefile index b428b81e78d8..6c70c897850e 100644 --- a/mcs/class/System.Web.Extensions.Design_1.0/Makefile +++ b/mcs/class/System.Web.Extensions.Design_1.0/Makefile @@ -8,8 +8,7 @@ LIBRARY_COMPAT = yes NO_TEST = yes LIB_MCS_FLAGS = \ - -r:System.dll \ - -r:System.Design.dll \ + -r:System.dll -r:System.Design.dll -r:System.Drawing.dll \ $(OTHER_LIB_MCS_FLAGS) include ../../build/library.make diff --git a/mcs/class/System.XML/Makefile b/mcs/class/System.XML/Makefile index ff68bdcee1ae..418e94f57f4a 100644 --- a/mcs/class/System.XML/Makefile +++ b/mcs/class/System.XML/Makefile @@ -10,10 +10,6 @@ ifndef lib_file USE_BOOT_COMPILE = yes endif -ifeq (monotouch, $(PROFILE)) -BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/monotouch$(PLATFORM_PATH_SEPARATOR)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS) -endif - ifdef USE_BOOT_COMPILE LIBRARY_COMPILE = $(BOOT_COMPILE) endif diff --git a/mcs/class/aot-compiler/Makefile b/mcs/class/aot-compiler/Makefile index 567c7dbcb75b..af2fea017770 100644 --- a/mcs/class/aot-compiler/Makefile +++ b/mcs/class/aot-compiler/Makefile @@ -10,12 +10,7 @@ include ../../build/rules.make the_libdir = $(topdir)/class/lib/$(PROFILE)/ -ifeq (net_2_0, $(PROFILE)) -mcs_exe = $(the_libdir)/gmcs.exe -else ifeq (net_4_0, $(PROFILE)) -mcs_exe = $(the_libdir)/dmcs.exe -endif - +mcs_exe = $(the_libdir)/mcs.exe mcs_aot_image = $(mcs_exe)$(PLATFORM_AOT_SUFFIX) mscorlib_dll = $(the_libdir)/mscorlib.dll @@ -34,13 +29,7 @@ $(mscorlib_aot_image): $(mscorlib_dll) ifdef ENABLE_AOT -ifeq (net_2_0, $(PROFILE)) -all-local: $(mscorlib_aot_image) $(mcs_aot_image) -endif - -ifeq (net_4_0, $(PROFILE)) all-local: $(mscorlib_aot_image) $(mcs_aot_image) -endif clean-local: -rm -f $(mscorlib_aot_image) $(mcs_aot_image) $(PROFILE)_aot.log diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile index 25cdd80c95aa..5c99b77bd010 100644 --- a/mcs/class/corlib/Makefile +++ b/mcs/class/corlib/Makefile @@ -5,9 +5,13 @@ export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib LIBRARY = corlib.dll LIBRARY_NAME = mscorlib.dll -LIB_MCS_FLAGS = $(corlib_flags) $(RESOURCE_FILES:%=-resource:%) +LIB_MCS_FLAGS = $(RESOURCE_FILES:%=-resource:%) LIBRARY_USE_INTERMEDIATE_FILE = yes +ifeq (4.0, $(FRAMEWORK_VERSION)) +LIB_MCS_FLAGS += --runtime:v4 +endif + LIBRARY_COMPILE = $(BOOT_COMPILE) LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION) @@ -20,8 +24,8 @@ RESOURCE_FILES = \ resources/collation.cjkKO.bin \ resources/collation.cjkKOlv2.bin -corlib_flags = -unsafe -nostdlib -LOCAL_MCS_FLAGS = -nowarn:612,618 -d:INSIDE_CORLIB -d:LIBC +LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618 -d:INSIDE_CORLIB -d:LIBC +DEFAULT_REFERENCES = # System.IO/DirectoryInfoTest.cs needs Mono.Posix TEST_MCS_FLAGS = -debug+ -debug:full -nowarn:168,219,618,672 -unsafe -r:$(topdir)/class/lib/$(PROFILE)/Mono.Posix.dll -define:MONO_DATACONVERTER_STATIC_METHODS @@ -43,6 +47,7 @@ include $(topdir)/build/library.make ifdef FIXME_CORLIB_CMP # corlib_cmp +corlib_flags = -unsafe -nostdlib cmplib = $(topdir)/class/lib/$(PROFILE)/corlib_cmp.dll cmppdb = $(cmplib:.dll=.pdb) cmp_response = $(depsdir)/$(PROFILE)_corlib_cmp.dll.response diff --git a/mcs/mcs/Makefile b/mcs/mcs/Makefile index 4599b6f8d59d..e7c27cfb32e8 100644 --- a/mcs/mcs/Makefile +++ b/mcs/mcs/Makefile @@ -12,14 +12,13 @@ EXTRA_DISTFILES = \ TODO \ *mcs.exe.config -COMPILER_NAME = gmcs - -ifeq (net_2_0, $(PROFILE)) -INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe +ifeq (basic, $(PROFILE)) +LOCAL_MCS_FLAGS += -d:STATIC +COMPILER_NAME = mcs endif -ifeq (moonlight_bootstrap, $(PROFILE)) -INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe +ifeq (net_2_0, $(PROFILE)) +COMPILER_NAME = gmcs endif ifeq (2.1, $(FRAMEWORK_VERSION)) diff --git a/mcs/mcs/mcs.csproj b/mcs/mcs/mcs.csproj new file mode 100644 index 000000000000..e5fdb950202a --- /dev/null +++ b/mcs/mcs/mcs.csproj @@ -0,0 +1,176 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {D4A01C5B-A1B5-48F5-BB5B-D2E1BD236E56} + Exe + Properties + Mono.CSharp + mcs + v4.0 + 512 + x86 + + + true + full + false + .\ + TRACE;DEBUG;NET_4_0;STATIC + prompt + 4 + true + + + pdbonly + true + TRACE;NET_4_0;STATIC + prompt + prompt + 4 + .\ + + + + + + + + + + CryptoConvert.cs + + + MonoSymbolFile.cs + + + MonoSymbolTable.cs + + + MonoSymbolWriter.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + outline.cs + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + + + \ No newline at end of file diff --git a/mcs/mcs/mcs.exe.sources b/mcs/mcs/mcs.exe.sources new file mode 100644 index 000000000000..bc28dbf84818 --- /dev/null +++ b/mcs/mcs/mcs.exe.sources @@ -0,0 +1,67 @@ +AssemblyInfo.cs +anonymous.cs +argument.cs +assign.cs +assembly.cs +attribute.cs +cs-tokenizer.cs +cfold.cs +class.cs +codegen.cs +complete.cs +const.cs +constant.cs +convert.cs +context.cs +decl.cs +delegate.cs +doc.cs +driver.cs +dynamic.cs +ecore.cs +enum.cs +eval.cs +expression.cs +field.cs +flowanalysis.cs +generic.cs +import.cs +iterators.cs +ikvm.cs +lambda.cs +linq.cs +literal.cs +location.cs +membercache.cs +method.cs +modifiers.cs +namespace.cs +nullable.cs +parameter.cs +pending.cs +property.cs +reflection.cs +report.cs +rootcontext.cs +roottypes.cs +statement.cs +support.cs +typemanager.cs +typespec.cs +visit.cs +symbolwriter.cs +../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs +../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs +../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs +../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs +../build/common/Consts.cs +../tools/monop/outline.cs + +../class/IKVM.Reflection/*.cs +../class/IKVM.Reflection/Emit/*.cs +../class/IKVM.Reflection/Metadata/*.cs +../class/IKVM.Reflection/Reader/*.cs +../class/IKVM.Reflection/Writer/*.cs +../class/IKVM.Reflection/Impl/CryptoHack.cs +../class/IKVM.Reflection/Impl/ITypeOwner.cs +../class/IKVM.Reflection/Impl/SymbolSupport.cs From de0d03146ae0512bcc0d70f4fd69fb8b71e55671 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 10:05:48 +0000 Subject: [PATCH 42/93] Add dist only Makefile --- mcs/class/IKVM.Reflection/Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mcs/class/IKVM.Reflection/Makefile diff --git a/mcs/class/IKVM.Reflection/Makefile b/mcs/class/IKVM.Reflection/Makefile new file mode 100644 index 000000000000..069df18f31eb --- /dev/null +++ b/mcs/class/IKVM.Reflection/Makefile @@ -0,0 +1,18 @@ +thisdir = class/IKVM.Reflection +SUBDIRS = + +include ../../build/rules.make + +DISTFILES = \ + Emit/*.cs \ + Impl/*.cs \ + Metadata/*.cs \ + Properties/*.cs \ + Reader/*.cs \ + Writer/*.cs \ + *.cs *.csproj \ + Makefile + +all-local install-local clean-local test-local run-test-local run-test-ondotnet-local uninstall-local doc-update-local csproj-local: + +dist-local: dist-default From 1fef6badac564e101f25fccd5455740ee1d35272 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 11:44:06 +0000 Subject: [PATCH 43/93] Fix resgen build order --- mcs/Makefile | 4 ++-- mcs/build/profiles/net_2_0.make | 1 - mcs/build/rules.make | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mcs/Makefile b/mcs/Makefile index 99d143abf372..90b8172b3a9a 100644 --- a/mcs/Makefile +++ b/mcs/Makefile @@ -3,13 +3,13 @@ thisdir := . SUBDIRS := build jay mcs class nunit24 ilasm tools tests errors docs basic_SUBDIRS := build jay mcs class tools -net_2_0_SUBDIRS := build class nunit24 ilasm tools tests errors mcs +net_2_0_SUBDIRS := build tools/resgen tools/culevel class nunit24 ilasm tools tests errors mcs moonlight_raw_SUBDIRS := build class tools mcs moonlight_SUBDIRS := tools monodroid_SUBDIRS := build class mcs monotouch_SUBDIRS := build class mcs net_3_5_SUBDIRS := build class tools/xbuild -net_4_0_SUBDIRS := build class nunit24 ilasm tools tests errors docs mcs +net_4_0_SUBDIRS := build tools/resgen tools/culevel class nunit24 ilasm tools tests errors docs mcs # List of test subdirs that should pass 100% centum_tests := \ diff --git a/mcs/build/profiles/net_2_0.make b/mcs/build/profiles/net_2_0.make index 796c78290e6e..0f79ea0f7649 100644 --- a/mcs/build/profiles/net_2_0.make +++ b/mcs/build/profiles/net_2_0.make @@ -1,7 +1,6 @@ # -*- makefile -*- BOOTSTRAP_PROFILE = basic -BUILD_TOOLS_PROFILE = net_2_0 BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) diff --git a/mcs/build/rules.make b/mcs/build/rules.make index 5ba5d649d791..da82cbf0220b 100644 --- a/mcs/build/rules.make +++ b/mcs/build/rules.make @@ -42,7 +42,7 @@ INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilas corlib = mscorlib.dll ifndef BUILD_TOOLS_PROFILE -BUILD_TOOLS_PROFILE = $(BOOTSTRAP_PROFILE) +BUILD_TOOLS_PROFILE = $(PROFILE) endif INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/resgen.exe From 8bb7d1d7b3ec14b52deacecc6c380e4ee4d010ae Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 12:06:53 +0000 Subject: [PATCH 44/93] Monolite mcs compiler --- mcs/class/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index f8680aebb35a..03363820c5c1 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -202,9 +202,8 @@ DISTFILES = \ all-local $(STD_TARGETS:=-local): @: -# What is this used for ? - -basic_files = gmcs.exe mscorlib.dll System.dll System.Xml.dll Mono.Security.dll System.Core.dll +# Files needed to bootstrap C# compiler +basic_files = mcs.exe mscorlib.dll System.dll System.Xml.dll Mono.Security.dll System.Core.dll monolite_files = $(basic_files:%=lib/monolite/%) lib/monolite: From de462599f2ba1add41730dfca7f553d021979a2a Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 12:16:23 +0000 Subject: [PATCH 45/93] Adjust MONO_PATH, it's still needed for all profiles --- mcs/build/profiles/net_3_5.make | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcs/build/profiles/net_3_5.make b/mcs/build/profiles/net_3_5.make index 71b8b60ad6a0..6bd8a93423ce 100644 --- a/mcs/build/profiles/net_3_5.make +++ b/mcs/build/profiles/net_3_5.make @@ -1,6 +1,8 @@ # -*- makefile -*- -MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) +BOOTSTRAP_PROFILE = basic + +MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS) # nuttzing! From 4eaa975aa3d38ed7a1a606b038847165e597a287 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 12:42:29 +0000 Subject: [PATCH 46/93] Don't build aot symbols on make dist --- mcs/class/Makefile | 2 +- mcs/class/aot-compiler/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index 03363820c5c1..da5b9590392f 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -214,7 +214,7 @@ $(monolite_files): lib/monolite/%: lib/basic/% cp -p $< $@ $(basic_files:%=lib/basic/%): - cd $(topdir) && $(MAKE) profile-do--basic--all + cd $(topdir) && $(MAKE) profile-do--basic--all SKIP_AOT=1 dist-default: $(monolite_files) dist-local: dist-default diff --git a/mcs/class/aot-compiler/Makefile b/mcs/class/aot-compiler/Makefile index af2fea017770..dc3a0bd438fa 100644 --- a/mcs/class/aot-compiler/Makefile +++ b/mcs/class/aot-compiler/Makefile @@ -19,6 +19,8 @@ mscorlib_aot_image = $(mscorlib_dll)$(PLATFORM_AOT_SUFFIX) PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION) LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION) +ifndef SKIP_AOT + ifdef PLATFORM_AOT_SUFFIX Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";) $(mcs_aot_image): $(mcs_exe) @@ -43,4 +45,6 @@ endif endif +endif + dist-local: dist-default From 9b61c27be8abd329358838b4aab1fcdc36ef02e7 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 13:04:10 +0000 Subject: [PATCH 47/93] Updated mcs translations, added Brazilian Portuguese --- po/mcs/LINGUAS | 1 + po/mcs/POTFILES.in | 12 +- po/mcs/de.po | 3358 ++++++++++++++++++-------------- po/mcs/es.po | 3635 +++++++++++++++++++--------------- po/mcs/ja.po | 3878 +++++++++++++++++++++---------------- po/mcs/mcs.pot | 3130 +++++++++++++++++------------- po/mcs/pt_BR.po | 4614 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 12741 insertions(+), 5887 deletions(-) create mode 100644 po/mcs/pt_BR.po diff --git a/po/mcs/LINGUAS b/po/mcs/LINGUAS index dc8819e43ca9..5751de4be9b6 100644 --- a/po/mcs/LINGUAS +++ b/po/mcs/LINGUAS @@ -1,3 +1,4 @@ es ja de +pt_BR \ No newline at end of file diff --git a/po/mcs/POTFILES.in b/po/mcs/POTFILES.in index bf6805ba9314..2a4baddf0ef6 100644 --- a/po/mcs/POTFILES.in +++ b/po/mcs/POTFILES.in @@ -1,11 +1,14 @@ # List of source files which contain translatable strings. mcs/mcs/anonymous.cs +mcs/mcs/argument.cs mcs/mcs/assign.cs mcs/mcs/attribute.cs +mcs/mcs/cs-parser.cs mcs/mcs/cs-tokenizer.cs mcs/mcs/cfold.cs mcs/mcs/class.cs mcs/mcs/codegen.cs +mcs/mcs/complete.cs mcs/mcs/const.cs mcs/mcs/constant.cs mcs/mcs/convert.cs @@ -13,27 +16,34 @@ mcs/mcs/decl.cs mcs/mcs/delegate.cs mcs/mcs/doc.cs mcs/mcs/driver.cs +mcs/mcs/dynamic.cs mcs/mcs/ecore.cs mcs/mcs/enum.cs mcs/mcs/eval.cs mcs/mcs/expression.cs +mcs/mcs/field.cs mcs/mcs/flowanalysis.cs mcs/mcs/generic.cs +mcs/mcs/import.cs mcs/mcs/iterators.cs mcs/mcs/lambda.cs mcs/mcs/linq.cs mcs/mcs/literal.cs mcs/mcs/location.cs +mcs/mcs/membercache.cs +mcs/mcs/method.cs mcs/mcs/modifiers.cs mcs/mcs/namespace.cs mcs/mcs/nullable.cs mcs/mcs/parameter.cs mcs/mcs/pending.cs +mcs/mcs/property.cs +mcs/mcs/reflection.cs mcs/mcs/report.cs mcs/mcs/rootcontext.cs mcs/mcs/roottypes.cs mcs/mcs/statement.cs mcs/mcs/support.cs +mcs/mcs/typespec.cs mcs/mcs/typemanager.cs mcs/mcs/symbolwriter.cs - diff --git a/po/mcs/de.po b/po/mcs/de.po index bf3a16eb9455..278bc7892e0b 100644 --- a/po/mcs/de.po +++ b/po/mcs/de.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2008-09-29 12:41-0300\n" +"POT-Creation-Date: 2010-12-16 13:01+0000\n" "PO-Revision-Date: 2008-09-26 15:14+0100\n" "Last-Translator: Daniel Nauck \n" "Language-Team: http://www.mono-project.de\n" @@ -13,82 +13,110 @@ msgstr "" "X-Poedit-Language: German\n" "X-Poedit-Country: GERMANY\n" -#: ../mcs/mcs/anonymous.cs:850 +#: mcs/mcs/anonymous.cs:880 #, csharp-format msgid "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:856 +#: mcs/mcs/anonymous.cs:885 #, csharp-format msgid "Cannot convert `{0}' to non-delegate type `{1}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:868 +#: mcs/mcs/anonymous.cs:897 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' since there is a parameter " "mismatch" msgstr "" -#: ../mcs/mcs/anonymous.cs:880 ../mcs/mcs/delegate.cs:568 +#: mcs/mcs/anonymous.cs:909 mcs/mcs/ecore.cs:4469 #, csharp-format msgid "Delegate `{0}' does not take `{1}' arguments" msgstr "" -#: ../mcs/mcs/anonymous.cs:895 +#: mcs/mcs/anonymous.cs:924 #, csharp-format msgid "Parameter `{0}' should not be declared with the `{1}' keyword" msgstr "" -#: ../mcs/mcs/anonymous.cs:898 +#: mcs/mcs/anonymous.cs:927 #, csharp-format msgid "Parameter `{0}' must be declared with the `{1}' keyword" msgstr "" -#: ../mcs/mcs/anonymous.cs:919 +#: mcs/mcs/anonymous.cs:948 #, csharp-format msgid "Parameter `{0}' is declared as type `{1}' but should be `{2}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:1043 +#: mcs/mcs/anonymous.cs:1103 msgid "An anonymous method cannot be converted to an expression tree" msgstr "" -#: ../mcs/mcs/anonymous.cs:1060 +#: mcs/mcs/anonymous.cs:1122 #, csharp-format msgid "" "Cannot convert anonymous method block without a parameter list to delegate " -"type `{0}' because it has one or more `out' parameters." +"type `{0}' because it has one or more `out' parameters" msgstr "" -#: ../mcs/mcs/anonymous.cs:1085 +#: mcs/mcs/anonymous.cs:1146 msgid "" "Anonymous methods and lambda expressions cannot be used in the current " "context" msgstr "" -#: ../mcs/mcs/anonymous.cs:1122 +#: mcs/mcs/anonymous.cs:1188 #, csharp-format msgid "" "Local variable or parameter `{0}' cannot have their address taken and be " "used inside an anonymous method or lambda expression" msgstr "" -#: ../mcs/mcs/anonymous.cs:1353 +#: mcs/mcs/anonymous.cs:1438 msgid "An expression tree cannot contain an anonymous method expression" msgstr "" -#: ../mcs/mcs/anonymous.cs:1647 +#: mcs/mcs/argument.cs:101 +msgid "" +"An expression tree cannot contain an invocation which uses optional parameter" +msgstr "" + +#: mcs/mcs/argument.cs:184 +msgid "An expression tree cannot contain named argument" +msgstr "" + +#: mcs/mcs/argument.cs:303 #, csharp-format msgid "" -"`{0}': An anonymous type cannot have multiple properties with the same name" +"The method group `{0}' cannot be used as an argument of dynamic operation. " +"Consider using parentheses to invoke the method" +msgstr "" + +#: mcs/mcs/argument.cs:307 +msgid "" +"An anonymous method or lambda expression cannot be used as an argument of " +"dynamic operation. Consider using a cast" +msgstr "" + +#: mcs/mcs/argument.cs:310 +#, csharp-format +msgid "" +"An expression of type `{0}' cannot be used as an argument of dynamic " +"operation" msgstr "" -#: ../mcs/mcs/assign.cs:325 +#: mcs/mcs/assign.cs:299 msgid "An expression tree cannot contain an assignment operator" msgstr "" -#: ../mcs/mcs/attribute.cs:165 +#: mcs/mcs/assign.cs:627 +#, csharp-format +msgid "Cannot assign to `{0}' because it is a `{1}'" +msgstr "" + +#: mcs/mcs/attribute.cs:196 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument. Named attribute arguments " @@ -96,2176 +124,2219 @@ msgid "" "properties which are public and not static" msgstr "" -#: ../mcs/mcs/attribute.cs:173 +#: mcs/mcs/attribute.cs:205 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument because it is not a valid " "attribute parameter type" msgstr "" -#: ../mcs/mcs/attribute.cs:180 -msgid "" -"An attribute argument must be a constant expression, typeof expression or " -"array creation expression" -msgstr "" - -#: ../mcs/mcs/attribute.cs:187 -msgid "Can not use a type parameter in an attribute" +#: mcs/mcs/attribute.cs:211 +msgid "An attribute argument cannot be dynamic expression" msgstr "" -#: ../mcs/mcs/attribute.cs:192 +#: mcs/mcs/attribute.cs:216 msgid "The Guid attribute must be specified with the ComImport attribute" msgstr "" -#: ../mcs/mcs/attribute.cs:197 +#: mcs/mcs/attribute.cs:221 #, csharp-format msgid "Do not use `{0}' directly. Use parameter modifier `this' instead" msgstr "" -#: ../mcs/mcs/attribute.cs:206 +#: mcs/mcs/attribute.cs:226 +#, csharp-format +msgid "Do not use `{0}' directly. Use `dynamic' keyword instead" +msgstr "" + +#: mcs/mcs/attribute.cs:235 #, csharp-format msgid "Error during emitting `{0}' attribute. The reason is `{1}'" msgstr "" -#: ../mcs/mcs/attribute.cs:245 +#: mcs/mcs/attribute.cs:266 #, csharp-format msgid "`{0}': is not an attribute class" msgstr "" -#: ../mcs/mcs/attribute.cs:263 +#: mcs/mcs/attribute.cs:302 #, csharp-format msgid "" -"`{0}' is ambiguous between `{0}' and `{0}Attribute'. Use either `@{0}' or `" -"{0}Attribute'" +"`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}" +"Attribute'" msgstr "" -#: ../mcs/mcs/attribute.cs:365 +#: mcs/mcs/attribute.cs:385 #, csharp-format msgid "Cannot apply attribute class `{0}' because it is abstract" msgstr "" -#: ../mcs/mcs/attribute.cs:490 -msgid "Invalid value for argument to `System.AttributeUsage' attribute" -msgstr "" - -#: ../mcs/mcs/attribute.cs:498 -#, csharp-format -msgid "The argument to the `{0}' attribute must be a valid identifier" -msgstr "" - -#: ../mcs/mcs/attribute.cs:528 +#: mcs/mcs/attribute.cs:453 #, csharp-format -msgid "'{0}' duplicate named attribute argument" +msgid "Duplicate named attribute `{0}' argument" msgstr "" -#: ../mcs/mcs/attribute.cs:870 +#: mcs/mcs/attribute.cs:730 #, csharp-format msgid "" "`{0}' is not a valid attribute location for this declaration. Valid " "attribute locations for this declaration are `{1}'" msgstr "" -#: ../mcs/mcs/attribute.cs:1199 +#: mcs/mcs/attribute.cs:1004 #, csharp-format msgid "" "The attribute `{0}' is not valid on this declaration type. It is valid on `" "{1}' declarations only" msgstr "" -#: ../mcs/mcs/attribute.cs:1493 +#: mcs/mcs/attribute.cs:1022 #, csharp-format -msgid "The attribute `{0}' cannot be applied multiple times" +msgid "The argument to the `{0}' attribute must be a valid identifier" msgstr "" -#: ../mcs/mcs/attribute.cs:1661 -msgid "" -"Added modules must be marked with the CLSCompliant attribute to match the " -"assembly" +#: mcs/mcs/attribute.cs:1035 +#, csharp-format +msgid "Invalid value for argument to `{0}' attribute" +msgstr "" + +#: mcs/mcs/attribute.cs:1341 +#, csharp-format +msgid "The attribute `{0}' cannot be applied multiple times" msgstr "" -#: ../mcs/mcs/attribute.cs:1802 +#: mcs/mcs/attribute.cs:1603 #, csharp-format msgid "`{0}' is obsolete: `{1}'" msgstr "`{0}' ist veraltet: `{1}'" -#: ../mcs/mcs/cs-tokenizer.cs:1276 ../mcs/mcs/cs-tokenizer.cs:1346 -msgid "Invalid number" -msgstr "Ungültige Zahl" - -#: ../mcs/mcs/cs-tokenizer.cs:1532 -#, csharp-format -msgid "Unrecognized escape sequence `\\{0}'" +#: mcs/mcs/cs-parser.cs:1646 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1551 -msgid "Unrecognized escape sequence" +#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 +msgid "Interfaces cannot contain fields or constants" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1811 +#: mcs/mcs/cs-parser.cs:1952 #, fuzzy -msgid "Missing identifier to pre-processor directive" -msgstr "Ungültige Präprozessor Direktive" - -#: ../mcs/mcs/cs-tokenizer.cs:1821 ../mcs/mcs/cs-tokenizer.cs:1825 -#, csharp-format -msgid "Identifier expected: {0}" +msgid "Interfaces cannot contain operators" msgstr "" +"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " +"beinhalten" -#: ../mcs/mcs/cs-tokenizer.cs:2201 -msgid "Numeric constant too long" -msgstr "Numerische Konstante ist zu lang" - -#: ../mcs/mcs/cs-tokenizer.cs:2206 -msgid "Invalid preprocessor directive" -msgstr "Ungültige Präprozessor Direktive" - -#: ../mcs/mcs/cs-tokenizer.cs:2213 -#, csharp-format -msgid "Unexpected processor directive ({0})" -msgstr "Unerwartete Prozessor Direktive ({0})" - -#: ../mcs/mcs/cs-tokenizer.cs:2218 -#, csharp-format -msgid "Expected `{0}'" -msgstr "`{0}' erwartet" +#: mcs/mcs/cs-parser.cs:1958 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: ../mcs/mcs/cs-tokenizer.cs:2224 +#: mcs/mcs/cs-parser.cs:1964 msgid "" -"Cannot define or undefine preprocessor symbols after first token in file" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2230 -msgid "" -"Preprocessor directives must appear as the first non-whitespace character on " -"a line" +#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 +msgid "A const field requires a value to be provided" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2235 -msgid "Single-line comment or end-of-line expected" +#: mcs/mcs/cs-parser.cs:3602 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2280 ../mcs/mcs/cs-tokenizer.cs:3006 -msgid "Expected `#endif' directive" -msgstr "`#endif' Direktive erwartet" - -#: ../mcs/mcs/cs-tokenizer.cs:2313 ../mcs/mcs/cs-tokenizer.cs:2334 -#: ../mcs/mcs/cs-tokenizer.cs:2365 ../mcs/mcs/cs-tokenizer.cs:3004 -msgid "#endregion directive expected" -msgstr "`#endregion' Direktive erwartet" - -#: ../mcs/mcs/cs-tokenizer.cs:2420 -#, csharp-format -msgid "#error: '{0}'" -msgstr "#Fehler: '{0}'" - -#: ../mcs/mcs/cs-tokenizer.cs:2440 -msgid "The line number specified for #line directive is missing or invalid" +#: mcs/mcs/cs-parser.cs:3884 +msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2444 -msgid "Wrong preprocessor directive" -msgstr "Falsche Präprozessor Direktive" - -#: ../mcs/mcs/cs-tokenizer.cs:2474 ../mcs/mcs/cs-tokenizer.cs:2837 -msgid "Newline in constant" +#: mcs/mcs/cs-parser.cs:3948 +msgid "" +"Namespace elements cannot be explicitly declared as private, protected or " +"protected internal" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2490 -msgid "Unterminated string literal" -msgstr "Nicht beendetes Zeichenfolgeliteral" - -#: ../mcs/mcs/cs-tokenizer.cs:2537 +#: mcs/mcs/cs-parser.cs:3963 msgid "" -"The `partial' modifier can be used only immediately before `class', " -"`struct', `interface', or `void' keyword" +"Assembly and module attributes must precede all other elements except using " +"clauses and extern alias declarations" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2568 -msgid "Identifier too long (limit is 512 chars)" -msgstr "Der Bezeichner ist zu lang. (Maximal 512 Zeichen)" +#: mcs/mcs/cs-parser.cs:4080 +msgid "'<' unexpected: attributes cannot be generic" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2624 +#: mcs/mcs/cs-parser.cs:4117 +msgid "Named attribute arguments must appear after the positional arguments" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4163 #, csharp-format msgid "" -"`{0}': Any identifier with double underscores cannot be used when ISO " -"language version mode is specified" +"Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2739 -msgid "End-of-file found, '*/' expected" -msgstr "Dateiende gefunden. `*/' erwartet." +#: mcs/mcs/cs-parser.cs:4220 +#, fuzzy, csharp-format +msgid "The constant `{0}' cannot be marked static" +msgstr "`{0}': Eine abstrakte Klasse darf nicht versiegelt oder statisch sein" -#: ../mcs/mcs/cs-tokenizer.cs:2876 -msgid "Keyword, identifier, or string expected after verbatim specifier: @" +#: mcs/mcs/cs-parser.cs:4268 +msgid "Fields cannot have void type" msgstr "" -#: ../mcs/mcs/cfold.cs:66 -msgid "The operation overflows at compile time in checked mode" -msgstr "" +#: mcs/mcs/cs-parser.cs:4369 +#, fuzzy +msgid "Value or constant expected" +msgstr "Methodennamen erwartet" -#: ../mcs/mcs/cfold.cs:693 ../mcs/mcs/cfold.cs:773 -msgid "Division by constant zero" -msgstr "" +#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 +#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 +#: mcs/mcs/cs-parser.cs:5427 +#, fuzzy, csharp-format +msgid "`{0}': interface members cannot have a definition" +msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" + +#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +msgid "Constraints are not allowed on non-generic declarations" +msgstr "Einschränkungen sind nicht erlaubt für nicht generische Deklarationen" -#: ../mcs/mcs/class.cs:156 +#: mcs/mcs/cs-parser.cs:4429 #, csharp-format msgid "" -"The operator `{0}' requires a matching operator `{1}' to also be defined" +"`{0}': Cannot specify constraints for overrides and explicit interface " +"implementation methods" msgstr "" -#: ../mcs/mcs/class.cs:351 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4470 msgid "" -"Partial declarations of `{0}' must be all classes, all structs or all " -"interfaces" +"A partial method cannot define access modifier or any of abstract, extern, " +"new, override, sealed, or virtual modifiers" msgstr "" -#: ../mcs/mcs/class.cs:360 -#, csharp-format -msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" +#: mcs/mcs/cs-parser.cs:4476 +msgid "" +"A partial method must be declared within a partial class or partial struct" msgstr "" -#: ../mcs/mcs/class.cs:416 +#: mcs/mcs/cs-parser.cs:4499 #, csharp-format -msgid "" -"`{0}': explicit interface declaration can only be declared in a class or " -"struct" +msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: ../mcs/mcs/class.cs:455 ../mcs/mcs/decl.cs:2803 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 msgid "" -"A member `{0}' is already defined. Rename this member or use different " -"parameter types" +"A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: ../mcs/mcs/class.cs:572 +#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 msgid "" -"Cannot specify the `DefaultMember' attribute on type containing an indexer" +"An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: ../mcs/mcs/class.cs:855 -#, csharp-format -msgid "`{0}' is already listed in interface list" +#: mcs/mcs/cs-parser.cs:4601 +msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: ../mcs/mcs/class.cs:863 -#, csharp-format -msgid "" -"Inconsistent accessibility: base interface `{0}' is less accessible than " -"interface `{1}'" +#: mcs/mcs/cs-parser.cs:4603 +msgid "Optional parameter cannot precede required parameters" msgstr "" -#: ../mcs/mcs/class.cs:869 -#, csharp-format -msgid "Type `{0}' in interface list is not an interface" +#: mcs/mcs/cs-parser.cs:4625 +msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: ../mcs/mcs/class.cs:871 +#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 #, csharp-format -msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" +msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" -#: ../mcs/mcs/class.cs:874 -#, csharp-format -msgid "`{0}': Base class `{1}' must be specified as first" +#: mcs/mcs/cs-parser.cs:4666 +msgid "Optional parameter is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:901 -#, csharp-format -msgid "Partial declarations of `{0}' must not specify different base classes" +#: mcs/mcs/cs-parser.cs:4686 +msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:942 -#, csharp-format -msgid "" -"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " -"type parameter substitutions" +#: mcs/mcs/cs-parser.cs:4689 +msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:1164 -#, csharp-format -msgid "" -"Partial declarations of `{0}' must have the same type parameter names in the " -"same order" +#: mcs/mcs/cs-parser.cs:4692 +msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: ../mcs/mcs/class.cs:1184 -#, csharp-format -msgid "" -"Partial declarations of `{0}' have inconsistent constraints for type " -"parameter `{1}'" +#: mcs/mcs/cs-parser.cs:4739 +msgid "Cannot specify a default value for a parameter array" msgstr "" -#: ../mcs/mcs/class.cs:1274 -#, csharp-format -msgid "" -"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" +#: mcs/mcs/cs-parser.cs:4756 +msgid "The `params' modifier is not allowed in current context" msgstr "" -#: ../mcs/mcs/class.cs:1279 -#, csharp-format -msgid "Circular base class dependency involving `{0}' and `{1}'" +#: mcs/mcs/cs-parser.cs:4764 +msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:1459 -msgid "" -"Two indexers have different names; the IndexerName attribute must be used " -"with the same name on every indexer within a type" +#: mcs/mcs/cs-parser.cs:4766 +msgid "The params parameter cannot be declared as ref or out" msgstr "" -#: ../mcs/mcs/class.cs:2293 -#, csharp-format -msgid "A static member `{0}' cannot be marked as override, virtual or abstract" +#: mcs/mcs/cs-parser.cs:4774 +msgid "__arglist is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:2307 +#: mcs/mcs/cs-parser.cs:4791 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer cannot have void type" +msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" + +#: mcs/mcs/cs-parser.cs:4829 #, csharp-format -msgid "A member `{0}' marked as override cannot be marked as new or virtual" +msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: ../mcs/mcs/class.cs:2319 -#, csharp-format -msgid "`{0}' cannot be both extern and abstract" +#: mcs/mcs/cs-parser.cs:4832 +msgid "Indexers must have at least one parameter" msgstr "" -#: ../mcs/mcs/class.cs:2324 -#, csharp-format -msgid "`{0}' cannot be both abstract and sealed" -msgstr "`{0}' Eine Klasse kann nicht gleichzeitig statisch und versiegelt sein" +#: mcs/mcs/cs-parser.cs:4857 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer must have at least one accessor" +msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: ../mcs/mcs/class.cs:2329 -#, csharp-format -msgid "The abstract method `{0}' cannot be marked virtual" +#: mcs/mcs/cs-parser.cs:4860 +msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: ../mcs/mcs/class.cs:2335 -#, csharp-format -msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" -msgstr "" +#: mcs/mcs/cs-parser.cs:4862 +#, fuzzy +msgid "A get or set accessor expected" +msgstr "Methodennamen erwartet" -#: ../mcs/mcs/class.cs:2343 -#, csharp-format -msgid "`{0}': virtual or abstract members cannot be private" +#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +msgid "Property accessor already defined" msgstr "" -#: ../mcs/mcs/class.cs:2350 -#, csharp-format -msgid "`{0}' cannot be sealed because it is not an override" +#: mcs/mcs/cs-parser.cs:5036 +msgid "User-defined operators cannot return void" msgstr "" -#: ../mcs/mcs/class.cs:2436 -#, csharp-format -msgid "`{0}': containing type does not implement interface `{1}'" +#: mcs/mcs/cs-parser.cs:5059 +msgid "Overloadable binary operator expected" msgstr "" -#: ../mcs/mcs/class.cs:2570 +#: mcs/mcs/cs-parser.cs:5061 #, csharp-format -msgid "Type parameter `{0}' has same name as containing type, or method" +msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "" -#: ../mcs/mcs/class.cs:2576 +#: mcs/mcs/cs-parser.cs:5066 #, csharp-format -msgid "`{0}': member names cannot be the same as their enclosing type" +msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: ../mcs/mcs/class.cs:2718 -msgid "" -"The class System.Object cannot have a base class or implement an interface." +#: mcs/mcs/cs-parser.cs:5069 +msgid "Overloadable unary operator expected" msgstr "" -#: ../mcs/mcs/class.cs:2727 -#, csharp-format -msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" +#: mcs/mcs/cs-parser.cs:5183 +msgid "Class, struct, or interface method must have a return type" msgstr "" -#: ../mcs/mcs/class.cs:2732 +#: mcs/mcs/cs-parser.cs:5187 +#, fuzzy, csharp-format +msgid "`{0}': static constructor cannot have an access modifier" +msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" + +#: mcs/mcs/cs-parser.cs:5192 +#, fuzzy, csharp-format msgid "" -"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " -"or attribute classes" -msgstr "" +"`{0}': static constructor cannot have an explicit `this' or `base' " +"constructor call" +msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: ../mcs/mcs/class.cs:2771 -#, csharp-format -msgid "`{0}': Static classes cannot contain user-defined operators" +#: mcs/mcs/cs-parser.cs:5241 +msgid "Name of destructor must match name of class" msgstr "" -"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " -"beinhalten" -#: ../mcs/mcs/class.cs:2776 -#, csharp-format -msgid "`{0}': Static classes cannot contain destructor" +#: mcs/mcs/cs-parser.cs:5243 +#, fuzzy +msgid "Only class types can contain destructor" msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: ../mcs/mcs/class.cs:2781 +#: mcs/mcs/cs-parser.cs:5265 #, csharp-format -msgid "`{0}': cannot declare indexers in a static class" +msgid "" +"`{0}': An explicit interface implementation of an event must use property " +"syntax" msgstr "" -#: ../mcs/mcs/class.cs:2789 -#, csharp-format -msgid "`{0}': Static classes cannot have instance constructors" +#: mcs/mcs/cs-parser.cs:5298 +msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: ../mcs/mcs/class.cs:2795 -#, csharp-format -msgid "`{0}': Extension methods must be declared static" -msgstr "`{0}': Erweiterungsmethoden müssen statisch sein" +#: mcs/mcs/cs-parser.cs:5344 +#, fuzzy, csharp-format +msgid "`{0}': event in interface cannot have an initializer" +msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" -#: ../mcs/mcs/class.cs:2799 -#, csharp-format -msgid "`{0}': cannot declare instance members in a static class" -msgstr "" +#: mcs/mcs/cs-parser.cs:5349 +#, fuzzy, csharp-format +msgid "`{0}': abstract event cannot have an initializer" +msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" -#: ../mcs/mcs/class.cs:2808 -#, csharp-format -msgid "`{0}': an abstract class cannot be sealed or static" -msgstr "`{0}': Eine abstrakte Klasse darf nicht versiegelt oder statisch sein" +#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#, fuzzy, csharp-format +msgid "`{0}': event property must have both add and remove accessors" +msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: ../mcs/mcs/class.cs:2812 -#, csharp-format -msgid "`{0}': a class cannot be both static and sealed" +#: mcs/mcs/cs-parser.cs:5371 +msgid "An add or remove accessor expected" msgstr "" -#: ../mcs/mcs/class.cs:2849 -#, csharp-format -msgid "Cannot derive from `{0}' because it is a type parameter" +#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: ../mcs/mcs/class.cs:2856 -#, csharp-format -msgid "" -"A generic type cannot derive from `{0}' because it is an attribute class" +#: mcs/mcs/cs-parser.cs:5436 +msgid "An add or remove accessor must have a body" msgstr "" -#: ../mcs/mcs/class.cs:2863 -#, csharp-format -msgid "`{0}': Cannot derive from static class `{1}'" +#: mcs/mcs/cs-parser.cs:5455 +#, fuzzy +msgid "Enums cannot have type parameters" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/cs-parser.cs:5755 +#, fuzzy +msgid "Type parameter declaration must be an identifier not a type" +msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" + +#: mcs/mcs/cs-parser.cs:5779 +msgid "Invalid parameter type `void'" +msgstr "Ungültiger Parametertyp `void'" + +#: mcs/mcs/cs-parser.cs:5825 +#, fuzzy, csharp-format +msgid "Invalid base type `{0}'" +msgstr "Ungültiger Parametertyp `void'" + +#: mcs/mcs/cs-parser.cs:5984 +msgid "An element initializer cannot be empty" msgstr "" -#: ../mcs/mcs/class.cs:2866 +#: mcs/mcs/cs-parser.cs:6015 #, csharp-format -msgid "`{0}': cannot derive from sealed class `{1}'" +msgid "Named argument `{0}' specified multiple times" msgstr "" -#: ../mcs/mcs/class.cs:2873 -#, csharp-format -msgid "`{0}' cannot derive from special class `{1}'" +#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +msgid "An argument is missing" msgstr "" -#: ../mcs/mcs/class.cs:2880 -#, csharp-format -msgid "" -"Inconsistent accessibility: base class `{0}' is less accessible than class `" -"{1}'" +#: mcs/mcs/cs-parser.cs:6166 +msgid "Array creation must have array size or array initializer" msgstr "" -#: ../mcs/mcs/class.cs:2887 -#, csharp-format +#: mcs/mcs/cs-parser.cs:6183 +msgid "Invalid rank specifier, expecting `,' or `]'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6256 msgid "" -"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " -"from object" +"Invalid anonymous type member declarator. Anonymous type members must be a " +"member assignment, simple name or member access expression" msgstr "" -#: ../mcs/mcs/class.cs:2895 -#, csharp-format -msgid "Static class `{0}' cannot implement interfaces" +#: mcs/mcs/cs-parser.cs:6658 +msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: ../mcs/mcs/class.cs:3041 +#: mcs/mcs/cs-parser.cs:6799 #, csharp-format -msgid "`{0}': Structs cannot have instance field initializers" -msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" +msgid "Duplicate `{0}' modifier" +msgstr "" -#: ../mcs/mcs/class.cs:3362 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not an event" +#: mcs/mcs/cs-parser.cs:6803 +msgid "More than one protection modifier specified" msgstr "" -#: ../mcs/mcs/class.cs:3364 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not a property" +#: mcs/mcs/cs-parser.cs:6816 +msgid "Keyword `new' is not allowed on namespace elements" msgstr "" -#: ../mcs/mcs/class.cs:3366 +#: mcs/mcs/cs-parser.cs:6936 #, csharp-format -msgid "`{0}': cannot override because `{1}' is not a method" +msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:3368 -#, csharp-format -msgid "`{0}' is marked as an override but no suitable {1} found to override" +#: mcs/mcs/cs-parser.cs:6966 +#, fuzzy +msgid "The `new()' constraint must be the last constraint specified" msgstr "" +"Die `new()'-Einschränkung muss als letzte Einschränkung definiert werden" -#: ../mcs/mcs/class.cs:3407 -#, csharp-format +#: mcs/mcs/cs-parser.cs:6972 msgid "" -"`{0}': cannot override inherited member `{1}' because it is not marked " -"virtual, abstract or override" -msgstr "" - -#: ../mcs/mcs/class.cs:3416 -#, csharp-format -msgid "`{0}': cannot override inherited member `{1}' because it is sealed" +"The `class' or `struct' constraint must be the first constraint specified" msgstr "" +"Die `class'- oder `struct'-Einschränkung muss als erste Einschränkung " +"definiert werden" -#: ../mcs/mcs/class.cs:3434 -#, csharp-format -msgid "`{0}': type must be `{1}' to match overridden member `{2}'" +#: mcs/mcs/cs-parser.cs:6976 +msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" +"Die `new()'-Einschränkung kann nicht mit der `struct'-Einschränkung genutzt " +"werden" -#: ../mcs/mcs/class.cs:3438 -#, csharp-format -msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" -msgstr "" +#: mcs/mcs/cs-parser.cs:6989 +#, fuzzy, csharp-format +msgid "Invalid constraint type `{0}'" +msgstr "Ungültiger Parametertyp `void'" -#: ../mcs/mcs/class.cs:3460 -#, csharp-format -msgid "`{0}' hides inherited abstract member `{1}'" +#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: ../mcs/mcs/class.cs:3520 -#, csharp-format +#: mcs/mcs/cs-parser.cs:7213 msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"indexer `{1}'" +"Syntax error, bad array declarator. To declare a managed array the rank " +"specifier precedes the variable's identifier. To declare a fixed size buffer " +"field, use the fixed keyword before the field type" msgstr "" -#: ../mcs/mcs/class.cs:3524 -#, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"operator `{1}'" +#: mcs/mcs/cs-parser.cs:7262 +msgid "A stackalloc expression requires [] after type" msgstr "" -#: ../mcs/mcs/class.cs:3528 -#, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"method `{1}'" +#: mcs/mcs/cs-parser.cs:7468 +msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: ../mcs/mcs/class.cs:3548 -#, csharp-format -msgid "`{0}' in explicit interface declaration is not an interface" -msgstr "" +#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#, fuzzy +msgid "; expected" +msgstr "Methodennamen erwartet" -#: ../mcs/mcs/class.cs:3587 -#, csharp-format -msgid "A partial method `{0}' cannot explicitly implement an interface" +#: mcs/mcs/cs-parser.cs:7555 +msgid "Expression expected after yield return" msgstr "" -#: ../mcs/mcs/class.cs:3595 -#, csharp-format -msgid "'{0}' in explicit interface declaration is not an interface" +#: mcs/mcs/cs-parser.cs:7598 +msgid "Expected catch or finally" msgstr "" -#: ../mcs/mcs/class.cs:3614 -#, csharp-format -msgid "" -"`{0}' is marked as an external but has no DllImport attribute. Consider " -"adding a DllImport attribute to specify the external implementation" +#: mcs/mcs/cs-parser.cs:7618 +msgid "Try statement already has an empty catch block" msgstr "" -#: ../mcs/mcs/class.cs:3631 -#, csharp-format +#: mcs/mcs/cs-parser.cs:7651 msgid "" -"`{0}': cannot change access modifiers when overriding `{1}' inherited member " -"`{2}'" +"A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: ../mcs/mcs/class.cs:3724 -msgid "" -"The DllImport attribute must be specified on a method marked `static' and " -"`extern'" +#: mcs/mcs/cs-parser.cs:11367 +msgid "Expecting `;'" msgstr "" -#: ../mcs/mcs/class.cs:3787 +#: mcs/mcs/cs-parser.cs:11375 #, csharp-format -msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgid "The parameter modifier `{0}' is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:3867 +#: mcs/mcs/cs-parser.cs:11381 #, csharp-format -msgid "" -"Conditional not valid on `{0}' because it is a constructor, destructor, " -"operator or explicit interface implementation" +msgid "Duplicate parameter modifier `{0}'" msgstr "" -"Das Conditional-Attribut ist für `{0}' ungültig, weil dies ein Konstruktor, " -"Destruktor, Operator oder eine explizite Schnittstellenimplementierung ist" -#: ../mcs/mcs/class.cs:3924 -msgid "Do not override object.Finalize. Instead, provide a destructor" -msgstr "" +#: mcs/mcs/cs-parser.cs:11387 +#, fuzzy +msgid "Type expected" +msgstr "Methodennamen erwartet" -#: ../mcs/mcs/class.cs:4096 -#, csharp-format -msgid "Program `{0}' has more than one entry point defined: `{1}'" +#: mcs/mcs/cs-parser.cs:11392 +msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: ../mcs/mcs/class.cs:4127 -#, csharp-format -msgid "Conditional not valid on `{0}' because its return type is not void" +#: mcs/mcs/cs-parser.cs:11402 +msgid "Named arguments must appear after the positional arguments" msgstr "" -"Das Conditional-Attribut ist für `{0}' ungültig, da der Rückgabetyp nicht " -"leer ist" -#: ../mcs/mcs/class.cs:4132 -#, csharp-format -msgid "Conditional not valid on `{0}' because it is an override method" +#: mcs/mcs/cs-parser.cs:11493 +msgid "Syntax error, " msgstr "" -"Das Conditional-Attribut ist für `{0}' ungültig, da es eine überschriebene " -"Funktion ist" -#: ../mcs/mcs/class.cs:4137 -msgid "Conditional not valid on interface members" -msgstr "Das Conditional-Attribut ist für Schnittstellenmember ungültig" +#: mcs/mcs/cs-parser.cs:11547 +msgid "Parsing error" +msgstr "" -#: ../mcs/mcs/class.cs:4143 -#, csharp-format -msgid "Conditional member `{0}' cannot implement interface member `{1}'" +#: mcs/mcs/cs-parser.cs:11553 +msgid "Internal compiler error during parsing" msgstr "" -#: ../mcs/mcs/class.cs:4150 +#: mcs/mcs/cs-parser.cs:11564 #, csharp-format -msgid "Conditional method `{0}' cannot have an out parameter" +msgid "{0}: `{1}' is a keyword" msgstr "" -#: ../mcs/mcs/class.cs:4218 +#: mcs/mcs/cs-parser.cs:11690 #, csharp-format -msgid "`{0}': Extension methods cannot be defined in a nested class" +msgid "Identifier expected, `{0}' is a keyword" msgstr "" -#: ../mcs/mcs/class.cs:4223 +#: mcs/mcs/cs-parser.cs:11704 #, csharp-format -msgid "" -"`{0}': Extension methods cannot be declared without a reference to System." -"Core.dll assembly. Add the assembly reference or remove `this' modifer from " -"the first parameter" +msgid "{1} `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:4237 +#: mcs/mcs/cs-parser.cs:11706 #, csharp-format -msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgid "{2} `{0}', expecting {1}" msgstr "" -"`{0}': Erweiterungsmethoden müssen in einer nicht generischen statischen " -"Klasse definiert werden" -#: ../mcs/mcs/class.cs:4293 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:760 msgid "" -"A partial method `{0}' implementation is missing a partial method declaration" +"The `partial' modifier can be used only immediately before `class', " +"`struct', `interface', or `void' keyword" msgstr "" -#: ../mcs/mcs/class.cs:4327 -#, csharp-format -msgid "Method or delegate cannot return type `{0}'" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:1395 mcs/mcs/cs-tokenizer.cs:1462 +msgid "Invalid number" +msgstr "Ungültige Zahl" -#: ../mcs/mcs/class.cs:4412 +#: mcs/mcs/cs-tokenizer.cs:1647 #, csharp-format -msgid "`{0}': Struct constructors cannot call base constructors" +msgid "Unrecognized escape sequence `\\{0}'" msgstr "" -#: ../mcs/mcs/class.cs:4445 -#, csharp-format -msgid "Constructor `{0}' cannot call itself" +#: mcs/mcs/cs-tokenizer.cs:1666 +msgid "Unrecognized escape sequence" msgstr "" -#: ../mcs/mcs/class.cs:4570 +#: mcs/mcs/cs-tokenizer.cs:1887 +#, fuzzy +msgid "Missing identifier to pre-processor directive" +msgstr "Ungültige Präprozessor Direktive" + +#: mcs/mcs/cs-tokenizer.cs:1897 mcs/mcs/cs-tokenizer.cs:1901 #, csharp-format -msgid "`{0}': The static constructor must be parameterless" +msgid "Identifier expected: {0}" msgstr "" -#: ../mcs/mcs/class.cs:4590 -msgid "Structs cannot contain explicit parameterless constructors" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:2373 +#, fuzzy +msgid "Integral constant is too large" +msgstr "Numerische Konstante ist zu lang" -#: ../mcs/mcs/class.cs:4642 -#, csharp-format -msgid "" -"`{0}': A class with the ComImport attribute cannot have a user-defined " -"constructor" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:2378 +msgid "Invalid preprocessor directive" +msgstr "Ungültige Präprozessor Direktive" -#: ../mcs/mcs/class.cs:4934 +#: mcs/mcs/cs-tokenizer.cs:2385 #, csharp-format -msgid "`{0}' is an accessor not found in interface member `{1}{2}'" -msgstr "" +msgid "Unexpected processor directive ({0})" +msgstr "Unerwartete Prozessor Direktive ({0})" -#: ../mcs/mcs/class.cs:4940 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:2391 msgid "" -"`{0}.{1}' in explicit interface declaration is not a member of interface" +"Cannot define or undefine preprocessor symbols after first token in file" msgstr "" -#: ../mcs/mcs/class.cs:4947 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:2397 msgid "" -"`{0}' explicit method implementation cannot implement `{1}' because it is an " -"accessor" +"Preprocessor directives must appear as the first non-whitespace character on " +"a line" msgstr "" -#: ../mcs/mcs/class.cs:4957 -#, csharp-format -msgid "Method `{0}' cannot implement interface accessor `{1}.{2}'" +#: mcs/mcs/cs-tokenizer.cs:2402 +msgid "Single-line comment or end-of-line expected" msgstr "" -#: ../mcs/mcs/class.cs:4964 -#, csharp-format -msgid "" -"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " -"an explicit interface implementation" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:2435 mcs/mcs/cs-tokenizer.cs:3431 +msgid "Expected `#endif' directive" +msgstr "`#endif' Direktive erwartet" -#: ../mcs/mcs/class.cs:4971 -#, csharp-format -msgid "" -"Accessor `{0}' must be declared public to implement interface member `{1}'" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:2468 mcs/mcs/cs-tokenizer.cs:2489 +#: mcs/mcs/cs-tokenizer.cs:2520 mcs/mcs/cs-tokenizer.cs:3429 +msgid "#endregion directive expected" +msgstr "`#endregion' Direktive erwartet" -#: ../mcs/mcs/class.cs:4995 -#, csharp-format -msgid "" -"`{0}': the explicit interface implementation cannot introduce the params " -"modifier" -msgstr "" +#: mcs/mcs/cs-tokenizer.cs:2567 +msgid "Wrong preprocessor directive" +msgstr "Falsche Präprozessor Direktive" -#: ../mcs/mcs/class.cs:5291 +#: mcs/mcs/cs-tokenizer.cs:2579 #, csharp-format -msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgid "#error: '{0}'" +msgstr "#Fehler: '{0}'" + +#: mcs/mcs/cs-tokenizer.cs:2598 +msgid "The line number specified for #line directive is missing or invalid" msgstr "" -#: ../mcs/mcs/class.cs:5301 -msgid "Inconsistent accessibility: property type `" +#: mcs/mcs/cs-tokenizer.cs:2625 mcs/mcs/cs-tokenizer.cs:3243 +msgid "Newline in constant" msgstr "" -#: ../mcs/mcs/class.cs:5306 -msgid "Inconsistent accessibility: indexer return type `" +#: mcs/mcs/cs-tokenizer.cs:2636 +msgid "Unterminated string literal" +msgstr "Nicht beendetes Zeichenfolgeliteral" + +#: mcs/mcs/cs-tokenizer.cs:2705 +msgid "Identifier too long (limit is 512 chars)" +msgstr "Der Bezeichner ist zu lang. (Maximal 512 Zeichen)" + +#: mcs/mcs/cs-tokenizer.cs:3092 +msgid "End-of-file found, '*/' expected" +msgstr "Dateiende gefunden. `*/' erwartet." + +#: mcs/mcs/cs-tokenizer.cs:3201 +msgid "Keyword, identifier, or string expected after verbatim specifier: @" msgstr "" -#: ../mcs/mcs/class.cs:5312 ../mcs/mcs/class.cs:5317 -#: ../mcs/mcs/delegate.cs:220 -msgid "Inconsistent accessibility: return type `" +#: mcs/mcs/cs-tokenizer.cs:3217 +#, fuzzy, csharp-format +msgid "Unexpected character `{0}'" +msgstr "`{0}' erwartet" + +#: mcs/mcs/cs-tokenizer.cs:3238 +msgid "Empty character literal" msgstr "" -#: ../mcs/mcs/class.cs:5322 -msgid "Inconsistent accessibility: field type `" +#: mcs/mcs/cs-tokenizer.cs:3258 +msgid "Too many characters in character literal" msgstr "" -#: ../mcs/mcs/class.cs:5335 -#, csharp-format -msgid "Field or property cannot be of type `{0}'" +#: mcs/mcs/cfold.cs:84 +msgid "The operation overflows at compile time in checked mode" msgstr "" -#: ../mcs/mcs/class.cs:5363 -msgid "" -"The modifier 'abstract' is not valid on fields. Try using a property instead" +#: mcs/mcs/cfold.cs:764 mcs/mcs/cfold.cs:849 +msgid "Division by constant zero" msgstr "" -#: ../mcs/mcs/class.cs:5378 +#: mcs/mcs/class.cs:371 +#, csharp-format msgid "" -"The FieldOffset attribute can only be placed on members of types marked with " -"the StructLayout(LayoutKind.Explicit)" +"Partial declarations of `{0}' must be all classes, all structs or all " +"interfaces" msgstr "" -#: ../mcs/mcs/class.cs:5383 -msgid "The FieldOffset attribute is not allowed on static or const fields" +#: mcs/mcs/class.cs:380 +#, csharp-format +msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" msgstr "" -#: ../mcs/mcs/class.cs:5390 +#: mcs/mcs/class.cs:433 +#, csharp-format msgid "" -"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " -"'fixed' field modifier instead" +"`{0}': explicit interface declaration can only be declared in a class or " +"struct" msgstr "" -#: ../mcs/mcs/class.cs:5478 +#: mcs/mcs/class.cs:470 mcs/mcs/membercache.cs:1347 #, csharp-format msgid "" -"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " -"must have a FieldOffset attribute" +"A member `{0}' is already defined. Rename this member or use different " +"parameter types" msgstr "" -#: ../mcs/mcs/class.cs:5487 -#, csharp-format -msgid "`{0}': cannot declare variables of static types" +#: mcs/mcs/class.cs:578 +msgid "" +"Cannot specify the `DefaultMember' attribute on type containing an indexer" msgstr "" -#: ../mcs/mcs/class.cs:5605 -#, csharp-format -msgid "" -"`{0}': Fixed size buffers type must be one of the following: bool, byte, " -"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +#: mcs/mcs/class.cs:584 +msgid "The RequiredAttribute attribute is not permitted on C# types" msgstr "" -#: ../mcs/mcs/class.cs:5627 +#: mcs/mcs/class.cs:855 #, csharp-format -msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgid "Class `{0}' cannot derive from the dynamic type" msgstr "" -#: ../mcs/mcs/class.cs:5643 +#: mcs/mcs/class.cs:872 #, csharp-format -msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgid "`{0}' is already listed in interface list" msgstr "" -#: ../mcs/mcs/class.cs:5650 +#: mcs/mcs/class.cs:880 #, csharp-format msgid "" -"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +"Inconsistent accessibility: base interface `{0}' is less accessible than " +"interface `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:5843 +#: mcs/mcs/class.cs:886 #, csharp-format -msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" +msgid "Type `{0}' in interface list is not an interface" msgstr "" -#: ../mcs/mcs/class.cs:5855 +#: mcs/mcs/class.cs:888 #, csharp-format -msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" msgstr "" -#: ../mcs/mcs/class.cs:5860 +#: mcs/mcs/class.cs:891 #, csharp-format -msgid "`{0}': A field cannot be both volatile and readonly" +msgid "`{0}': Base class `{1}' must be specified as first" msgstr "" -#: ../mcs/mcs/class.cs:6049 +#: mcs/mcs/class.cs:915 #, csharp-format -msgid "" -"Attribute `{0}' is not valid on property or event accessors. It is valid on `" -"{1}' declarations only" +msgid "Partial declarations of `{0}' must not specify different base classes" msgstr "" -#: ../mcs/mcs/class.cs:6149 ../mcs/mcs/decl.cs:2792 +#: mcs/mcs/class.cs:996 #, csharp-format -msgid "A member `{0}' is already reserved" +msgid "" +"The operator `{0}' requires a matching operator `{1}' to also be defined" msgstr "" -#: ../mcs/mcs/class.cs:6352 +#: mcs/mcs/class.cs:1021 #, csharp-format -msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgid "`{0}' clashes with a predefined namespace" msgstr "" -#: ../mcs/mcs/class.cs:6369 +#: mcs/mcs/class.cs:1150 #, csharp-format msgid "" -"`{0}': accessibility modifiers may not be used on accessors in an interface" +"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6373 +#: mcs/mcs/class.cs:1156 #, csharp-format -msgid "`{0}': abstract properties cannot have private accessors" -msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" +msgid "Circular base class dependency involving `{0}' and `{1}'" +msgstr "" -#: ../mcs/mcs/class.cs:6435 +#: mcs/mcs/class.cs:1183 #, csharp-format msgid "" -"The accessibility modifier of the `{0}' accessor must be more restrictive " -"than the modifier of the property or indexer `{1}'" +"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " +"type parameter substitutions" msgstr "" -#: ../mcs/mcs/class.cs:6500 +#: mcs/mcs/class.cs:1223 #, csharp-format msgid "" -"`{0}': Cannot specify accessibility modifiers for both accessors of the " -"property or indexer" +"The type `{0}' is defined in an assembly that is not referenced. Consider " +"adding a reference to assembly `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6509 +#: mcs/mcs/class.cs:1339 #, csharp-format msgid "" -"`{0}': accessibility modifiers on accessors may only be used if the property " -"or indexer has both a get and a set accessor" +"Partial declarations of `{0}' must have the same type parameter names in the " +"same order" msgstr "" -#: ../mcs/mcs/class.cs:6571 +#: mcs/mcs/class.cs:1346 #, csharp-format msgid "" -"`{0}.get': cannot override because `{1}' does not have an overridable get " -"accessor" +"Partial declarations of `{0}' must have the same type parameter variance " +"modifiers" msgstr "" -#: ../mcs/mcs/class.cs:6586 +#: mcs/mcs/class.cs:1371 #, csharp-format msgid "" -"`{0}.set': cannot override because `{1}' does not have an overridable set " -"accessor" +"Partial declarations of `{0}' have inconsistent constraints for type " +"parameter `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6783 -#, csharp-format +#: mcs/mcs/class.cs:1510 +#, fuzzy, csharp-format +msgid "`{0}': cannot implement a dynamic interface `{1}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/class.cs:1623 msgid "" -"Automatically implemented property `{0}' cannot be used inside a type with " -"an explicit StructLayout attribute" +"Two indexers have different names; the IndexerName attribute must be used " +"with the same name on every indexer within a type" msgstr "" -#: ../mcs/mcs/class.cs:7151 +#: mcs/mcs/class.cs:1957 #, csharp-format -msgid "`{0}': abstract event cannot have an initializer" +msgid "A static member `{0}' cannot be marked as override, virtual or abstract" msgstr "" -#: ../mcs/mcs/class.cs:7337 +#: mcs/mcs/class.cs:1964 #, csharp-format -msgid "`{0}': event must be of a delegate type" +msgid "A member `{0}' marked as override cannot be marked as new or virtual" msgstr "" -#: ../mcs/mcs/class.cs:7544 -msgid "" -"The `IndexerName' attribute is valid only on an indexer that is not an " -"explicit interface member declaration" +#: mcs/mcs/class.cs:1976 +#, csharp-format +msgid "`{0}' cannot be both extern and abstract" msgstr "" -#: ../mcs/mcs/class.cs:7551 -msgid "Cannot set the `IndexerName' attribute on an indexer marked override" -msgstr "" +#: mcs/mcs/class.cs:1981 +#, csharp-format +msgid "`{0}' cannot be both abstract and sealed" +msgstr "`{0}' Eine Klasse kann nicht gleichzeitig statisch und versiegelt sein" -#: ../mcs/mcs/class.cs:7753 +#: mcs/mcs/class.cs:1986 #, csharp-format -msgid "User-defined operator `{0}' must be declared static and public" +msgid "The abstract method `{0}' cannot be marked virtual" msgstr "" -#: ../mcs/mcs/class.cs:7784 -msgid "" -"User-defined operator cannot take an object of the enclosing type and " -"convert to an object of the enclosing type" +#: mcs/mcs/class.cs:1992 +#, csharp-format +msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7795 -msgid "User-defined conversion must convert to or from the enclosing type" +#: mcs/mcs/class.cs:2000 +#, csharp-format +msgid "`{0}': virtual or abstract members cannot be private" msgstr "" -#: ../mcs/mcs/class.cs:7804 +#: mcs/mcs/class.cs:2007 #, csharp-format -msgid "" -"User-defined conversion `{0}' cannot convert to or from an interface type" +msgid "`{0}' cannot be sealed because it is not an override" msgstr "" -#: ../mcs/mcs/class.cs:7811 +#: mcs/mcs/class.cs:2054 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a base class" +msgid "`{0}': containing type does not implement interface `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7817 +#: mcs/mcs/class.cs:2230 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgid "Type parameter `{0}' has same name as containing type, or method" msgstr "" -#: ../mcs/mcs/class.cs:7825 -msgid "" -"Overloaded shift operator must have the type of the first operand be the " -"containing type, and the type of the second operand must be int" +#: mcs/mcs/class.cs:2238 +#, csharp-format +msgid "`{0}': member names cannot be the same as their enclosing type" msgstr "" -#: ../mcs/mcs/class.cs:7834 +#: mcs/mcs/class.cs:2404 msgid "" -"The return type for ++ or -- operator must be the containing type or derived " -"from the containing type" +"The class System.Object cannot have a base class or implement an interface." msgstr "" -"Der Rückgabetyp für die Operatoren ++ und -- muss der enthaltene Typ sein " -"oder vom enthaltenen Typ abgeleitet sein" - -#: ../mcs/mcs/class.cs:7839 -msgid "The parameter type for ++ or -- operator must be the containing type" -msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" -#: ../mcs/mcs/class.cs:7846 -msgid "The parameter type of a unary operator must be the containing type" +#: mcs/mcs/class.cs:2412 +#, csharp-format +msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" msgstr "" -#: ../mcs/mcs/class.cs:7854 -msgid "The return type of operator True or False must be bool" +#: mcs/mcs/class.cs:2417 +msgid "" +"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " +"or attribute classes" msgstr "" -#: ../mcs/mcs/class.cs:7867 -msgid "One of the parameters of a binary operator must be the containing type" +#: mcs/mcs/class.cs:2455 +#, csharp-format +msgid "`{0}': Static classes cannot contain user-defined operators" msgstr "" +"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " +"beinhalten" + +#: mcs/mcs/class.cs:2460 +#, csharp-format +msgid "`{0}': Static classes cannot contain destructor" +msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: ../mcs/mcs/codegen.cs:122 -msgid "Assembly generation failed -- Referenced assembly '" +#: mcs/mcs/class.cs:2465 +#, csharp-format +msgid "`{0}': cannot declare indexers in a static class" msgstr "" -#: ../mcs/mcs/codegen.cs:140 -msgid "Could not access the key inside the container `" +#: mcs/mcs/class.cs:2473 +#, csharp-format +msgid "`{0}': Static classes cannot have instance constructors" msgstr "" -#: ../mcs/mcs/codegen.cs:148 -msgid "Could not use the specified key to strongname the assembly." +#: mcs/mcs/class.cs:2479 +#, csharp-format +msgid "`{0}': Extension methods must be declared static" +msgstr "`{0}': Erweiterungsmethoden müssen statisch sein" + +#: mcs/mcs/class.cs:2483 +#, csharp-format +msgid "`{0}': cannot declare instance members in a static class" msgstr "" -#: ../mcs/mcs/codegen.cs:176 -msgid "" -"Could not find the symbol writer assembly (Mono.CompilerServices." -"SymbolWriter.dll)" +#: mcs/mcs/class.cs:2492 +#, csharp-format +msgid "`{0}': an abstract class cannot be sealed or static" +msgstr "`{0}': Eine abstrakte Klasse darf nicht versiegelt oder statisch sein" + +#: mcs/mcs/class.cs:2496 +#, csharp-format +msgid "`{0}': a class cannot be both static and sealed" msgstr "" -#: ../mcs/mcs/codegen.cs:181 +#: mcs/mcs/class.cs:2526 +#, fuzzy, csharp-format +msgid "`{0}': Cannot derive from type parameter `{1}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/class.cs:2530 #, csharp-format -msgid "Unexpected debug information initialization error `{0}'" +msgid "" +"A generic type cannot derive from `{0}' because it is an attribute class" msgstr "" -#: ../mcs/mcs/codegen.cs:199 -msgid "Couldn't delay-sign the assembly with the '" +#: mcs/mcs/class.cs:2534 +#, csharp-format +msgid "`{0}': Cannot derive from static class `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:204 ../mcs/mcs/codegen.cs:208 -msgid "Could not write to file `" +#: mcs/mcs/class.cs:2538 +#, csharp-format +msgid "`{0}': cannot derive from sealed type `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:822 +#: mcs/mcs/class.cs:2541 #, csharp-format -msgid "`{0}': not all code paths return a value" +msgid "" +"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " +"from object" msgstr "" -#: ../mcs/mcs/codegen.cs:825 +#: mcs/mcs/class.cs:2548 #, csharp-format -msgid "Not all code paths return a value in anonymous method of type `{0}'" +msgid "`{0}' cannot derive from special class `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1224 ../mcs/mcs/codegen.cs:1237 +#: mcs/mcs/class.cs:2556 #, csharp-format msgid "" -"Option `{0}' overrides attribute `{1}' given in a source file or added module" +"Inconsistent accessibility: base class `{0}' is less accessible than class `" +"{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1300 -msgid "" -"Could not sign the assembly. ECMA key can only be used to delay-sign " -"assemblies" +#: mcs/mcs/class.cs:2564 +#, csharp-format +msgid "Static class `{0}' cannot implement interfaces" msgstr "" -#: ../mcs/mcs/codegen.cs:1320 -msgid "Error during assembly signing. " +#: mcs/mcs/class.cs:2683 mcs/mcs/class.cs:2694 +#, csharp-format +msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" msgstr "" -#: ../mcs/mcs/codegen.cs:1345 -msgid "Friend assembly reference `" +#: mcs/mcs/class.cs:2784 +#, csharp-format +msgid "`{0}': Structs cannot have instance field initializers" +msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" + +#: mcs/mcs/class.cs:2965 +#, csharp-format +msgid "Do not override `{0}'. Use destructor syntax instead" msgstr "" -#: ../mcs/mcs/codegen.cs:1417 -msgid "Invalid type specified as an argument for TypeForwardedTo attribute" +#: mcs/mcs/class.cs:2968 +#, csharp-format +msgid "`{0}' is marked as an override but no suitable {1} found to override" msgstr "" -#: ../mcs/mcs/codegen.cs:1425 +#: mcs/mcs/class.cs:2974 #, csharp-format -msgid "A duplicate type forward of type `{0}'" +msgid "`{0}': cannot override because `{1}' is not an event" msgstr "" -#: ../mcs/mcs/codegen.cs:1434 +#: mcs/mcs/class.cs:2977 #, csharp-format -msgid "Cannot forward type `{0}' because it is defined in this assembly" +msgid "`{0}': cannot override because `{1}' is not a property" msgstr "" -#: ../mcs/mcs/codegen.cs:1440 +#: mcs/mcs/class.cs:2980 #, csharp-format -msgid "Cannot forward type `{0}' because it is a nested type" +msgid "`{0}': cannot override because `{1}' is not a method" msgstr "" -#: ../mcs/mcs/codegen.cs:1446 +#: mcs/mcs/class.cs:3036 mcs/mcs/field.cs:187 #, csharp-format -msgid "Cannot forward generic type `{0}'" +msgid "`{0}' hides inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1651 +#: mcs/mcs/class.cs:3060 +#, csharp-format msgid "" -"Value specified for the argument to 'System.Runtime.InteropServices." -"DefaultCharSetAttribute' is not valid" +"`{0}': cannot override inherited member `{1}' because it is not marked " +"virtual, abstract or override" msgstr "" -#: ../mcs/mcs/const.cs:177 +#: mcs/mcs/class.cs:3068 #, csharp-format -msgid "The expression being assigned to `{0}' must be constant" +msgid "`{0}': cannot override inherited member `{1}' because it is sealed" msgstr "" -#: ../mcs/mcs/const.cs:182 +#: mcs/mcs/class.cs:3077 #, csharp-format -msgid "" -"The evaluation of the constant value for `{0}' involves a circular definition" +msgid "`{0}': type must be `{1}' to match overridden member `{2}'" msgstr "" -#: ../mcs/mcs/const.cs:188 +#: mcs/mcs/class.cs:3080 #, csharp-format -msgid "" -"A constant `{0}' of reference type `{1}' can only be initialized with null" +msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" msgstr "" -#: ../mcs/mcs/const.cs:194 +#: mcs/mcs/class.cs:3152 #, csharp-format -msgid "The type `{0}' cannot be declared const" +msgid "A partial method `{0}' cannot explicitly implement an interface" msgstr "" -#: ../mcs/mcs/constant.cs:84 ../mcs/mcs/constant.cs:285 +#: mcs/mcs/class.cs:3160 #, csharp-format -msgid "Constant value `{0}' cannot be converted to a `{1}'" +msgid "The type `{0}' in explicit interface declaration is not an interface" msgstr "" -#: ../mcs/mcs/constant.cs:192 +#: mcs/mcs/class.cs:3191 #, csharp-format msgid "" -"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " -"to override)" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"indexer `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:363 +#: mcs/mcs/class.cs:3195 #, csharp-format -msgid "`{0}' cannot declare a body because it is marked extern" +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"operator `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:369 +#: mcs/mcs/class.cs:3199 #, csharp-format -msgid "`{0}' cannot declare a body because it is marked abstract" +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"method `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:377 +#: mcs/mcs/class.cs:3213 #, csharp-format msgid "" -"`{0}' must have a body because it is not marked abstract or extern. The " -"property can be automatically implemented when you define both accessors" +"Constructor `{0}' is marked `external' but has no external implementation " +"specified" msgstr "" -#: ../mcs/mcs/decl.cs:380 +#: mcs/mcs/class.cs:3216 #, csharp-format msgid "" -"`{0}' must have a body because it is not marked abstract, extern, or partial" +"`{0}' is marked as an external but has no DllImport attribute. Consider " +"adding a DllImport attribute to specify the external implementation" msgstr "" -#: ../mcs/mcs/decl.cs:396 +#: mcs/mcs/class.cs:3245 #, csharp-format -msgid "`{0}': Structs cannot contain protected members" +msgid "" +"`{0}': cannot change access modifiers when overriding `{1}' inherited member " +"`{2}'" +msgstr "" + +#: mcs/mcs/class.cs:3254 +#, fuzzy, csharp-format +msgid "`{0}': static types cannot be used as return types" msgstr "" +"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " +"beinhalten" -#: ../mcs/mcs/decl.cs:402 +#: mcs/mcs/class.cs:3379 #, csharp-format -msgid "`{0}': Static classes cannot contain protected members" +msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgstr "" + +#: mcs/mcs/class.cs:3394 +msgid "Inconsistent accessibility: property type `" +msgstr "" + +#: mcs/mcs/class.cs:3399 +msgid "Inconsistent accessibility: indexer return type `" +msgstr "" + +#: mcs/mcs/class.cs:3405 mcs/mcs/class.cs:3410 mcs/mcs/delegate.cs:159 +msgid "Inconsistent accessibility: return type `" +msgstr "" + +#: mcs/mcs/class.cs:3415 +msgid "Inconsistent accessibility: field type `" msgstr "" -#: ../mcs/mcs/decl.cs:950 +#: mcs/mcs/class.cs:3428 #, csharp-format -msgid "The namespace `{0}' already contains a definition for `{1}'" +msgid "Field or property cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/decl.cs:954 +#: mcs/mcs/const.cs:103 #, csharp-format -msgid "Duplicate type parameter `{0}'" +msgid "Type parameter `{0}' cannot be declared const" msgstr "" -#: ../mcs/mcs/decl.cs:957 +#: mcs/mcs/const.cs:106 #, csharp-format -msgid "The type `{0}' already contains a definition for `{1}'" +msgid "The type `{0}' cannot be declared const" msgstr "" -#: ../mcs/mcs/decl.cs:1025 +#: mcs/mcs/const.cs:181 #, csharp-format msgid "" -"Missing partial modifier on declaration of type `{0}'. Another partial " -"declaration of this type exists" +"The evaluation of the constant value for `{0}' involves a circular definition" msgstr "" -#: ../mcs/mcs/decl.cs:1248 -msgid "The RequiredAttribute attribute is not permitted on C# types" +#: mcs/mcs/constant.cs:68 mcs/mcs/constant.cs:319 +#, csharp-format +msgid "Constant value `{0}' cannot be converted to a `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:1303 -msgid "Constraints are not allowed on non-generic declarations" -msgstr "Einschränkungen sind nicht erlaubt für nicht generische Deklarationen" - -#: ../mcs/mcs/decl.cs:1347 +#: mcs/mcs/constant.cs:187 #, csharp-format -msgid "`{0}': A constraint references nonexistent type parameter `{1}'" +msgid "" +"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " +"to override)" msgstr "" -#: ../mcs/mcs/decl.cs:2725 +#: mcs/mcs/convert.cs:1158 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation cannot differ " -"on use of `params' modifier" +"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' " +"to `{3}'" msgstr "" -#: ../mcs/mcs/decl.cs:2728 -msgid "" -"A partial method declaration and partial method implementation must be both " -"an extension method or neither" +#: mcs/mcs/decl.cs:376 +#, csharp-format +msgid "`{0}' cannot declare a body because it is marked extern" msgstr "" -#: ../mcs/mcs/decl.cs:2732 +#: mcs/mcs/decl.cs:382 #, csharp-format -msgid "" -"An overloaded method `{0}' cannot differ on use of parameter modifiers only" +msgid "`{0}' cannot declare a body because it is marked abstract" msgstr "" -#: ../mcs/mcs/decl.cs:2760 +#: mcs/mcs/decl.cs:395 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation must be both " -"`static' or neither" +"`{0}' must have a body because it is not marked abstract or extern. The " +"property can be automatically implemented when you define both accessors" msgstr "" -#: ../mcs/mcs/decl.cs:2765 +#: mcs/mcs/decl.cs:401 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation must be both " -"`unsafe' or neither" +"`{0}' must have a body because it is not marked abstract, extern, or partial" msgstr "" -#: ../mcs/mcs/decl.cs:2771 +#: mcs/mcs/decl.cs:416 #, csharp-format -msgid "A partial method `{0}' declaration is already defined" +msgid "`{0}': Structs cannot contain protected members" msgstr "" -#: ../mcs/mcs/decl.cs:2775 +#: mcs/mcs/decl.cs:422 #, csharp-format -msgid "A partial method `{0}' implementation is already defined" +msgid "`{0}': Static classes cannot contain protected members" msgstr "" -#: ../mcs/mcs/decl.cs:2783 +#: mcs/mcs/decl.cs:1264 #, csharp-format -msgid "Duplicate user-defined conversion in type `{0}'" +msgid "The namespace `{0}' already contains a definition for `{1}'" +msgstr "" + +#: mcs/mcs/decl.cs:1268 +#, csharp-format +msgid "Duplicate type parameter `{0}'" +msgstr "" + +#: mcs/mcs/decl.cs:1271 +#, csharp-format +msgid "The type `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:204 +#: mcs/mcs/decl.cs:1321 #, csharp-format msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"delegate `{1}'" +"Missing partial modifier on declaration of type `{0}'. Another partial " +"declaration of this type exists" +msgstr "" + +#: mcs/mcs/decl.cs:1410 +msgid "Variant type parameters can only be used with interfaces and delegates" msgstr "" -#: ../mcs/mcs/delegate.cs:403 -msgid "Internal error: could not find delegate constructor!" +#: mcs/mcs/decl.cs:1422 +#, csharp-format +msgid "`{0}': A constraint references nonexistent type parameter `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:445 ../mcs/mcs/delegate.cs:553 -msgid "Internal error: could not find Invoke method!" +#: mcs/mcs/delegate.cs:141 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"delegate `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:732 +#: mcs/mcs/delegate.cs:487 #, csharp-format msgid "" "Cannot create delegate from method `{0}' because it is a member of System." "Nullable type" msgstr "" -#: ../mcs/mcs/delegate.cs:744 +#: mcs/mcs/delegate.cs:499 #, csharp-format msgid "" "Extension method `{0}' of value type `{1}' cannot be used to create delegates" msgstr "" -#: ../mcs/mcs/delegate.cs:759 +#: mcs/mcs/delegate.cs:514 #, csharp-format msgid "Cannot create delegate from partial method declaration `{0}'" msgstr "" -#: ../mcs/mcs/delegate.cs:762 +#: mcs/mcs/delegate.cs:517 #, csharp-format msgid "" "Cannot create delegate with `{0}' because it has a Conditional attribute" msgstr "" -#: ../mcs/mcs/delegate.cs:818 +#: mcs/mcs/delegate.cs:560 #, csharp-format msgid "" "A method or delegate `{0} {1}' parameters and return type must be same as " "delegate `{2} {3}' parameters and return type" msgstr "" -#: ../mcs/mcs/delegate.cs:824 +#: mcs/mcs/delegate.cs:567 #, csharp-format msgid "" "A method or delegate `{0}' parameters do not match delegate `{1}' parameters" msgstr "" -#: ../mcs/mcs/delegate.cs:829 +#: mcs/mcs/delegate.cs:572 #, csharp-format msgid "" "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " "return type" msgstr "" -#: ../mcs/mcs/delegate.cs:949 +#: mcs/mcs/delegate.cs:655 msgid "Method name expected" msgstr "Methodennamen erwartet" -#: ../mcs/mcs/doc.cs:1007 +#: mcs/mcs/doc.cs:914 #, csharp-format msgid "Error generating XML documentation file `{0}' (`{1}')" msgstr "Fehler beim erstellen der XML-Dokumentationsdatei `{0}' (`{1}')" -#: ../mcs/mcs/driver.cs:152 ../mcs/mcs/driver.cs:707 ../mcs/mcs/driver.cs:710 +#: mcs/mcs/driver.cs:96 mcs/mcs/driver.cs:465 mcs/mcs/driver.cs:468 msgid "Source file `" msgstr "" -#: ../mcs/mcs/driver.cs:179 +#: mcs/mcs/driver.cs:123 #, csharp-format msgid "Source file `{0}' could not be found" msgstr "" -#: ../mcs/mcs/driver.cs:187 +#: mcs/mcs/driver.cs:129 #, csharp-format msgid "Source file `{0}' is a binary file and not a text file" msgstr "" -#: ../mcs/mcs/driver.cs:205 -#, csharp-format -msgid "Compilation aborted in file `{0}', {1}" -msgstr "Kompilierung abgebrochen in Datei `{0}', {1}" - -#: ../mcs/mcs/driver.cs:272 +#: mcs/mcs/driver.cs:214 msgid "" "Invalid target type for -target. Valid options are `exe', `winexe', " "`library' or `module'" msgstr "" -#: ../mcs/mcs/driver.cs:320 -#, csharp-format -msgid "cannot find metadata file `{0}'" -msgstr "" - -#: ../mcs/mcs/driver.cs:327 -#, csharp-format -msgid "file `{0}' has invalid `{1}' metadata" -msgstr "" - -#: ../mcs/mcs/driver.cs:347 -#, csharp-format -msgid "" -"Referenced file `{0}' is not an assembly. Consider using `-addmodule' option " -"instead" -msgstr "" - -#: ../mcs/mcs/driver.cs:603 +#: mcs/mcs/driver.cs:361 msgid "Response file `" msgstr "" -#: ../mcs/mcs/driver.cs:612 +#: mcs/mcs/driver.cs:370 msgid "Unable to open response file: " msgstr "" -#: ../mcs/mcs/driver.cs:662 ../mcs/mcs/driver.cs:672 +#: mcs/mcs/driver.cs:420 mcs/mcs/driver.cs:430 msgid "No files to compile were specified" msgstr "Es wurden keine Dateien zum kompilieren angegeben" -#: ../mcs/mcs/driver.cs:802 +#: mcs/mcs/driver.cs:502 msgid "Warning level must be in the range 0-4" msgstr "" -#: ../mcs/mcs/driver.cs:836 +#: mcs/mcs/driver.cs:536 msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" msgstr "" -#: ../mcs/mcs/driver.cs:845 +#: mcs/mcs/driver.cs:545 msgid "Compatibility: Use -unsafe instead of --unsafe" msgstr "" -#: ../mcs/mcs/driver.cs:856 +#: mcs/mcs/driver.cs:556 msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" msgstr "" -#: ../mcs/mcs/driver.cs:870 +#: mcs/mcs/driver.cs:570 msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" msgstr "" -#: ../mcs/mcs/driver.cs:879 +#: mcs/mcs/driver.cs:579 msgid "Compatibility: Use -checked instead of --checked" msgstr "" -#: ../mcs/mcs/driver.cs:889 +#: mcs/mcs/driver.cs:589 msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" msgstr "" -#: ../mcs/mcs/driver.cs:892 +#: mcs/mcs/driver.cs:592 msgid "Missing argument to --linkres" msgstr "Fehlendes Argument bei --linkres" -#: ../mcs/mcs/driver.cs:903 +#: mcs/mcs/driver.cs:601 msgid "Compatibility: Use -res:VALUE instead of --res VALUE" msgstr "" -#: ../mcs/mcs/driver.cs:906 +#: mcs/mcs/driver.cs:604 msgid "Missing argument to --resource" msgstr "Fehlendes Argument bei --resource" -#: ../mcs/mcs/driver.cs:916 +#: mcs/mcs/driver.cs:612 msgid "Compatibility: Use -target:KIND instead of --target KIND" msgstr "" -#: ../mcs/mcs/driver.cs:948 +#: mcs/mcs/driver.cs:644 msgid "Compatibility: Use -r:LIBRARY instead of -r library" msgstr "" -#: ../mcs/mcs/driver.cs:967 +#: mcs/mcs/driver.cs:663 msgid "Compatibility: Use -lib:ARG instead of --L arg" msgstr "" -#: ../mcs/mcs/driver.cs:976 +#: mcs/mcs/driver.cs:676 msgid "Compatibility: Use -nostdlib instead of --nostdlib" msgstr "" -#: ../mcs/mcs/driver.cs:985 -msgid "Compatibility: Use -warnaserror: option instead of --werror" -msgstr "" - -#: ../mcs/mcs/driver.cs:990 +#: mcs/mcs/driver.cs:681 msgid "Compatibility: Use -nowarn instead of --nowarn" msgstr "" -#: ../mcs/mcs/driver.cs:1007 +#: mcs/mcs/driver.cs:698 msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" msgstr "" -#: ../mcs/mcs/driver.cs:1011 +#: mcs/mcs/driver.cs:702 msgid "--wlevel requires a value from 0 to 4" msgstr "--wlevel benötigt einen Wert zwischen 0 und 4" -#: ../mcs/mcs/driver.cs:1020 +#: mcs/mcs/driver.cs:711 msgid "--mcs-debug requires an argument" msgstr "--mcs-debug benötigt ein Argument" -#: ../mcs/mcs/driver.cs:1027 +#: mcs/mcs/driver.cs:718 msgid "Invalid argument to --mcs-debug" msgstr "Ungültiges Argument für --mcs-debug" -#: ../mcs/mcs/driver.cs:1037 +#: mcs/mcs/driver.cs:728 msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" msgstr "" -#: ../mcs/mcs/driver.cs:1039 +#: mcs/mcs/driver.cs:730 msgid "--recurse requires an argument" msgstr "--recurse benötigt ein Argument" -#: ../mcs/mcs/driver.cs:1051 +#: mcs/mcs/driver.cs:741 msgid "Compatibility: Use -debug option instead of -g or --debug" msgstr "" -#: ../mcs/mcs/driver.cs:1056 +#: mcs/mcs/driver.cs:746 msgid "Compatibility: Use -noconfig option instead of --noconfig" msgstr "" -#: ../mcs/mcs/driver.cs:1076 -msgid "Couldn't run pkg-config: " -msgstr "Kann pkg-config nicht ausführen:" - -#: ../mcs/mcs/driver.cs:1084 -msgid "Specified package did not return any information" -msgstr "" - -#: ../mcs/mcs/driver.cs:1091 -msgid "Error running pkg-config. Check the above output." -msgstr "" -"Fehler beim ausführen von pkg-config. Bitte prüfen Sie die Ausgabe oben." - -#: ../mcs/mcs/driver.cs:1187 +#: mcs/mcs/driver.cs:910 #, csharp-format msgid "Invalid conditional define symbol `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1241 +#: mcs/mcs/driver.cs:961 #, csharp-format msgid "" "Invalid resource visibility option `{0}'. Use either `public' or `private' " "instead" msgstr "" -#: ../mcs/mcs/driver.cs:1247 +#: mcs/mcs/driver.cs:967 #, csharp-format msgid "Wrong number of arguments for option `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1255 -msgid "-recurse requires an argument" -msgstr "-recurse benötigt ein Argument" - -#: ../mcs/mcs/driver.cs:1264 -msgid "-reference requires an argument" -msgstr "-reference benötigt ein Argument" - -#: ../mcs/mcs/driver.cs:1286 ../mcs/mcs/driver.cs:1298 -#: ../mcs/mcs/driver.cs:1310 ../mcs/mcs/driver.cs:1322 -#: ../mcs/mcs/driver.cs:1431 ../mcs/mcs/driver.cs:1451 -#: ../mcs/mcs/driver.cs:1458 -msgid " requires an argument" -msgstr "benötigt ein Argument" +#: mcs/mcs/driver.cs:1005 +msgid "Cannot specify multiple aliases using single /reference option" +msgstr "" -#: ../mcs/mcs/driver.cs:1303 ../mcs/mcs/driver.cs:1315 +#: mcs/mcs/driver.cs:1033 mcs/mcs/driver.cs:1045 msgid "" "Cannot specify the `win32res' and the `win32ico' compiler option at the same " "time" msgstr "" -#: ../mcs/mcs/driver.cs:1332 -msgid "/lib requires an argument" -msgstr "/lib benötigt ein Argument" +#: mcs/mcs/driver.cs:1160 +#, csharp-format +msgid "`{0}' is not a valid warning number" +msgstr "" -#: ../mcs/mcs/driver.cs:1394 -msgid "/nowarn requires an argument" -msgstr "/nowarn benötigt ein Argument" +#: mcs/mcs/driver.cs:1190 +msgid "" +"Invalid platform type for -platform. Valid options are `anycpu', `x86', " +"`x64' or `itanium'" +msgstr "" -#: ../mcs/mcs/driver.cs:1488 -#, csharp-format +#: mcs/mcs/driver.cs:1288 +#, fuzzy, csharp-format msgid "" -"Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or " +"Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or " "`Default'" msgstr "" "Ungültige Option `{0}' für /langversion. Es muss entweder `ISO-1', `ISO-2' " "oder `Default' sein" -#: ../mcs/mcs/driver.cs:1504 +#: mcs/mcs/driver.cs:1308 #, csharp-format msgid "Code page `{0}' is invalid or not installed" msgstr "" -#: ../mcs/mcs/driver.cs:1516 +#: mcs/mcs/driver.cs:1323 #, csharp-format msgid "Unrecognized command-line option: `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1546 -msgid "Invalid reference alias '" -msgstr "Ungültiger Referenz Alias '" - -#: ../mcs/mcs/driver.cs:1551 -msgid "Invalid extern alias for /reference. Alias '" -msgstr "Ungültiger externer Alias für /reference. Alias '" - -#: ../mcs/mcs/driver.cs:1617 -msgid "" -"If no source files are specified you must specify the output file with -out:" -msgstr "" - -#: ../mcs/mcs/driver.cs:1739 +#: mcs/mcs/driver.cs:1328 #, csharp-format -msgid "Could not find `{0}' specified for Main method" +msgid "Missing file specification for `{0}' option" msgstr "" -#: ../mcs/mcs/driver.cs:1744 -#, csharp-format -msgid "`{0}' specified for Main method must be a valid class or struct" -msgstr "" +#: mcs/mcs/driver.cs:1333 +#, fuzzy, csharp-format +msgid "Missing argument for `{0}' option" +msgstr "Fehlendes Argument bei --linkres" -#: ../mcs/mcs/driver.cs:1748 -#, csharp-format -msgid "`{0}' does not have a suitable static Main method" -msgstr "" +#: mcs/mcs/driver.cs:1368 +#, fuzzy, csharp-format +msgid "Invalid reference alias `{0}='. Missing filename" +msgstr "Ungültiger Referenz Alias '" -#: ../mcs/mcs/driver.cs:1753 -#, csharp-format +#: mcs/mcs/driver.cs:1373 +#, fuzzy, csharp-format msgid "" -"Program `{0}' does not contain a static `Main' method suitable for an entry " -"point" +"Invalid extern alias for -reference. Alias `{0}' is not a valid identifier" +msgstr "Ungültiger externer Alias für /reference. Alias '" + +#: mcs/mcs/driver.cs:1389 +#, csharp-format +msgid "The resource identifier `{0}' has already been used in this assembly" msgstr "" -#: ../mcs/mcs/driver.cs:1760 -msgid "Cannot specify -main if building a module or library" +#: mcs/mcs/driver.cs:1450 +msgid "" +"If no source files are specified you must specify the output file with -out:" msgstr "" -#: ../mcs/mcs/driver.cs:1765 -msgid "Cannot link resource file when building a module" +#: mcs/mcs/dynamic.cs:272 +msgid "An expression tree cannot contain a dynamic operation" msgstr "" -#: ../mcs/mcs/driver.cs:1915 -#, csharp-format -msgid "The resource identifier `{0}' has already been used in this assembly" +#: mcs/mcs/dynamic.cs:302 +msgid "" +"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly " +"reference" msgstr "" -#: ../mcs/mcs/driver.cs:1929 +#: mcs/mcs/ecore.cs:242 #, csharp-format -msgid "Error reading resource file `{0}'" +msgid "`{0}' is inaccessible due to its protection level" msgstr "" -#: ../mcs/mcs/ecore.cs:321 +#: mcs/mcs/ecore.cs:247 #, csharp-format -msgid "`{0}' is inaccessible due to its protection level" +msgid "The expression being assigned to `{0}' must be constant" msgstr "" -#: ../mcs/mcs/ecore.cs:326 +#: mcs/mcs/ecore.cs:252 #, csharp-format msgid "" -"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " -"qualifier must be of type `{2}' or derived from it" +"A constant `{0}' of reference type `{1}' can only be initialized with null" msgstr "" -#: ../mcs/mcs/ecore.cs:336 +#: mcs/mcs/ecore.cs:258 msgid "" "Only assignment, call, increment, decrement, and new object expressions can " "be used as a statement" msgstr "" -#: ../mcs/mcs/ecore.cs:347 -#, csharp-format -msgid "Cannot assign to `{0}' because it is a `{1}'" -msgstr "" - -#: ../mcs/mcs/ecore.cs:353 +#: mcs/mcs/ecore.cs:269 msgid "Keyword `void' cannot be used in this context" msgstr "" -#: ../mcs/mcs/ecore.cs:383 ../mcs/mcs/statement.cs:1098 +#: mcs/mcs/ecore.cs:303 #, csharp-format msgid "Cannot convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:393 +#: mcs/mcs/ecore.cs:313 #, csharp-format msgid "" "Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " "(are you missing a cast?)" msgstr "" -#: ../mcs/mcs/ecore.cs:399 +#: mcs/mcs/ecore.cs:319 #, csharp-format msgid "Cannot implicitly convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:406 -#, csharp-format -msgid "A local variable `{0}' cannot be used before it is declared" -msgstr "" - -#: ../mcs/mcs/ecore.cs:417 +#: mcs/mcs/ecore.cs:360 #, csharp-format msgid "`{0}' does not contain a definition for `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:423 +#: mcs/mcs/ecore.cs:366 msgid "" "The left-hand side of an assignment must be a variable, a property or an " "indexer" msgstr "" -#: ../mcs/mcs/ecore.cs:560 -msgid "A ref or out argument must be an assignable variable" +#: mcs/mcs/ecore.cs:371 +msgid "The operation in question is undefined on void pointers" msgstr "" -#: ../mcs/mcs/ecore.cs:714 ../mcs/mcs/ecore.cs:730 +#: mcs/mcs/ecore.cs:433 mcs/mcs/statement.cs:2558 mcs/mcs/statement.cs:2560 #, csharp-format -msgid "Ambiguity between `{0}' and `{1}'" +msgid "Internal compiler error: {0}" msgstr "" -#: ../mcs/mcs/ecore.cs:831 ../mcs/mcs/ecore.cs:2777 -#, csharp-format +#: mcs/mcs/ecore.cs:473 +msgid "A ref or out argument must be an assignable variable" +msgstr "" + +#: mcs/mcs/ecore.cs:492 msgid "" -"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +"An attribute argument must be a constant expression, typeof expression or " +"array creation expression" msgstr "" -#: ../mcs/mcs/ecore.cs:872 +#: mcs/mcs/ecore.cs:563 #, csharp-format -msgid "The name `{0}' does not exist in the current context" +msgid "The class `{0}' has no constructors defined" msgstr "" -#: ../mcs/mcs/ecore.cs:887 ../mcs/mcs/generic.cs:1398 +#: mcs/mcs/ecore.cs:648 #, csharp-format -msgid "Using the generic type `{0}' requires {1} type arguments" +msgid "Ambiguity between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:916 +#: mcs/mcs/ecore.cs:675 msgid "An expression tree cannot contain an unsafe pointer operation" msgstr "" -#: ../mcs/mcs/ecore.cs:1030 -#, csharp-format -msgid "`{0}' is a `{1}' but a `{2}' was expected" -msgstr "" - -#: ../mcs/mcs/ecore.cs:1064 +#: mcs/mcs/ecore.cs:796 #, csharp-format msgid "Expression denotes a `{0}', where a `{1}' was expected" msgstr "" -#: ../mcs/mcs/ecore.cs:1069 +#: mcs/mcs/ecore.cs:806 msgid "Pointers and fixed size buffers may only be used in an unsafe context" msgstr "" -#: ../mcs/mcs/ecore.cs:1175 -#, csharp-format -msgid "Cannot call an abstract base member `{0}'" -msgstr "" - -#: ../mcs/mcs/ecore.cs:1182 +#: mcs/mcs/ecore.cs:841 #, csharp-format msgid "" "Members of value type `{0}' cannot be assigned using a property `{1}' object " "initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:1185 +#: mcs/mcs/ecore.cs:844 #, csharp-format msgid "" "Cannot modify a value type return value of `{0}'. Consider storing the value " "in a temporary variable" msgstr "" -#: ../mcs/mcs/ecore.cs:1833 -msgid "Cannot modify the result of an unboxing conversion" -msgstr "Das Ergebnis einer Unboxing-Konvertierung kann nicht geändert werden" +#: mcs/mcs/ecore.cs:2270 +#, fuzzy, csharp-format +msgid "" +"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core." +"dll assembly reference?" +msgstr "" +"Der Typ oder Namespacename `{0}' konnte nicht gefunden werden. Fehlt eine " +"using-Direktive oder ein Assemblyverweis?" -#: ../mcs/mcs/ecore.cs:2401 +#: mcs/mcs/ecore.cs:2344 #, csharp-format msgid "" -"A field initializer cannot reference the nonstatic field, method, or " -"property `{0}'" +"A local variable `{0}' cannot be used before it is declared. Consider " +"renaming the local variable when it hides the member `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:2405 +#: mcs/mcs/ecore.cs:2359 mcs/mcs/ecore.cs:2403 #, csharp-format -msgid "An object reference is required to access non-static member `{0}'" +msgid "`{0}' conflicts with a declaration in a child block" +msgstr "" + +#: mcs/mcs/ecore.cs:2412 +#, csharp-format +msgid "A local variable `{0}' cannot be used before it is declared" +msgstr "" + +#: mcs/mcs/ecore.cs:2414 +#, csharp-format +msgid "The name `{0}' does not exist in the current context" +msgstr "" + +#: mcs/mcs/ecore.cs:2664 +#, csharp-format +msgid "" +"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " +"qualifier must be of type `{2}' or derived from it" msgstr "" -#: ../mcs/mcs/ecore.cs:2612 ../mcs/mcs/ecore.cs:2632 +#: mcs/mcs/ecore.cs:2708 #, csharp-format -msgid "The variable `{0}' cannot be used with type arguments" +msgid "Cannot call an abstract base member `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3160 +#: mcs/mcs/ecore.cs:2747 #, csharp-format msgid "" "Static member `{0}' cannot be accessed with an instance reference, qualify " "it with a type name instead" msgstr "" -#: ../mcs/mcs/ecore.cs:3166 -msgid "An expression tree may not contain a base access" +#: mcs/mcs/ecore.cs:2762 +#, csharp-format +msgid "" +"A field initializer cannot reference the nonstatic field, method, or " +"property `{0}'" +msgstr "" + +#: mcs/mcs/ecore.cs:2766 +#, csharp-format +msgid "An object reference is required to access non-static member `{0}'" +msgstr "" + +#: mcs/mcs/ecore.cs:2774 +#, csharp-format +msgid "" +"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +msgstr "" + +#: mcs/mcs/ecore.cs:2822 +msgid "Cannot modify the result of an unboxing conversion" +msgstr "Das Ergebnis einer Unboxing-Konvertierung kann nicht geändert werden" + +#: mcs/mcs/ecore.cs:2943 +#, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3256 +#: mcs/mcs/ecore.cs:2948 #, csharp-format -msgid "The property `{0}' cannot be used with type arguments" +msgid "Extension method instance type `{0}' cannot be converted to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3710 +#: mcs/mcs/ecore.cs:3072 msgid "An expression tree cannot contain an expression with method group" msgstr "" -#: ../mcs/mcs/ecore.cs:3720 +#: mcs/mcs/ecore.cs:3078 msgid "" "Partial methods with only a defining declaration or removed conditional " "methods cannot be used in an expression tree" msgstr "" -#: ../mcs/mcs/ecore.cs:3738 -msgid "Method `" -msgstr "" - -#: ../mcs/mcs/ecore.cs:3765 +#: mcs/mcs/ecore.cs:3108 #, csharp-format msgid "" -"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " -"`out' modifier" +"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " +"parentheses to invoke the method" msgstr "" -#: ../mcs/mcs/ecore.cs:3769 +#: mcs/mcs/ecore.cs:3676 #, csharp-format msgid "" -"The best overloaded collection initalizer method `{0}' has some invalid " -"arguments" +"The type `{0}' does not contain a constructor that takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3775 +#: mcs/mcs/ecore.cs:4284 #, csharp-format msgid "" "Type `{0}' does not contain a member `{1}' and the best extension method " -"overload `{2}' has some invalid arguments" +"overload `{2}' cannot be dynamically dispatched. Consider calling the method " +"without the extension method syntax" msgstr "" -#: ../mcs/mcs/ecore.cs:3779 +#: mcs/mcs/ecore.cs:4305 #, csharp-format -msgid "The best overloaded method match for `{0}' has some invalid arguments" +msgid "" +"The call is ambiguous between the following methods or properties: `{0}' and " +"`{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3783 +#: mcs/mcs/ecore.cs:4360 #, csharp-format -msgid "Delegate `{0}' has some invalid arguments" +msgid "" +"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " +"`out' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:3792 +#: mcs/mcs/ecore.cs:4364 #, csharp-format msgid "" -"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " -"modifier" +"The best overloaded collection initalizer method `{0}' has some invalid " +"arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3795 +#: mcs/mcs/ecore.cs:4367 #, csharp-format -msgid "Argument `#{0}' is missing `{1}' modifier" +msgid "Delegate `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3809 +#: mcs/mcs/ecore.cs:4371 #, csharp-format -msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +msgid "The best overloaded method match for `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3812 +#: mcs/mcs/ecore.cs:4381 #, csharp-format -msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" +msgid "" +"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " +"modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:3819 +#: mcs/mcs/ecore.cs:4384 #, csharp-format -msgid "" -"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " -"parentheses to invoke the method" +msgid "Argument `#{0}' is missing `{1}' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:4105 -msgid "Invoke cannot be called directly on a delegate" +#: mcs/mcs/ecore.cs:4397 +#, csharp-format +msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4237 +#: mcs/mcs/ecore.cs:4445 #, csharp-format msgid "" "The type arguments for method `{0}' cannot be inferred from the usage. Try " "specifying the type arguments explicitly" msgstr "" -#: ../mcs/mcs/ecore.cs:4246 +#: mcs/mcs/ecore.cs:4474 #, csharp-format -msgid "Using the generic method `{0}' requires `{1}' type argument(s)" +msgid "No overload for method `{0}' takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:4275 +#: mcs/mcs/ecore.cs:4527 #, csharp-format -msgid "" -"The type `{0}' does not contain a constructor that takes `{1}' arguments" +msgid "The delegate `{0}' does not contain a parameter named `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4278 +#: mcs/mcs/ecore.cs:4532 #, csharp-format -msgid "No overload for method `{0}' takes `{1}' arguments" +msgid "" +"The best overloaded method match for `{0}' does not contain a parameter " +"named `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4383 +#: mcs/mcs/ecore.cs:4542 #, csharp-format msgid "" -"The call is ambiguous between the following methods or properties: `{0}' and " -"`{1}'" +"Named argument `{0}' cannot be used for a parameter which has positional " +"argument specified" msgstr "" -#: ../mcs/mcs/ecore.cs:4810 +#: mcs/mcs/ecore.cs:4855 msgid "" "You cannot use fixed size buffers contained in unfixed expressions. Try " "using the fixed statement" msgstr "" -#: ../mcs/mcs/ecore.cs:4815 +#: mcs/mcs/ecore.cs:4860 #, csharp-format msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" msgstr "" -#: ../mcs/mcs/ecore.cs:5083 -#, csharp-format -msgid "" -"A local variable `{0}' cannot be used before it is declared. Consider " -"renaming the local variable when it hides the field `{1}'" +#: mcs/mcs/ecore.cs:5255 +#, fuzzy, csharp-format +msgid "Property or event `{0}' is not supported by the C# language" msgstr "" +"Die Eigenschaft `{0}' wird von der C# Sprache nicht unterstützt. Rufen Sie " +"die `{1}'-Accessormethode direkt auf." -#: ../mcs/mcs/ecore.cs:5368 +#: mcs/mcs/ecore.cs:5416 #, csharp-format -msgid "" -"Property `{0}' is not supported by the C# language. Try to call the accessor " -"method `{1}' directly" +msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" msgstr "" -"Die Eigenschaft `{0}' wird von der C# Sprache nicht unterstützt. Rufen Sie " -"die `{1}'-Accessormethode direkt auf." -#: ../mcs/mcs/ecore.cs:5414 +#: mcs/mcs/ecore.cs:5464 #, csharp-format msgid "" "The property or indexer `{0}' cannot be used in this context because it " "lacks the `get' accessor" msgstr "" -#: ../mcs/mcs/ecore.cs:5426 +#: mcs/mcs/ecore.cs:5471 #, csharp-format msgid "" "The property or indexer `{0}' cannot be used in this context because the get " "accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:5470 -#, csharp-format -msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" -msgstr "" - -#: ../mcs/mcs/ecore.cs:5473 -#, csharp-format -msgid "" -"A property or indexer `{0}' may not be passed as `ref' or `out' parameter" -msgstr "" - -#: ../mcs/mcs/ecore.cs:5494 -#, csharp-format -msgid "" -"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " -"store the value" -msgstr "" - -#: ../mcs/mcs/ecore.cs:5497 +#: mcs/mcs/ecore.cs:5490 #, csharp-format -msgid "Property or indexer `{0}' cannot be assigned to (it is read only)" +msgid "Property or indexer `{0}' cannot be assigned to (it is read-only)" msgstr "" -#: ../mcs/mcs/ecore.cs:5513 +#: mcs/mcs/ecore.cs:5498 #, csharp-format msgid "" "The property or indexer `{0}' cannot be used in this context because the set " "accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:5671 +#: mcs/mcs/ecore.cs:5659 #, csharp-format msgid "" "The event `{0}' can only appear on the left hand side of `+=' or `-=' " "operator" msgstr "" -#: ../mcs/mcs/ecore.cs:5805 +#: mcs/mcs/ecore.cs:5663 #, csharp-format msgid "" "The event `{0}' can only appear on the left hand side of += or -= when used " "outside of the type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5932 +#: mcs/mcs/ecore.cs:5827 #, csharp-format msgid "" "An implicitly typed local variable declaration cannot be initialized with `" "{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5943 +#: mcs/mcs/ecore.cs:5841 msgid "" "The contextual keyword `var' may only appear within a local variable " "declaration" msgstr "" -#: ../mcs/mcs/ecore.cs:5957 -msgid "" -"An implicitly typed local variable declaration cannot include multiple " -"declarators" -msgstr "" - -#: ../mcs/mcs/ecore.cs:5964 -msgid "" -"An implicitly typed local variable declarator must include an initializer" -msgstr "" - -#: ../mcs/mcs/enum.cs:112 +#: mcs/mcs/enum.cs:125 #, csharp-format -msgid "The enumerator value `{0}' is too large to fit in its type `{1}'" +msgid "" +"The enumerator value `{0}' is outside the range of enumerator underlying " +"type `{1}'" msgstr "" -#: ../mcs/mcs/enum.cs:148 +#: mcs/mcs/enum.cs:189 #, csharp-format msgid "An item in an enumeration cannot have an identifier `{0}'" msgstr "" -#: ../mcs/mcs/enum.cs:158 +#: mcs/mcs/enum.cs:200 msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" msgstr "Typ byte, sbyte, short, ushort, int, uint, long oder ulong erwartet" -#: ../mcs/mcs/eval.cs:496 +#: mcs/mcs/eval.cs:625 msgid "Detection Parsing Error" msgstr "" -#: ../mcs/mcs/expression.cs:553 +#: mcs/mcs/expression.cs:542 #, csharp-format msgid "The `{0}' operator cannot be applied to operand of type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:720 +#: mcs/mcs/expression.cs:622 +msgid "Cannot take the address of the given expression" +msgstr "" + +#: mcs/mcs/expression.cs:656 +msgid "" +"You can only take the address of unfixed expression inside of a fixed " +"statement initializer" +msgstr "" + +#: mcs/mcs/expression.cs:745 #, csharp-format msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:979 +#: mcs/mcs/expression.cs:868 +msgid "The * or -> operator must be applied to a pointer" +msgstr "" + +#: mcs/mcs/expression.cs:1070 msgid "" "The operand of an increment or decrement operator must be a variable, " "property or indexer" msgstr "" -#: ../mcs/mcs/expression.cs:1146 +#: mcs/mcs/expression.cs:1260 #, csharp-format msgid "The `{0}' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/expression.cs:1151 +#: mcs/mcs/expression.cs:1265 #, csharp-format msgid "The `{0}' operator cannot be applied to an operand of pointer type" msgstr "" -#: ../mcs/mcs/expression.cs:1157 +#: mcs/mcs/expression.cs:1271 #, csharp-format msgid "" "The `{0}' operator cannot be applied to a lambda expression or anonymous " "method" msgstr "" -#: ../mcs/mcs/expression.cs:1395 +#: mcs/mcs/expression.cs:1507 #, csharp-format msgid "" -"The `as' operator cannot be used with a non-reference type parameter `{0}'" +"The `as' operator cannot be used with a non-reference type parameter `{0}'. " +"Consider adding `class' or a reference type constraint" msgstr "" -#: ../mcs/mcs/expression.cs:1399 +#: mcs/mcs/expression.cs:1511 #, csharp-format msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1431 +#: mcs/mcs/expression.cs:1548 #, csharp-format msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" msgstr "" -#: ../mcs/mcs/expression.cs:1495 +#: mcs/mcs/expression.cs:1589 #, csharp-format msgid "Cannot convert to static type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1560 +#: mcs/mcs/expression.cs:1679 msgid "" "The `default value' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/expression.cs:1978 +#: mcs/mcs/expression.cs:2184 #, csharp-format msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:2487 +#: mcs/mcs/expression.cs:2747 msgid "To cast a negative value, you must enclose the value in parentheses" msgstr "" -#: ../mcs/mcs/expression.cs:2985 +#: mcs/mcs/expression.cs:3400 #, csharp-format msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:3677 +#: mcs/mcs/expression.cs:4152 #, csharp-format msgid "" "A user-defined operator `{0}' must have parameters and return values of the " "same type in order to be applicable as a short circuit operator" msgstr "" -#: ../mcs/mcs/expression.cs:3687 +#: mcs/mcs/expression.cs:4162 #, csharp-format msgid "" "The type `{0}' must have operator `true' and operator `false' defined when `" "{1}' is used as a short circuit operator" msgstr "" -#: ../mcs/mcs/expression.cs:3934 +#: mcs/mcs/expression.cs:4472 +#, csharp-format +msgid "" +"Type of conditional expression cannot be determined as `{0}' and `{1}' " +"convert implicitly to each other" +msgstr "" + +#: mcs/mcs/expression.cs:4482 #, csharp-format msgid "" "Type of conditional expression cannot be determined because there is no " "implicit conversion between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:4395 +#: mcs/mcs/expression.cs:4934 #, csharp-format msgid "Use of unassigned out parameter `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:4423 +#: mcs/mcs/expression.cs:4964 #, csharp-format msgid "" "Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " "modifier" msgstr "" -#: ../mcs/mcs/expression.cs:4749 +#: mcs/mcs/expression.cs:5165 +#, fuzzy, csharp-format +msgid "Cannot invoke a non-delegate type `{0}'" +msgstr "Kann Typ `{0}'<...> nicht finden" + +#: mcs/mcs/expression.cs:5176 #, csharp-format msgid "The member `{0}' cannot be used as method or delegate" msgstr "" -#: ../mcs/mcs/expression.cs:4811 +#: mcs/mcs/expression.cs:5196 msgid "" "Do not directly call your base class Finalize method. It is called " "automatically from your destructor" msgstr "" -#: ../mcs/mcs/expression.cs:4813 +#: mcs/mcs/expression.cs:5198 msgid "" "Destructors and object.Finalize cannot be called directly. Consider calling " "IDisposable.Dispose if available" msgstr "" -#: ../mcs/mcs/expression.cs:4837 +#: mcs/mcs/expression.cs:5227 +#, csharp-format +msgid "" +"The base call to method `{0}' cannot be dynamically dispatched. Consider " +"casting the dynamic arguments or eliminating the base access" +msgstr "" + +#: mcs/mcs/expression.cs:5304 #, csharp-format msgid "`{0}': cannot explicitly call operator or accessor" msgstr "" -#: ../mcs/mcs/expression.cs:5390 +#: mcs/mcs/expression.cs:5631 #, csharp-format msgid "Unsafe type `{0}' cannot be used in an object creation expression" msgstr "" -#: ../mcs/mcs/expression.cs:5442 +#: mcs/mcs/expression.cs:5654 +#, csharp-format +msgid "" +"Cannot create an instance of the variable type `{0}' because it does not " +"have the new() constraint" +msgstr "" + +#: mcs/mcs/expression.cs:5660 +#, csharp-format +msgid "" +"`{0}': cannot provide arguments when creating an instance of a variable type" +msgstr "" + +#: mcs/mcs/expression.cs:5669 #, csharp-format msgid "Cannot create an instance of the static class `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:5454 +#: mcs/mcs/expression.cs:5681 #, csharp-format msgid "Cannot create an instance of the abstract class or interface `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:5767 +#: mcs/mcs/expression.cs:5977 +msgid "" +"An implicitly typed local variable declarator cannot use an array initializer" +msgstr "" + +#: mcs/mcs/expression.cs:6070 msgid "Cannot create an array with a negative size" msgstr "" -#: ../mcs/mcs/expression.cs:5784 ../mcs/mcs/statement.cs:2991 +#: mcs/mcs/expression.cs:6102 mcs/mcs/expression.cs:6110 +#: mcs/mcs/statement.cs:1009 mcs/mcs/statement.cs:3055 msgid "A constant value is expected" msgstr "" -#: ../mcs/mcs/expression.cs:5871 +#: mcs/mcs/expression.cs:6116 +#, csharp-format +msgid "An array initializer of length `{0}' was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6132 +msgid "" +"Array initializers can only be used in a variable or field initializer. Try " +"using a new expression instead" +msgstr "" + +#: mcs/mcs/expression.cs:6140 +msgid "A nested array initializer was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6177 msgid "An expression tree cannot contain a multidimensional array initializer" msgstr "" -#: ../mcs/mcs/expression.cs:5965 +#: mcs/mcs/expression.cs:6279 msgid "" "Can only use array initializer expressions to assign to array types. Try " "using a new expression instead" msgstr "" -#: ../mcs/mcs/expression.cs:5970 +#: mcs/mcs/expression.cs:6718 msgid "" -"An implicitly typed local variable declarator cannot use an array initializer" +"The type of an implicitly typed array cannot be inferred from the " +"initializer. Try specifying array type explicitly" msgstr "" -#: ../mcs/mcs/expression.cs:6045 -msgid "New invocation: Can not find a constructor for this argument list" +#: mcs/mcs/expression.cs:6855 +msgid "" +"The `this' object cannot be used before all of its fields are assigned to" msgstr "" -#: ../mcs/mcs/expression.cs:6488 +#: mcs/mcs/expression.cs:6862 msgid "" -"The type of an implicitly typed array cannot be inferred from the " -"initializer. Try specifying array type explicitly" +"Keyword `this' is not valid in a static property, static method, or static " +"field initializer" msgstr "" -#: ../mcs/mcs/expression.cs:6666 +#: mcs/mcs/expression.cs:6865 msgid "" "Anonymous methods inside structs cannot access instance members of `this'. " "Consider copying `this' to a local variable outside the anonymous method and " "using the local instead" msgstr "" -#: ../mcs/mcs/expression.cs:6740 +#: mcs/mcs/expression.cs:6868 +msgid "Keyword `this' is not available in the current context" +msgstr "" + +#: mcs/mcs/expression.cs:6955 msgid "Cannot take the address of `this' because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6742 +#: mcs/mcs/expression.cs:6957 msgid "Cannot pass `this' as a ref or out argument because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6744 +#: mcs/mcs/expression.cs:6959 msgid "Cannot assign to `this' because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6856 +#: mcs/mcs/expression.cs:7012 +msgid "The __arglist construct is valid only within a variable argument method" +msgstr "" + +#: mcs/mcs/expression.cs:7062 msgid "An expression tree cannot contain a method with variable arguments" msgstr "" -#: ../mcs/mcs/expression.cs:6966 +#: mcs/mcs/expression.cs:7146 +msgid "" +"System.Void cannot be used from C#. Use typeof (void) to get the void type " +"object" +msgstr "" + +#: mcs/mcs/expression.cs:7149 +msgid "The typeof operator cannot be used on the dynamic type" +msgstr "" + +#: mcs/mcs/expression.cs:7218 #, csharp-format msgid "`{0}': an attribute argument cannot use type parameters" msgstr "" -#: ../mcs/mcs/expression.cs:7199 +#: mcs/mcs/expression.cs:7472 #, csharp-format msgid "" "`{0}' does not have a predefined size, therefore sizeof can only be used in " @@ -2273,12 +2344,12 @@ msgid "" "SizeOf)" msgstr "" -#: ../mcs/mcs/expression.cs:7254 +#: mcs/mcs/expression.cs:7528 #, csharp-format msgid "Alias `{0}' not found" msgstr "Alias `{0}' wurde nicht gefunden" -#: ../mcs/mcs/expression.cs:7265 +#: mcs/mcs/expression.cs:7539 #, csharp-format msgid "" "Alias `{0}' cannot be used with '::' since it denotes a type. Consider " @@ -2287,28 +2358,32 @@ msgstr "" "Der Alias `{0}' kann nicht mit '::' verwendet werden, da der Alias auf einen " "Typ verweist. Verwenden Sie '.' stattdessen." -#: ../mcs/mcs/expression.cs:7281 +#: mcs/mcs/expression.cs:7555 #, csharp-format msgid "" "A namespace alias qualifier `{0}' did not resolve to a namespace or a type" msgstr "" -#: ../mcs/mcs/expression.cs:7422 +#: mcs/mcs/expression.cs:7712 +msgid "Cannot perform member binding on `null' value" +msgstr "" + +#: mcs/mcs/expression.cs:7779 #, csharp-format msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" msgstr "" -#: ../mcs/mcs/expression.cs:7519 +#: mcs/mcs/expression.cs:7855 #, csharp-format msgid "A nested type cannot be specified through a type parameter `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:7587 +#: mcs/mcs/expression.cs:7914 #, csharp-format msgid "The nested type `{0}' does not exist in the type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:7599 +#: mcs/mcs/expression.cs:7923 #, csharp-format msgid "" "Type `{0}' does not contain a definition for `{1}' and no extension method `" @@ -2316,204 +2391,289 @@ msgid "" "assembly reference?)" msgstr "" -#: ../mcs/mcs/expression.cs:7817 -msgid "Cannot apply indexing with [] to an expression of type `System.Array'" +#: mcs/mcs/expression.cs:8103 +#, csharp-format +msgid "Cannot apply indexing with [] to an expression of type `{0}'" +msgstr "" + +#: mcs/mcs/expression.cs:8119 +msgid "A pointer must be indexed by only one value" msgstr "" -#: ../mcs/mcs/expression.cs:7923 +#: mcs/mcs/expression.cs:8168 +msgid "An element access expression cannot use named argument" +msgstr "" + +#: mcs/mcs/expression.cs:8224 #, csharp-format msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8410 -#, csharp-format +#: mcs/mcs/expression.cs:8560 msgid "" -"A property or indexer `{0}' may not be passed as an out or ref parameter" +"The indexer base access cannot be dynamically dispatched. Consider casting " +"the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/expression.cs:8435 -#, csharp-format -msgid "Cannot apply indexing with [] to an expression of type `{0}'" +#: mcs/mcs/expression.cs:8641 +msgid "An expression tree may not contain a base access" msgstr "" -#: ../mcs/mcs/expression.cs:8465 -#, csharp-format -msgid "The read only property or indexer `{0}' cannot be assigned to" +#: mcs/mcs/expression.cs:8658 +msgid "Keyword `base' is not available in a static method" msgstr "" -#: ../mcs/mcs/expression.cs:8473 -#, csharp-format -msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks a `{1}' accessor" +#: mcs/mcs/expression.cs:8660 +msgid "Keyword `base' is not available in the current context" msgstr "" -#: ../mcs/mcs/expression.cs:8495 -#, csharp-format +#: mcs/mcs/expression.cs:8691 msgid "" -"The property or indexer `{0}' cannot be used in this context because a `{1}' " -"accessor is inaccessible" +"A property, indexer or dynamic member access may not be passed as `ref' or " +"`out' parameter" msgstr "" -#: ../mcs/mcs/expression.cs:8958 +#: mcs/mcs/expression.cs:8968 #, csharp-format msgid "Array elements cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:8964 +#: mcs/mcs/expression.cs:8971 #, csharp-format msgid "Array elements cannot be of static type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:9130 +#: mcs/mcs/expression.cs:9121 msgid "Cannot use a negative size with stackalloc" msgstr "" -#: ../mcs/mcs/expression.cs:9257 +#: mcs/mcs/expression.cs:9125 +msgid "Cannot use stackalloc in finally or catch" +msgstr "" + +#: mcs/mcs/expression.cs:9230 #, csharp-format msgid "" "Member `{0}' cannot be initialized. An object initializer may only be used " "for fields, or properties" msgstr "" -#: ../mcs/mcs/expression.cs:9260 +#: mcs/mcs/expression.cs:9239 #, csharp-format msgid "" -" Static field or property `{0}' cannot be assigned in an object initializer" +"Static field or property `{0}' cannot be assigned in an object initializer" msgstr "" -#: ../mcs/mcs/expression.cs:9433 +#: mcs/mcs/expression.cs:9414 #, csharp-format msgid "" "A field or property `{0}' cannot be initialized with a collection object " "initializer because type `{1}' does not implement `{2}' interface" msgstr "" -#: ../mcs/mcs/expression.cs:9444 +#: mcs/mcs/expression.cs:9425 #, csharp-format msgid "Inconsistent `{0}' member declaration" msgstr "" -#: ../mcs/mcs/expression.cs:9452 +#: mcs/mcs/expression.cs:9433 #, csharp-format msgid "" "An object initializer includes more than one member `{0}' initialization" msgstr "" -#: ../mcs/mcs/expression.cs:9469 +#: mcs/mcs/expression.cs:9451 #, csharp-format msgid "Cannot initialize object of type `{0}' with a collection initializer" msgstr "" -#: ../mcs/mcs/expression.cs:9717 +#: mcs/mcs/expression.cs:9688 msgid "Anonymous types cannot be used in this expression" msgstr "" -#: ../mcs/mcs/expression.cs:9824 +#: mcs/mcs/expression.cs:9776 #, csharp-format msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:310 -msgid "Control cannot fall through from one case label to another" -msgstr "" +#: mcs/mcs/field.cs:70 +msgid "" +"The modifier 'abstract' is not valid on fields. Try using a property instead" +msgstr "" + +#: mcs/mcs/field.cs:121 +msgid "" +"The FieldOffset attribute can only be placed on members of types marked with " +"the StructLayout(LayoutKind.Explicit)" +msgstr "" + +#: mcs/mcs/field.cs:126 +msgid "The FieldOffset attribute is not allowed on static or const fields" +msgstr "" + +#: mcs/mcs/field.cs:132 +msgid "" +"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " +"'fixed' field modifier instead" +msgstr "" + +#: mcs/mcs/field.cs:237 +#, csharp-format +msgid "" +"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " +"must have a FieldOffset attribute" +msgstr "" + +#: mcs/mcs/field.cs:246 +#, csharp-format +msgid "`{0}': cannot declare variables of static types" +msgstr "" + +#: mcs/mcs/field.cs:388 +#, csharp-format +msgid "" +"`{0}': Fixed size buffers type must be one of the following: bool, byte, " +"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +msgstr "" + +#: mcs/mcs/field.cs:424 +#, csharp-format +msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgstr "" + +#: mcs/mcs/field.cs:439 +#, csharp-format +msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgstr "" + +#: mcs/mcs/field.cs:446 +#, csharp-format +msgid "" +"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +msgstr "" -#: ../mcs/mcs/flowanalysis.cs:529 +#: mcs/mcs/field.cs:628 +#, csharp-format +msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgstr "" + +#: mcs/mcs/field.cs:633 +#, fuzzy, csharp-format +msgid "`{0}': A field cannot be both volatile and readonly" +msgstr "`{0}' Eine Klasse kann nicht gleichzeitig statisch und versiegelt sein" + +#: mcs/mcs/flowanalysis.cs:307 +msgid "Control cannot fall through from one case label to another" +msgstr "" + +#: mcs/mcs/flowanalysis.cs:536 #, csharp-format msgid "" "The label `{0}:' could not be found within the scope of the goto statement" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:657 +#: mcs/mcs/flowanalysis.cs:664 msgid "" "A throw statement with no arguments is not allowed outside of a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:668 ../mcs/mcs/flowanalysis.cs:674 +#: mcs/mcs/flowanalysis.cs:675 mcs/mcs/flowanalysis.cs:681 msgid "No enclosing loop out of which to break or continue" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:702 +#: mcs/mcs/flowanalysis.cs:709 msgid "Control cannot leave the body of an anonymous method" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:743 +#: mcs/mcs/flowanalysis.cs:750 msgid "Cannot yield a value in the body of a try block with a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:745 +#: mcs/mcs/flowanalysis.cs:752 msgid "Cannot yield a value in the body of a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:897 +#: mcs/mcs/flowanalysis.cs:904 msgid "" "A throw statement with no arguments is not allowed inside of a finally " "clause nested inside of the innermost catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:909 ../mcs/mcs/iterators.cs:112 +#: mcs/mcs/flowanalysis.cs:916 mcs/mcs/iterators.cs:102 msgid "Cannot yield in the body of a finally clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:920 ../mcs/mcs/flowanalysis.cs:936 -#: ../mcs/mcs/flowanalysis.cs:972 ../mcs/mcs/statement.cs:778 +#: mcs/mcs/flowanalysis.cs:927 mcs/mcs/flowanalysis.cs:943 +#: mcs/mcs/flowanalysis.cs:979 mcs/mcs/statement.cs:694 msgid "Control cannot leave the body of a finally clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1140 +#: mcs/mcs/flowanalysis.cs:1130 #, csharp-format msgid "" "An automatically implemented property `{0}' must be fully assigned before " -"control leaves the constructor. Consider calling default contructor" +"control leaves the constructor. Consider calling the default struct " +"contructor from a constructor initializer" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1144 +#: mcs/mcs/flowanalysis.cs:1134 #, csharp-format msgid "" "Field `{0}' must be fully assigned before control leaves the constructor" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1438 +#: mcs/mcs/flowanalysis.cs:1376 msgid "Use of unassigned local variable `" msgstr "Verwendung der nicht zugewiesenen lokalen Variable `" -#: ../mcs/mcs/flowanalysis.cs:1508 +#: mcs/mcs/flowanalysis.cs:1446 msgid "Use of possibly unassigned field `" msgstr "Verwendung eines möglicherweise nicht zugewiesenen Feldes `" -#: ../mcs/mcs/generic.cs:191 -msgid "The new() constraint must be the last constraint specified" +#: mcs/mcs/generic.cs:102 mcs/mcs/generic.cs:120 +#, csharp-format +msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" msgstr "" -"Die `new()'-Einschränkung muss als letzte Einschränkung definiert werden" +"Der Typparameter `{0}' erbt die in Konflikt stehenden Einschränkungen `" +"{1}' und `{2}'" -#: ../mcs/mcs/generic.cs:204 -msgid "The `new()' constraint cannot be used with the `struct' constraint" +#: mcs/mcs/generic.cs:173 +#, csharp-format +msgid "A constraint cannot be the dynamic type `{0}'" msgstr "" -"Die `new()'-Einschränkung kann nicht mit der `struct'-Einschränkung genutzt " -"werden" -#: ../mcs/mcs/generic.cs:210 +#: mcs/mcs/generic.cs:182 +#, csharp-format msgid "" -"The `class' or `struct' constraint must be the first constraint specified" +"Inconsistent accessibility: constraint type `{0}' is less accessible than `" +"{1}'" msgstr "" -"Die `class'- oder `struct'-Einschränkung muss als erste Einschränkung " -"definiert werden" -#: ../mcs/mcs/generic.cs:249 +#: mcs/mcs/generic.cs:189 mcs/mcs/generic.cs:203 +#, csharp-format +msgid "Duplicate constraint `{0}' for type parameter `{1}'" +msgstr "" + +#: mcs/mcs/generic.cs:218 +#, csharp-format +msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgstr "Einschränkungsringabhängigkeit zwischen `{0}' und `{1}'" + +#: mcs/mcs/generic.cs:249 #, csharp-format msgid "" -"Inconsistent accessibility: constraint type `{0}' is less accessible than `" -"{1}'" +"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " +"constraint for `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:261 +#: mcs/mcs/generic.cs:260 #, csharp-format msgid "" "The class type constraint `{0}' must be listed before any other constraints. " "Consider moving type constraint to the beginning of the constraint list" msgstr "" -#: ../mcs/mcs/generic.cs:265 +#: mcs/mcs/generic.cs:266 #, csharp-format msgid "" "`{0}': cannot specify both a constraint class and the `class' or `struct' " @@ -2522,251 +2682,522 @@ msgstr "" "`{0}': Eine Einschränkung kann nicht gleichzeitig mit einer `class'- oder " "`struct'-Einschränkung angegeben werden" -#: ../mcs/mcs/generic.cs:282 ../mcs/mcs/generic.cs:297 +#: mcs/mcs/generic.cs:271 +msgid "A constraint cannot be the dynamic type" +msgstr "" + +#: mcs/mcs/generic.cs:277 #, csharp-format -msgid "Duplicate constraint `{0}' for type parameter `{1}'." +msgid "" +"`{0}' is not a valid constraint. A constraint must be an interface, a non-" +"sealed class or a type parameter" msgstr "" -#: ../mcs/mcs/generic.cs:316 +#: mcs/mcs/generic.cs:284 #, csharp-format msgid "" "`{0}' is not a valid constraint. Static classes cannot be used as constraints" msgstr "" -#: ../mcs/mcs/generic.cs:321 +#: mcs/mcs/generic.cs:290 +#, csharp-format +msgid "A constraint cannot be special class `{0}'" +msgstr "" + +#: mcs/mcs/generic.cs:538 #, csharp-format +msgid "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'" +msgstr "" + +#: mcs/mcs/generic.cs:1720 +#, csharp-format +msgid "`{0}': static classes cannot be used as generic arguments" +msgstr "" + +#: mcs/mcs/generic.cs:1727 +#, csharp-format +msgid "The type `{0}' may not be used as a type argument" +msgstr "" + +#: mcs/mcs/generic.cs:1982 +#, fuzzy, csharp-format msgid "" -"`{0}' is not a valid constraint. A constraint must be an interface, a non-" -"sealed class or a type parameter" +"The type `{0}' must be a reference type in order to use it as type parameter " +"`{1}' in the generic type or method `{2}'" +msgstr "" +"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." + +#: mcs/mcs/generic.cs:1992 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' must be a non-nullable value type in order to use it as type " +"parameter `{1}' in the generic type or method `{2}'" msgstr "" +"Der Typ `{0}' darf keine NULL-Werte zulassen, wenn er als `{1}'-Parameter im " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden soll." -#: ../mcs/mcs/generic.cs:334 +#: mcs/mcs/generic.cs:2022 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. The nullable type `{0}' never satisfies interface constraint" +msgstr "" +"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." + +#: mcs/mcs/generic.cs:2061 #, csharp-format -msgid "A constraint cannot be special class `{0}'" +msgid "" +"The type `{0}' must have a public parameterless constructor in order to use " +"it as parameter `{1}' in the generic type or method `{2}'" +msgstr "" + +#: mcs/mcs/generic.cs:2113 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing conversion from `{0}' to `{3}'" +msgstr "" +"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." + +#: mcs/mcs/generic.cs:2117 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing or type parameter conversion from `{0}' to `" +"{3}'" msgstr "" +"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." -#: ../mcs/mcs/generic.cs:364 +#: mcs/mcs/generic.cs:2121 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'" +msgstr "" +"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " +"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." + +#: mcs/mcs/iterators.cs:44 +msgid "The yield statement cannot be used inside anonymous method blocks" +msgstr "" + +#: mcs/mcs/iterators.cs:856 #, csharp-format msgid "" -"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " -"constraint for `{1}'" +"The body of `{0}' cannot be an iterator block because `{1}' is not an " +"iterator interface type" +msgstr "" + +#: mcs/mcs/iterators.cs:869 +msgid "Iterators cannot have ref or out parameters" +msgstr "" + +#: mcs/mcs/iterators.cs:875 +msgid "__arglist is not allowed in parameter list of iterators" +msgstr "" + +#: mcs/mcs/iterators.cs:881 +msgid "Iterators cannot have unsafe parameters or yield types" +msgstr "" + +#: mcs/mcs/iterators.cs:888 mcs/mcs/statement.cs:4324 +msgid "Unsafe code may not appear in iterators" msgstr "" -#: ../mcs/mcs/generic.cs:384 +#: mcs/mcs/linq.cs:68 #, csharp-format -msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" +msgid "" +"An implementation of `{0}' query expression pattern could not be found. Are " +"you missing `System.Linq' using directive or `System.Core.dll' assembly " +"reference?" msgstr "" -"Der Typparameter `{0}' erbt die in Konflikt stehenden Einschränkungen `" -"{1}' und `{2}'" -#: ../mcs/mcs/generic.cs:398 +#: mcs/mcs/linq.cs:93 #, csharp-format -msgid "Circular constraint dependency involving `{0}' and `{1}'" -msgstr "Einschränkungsringabhängigkeit zwischen `{0}' und `{1}'" +msgid "" +"Ambiguous implementation of the query pattern `{0}' for source type `{1}'" +msgstr "" -#: ../mcs/mcs/generic.cs:702 +#: mcs/mcs/linq.cs:124 #, csharp-format msgid "" -"`{0}': Cannot specify constraints for overrides or explicit interface " -"implementation methods" +"An implementation of `{0}' query expression pattern for source type `{1}' " +"could not be found" msgstr "" -#: ../mcs/mcs/generic.cs:733 +#: mcs/mcs/linq.cs:132 #, csharp-format msgid "" -"The constraints for type parameter `{0}' of method `{1}' must match the " -"constraints for type parameter `{2}' of interface method `{3}'. Consider " -"using an explicit interface implementation instead" +"An expression type is incorrect in a subsequent `from' clause in a query " +"expression with source type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1139 -msgid "Type parameter declaration must be an identifier not a type" +#: mcs/mcs/linq.cs:136 +#, csharp-format +msgid "" +"An expression type in `{0}' clause is incorrect. Type inference failed in " +"the call to `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:1231 +#: mcs/mcs/linq.cs:248 #, csharp-format -msgid "`{0}': static classes cannot be used as generic arguments" +msgid "A range variable `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:1238 +#: mcs/mcs/linq.cs:750 #, csharp-format -msgid "The type `{0}' may not be used as a type argument" +msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1368 +#: mcs/mcs/linq.cs:757 #, csharp-format -msgid "Cannot find type `{0}'<...>" -msgstr "Kann Typ `{0}'<...> nicht finden" +msgid "A range variable `{0}' has already been declared in this scope" +msgstr "" -#: ../mcs/mcs/generic.cs:1375 +#: mcs/mcs/linq.cs:764 #, csharp-format -msgid "The non-generic type `{0}' cannot be used with type arguments." +msgid "A range variable `{0}' conflicts with a method type parameter" msgstr "" -#: ../mcs/mcs/generic.cs:1531 +#: mcs/mcs/linq.cs:796 #, csharp-format msgid "" -"The type `{0}' must be a reference type in order to use it as type parameter " -"`{1}' in the generic type or method `{2}'." +"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " +"store the value" msgstr "" -"Der Typ `{0}' muss ein Referenztyp sein, damit er als `{1}'-Parameter in " -"generischen Typ oder in der generischen Methode `{2}' verwendet werden kann." -#: ../mcs/mcs/generic.cs:1540 +#: mcs/mcs/literal.cs:49 #, csharp-format msgid "" -"The type `{0}' must be a non-nullable value type in order to use it as type " -"parameter `{1}' in the generic type or method `{2}'." +"Cannot convert null to the type parameter `{0}' because it could be a value " +"type. Consider using `default ({0})' instead" msgstr "" -"Der Typ `{0}' darf keine NULL-Werte zulassen, wenn er als `{1}'-Parameter im " -"generischen Typ oder in der generischen Methode `{2}' verwendet werden soll." -#: ../mcs/mcs/generic.cs:1583 +#: mcs/mcs/literal.cs:55 +#, csharp-format +msgid "Cannot convert null to `{0}' because it is a value type" +msgstr "" +"NULL kann nicht in `{0}' konvertiert werden, da dies ein Werttyp ist, der " +"nicht auf NULL festgelegt werden kann" + +#: mcs/mcs/literal.cs:204 #, csharp-format msgid "" -"The type `{0}' must have a public parameterless constructor in order to use " -"it as parameter `{1}' in the generic type or method `{2}'" +"Literal of type double cannot be implicitly converted to type `{0}'. Add " +"suffix `{1}' to create a literal of this type" +msgstr "" + +#: mcs/mcs/membercache.cs:1261 +msgid "" +"A partial method declaration and partial method implementation cannot differ " +"on use of `params' modifier" +msgstr "" + +#: mcs/mcs/membercache.cs:1264 +msgid "" +"A partial method declaration and partial method implementation must be both " +"an extension method or neither" msgstr "" -#: ../mcs/mcs/generic.cs:1628 +#: mcs/mcs/membercache.cs:1268 #, csharp-format msgid "" -"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " -"method `{2}'. The nullable type `{0}' never satisfies interface constraint " -"of type `{3}'" +"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only" msgstr "" -#: ../mcs/mcs/generic.cs:1634 +#: mcs/mcs/membercache.cs:1272 #, csharp-format msgid "" -"The type `{0}' must be convertible to `{1}' in order to use it as parameter `" -"{2}' in the generic type or method `{3}'" +"Overloaded method `{0}' cannot differ on use of parameter modifiers only" msgstr "" -#: ../mcs/mcs/generic.cs:1827 +#: mcs/mcs/membercache.cs:1304 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`static' or neither" +msgstr "" + +#: mcs/mcs/membercache.cs:1309 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`unsafe' or neither" +msgstr "" + +#: mcs/mcs/membercache.cs:1315 #, csharp-format -msgid "The type parameter name `{0}' is the same as `{1}'" +msgid "A partial method `{0}' declaration is already defined" msgstr "" -#: ../mcs/mcs/iterators.cs:42 ../mcs/mcs/iterators.cs:939 -msgid "Unsafe code may not appear in iterators" +#: mcs/mcs/membercache.cs:1319 +#, csharp-format +msgid "A partial method `{0}' implementation is already defined" msgstr "" -#: ../mcs/mcs/iterators.cs:52 -msgid "The yield statement cannot be used inside anonymous method blocks" +#: mcs/mcs/membercache.cs:1330 mcs/mcs/property.cs:81 +#, csharp-format +msgid "A member `{0}' is already reserved" msgstr "" -#: ../mcs/mcs/iterators.cs:907 +#: mcs/mcs/membercache.cs:1341 #, csharp-format +msgid "Duplicate user-defined conversion in type `{0}'" +msgstr "" + +#: mcs/mcs/method.cs:484 msgid "" -"The body of `{0}' cannot be an iterator block because `{1}' is not an " -"iterator interface type" +"The DllImport attribute must be specified on a method marked `static' and " +"`extern'" msgstr "" -#: ../mcs/mcs/iterators.cs:920 -msgid "Iterators cannot have ref or out parameters" +#: mcs/mcs/method.cs:572 +#, csharp-format +msgid "`{0}': A partial method parameters cannot use `out' modifier" msgstr "" -#: ../mcs/mcs/iterators.cs:926 -msgid "__arglist is not allowed in parameter list of iterators" +#: mcs/mcs/method.cs:631 +#, csharp-format +msgid "" +"Conditional not valid on `{0}' because it is a constructor, destructor, " +"operator or explicit interface implementation" msgstr "" +"Das Conditional-Attribut ist für `{0}' ungültig, weil dies ein Konstruktor, " +"Destruktor, Operator oder eine explizite Schnittstellenimplementierung ist" -#: ../mcs/mcs/iterators.cs:932 -msgid "Iterators cannot have unsafe parameters or yield types" +#: mcs/mcs/method.cs:844 +#, csharp-format +msgid "Program `{0}' has more than one entry point defined: `{1}'" +msgstr "" + +#: mcs/mcs/method.cs:888 +#, csharp-format +msgid "Conditional not valid on `{0}' because it is an override method" +msgstr "" +"Das Conditional-Attribut ist für `{0}' ungültig, da es eine überschriebene " +"Funktion ist" + +#: mcs/mcs/method.cs:893 +#, csharp-format +msgid "Conditional not valid on `{0}' because its return type is not void" +msgstr "" +"Das Conditional-Attribut ist für `{0}' ungültig, da der Rückgabetyp nicht " +"leer ist" + +#: mcs/mcs/method.cs:898 +msgid "Conditional not valid on interface members" +msgstr "Das Conditional-Attribut ist für Schnittstellenmember ungültig" + +#: mcs/mcs/method.cs:904 +#, fuzzy, csharp-format +msgid "Conditional member `{0}' cannot implement interface member `{1}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/method.cs:911 +#, csharp-format +msgid "Conditional method `{0}' cannot have an out parameter" msgstr "" -#: ../mcs/mcs/linq.cs:79 +#: mcs/mcs/method.cs:1017 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern could not be found. Are " -"you missing `System.Linq' using directive or `System.Core.dll' assembly " -"reference?" +"The constraints for type parameter `{0}' of method `{1}' must match the " +"constraints for type parameter `{2}' of interface method `{3}'. Consider " +"using an explicit interface implementation instead" +msgstr "" + +#: mcs/mcs/method.cs:1071 +#, fuzzy, csharp-format +msgid "`{0}': Extension methods cannot be defined in a nested class" +msgstr "" +"`{0}': Erweiterungsmethoden müssen in einer nicht generischen statischen " +"Klasse definiert werden" + +#: mcs/mcs/method.cs:1077 +#, csharp-format +msgid "" +"`{0}': Extension methods cannot be declared without a reference to System." +"Core.dll assembly. Add the assembly reference or remove `this' modifer from " +"the first parameter" msgstr "" -#: ../mcs/mcs/linq.cs:117 +#: mcs/mcs/method.cs:1086 +#, csharp-format +msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgstr "" +"`{0}': Erweiterungsmethoden müssen in einer nicht generischen statischen " +"Klasse definiert werden" + +#: mcs/mcs/method.cs:1139 +#, csharp-format +msgid "" +"A partial method `{0}' implementation is missing a partial method declaration" +msgstr "" + +#: mcs/mcs/method.cs:1186 +#, csharp-format +msgid "Method or delegate cannot return type `{0}'" +msgstr "" + +#: mcs/mcs/method.cs:1261 +msgid "" +"The constructor call cannot be dynamically dispatched within constructor " +"initializer" +msgstr "" + +#: mcs/mcs/method.cs:1275 +#, fuzzy, csharp-format +msgid "`{0}': Struct constructors cannot call base constructors" +msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" + +#: mcs/mcs/method.cs:1294 +#, csharp-format +msgid "Constructor `{0}' cannot call itself" +msgstr "" + +#: mcs/mcs/method.cs:1413 +#, csharp-format +msgid "`{0}': The static constructor must be parameterless" +msgstr "" + +#: mcs/mcs/method.cs:1431 +msgid "Structs cannot contain explicit parameterless constructors" +msgstr "" + +#: mcs/mcs/method.cs:1487 +#, csharp-format +msgid "" +"`{0}': A class with the ComImport attribute cannot have a user-defined " +"constructor" +msgstr "" + +#: mcs/mcs/method.cs:1730 +#, fuzzy, csharp-format +msgid "`{0}' is an accessor not found in interface member `{1}{2}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/method.cs:1736 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern for source type `{1}' " -"could not be found" +"`{0}.{1}' in explicit interface declaration is not a member of interface" msgstr "" -#: ../mcs/mcs/linq.cs:126 +#: mcs/mcs/method.cs:1743 #, csharp-format msgid "" -"Type inference failed to infer type argument for `{0}' clause. Try " -"specifying the type argument explicitly" +"`{0}' explicit method implementation cannot implement `{1}' because it is an " +"accessor" msgstr "" -#: ../mcs/mcs/linq.cs:525 +#: mcs/mcs/method.cs:1753 +#, fuzzy, csharp-format +msgid "Method `{0}' cannot implement interface accessor `{1}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/method.cs:1759 #, csharp-format -msgid "A range variable `{0}' cannot be initialized with `{1}'" +msgid "" +"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " +"an explicit interface implementation" msgstr "" -#: ../mcs/mcs/linq.cs:825 +#: mcs/mcs/method.cs:1765 +#, fuzzy, csharp-format +msgid "" +"Accessor `{0}' must be declared public to implement interface member `{1}'" +msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" + +#: mcs/mcs/method.cs:1789 #, csharp-format -msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" +msgid "" +"`{0}': the explicit interface implementation cannot introduce the params " +"modifier" msgstr "" -#: ../mcs/mcs/linq.cs:831 +#: mcs/mcs/method.cs:2107 #, csharp-format -msgid "A range variable `{0}' has already been declared in this scope" +msgid "" +"Attribute `{0}' is not valid on property or event accessors. It is valid on `" +"{1}' declarations only" msgstr "" -#: ../mcs/mcs/linq.cs:837 +#: mcs/mcs/method.cs:2318 #, csharp-format -msgid "A range variable `{0}' conflicts with a method type parameter" +msgid "User-defined operator `{0}' must be declared static and public" msgstr "" -#: ../mcs/mcs/literal.cs:76 -#, csharp-format +#: mcs/mcs/method.cs:2357 msgid "" -"Cannot convert null to the type parameter `{0}' because it could be a value " -"type. Consider using `default ({0})' instead" +"User-defined operator cannot take an object of the enclosing type and " +"convert to an object of the enclosing type" +msgstr "" + +#: mcs/mcs/method.cs:2368 +msgid "User-defined conversion must convert to or from the enclosing type" msgstr "" -#: ../mcs/mcs/literal.cs:79 +#: mcs/mcs/method.cs:2374 #, csharp-format -msgid "Cannot convert null to `{0}' because it is a value type" +msgid "" +"User-defined conversion `{0}' cannot convert to or from the dynamic type" msgstr "" -"NULL kann nicht in `{0}' konvertiert werden, da dies ein Werttyp ist, der " -"nicht auf NULL festgelegt werden kann" -#: ../mcs/mcs/literal.cs:323 +#: mcs/mcs/method.cs:2381 #, csharp-format msgid "" -"Literal of type double cannot be implicitly converted to type `{0}'. Add " -"suffix `{1}' to create a literal of this type" +"User-defined conversion `{0}' cannot convert to or from an interface type" msgstr "" -#: ../mcs/mcs/location.cs:224 +#: mcs/mcs/method.cs:2388 #, csharp-format -msgid "Source file `{0}' specified multiple times" +msgid "User-defined conversion `{0}' cannot convert to or from a base class" msgstr "" -#: ../mcs/mcs/location.cs:226 +#: mcs/mcs/method.cs:2394 #, csharp-format -msgid "Source filenames `{0}' and `{1}' both refer to the same file: {2}" +msgid "User-defined conversion `{0}' cannot convert to or from a derived class" msgstr "" -#: ../mcs/mcs/modifiers.cs:241 -msgid "More than one protection modifier specified" +#: mcs/mcs/method.cs:2401 +msgid "" +"Overloaded shift operator must have the type of the first operand be the " +"containing type, and the type of the second operand must be int" msgstr "" -#: ../mcs/mcs/modifiers.cs:258 -msgid "The modifier `" +#: mcs/mcs/method.cs:2410 +msgid "" +"The return type for ++ or -- operator must be the containing type or derived " +"from the containing type" msgstr "" +"Der Rückgabetyp für die Operatoren ++ und -- muss der enthaltene Typ sein " +"oder vom enthaltenen Typ abgeleitet sein" -#: ../mcs/mcs/namespace.cs:113 -#, csharp-format -msgid "An assembly `{0}' is used without being referenced" +#: mcs/mcs/method.cs:2415 +msgid "The parameter type for ++ or -- operator must be the containing type" +msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" + +#: mcs/mcs/method.cs:2422 +#, fuzzy +msgid "The parameter type of a unary operator must be the containing type" +msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" + +#: mcs/mcs/method.cs:2430 +msgid "The return type of operator True or False must be bool" msgstr "" -#: ../mcs/mcs/namespace.cs:136 +#: mcs/mcs/method.cs:2445 +#, fuzzy +msgid "One of the parameters of a binary operator must be the containing type" +msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" + +#: mcs/mcs/modifiers.cs:275 #, csharp-format -msgid "The imported type `{0}' is defined multiple times" +msgid "The modifier `{0}' is not valid for this item" msgstr "" -#: ../mcs/mcs/namespace.cs:259 +#: mcs/mcs/namespace.cs:70 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found in the global namespace " @@ -2775,7 +3206,7 @@ msgstr "" "Der Typ oder Namespacename `{0}' konnte im globalen Namesapce nicht gefunden " "werden. Fehlt ein Assemblyverweis?" -#: ../mcs/mcs/namespace.cs:380 +#: mcs/mcs/namespace.cs:177 #, csharp-format msgid "" "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are " @@ -2784,59 +3215,54 @@ msgstr "" "Der Typ oder Namespacename `{0}' existiert nicht im Namespace `{1}'. Fehlt " "ein Assemblyverweis?" -#: ../mcs/mcs/namespace.cs:387 -#, csharp-format -msgid "Using the generic type `{0}' requires `{1}' type argument(s)" -msgstr "" - -#: ../mcs/mcs/namespace.cs:405 +#: mcs/mcs/namespace.cs:256 #, csharp-format -msgid "The non-generic {0} `{1}' cannot be used with the type arguments" +msgid "The imported type `{0}' is defined multiple times" msgstr "" -#: ../mcs/mcs/namespace.cs:642 +#: mcs/mcs/namespace.cs:583 #, csharp-format msgid "" "`{0}' is a type not a namespace. A using namespace directive can only be " "applied to namespaces" msgstr "" -#: ../mcs/mcs/namespace.cs:669 +#: mcs/mcs/namespace.cs:610 #, csharp-format msgid "The extern alias `{0}' was not specified in -reference option" msgstr "" "Der externe Alias `{0}' wurde nicht in der -reference-Option angegeben." -#: ../mcs/mcs/namespace.cs:880 ../mcs/mcs/namespace.cs:902 +#: mcs/mcs/namespace.cs:820 mcs/mcs/namespace.cs:842 msgid "" "A using clause must precede all other namespace elements except extern alias " "declarations" msgstr "" -#: ../mcs/mcs/namespace.cs:926 +#: mcs/mcs/namespace.cs:866 msgid "An extern alias declaration must precede all other elements" msgstr "Eine externe Aliasdeklaration muss allen anderen Elementen vorangehen" -#: ../mcs/mcs/namespace.cs:944 +#: mcs/mcs/namespace.cs:884 #, csharp-format msgid "The using alias `{0}' appeared previously in this namespace" msgstr "" -#: ../mcs/mcs/namespace.cs:1017 +#: mcs/mcs/namespace.cs:1005 #, csharp-format -msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" +msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1056 +#: mcs/mcs/namespace.cs:1059 #, csharp-format -msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" +msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1149 -msgid "You cannot redefine the global extern alias" +#: mcs/mcs/namespace.cs:1127 +msgid "The global extern alias cannot be redefined" msgstr "" -#: ../mcs/mcs/namespace.cs:1159 +#: mcs/mcs/namespace.cs:1132 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found. Are you missing a using " @@ -2845,93 +3271,119 @@ msgstr "" "Der Typ oder Namespacename `{0}' konnte nicht gefunden werden. Fehlt eine " "using-Direktive oder ein Assemblyverweis?" -#: ../mcs/mcs/nullable.cs:985 +#: mcs/mcs/nullable.cs:1036 msgid "" "An expression tree cannot contain a coalescing operator with null left side" msgstr "" -#: ../mcs/mcs/parameter.cs:176 +#: mcs/mcs/parameter.cs:156 msgid "The params parameter must be a single dimensional array" msgstr "" -#: ../mcs/mcs/parameter.cs:277 -msgid "Invalid parameter type `void'" -msgstr "Ungültiger Parametertyp `void'" - -#: ../mcs/mcs/parameter.cs:288 +#: mcs/mcs/parameter.cs:288 msgid "An out parameter cannot have the `In' attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:293 +#: mcs/mcs/parameter.cs:293 msgid "" "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead" msgstr "" -#: ../mcs/mcs/parameter.cs:300 +#: mcs/mcs/parameter.cs:300 msgid "" "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and " "`Out' attributes or neither" msgstr "" -#: ../mcs/mcs/parameter.cs:318 +#: mcs/mcs/parameter.cs:310 +#, csharp-format +msgid "Cannot specify `{0}' attribute on optional parameter `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:320 #, csharp-format -msgid "Argument of type `{0}' is not applicable for the DefaultValue attribute" +msgid "" +"Argument of type `{0}' is not applicable for the DefaultParameterValue " +"attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:321 +#: mcs/mcs/parameter.cs:323 #, csharp-format msgid "" -"The DefaultValue attribute is not applicable on parameters of type `{0}'" +"The DefaultParameterValue attribute is not applicable on parameters of type `" +"{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:333 +#: mcs/mcs/parameter.cs:334 msgid "The type of the default value should match the type of the parameter" msgstr "" -#: ../mcs/mcs/parameter.cs:373 +#: mcs/mcs/parameter.cs:376 #, csharp-format msgid "Method or delegate parameter cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:386 +#: mcs/mcs/parameter.cs:386 #, csharp-format msgid "`{0}': static types cannot be used as parameters" msgstr "" -#: ../mcs/mcs/parameter.cs:392 +#: mcs/mcs/parameter.cs:392 #, csharp-format -msgid "The type of extension method cannot be `{0}'" +msgid "The extension method cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:497 -msgid "An expression tree parameter cannot use `ref' or `out' modifier" +#: mcs/mcs/parameter.cs:448 +#, csharp-format +msgid "" +"The expression being assigned to optional parameter `{0}' must be a constant " +"or default value" msgstr "" -#: ../mcs/mcs/parameter.cs:884 +#: mcs/mcs/parameter.cs:464 #, csharp-format -msgid "The parameter name `{0}' is a duplicate" +msgid "" +"The expression being assigned to nullable optional parameter `{0}' must be " +"default value" +msgstr "" + +#: mcs/mcs/parameter.cs:472 +#, csharp-format +msgid "" +"Optional parameter `{0}' of type `{1}' can only be initialized with `null'" +msgstr "" + +#: mcs/mcs/parameter.cs:482 +#, csharp-format +msgid "" +"Optional parameter expression of type `{0}' cannot be converted to parameter " +"type `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:624 +msgid "An expression tree parameter cannot use `ref' or `out' modifier" msgstr "" -#: ../mcs/mcs/parameter.cs:936 +#: mcs/mcs/parameter.cs:1096 #, csharp-format msgid "The parameter name `{0}' conflicts with a compiler generated name" msgstr "" -#: ../mcs/mcs/pending.cs:598 +#: mcs/mcs/pending.cs:443 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' is static" msgstr "" -#: ../mcs/mcs/pending.cs:602 +#: mcs/mcs/pending.cs:447 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' in not public" msgstr "" -#: ../mcs/mcs/pending.cs:606 +#: mcs/mcs/pending.cs:451 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " @@ -2939,92 +3391,165 @@ msgid "" "type `{4}'" msgstr "" -#: ../mcs/mcs/pending.cs:611 +#: mcs/mcs/pending.cs:456 #, csharp-format msgid "`{0}' does not implement interface member `{1}'" msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" -#: ../mcs/mcs/pending.cs:615 +#: mcs/mcs/pending.cs:461 #, csharp-format msgid "`{0}' does not implement inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:574 +#: mcs/mcs/property.cs:352 #, csharp-format msgid "" -"Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " -"`gmcs' compiler instead" +"`{0}': accessibility modifiers may not be used on accessors in an interface" msgstr "" -"Das Feature `{0}' ist im Mono mcs1 Kompiler nicht verfügbar. Benutzen Sie " -"stattdessen bitte den `gmcs' Kompiler." -#: ../mcs/mcs/report.cs:582 +#: mcs/mcs/property.cs:356 +#, csharp-format +msgid "`{0}': abstract properties cannot have private accessors" +msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" + +#: mcs/mcs/property.cs:401 #, csharp-format msgid "" -"Feature `{0}' cannot be used because it is not part of the C# {1} language " -"specification" +"The accessibility modifier of the `{0}' accessor must be more restrictive " +"than the modifier of the property or indexer `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:502 +#, csharp-format +msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:639 +#: mcs/mcs/property.cs:521 #, csharp-format msgid "" -"Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime " -"instead." +"`{0}': cannot override because `{1}' does not have an overridable get " +"accessor" msgstr "" -"Ihre .NET Laufzeitumgebung unterstützt kein `{0}'. Bitte benutzen Sie die " -"letzte aktuelle Mono Laufzeitumgebung stattdessen." -#: ../mcs/mcs/rootcontext.cs:410 -msgid "Unsafe code requires the `unsafe' command line option to be specified" +#: mcs/mcs/property.cs:538 +#, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable set " +"accessor" +msgstr "" + +#: mcs/mcs/property.cs:579 +#, csharp-format +msgid "" +"`{0}': Cannot specify accessibility modifiers for both accessors of the " +"property or indexer" +msgstr "" + +#: mcs/mcs/property.cs:586 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers on accessors may only be used if the property " +"or indexer has both a get and a set accessor" +msgstr "" + +#: mcs/mcs/property.cs:783 +#, csharp-format +msgid "" +"Automatically implemented property `{0}' cannot be used inside a type with " +"an explicit StructLayout attribute" +msgstr "" + +#: mcs/mcs/property.cs:1274 +#, csharp-format +msgid "`{0}': event must be of a delegate type" +msgstr "" + +#: mcs/mcs/property.cs:1482 +#, csharp-format +msgid "" +"The `{0}' attribute is valid only on an indexer that is not an explicit " +"interface member declaration" +msgstr "" + +#: mcs/mcs/property.cs:1516 +msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +msgstr "" + +#: mcs/mcs/reflection.cs:217 +msgid "Could not access the key inside the container `" +msgstr "" + +#: mcs/mcs/roottypes.cs:363 +msgid "" +"The compilation may fail due to missing `System.Reflection.Emit." +"AssemblyBuilder.SetCorlibTypeBuilders(...)' method" +msgstr "" + +#: mcs/mcs/roottypes.cs:470 +#, csharp-format +msgid "Value specified for the argument to `{0}' is not valid" msgstr "" -#: ../mcs/mcs/statement.cs:105 +#: mcs/mcs/statement.cs:87 msgid "" "A lambda expression with statement body cannot be converted to an expresion " "tree" msgstr "" -#: ../mcs/mcs/statement.cs:818 +#: mcs/mcs/statement.cs:740 +#, csharp-format msgid "" -"Cannot return a value from iterators. Use the yield return statement to " -"return a value, or yield break to end the iteration" +"An object of a type convertible to `{0}' is required for the return statement" msgstr "" -#: ../mcs/mcs/statement.cs:825 +#: mcs/mcs/statement.cs:753 #, csharp-format msgid "" "`{0}': A return keyword must not be followed by any expression when method " "returns void" msgstr "" -#: ../mcs/mcs/statement.cs:849 +#: mcs/mcs/statement.cs:778 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' because some of the return types " "in the block are not implicitly convertible to the delegate return type" msgstr "" -#: ../mcs/mcs/statement.cs:1041 ../mcs/mcs/statement.cs:1073 +#: mcs/mcs/statement.cs:806 +msgid "" +"Cannot return a value from iterators. Use the yield return statement to " +"return a value, or yield break to end the iteration" +msgstr "" + +#: mcs/mcs/statement.cs:963 mcs/mcs/statement.cs:997 msgid "A goto case is only valid inside a switch statement" msgstr "" -#: ../mcs/mcs/statement.cs:1656 -#, csharp-format -msgid "" -"The label `{0}' shadows another label by the same name in a contained scope" +#: mcs/mcs/statement.cs:1076 mcs/mcs/statement.cs:4726 +msgid "The type caught or thrown must be derived from System.Exception" msgstr "" -#: ../mcs/mcs/statement.cs:1681 -#, csharp-format -msgid "The label `{0}' is a duplicate" +#: mcs/mcs/statement.cs:1298 +msgid "A fixed statement cannot use an implicitly typed local variable" msgstr "" -#: ../mcs/mcs/statement.cs:1776 -#, csharp-format -msgid "`{0}' conflicts with a declaration in a child block" +#: mcs/mcs/statement.cs:1303 +msgid "An implicitly typed local variable cannot be a constant" +msgstr "" + +#: mcs/mcs/statement.cs:1308 +msgid "" +"An implicitly typed local variable declarator must include an initializer" +msgstr "" + +#: mcs/mcs/statement.cs:1313 +msgid "" +"An implicitly typed local variable declaration cannot include multiple " +"declarators" msgstr "" -#: ../mcs/mcs/statement.cs:1877 +#: mcs/mcs/statement.cs:1883 #, csharp-format msgid "" "A local variable named `{0}' cannot be declared in this scope because it " @@ -3032,102 +3557,111 @@ msgid "" "scope to denote something else" msgstr "" -#: ../mcs/mcs/statement.cs:1886 +#: mcs/mcs/statement.cs:1894 +#, csharp-format +msgid "" +"`{0}': An anonymous type cannot have multiple properties with the same name" +msgstr "" + +#: mcs/mcs/statement.cs:1897 +#, csharp-format +msgid "The parameter name `{0}' is a duplicate" +msgstr "" + +#: mcs/mcs/statement.cs:1904 #, csharp-format msgid "A local variable named `{0}' is already defined in this scope" msgstr "" -#: ../mcs/mcs/statement.cs:2041 -msgid "An implicitly typed local variable cannot be a constant" +#: mcs/mcs/statement.cs:1910 +#, csharp-format +msgid "" +"The type parameter name `{0}' is the same as local variable or parameter name" msgstr "" -#: ../mcs/mcs/statement.cs:2891 +#: mcs/mcs/statement.cs:2482 #, csharp-format msgid "" "The out parameter `{0}' must be assigned to before control leaves the " "current method" msgstr "" -#: ../mcs/mcs/statement.cs:3024 +#: mcs/mcs/statement.cs:2573 #, csharp-format -msgid "The label `case {0}:' already occurs in this switch statement" +msgid "`{0}': not all code paths return a value" msgstr "" -#: ../mcs/mcs/statement.cs:3570 -msgid "A value of an integral type or string expected for switch" +#: mcs/mcs/statement.cs:2577 +#, csharp-format +msgid "Not all code paths return a value in anonymous method of type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4029 +#: mcs/mcs/statement.cs:2748 #, csharp-format -msgid "`{0}' is not a reference type as required by the lock statement" +msgid "The label `{0}' is a duplicate" msgstr "" -#: ../mcs/mcs/statement.cs:4346 -msgid "A fixed statement cannot use an implicitly typed local variable" +#: mcs/mcs/statement.cs:2757 mcs/mcs/statement.cs:2768 +#, csharp-format +msgid "" +"The label `{0}' shadows another label by the same name in a contained scope" +msgstr "" + +#: mcs/mcs/statement.cs:3088 +#, csharp-format +msgid "The label `case {0}:' already occurs in this switch statement" +msgstr "" + +#: mcs/mcs/statement.cs:3629 +#, csharp-format +msgid "" +"A switch expression of type `{0}' cannot be converted to an integral type, " +"bool, char, string, enum or nullable type" msgstr "" -#: ../mcs/mcs/statement.cs:4356 +#: mcs/mcs/statement.cs:4114 +#, csharp-format +msgid "`{0}' is not a reference type as required by the lock statement" +msgstr "" + +#: mcs/mcs/statement.cs:4455 msgid "The type of locals declared in a fixed statement must be a pointer type" msgstr "" -#: ../mcs/mcs/statement.cs:4380 +#: mcs/mcs/statement.cs:4471 msgid "" "The right hand side of a fixed statement assignment may not be a cast " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4457 +#: mcs/mcs/statement.cs:4542 msgid "" "You cannot use the fixed statement to take the address of an already fixed " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4707 -msgid "Try statement already has an empty catch block" -msgstr "" - -#: ../mcs/mcs/statement.cs:4745 +#: mcs/mcs/statement.cs:4856 #, csharp-format msgid "" "A previous catch clause already catches all exceptions of this or a super " "type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4920 ../mcs/mcs/statement.cs:5035 -msgid "Internal error: No Dispose method which takes 0 parameters." -msgstr "" - -#: ../mcs/mcs/statement.cs:4992 +#: mcs/mcs/statement.cs:5029 #, csharp-format msgid "" "`{0}': type used in a using statement must be implicitly convertible to " "`System.IDisposable'" msgstr "" -#: ../mcs/mcs/statement.cs:5115 -msgid "Use of null is not valid in this context" -msgstr "" - -#: ../mcs/mcs/statement.cs:5120 -#, csharp-format -msgid "Foreach statement cannot operate on a `{0}'" -msgstr "" - -#: ../mcs/mcs/statement.cs:5433 +#: mcs/mcs/statement.cs:5451 #, csharp-format msgid "" "foreach statement requires that the return type `{0}' of `{1}' must have a " "suitable public MoveNext method and public Current property" msgstr "" -#: ../mcs/mcs/statement.cs:5518 -#, csharp-format -msgid "" -"foreach statement cannot operate on variables of type `{0}' because it does " -"not contain a definition for `GetEnumerator' or is not accessible" -msgstr "" - -#: ../mcs/mcs/statement.cs:5570 +#: mcs/mcs/statement.cs:5490 #, csharp-format msgid "" "foreach statement cannot operate on variables of type `{0}' because it " @@ -3135,47 +3669,81 @@ msgid "" "implementation" msgstr "" -#: ../mcs/mcs/typemanager.cs:878 +#: mcs/mcs/statement.cs:5509 #, csharp-format -msgid "The predefined type `{0}.{1}' is not defined or imported" +msgid "" +"foreach statement cannot operate on variables of type `{0}' because it does " +"not contain a definition for `{1}' or is inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:902 -#, csharp-format -msgid "The predefined type `{0}.{1}' is not declared correctly" +#: mcs/mcs/statement.cs:5715 +msgid "Use of null is not valid in this context" msgstr "" -#: ../mcs/mcs/typemanager.cs:952 +#: mcs/mcs/statement.cs:5725 #, csharp-format -msgid "" -"The compiler required member `{0}.{1}{2}' could not be found or is " -"inaccessible" +msgid "Foreach statement cannot operate on a `{0}'" msgstr "" -#: ../mcs/mcs/typemanager.cs:1161 +#: mcs/mcs/typemanager.cs:389 #, csharp-format -msgid "" -"The compilation may fail due to missing `{0}.SetCorlibTypeBuilders({1})' " -"method" +msgid "The predefined type `{0}.{1}' is not defined or imported" msgstr "" -#: ../mcs/mcs/typemanager.cs:1706 +#: mcs/mcs/typemanager.cs:395 #, csharp-format -msgid "" -"Friend access was granted to `{0}', but the output assembly is named `{1}'. " -"Try adding a reference to `{0}' or change the output assembly name to match " -"it" +msgid "The predefined type `{0}.{1}' is not declared correctly" msgstr "" -#: ../mcs/mcs/typemanager.cs:1961 +#: mcs/mcs/typemanager.cs:574 #, csharp-format msgid "" -"Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" +"The compiler required member `{0}.{1}{2}' could not be found or is " +"inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:2308 +#: mcs/mcs/typemanager.cs:885 #, csharp-format msgid "" "Cannot take the address of, get the size of, or declare a pointer to a " "managed type `{0}'" msgstr "" + +#~ msgid "Compilation aborted in file `{0}', {1}" +#~ msgstr "Kompilierung abgebrochen in Datei `{0}', {1}" + +#~ msgid "Couldn't run pkg-config: " +#~ msgstr "Kann pkg-config nicht ausführen:" + +#~ msgid "Error running pkg-config. Check the above output." +#~ msgstr "" +#~ "Fehler beim ausführen von pkg-config. Bitte prüfen Sie die Ausgabe oben." + +#~ msgid "-recurse requires an argument" +#~ msgstr "-recurse benötigt ein Argument" + +#~ msgid "-reference requires an argument" +#~ msgstr "-reference benötigt ein Argument" + +#~ msgid " requires an argument" +#~ msgstr "benötigt ein Argument" + +#~ msgid "/lib requires an argument" +#~ msgstr "/lib benötigt ein Argument" + +#~ msgid "/nowarn requires an argument" +#~ msgstr "/nowarn benötigt ein Argument" + +#~ msgid "" +#~ "Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " +#~ "`gmcs' compiler instead" +#~ msgstr "" +#~ "Das Feature `{0}' ist im Mono mcs1 Kompiler nicht verfügbar. Benutzen Sie " +#~ "stattdessen bitte den `gmcs' Kompiler." + +#~ msgid "" +#~ "Your .NET Runtime does not support `{0}'. Please use the latest Mono " +#~ "runtime instead." +#~ msgstr "" +#~ "Ihre .NET Laufzeitumgebung unterstützt kein `{0}'. Bitte benutzen Sie die " +#~ "letzte aktuelle Mono Laufzeitumgebung stattdessen." diff --git a/po/mcs/es.po b/po/mcs/es.po index 2db39dea5577..061393c9ba69 100644 --- a/po/mcs/es.po +++ b/po/mcs/es.po @@ -6,68 +6,69 @@ msgid "" msgstr "" "Project-Id-Version: mono 2.1\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2008-09-29 12:41-0300\n" +"POT-Creation-Date: 2010-12-16 13:01+0000\n" "PO-Revision-Date: 2008-09-19 13:28-0400\n" "Last-Translator: Miguel de Icaza \n" "Language-Team: es \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../mcs/mcs/anonymous.cs:850 +#: mcs/mcs/anonymous.cs:880 #, csharp-format msgid "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'" msgstr "" "No es posible convertir `{0}' a un árbol de expresiónáéíóú de tipo `{1}; ya " "que no es un tipo de delegado" -#: ../mcs/mcs/anonymous.cs:856 +#: mcs/mcs/anonymous.cs:885 #, csharp-format msgid "Cannot convert `{0}' to non-delegate type `{1}'" msgstr "No es posible convertir `{0}' a un un tipo que no es un delegado `{1}'" -#: ../mcs/mcs/anonymous.cs:868 +#: mcs/mcs/anonymous.cs:897 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' since there is a parameter " "mismatch" msgstr "" -#: ../mcs/mcs/anonymous.cs:880 ../mcs/mcs/delegate.cs:568 +#: mcs/mcs/anonymous.cs:909 mcs/mcs/ecore.cs:4469 #, csharp-format msgid "Delegate `{0}' does not take `{1}' arguments" msgstr "El delegado `{0} no toma {1} argumentos" -#: ../mcs/mcs/anonymous.cs:895 +#: mcs/mcs/anonymous.cs:924 #, csharp-format msgid "Parameter `{0}' should not be declared with the `{1}' keyword" msgstr "" "El parámetro `{0}' no debe ser ser declarado con la palabra reservada `{1}'" -#: ../mcs/mcs/anonymous.cs:898 +#: mcs/mcs/anonymous.cs:927 #, csharp-format msgid "Parameter `{0}' must be declared with the `{1}' keyword" msgstr "" "El parámetro `{0}' debe de ser declarado con la palabra reservada `{1}'" -#: ../mcs/mcs/anonymous.cs:919 +#: mcs/mcs/anonymous.cs:948 #, csharp-format msgid "Parameter `{0}' is declared as type `{1}' but should be `{2}'" msgstr "El parámetro `{0}' está declarado con `{1}' pero debería de ser `{2}'" -#: ../mcs/mcs/anonymous.cs:1043 +#: mcs/mcs/anonymous.cs:1103 msgid "An anonymous method cannot be converted to an expression tree" msgstr "" "Los métodos anónimos no pueden ser convertidos a árboles de expresiones" -#: ../mcs/mcs/anonymous.cs:1060 +#: mcs/mcs/anonymous.cs:1122 #, csharp-format msgid "" "Cannot convert anonymous method block without a parameter list to delegate " -"type `{0}' because it has one or more `out' parameters." +"type `{0}' because it has one or more `out' parameters" msgstr "" -#: ../mcs/mcs/anonymous.cs:1085 +#: mcs/mcs/anonymous.cs:1146 msgid "" "Anonymous methods and lambda expressions cannot be used in the current " "context" @@ -75,7 +76,7 @@ msgstr "" "Los métodos anónimos y las expresiones lambdas no pueden ser usados en este " "contexto" -#: ../mcs/mcs/anonymous.cs:1122 +#: mcs/mcs/anonymous.cs:1188 #, csharp-format msgid "" "Local variable or parameter `{0}' cannot have their address taken and be " @@ -84,25 +85,56 @@ msgstr "" "No se le puede tomar la dirección a la variable local o el parámetro `{0}' y " "ser al mismo tiempo usada dentro de un método anónimo o una expresión lambda." -#: ../mcs/mcs/anonymous.cs:1353 +#: mcs/mcs/anonymous.cs:1438 msgid "An expression tree cannot contain an anonymous method expression" msgstr "" "Un árbol de expresiones no puede contener una expresión que sea una método " "anónimo" -#: ../mcs/mcs/anonymous.cs:1647 +#: mcs/mcs/argument.cs:101 +#, fuzzy +msgid "" +"An expression tree cannot contain an invocation which uses optional parameter" +msgstr "Un árbol de expresiones no puede contener un operador de asignación" + +#: mcs/mcs/argument.cs:184 +#, fuzzy +msgid "An expression tree cannot contain named argument" +msgstr "Un árbol de expresiones no puede contener un operador de asignación" + +#: mcs/mcs/argument.cs:303 #, csharp-format msgid "" -"`{0}': An anonymous type cannot have multiple properties with the same name" +"The method group `{0}' cannot be used as an argument of dynamic operation. " +"Consider using parentheses to invoke the method" msgstr "" -"`{0}' An tipo anónimo no puede tener multiples propiedades con el mismo " -"nombre" -#: ../mcs/mcs/assign.cs:325 +#: mcs/mcs/argument.cs:307 +#, fuzzy +msgid "" +"An anonymous method or lambda expression cannot be used as an argument of " +"dynamic operation. Consider using a cast" +msgstr "" +"Los métodos anónimos y las expresiones lambdas no pueden ser usados en este " +"contexto" + +#: mcs/mcs/argument.cs:310 +#, fuzzy, csharp-format +msgid "" +"An expression of type `{0}' cannot be used as an argument of dynamic " +"operation" +msgstr "Un árbol de expresiones no puede contener un operador de asignación" + +#: mcs/mcs/assign.cs:299 msgid "An expression tree cannot contain an assignment operator" msgstr "Un árbol de expresiones no puede contener un operador de asignación" -#: ../mcs/mcs/attribute.cs:165 +#: mcs/mcs/assign.cs:627 +#, csharp-format +msgid "Cannot assign to `{0}' because it is a `{1}'" +msgstr "" + +#: mcs/mcs/attribute.cs:196 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument. Named attribute arguments " @@ -110,153 +142,650 @@ msgid "" "properties which are public and not static" msgstr "" -#: ../mcs/mcs/attribute.cs:173 +#: mcs/mcs/attribute.cs:205 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument because it is not a valid " "attribute parameter type" msgstr "" -#: ../mcs/mcs/attribute.cs:180 -msgid "" -"An attribute argument must be a constant expression, typeof expression or " -"array creation expression" +#: mcs/mcs/attribute.cs:211 +#, fuzzy +msgid "An attribute argument cannot be dynamic expression" msgstr "" +"Los métodos anónimos no pueden ser convertidos a árboles de expresiones" -#: ../mcs/mcs/attribute.cs:187 -msgid "Can not use a type parameter in an attribute" -msgstr "No es posible usar un tipo parametrizado en un atributo" - -#: ../mcs/mcs/attribute.cs:192 +#: mcs/mcs/attribute.cs:216 msgid "The Guid attribute must be specified with the ComImport attribute" msgstr "" "El atributo Guid debe de ser especificado junto con el atributo ComImport" -#: ../mcs/mcs/attribute.cs:197 +#: mcs/mcs/attribute.cs:221 #, csharp-format msgid "Do not use `{0}' directly. Use parameter modifier `this' instead" msgstr "" "No use `{0}' directamente. Use el modificador de parámetro `this' en su " "lugar" -#: ../mcs/mcs/attribute.cs:206 +#: mcs/mcs/attribute.cs:226 +#, fuzzy, csharp-format +msgid "Do not use `{0}' directly. Use `dynamic' keyword instead" +msgstr "" +"No use `{0}' directamente. Use el modificador de parámetro `this' en su " +"lugar" + +#: mcs/mcs/attribute.cs:235 #, csharp-format msgid "Error during emitting `{0}' attribute. The reason is `{1}'" msgstr "Error al emitir el atributo `{0}'. La razón es `{1}'" -#: ../mcs/mcs/attribute.cs:245 +#: mcs/mcs/attribute.cs:266 #, csharp-format msgid "`{0}': is not an attribute class" msgstr "`{0}' no es una clase atributo" -#: ../mcs/mcs/attribute.cs:263 -#, csharp-format +#: mcs/mcs/attribute.cs:302 +#, fuzzy, csharp-format msgid "" -"`{0}' is ambiguous between `{0}' and `{0}Attribute'. Use either `@{0}' or `" -"{0}Attribute'" +"`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}" +"Attribute'" msgstr "" "`{0}' produce una amiguedad entre `{0}' y `{0}Attribute'. Use `@{0}' o `{0}" "Attribute'" -#: ../mcs/mcs/attribute.cs:365 +#: mcs/mcs/attribute.cs:385 #, csharp-format msgid "Cannot apply attribute class `{0}' because it is abstract" msgstr "No es posible aplicar el atributo `{0}' ya que es abstracto" -#: ../mcs/mcs/attribute.cs:490 -msgid "Invalid value for argument to `System.AttributeUsage' attribute" -msgstr "Valor inválido pasado a `System.AttributeUsage'" +#: mcs/mcs/attribute.cs:453 +#, csharp-format +msgid "Duplicate named attribute `{0}' argument" +msgstr "" + +#: mcs/mcs/attribute.cs:730 +#, csharp-format +msgid "" +"`{0}' is not a valid attribute location for this declaration. Valid " +"attribute locations for this declaration are `{1}'" +msgstr "" -#: ../mcs/mcs/attribute.cs:498 +#: mcs/mcs/attribute.cs:1004 +#, csharp-format +msgid "" +"The attribute `{0}' is not valid on this declaration type. It is valid on `" +"{1}' declarations only" +msgstr "" + +#: mcs/mcs/attribute.cs:1022 #, csharp-format msgid "The argument to the `{0}' attribute must be a valid identifier" msgstr "" "El argumento pasado al atributo `{0}' debe de ser un identificador válido" -#: ../mcs/mcs/attribute.cs:528 +#: mcs/mcs/attribute.cs:1035 +#, fuzzy, csharp-format +msgid "Invalid value for argument to `{0}' attribute" +msgstr "Valor inválido pasado a `System.AttributeUsage'" + +#: mcs/mcs/attribute.cs:1341 #, csharp-format -msgid "'{0}' duplicate named attribute argument" +msgid "The attribute `{0}' cannot be applied multiple times" msgstr "" -#: ../mcs/mcs/attribute.cs:870 +#: mcs/mcs/attribute.cs:1603 #, csharp-format +msgid "`{0}' is obsolete: `{1}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:1646 msgid "" -"`{0}' is not a valid attribute location for this declaration. Valid " -"attribute locations for this declaration are `{1}'" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 +msgid "Interfaces cannot contain fields or constants" +msgstr "" + +#: mcs/mcs/cs-parser.cs:1952 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "" +"`{0}': las clases estáticas no pueden contener operadores definidos por el " +"usuario" + +#: mcs/mcs/cs-parser.cs:1958 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': las clases estáticas no pueden contener un destructor" + +#: mcs/mcs/cs-parser.cs:1964 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3602 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3884 +msgid "A namespace declaration cannot have modifiers or attributes" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3948 +msgid "" +"Namespace elements cannot be explicitly declared as private, protected or " +"protected internal" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3963 +msgid "" +"Assembly and module attributes must precede all other elements except using " +"clauses and extern alias declarations" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4080 +msgid "'<' unexpected: attributes cannot be generic" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4117 +msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: ../mcs/mcs/attribute.cs:1199 +#: mcs/mcs/cs-parser.cs:4163 #, csharp-format msgid "" -"The attribute `{0}' is not valid on this declaration type. It is valid on `" -"{1}' declarations only" +"Unexpected symbol `{0}' in class, struct, or interface member declaration" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4220 +#, fuzzy, csharp-format +msgid "The constant `{0}' cannot be marked static" +msgstr "El método abstracto `{0} no puede ser marcado como virtual" + +#: mcs/mcs/cs-parser.cs:4268 +msgid "Fields cannot have void type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4369 +msgid "Value or constant expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 +#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 +#: mcs/mcs/cs-parser.cs:5427 +#, fuzzy, csharp-format +msgid "`{0}': interface members cannot have a definition" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +msgid "Constraints are not allowed on non-generic declarations" msgstr "" -#: ../mcs/mcs/attribute.cs:1493 +#: mcs/mcs/cs-parser.cs:4429 #, csharp-format -msgid "The attribute `{0}' cannot be applied multiple times" +msgid "" +"`{0}': Cannot specify constraints for overrides and explicit interface " +"implementation methods" msgstr "" -#: ../mcs/mcs/attribute.cs:1661 +#: mcs/mcs/cs-parser.cs:4470 msgid "" -"Added modules must be marked with the CLSCompliant attribute to match the " -"assembly" +"A partial method cannot define access modifier or any of abstract, extern, " +"new, override, sealed, or virtual modifiers" msgstr "" -#: ../mcs/mcs/attribute.cs:1802 +#: mcs/mcs/cs-parser.cs:4476 +msgid "" +"A partial method must be declared within a partial class or partial struct" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4499 #, csharp-format -msgid "`{0}' is obsolete: `{1}'" +msgid "Member modifier `{0}' must precede the member type and name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +msgid "" +"A params parameter must be the last parameter in a formal parameter list" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +msgid "" +"An __arglist parameter must be the last parameter in a formal parameter list" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4601 +msgid "The parameter modifier `this' can only be used on the first parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4603 +msgid "Optional parameter cannot precede required parameters" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4625 +msgid "Array type specifier, [], must appear before parameter name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#, fuzzy, csharp-format +msgid "Cannot specify a default value for the `{0}' parameter" +msgstr "" +"No puede especificar el atributo `DefaultMember' en un tipo que contiene un " +"indexador" + +#: mcs/mcs/cs-parser.cs:4666 +msgid "Optional parameter is not valid in this context" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4686 +msgid "The parameter modifiers `this' and `ref' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4689 +msgid "The parameter modifiers `this' and `out' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4692 +msgid "A parameter cannot have specified more than one modifier" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4739 +#, fuzzy +msgid "Cannot specify a default value for a parameter array" +msgstr "" +"No puede especificar el atributo `DefaultMember' en un tipo que contiene un " +"indexador" + +#: mcs/mcs/cs-parser.cs:4756 +#, fuzzy +msgid "The `params' modifier is not allowed in current context" +msgstr "" +"La palabra reservada `new' no está permitida en los elementos de un espacio " +"de nombres" + +#: mcs/mcs/cs-parser.cs:4764 +msgid "The parameter modifiers `this' and `params' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4766 +#, fuzzy +msgid "The params parameter cannot be declared as ref or out" +msgstr "El método abstracto `{0} no puede ser marcado como virtual" + +#: mcs/mcs/cs-parser.cs:4774 +msgid "__arglist is not valid in this context" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4791 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer cannot have void type" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/cs-parser.cs:4829 +#, csharp-format +msgid "`{0}': indexer return type cannot be `void'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4832 +msgid "Indexers must have at least one parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4857 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer must have at least one accessor" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/cs-parser.cs:4860 +msgid "Semicolon after method or accessor block is not valid" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4862 +msgid "A get or set accessor expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +msgid "Property accessor already defined" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5036 +msgid "User-defined operators cannot return void" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5059 +msgid "Overloadable binary operator expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5061 +#, csharp-format +msgid "Overloaded unary operator `{0}' takes one parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5066 +#, csharp-format +msgid "Overloaded binary operator `{0}' takes two parameters" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5069 +msgid "Overloadable unary operator expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5183 +msgid "Class, struct, or interface method must have a return type" +msgstr "El método debe tener un tipo de retorno" + +#: mcs/mcs/cs-parser.cs:5187 +#, fuzzy, csharp-format +msgid "`{0}': static constructor cannot have an access modifier" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/cs-parser.cs:5192 +#, fuzzy, csharp-format +msgid "" +"`{0}': static constructor cannot have an explicit `this' or `base' " +"constructor call" +msgstr "" +"`{0}': las clases estáticas no pueden tener constructores de instancias" + +#: mcs/mcs/cs-parser.cs:5241 +msgid "Name of destructor must match name of class" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5243 +#, fuzzy +msgid "Only class types can contain destructor" +msgstr "`{0}': las clases estáticas no pueden contener un destructor" + +#: mcs/mcs/cs-parser.cs:5265 +#, fuzzy, csharp-format +msgid "" +"`{0}': An explicit interface implementation of an event must use property " +"syntax" +msgstr "" +"`{0}': las declaraciones explícitas de interfaces solamente pueden ser " +"declaradas en una clase o estructura" + +#: mcs/mcs/cs-parser.cs:5298 +msgid "Event in interface cannot have add or remove accessors" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5344 +#, fuzzy, csharp-format +msgid "`{0}': event in interface cannot have an initializer" +msgstr "" +"`{0}': las estructuras no pueden tener inicializadores de campos en " +"instancias" + +#: mcs/mcs/cs-parser.cs:5349 +#, fuzzy, csharp-format +msgid "`{0}': abstract event cannot have an initializer" +msgstr "" +"`{0}': las estructuras no pueden tener inicializadores de campos en " +"instancias" + +#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#, fuzzy, csharp-format +msgid "`{0}': event property must have both add and remove accessors" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/cs-parser.cs:5371 +msgid "An add or remove accessor expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +msgid "Modifiers cannot be placed on event accessor declarations" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5436 +msgid "An add or remove accessor must have a body" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5455 +#, fuzzy +msgid "Enums cannot have type parameters" +msgstr "`{0}': no es posible derivar de una clase estática (`{1}')" + +#: mcs/mcs/cs-parser.cs:5755 +msgid "Type parameter declaration must be an identifier not a type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5779 +msgid "Invalid parameter type `void'" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1276 ../mcs/mcs/cs-tokenizer.cs:1346 +#: mcs/mcs/cs-parser.cs:5825 +#, csharp-format +msgid "Invalid base type `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5984 +msgid "An element initializer cannot be empty" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6015 +#, csharp-format +msgid "Named argument `{0}' specified multiple times" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +msgid "An argument is missing" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6166 +msgid "Array creation must have array size or array initializer" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6183 +msgid "Invalid rank specifier, expecting `,' or `]'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6256 +msgid "" +"Invalid anonymous type member declarator. Anonymous type members must be a " +"member assignment, simple name or member access expression" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6658 +msgid "All lambda parameters must be typed either explicitly or implicitly" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6799 +#, csharp-format +msgid "Duplicate `{0}' modifier" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6803 +msgid "More than one protection modifier specified" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6816 +#, fuzzy +msgid "Keyword `new' is not allowed on namespace elements" +msgstr "" +"La palabra reservada `new' no está permitida en los elementos de un espacio " +"de nombres" + +#: mcs/mcs/cs-parser.cs:6936 +#, csharp-format +msgid "A constraint clause has already been specified for type parameter `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6966 +msgid "The `new()' constraint must be the last constraint specified" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6972 +msgid "" +"The `class' or `struct' constraint must be the first constraint specified" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6976 +msgid "The `new()' constraint cannot be used with the `struct' constraint" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6989 +#, csharp-format +msgid "Invalid constraint type `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +msgid "An embedded statement may not be a declaration or labeled statement" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7213 +msgid "" +"Syntax error, bad array declarator. To declare a managed array the rank " +"specifier precedes the variable's identifier. To declare a fixed size buffer " +"field, use the fixed keyword before the field type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7262 +msgid "A stackalloc expression requires [] after type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7468 +msgid "Type and identifier are both required in a foreach statement" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +msgid "; expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7555 +msgid "Expression expected after yield return" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7598 +msgid "Expected catch or finally" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7618 +msgid "Try statement already has an empty catch block" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7651 +msgid "" +"A type that derives from `System.Exception', `object', or `string' expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11367 +msgid "Expecting `;'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11375 +#, fuzzy, csharp-format +msgid "The parameter modifier `{0}' is not valid in this context" +msgstr "El tipo predefinido `{0}.{1}' no está definido o no ha sido importado" + +#: mcs/mcs/cs-parser.cs:11381 +#, csharp-format +msgid "Duplicate parameter modifier `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11387 +msgid "Type expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11392 +msgid "Unsafe code requires the `unsafe' command line option to be specified" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11402 +msgid "Named arguments must appear after the positional arguments" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11493 +msgid "Syntax error, " +msgstr "" + +#: mcs/mcs/cs-parser.cs:11547 +msgid "Parsing error" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11553 +msgid "Internal compiler error during parsing" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11564 +#, csharp-format +msgid "{0}: `{1}' is a keyword" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11690 +#, fuzzy, csharp-format +msgid "Identifier expected, `{0}' is a keyword" +msgstr "Esperaba un identificador: {0}." + +#: mcs/mcs/cs-parser.cs:11704 +#, csharp-format +msgid "{1} `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11706 +#, csharp-format +msgid "{2} `{0}', expecting {1}" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:760 +msgid "" +"The `partial' modifier can be used only immediately before `class', " +"`struct', `interface', or `void' keyword" +msgstr "" +"El modificador `partial' solamente puede ser utilizado antes de `class', " +"`struct', `interface' o la palabra clave `void'" + +#: mcs/mcs/cs-tokenizer.cs:1395 mcs/mcs/cs-tokenizer.cs:1462 msgid "Invalid number" msgstr "Número inválido" -#: ../mcs/mcs/cs-tokenizer.cs:1532 +#: mcs/mcs/cs-tokenizer.cs:1647 #, csharp-format msgid "Unrecognized escape sequence `\\{0}'" msgstr "Secuencia de escape no reconocida: `\\\\{0}'" -#: ../mcs/mcs/cs-tokenizer.cs:1551 +#: mcs/mcs/cs-tokenizer.cs:1666 msgid "Unrecognized escape sequence" msgstr "Secuencia de escape no reconocida" -#: ../mcs/mcs/cs-tokenizer.cs:1811 +#: mcs/mcs/cs-tokenizer.cs:1887 #, fuzzy msgid "Missing identifier to pre-processor directive" msgstr "La directiva del pre-procesador requiere un identificador" -#: ../mcs/mcs/cs-tokenizer.cs:1821 ../mcs/mcs/cs-tokenizer.cs:1825 +#: mcs/mcs/cs-tokenizer.cs:1897 mcs/mcs/cs-tokenizer.cs:1901 #, csharp-format msgid "Identifier expected: {0}" msgstr "Esperaba un identificador: {0}." -#: ../mcs/mcs/cs-tokenizer.cs:2201 -msgid "Numeric constant too long" +#: mcs/mcs/cs-tokenizer.cs:2373 +#, fuzzy +msgid "Integral constant is too large" msgstr "La constante numérica es demasiado grande" -#: ../mcs/mcs/cs-tokenizer.cs:2206 +#: mcs/mcs/cs-tokenizer.cs:2378 msgid "Invalid preprocessor directive" msgstr "Directiva inválida para el pre-procesador." -#: ../mcs/mcs/cs-tokenizer.cs:2213 +#: mcs/mcs/cs-tokenizer.cs:2385 #, csharp-format msgid "Unexpected processor directive ({0})" msgstr "Directiva inválida para el pre-procesador ({0})." -#: ../mcs/mcs/cs-tokenizer.cs:2218 -#, csharp-format -msgid "Expected `{0}'" -msgstr "Esperaba `{0}'" - -#: ../mcs/mcs/cs-tokenizer.cs:2224 +#: mcs/mcs/cs-tokenizer.cs:2391 msgid "" "Cannot define or undefine preprocessor symbols after first token in file" msgstr "" "No es posible definir nuevos símbolos para el preprocesador o elimiar las " "definiciones existentes después del primer tóken del archivo" -#: ../mcs/mcs/cs-tokenizer.cs:2230 +#: mcs/mcs/cs-tokenizer.cs:2397 msgid "" "Preprocessor directives must appear as the first non-whitespace character on " "a line" @@ -264,92 +793,80 @@ msgstr "" "Las directivas del pre-procesador deben aparecer como el primer carácter en " "la línea (que no sea un espacio en blanco)" -#: ../mcs/mcs/cs-tokenizer.cs:2235 +#: mcs/mcs/cs-tokenizer.cs:2402 msgid "Single-line comment or end-of-line expected" msgstr "Esperaba un comentario de una sola línea o el final de archivo" -#: ../mcs/mcs/cs-tokenizer.cs:2280 ../mcs/mcs/cs-tokenizer.cs:3006 +#: mcs/mcs/cs-tokenizer.cs:2435 mcs/mcs/cs-tokenizer.cs:3431 msgid "Expected `#endif' directive" msgstr "Esperaba la directiva `#endif'" -#: ../mcs/mcs/cs-tokenizer.cs:2313 ../mcs/mcs/cs-tokenizer.cs:2334 -#: ../mcs/mcs/cs-tokenizer.cs:2365 ../mcs/mcs/cs-tokenizer.cs:3004 +#: mcs/mcs/cs-tokenizer.cs:2468 mcs/mcs/cs-tokenizer.cs:2489 +#: mcs/mcs/cs-tokenizer.cs:2520 mcs/mcs/cs-tokenizer.cs:3429 msgid "#endregion directive expected" msgstr "Esperaba la directiva `#endregion'" -#: ../mcs/mcs/cs-tokenizer.cs:2420 +#: mcs/mcs/cs-tokenizer.cs:2567 +msgid "Wrong preprocessor directive" +msgstr "La directiva del pre-procesador es errónea" + +#: mcs/mcs/cs-tokenizer.cs:2579 #, csharp-format msgid "#error: '{0}'" msgstr "#error: '{0}'" -#: ../mcs/mcs/cs-tokenizer.cs:2440 +#: mcs/mcs/cs-tokenizer.cs:2598 msgid "The line number specified for #line directive is missing or invalid" msgstr "" "Falta el número de linea especificado en la directiva #line o el número es " "inválido" -#: ../mcs/mcs/cs-tokenizer.cs:2444 -msgid "Wrong preprocessor directive" -msgstr "La directiva del pre-procesador es errónea" - -#: ../mcs/mcs/cs-tokenizer.cs:2474 ../mcs/mcs/cs-tokenizer.cs:2837 +#: mcs/mcs/cs-tokenizer.cs:2625 mcs/mcs/cs-tokenizer.cs:3243 msgid "Newline in constant" msgstr "Hay un carácter nueva-linea en la constante" -#: ../mcs/mcs/cs-tokenizer.cs:2490 +#: mcs/mcs/cs-tokenizer.cs:2636 msgid "Unterminated string literal" msgstr "La literal de texto no tiene fin" -#: ../mcs/mcs/cs-tokenizer.cs:2537 -msgid "" -"The `partial' modifier can be used only immediately before `class', " -"`struct', `interface', or `void' keyword" -msgstr "" -"El modificador `partial' solamente puede ser utilizado antes de `class', " -"`struct', `interface' o la palabra clave `void'" - -#: ../mcs/mcs/cs-tokenizer.cs:2568 +#: mcs/mcs/cs-tokenizer.cs:2705 msgid "Identifier too long (limit is 512 chars)" msgstr "El identificador es demasiado grande (el límite son 512 caracteres)" -#: ../mcs/mcs/cs-tokenizer.cs:2624 -#, csharp-format -msgid "" -"`{0}': Any identifier with double underscores cannot be used when ISO " -"language version mode is specified" -msgstr "" -"`{0}': Ningún identificador con dos subrayados contíguos puede ser usado " -"cuando la versión del lenguage seleccionada es ISO" - -#: ../mcs/mcs/cs-tokenizer.cs:2739 +#: mcs/mcs/cs-tokenizer.cs:3092 msgid "End-of-file found, '*/' expected" msgstr "El archivo se terminó, y esperaba encontrar un `*/'" -#: ../mcs/mcs/cs-tokenizer.cs:2876 -msgid "Keyword, identifier, or string expected after verbatim specifier: @" +#: mcs/mcs/cs-tokenizer.cs:3201 +msgid "Keyword, identifier, or string expected after verbatim specifier: @" +msgstr "" +"Esperaba una palabra clave, un identificador o una cadena después del " +"especificador '@' (al pie de la letra)" + +#: mcs/mcs/cs-tokenizer.cs:3217 +#, fuzzy, csharp-format +msgid "Unexpected character `{0}'" +msgstr "Esperaba `{0}'" + +#: mcs/mcs/cs-tokenizer.cs:3238 +msgid "Empty character literal" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:3258 +msgid "Too many characters in character literal" msgstr "" -"Esperaba una palabra clave, un identificador o una cadena después del " -"especificador '@' (al pie de la letra)" -#: ../mcs/mcs/cfold.cs:66 +#: mcs/mcs/cfold.cs:84 msgid "The operation overflows at compile time in checked mode" msgstr "" "La operación produjo un sobreflujo durante la compilación en el modo " "verificado (-checked)" -#: ../mcs/mcs/cfold.cs:693 ../mcs/mcs/cfold.cs:773 +#: mcs/mcs/cfold.cs:764 mcs/mcs/cfold.cs:849 msgid "Division by constant zero" msgstr "División por cero (con una constante)" -#: ../mcs/mcs/class.cs:156 -#, csharp-format -msgid "" -"The operator `{0}' requires a matching operator `{1}' to also be defined" -msgstr "" -"El operador `{0}' require que el operador correspondiente `{1}' también sea " -"definido" - -#: ../mcs/mcs/class.cs:351 +#: mcs/mcs/class.cs:371 #, csharp-format msgid "" "Partial declarations of `{0}' must be all classes, all structs or all " @@ -358,14 +875,14 @@ msgstr "" "Las declaraciones parciales de `{0}' deben o todas ser classes, o todas " "estructuras o todas interfaces" -#: ../mcs/mcs/class.cs:360 +#: mcs/mcs/class.cs:380 #, csharp-format msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" msgstr "" "Las varias declaraciones parciales de `{0} tienen modificadores de " "accesibilidad en conflicto" -#: ../mcs/mcs/class.cs:416 +#: mcs/mcs/class.cs:433 #, csharp-format msgid "" "`{0}': explicit interface declaration can only be declared in a class or " @@ -374,7 +891,7 @@ msgstr "" "`{0}': las declaraciones explícitas de interfaces solamente pueden ser " "declaradas en una clase o estructura" -#: ../mcs/mcs/class.cs:455 ../mcs/mcs/decl.cs:2803 +#: mcs/mcs/class.cs:470 mcs/mcs/membercache.cs:1347 #, csharp-format msgid "" "A member `{0}' is already defined. Rename this member or use different " @@ -383,19 +900,28 @@ msgstr "" "El miembro `{0} ya ha sido definido. Renombre este miembro o use tipos de " "parámetro distintos" -#: ../mcs/mcs/class.cs:572 +#: mcs/mcs/class.cs:578 msgid "" "Cannot specify the `DefaultMember' attribute on type containing an indexer" msgstr "" "No puede especificar el atributo `DefaultMember' en un tipo que contiene un " "indexador" -#: ../mcs/mcs/class.cs:855 +#: mcs/mcs/class.cs:584 +msgid "The RequiredAttribute attribute is not permitted on C# types" +msgstr "" + +#: mcs/mcs/class.cs:855 +#, fuzzy, csharp-format +msgid "Class `{0}' cannot derive from the dynamic type" +msgstr "`{0}' no es posible derivad de la clase especial `{1}'" + +#: mcs/mcs/class.cs:872 #, csharp-format msgid "`{0}' is already listed in interface list" msgstr "`{0}' ya está listado en la lista de interfaces" -#: ../mcs/mcs/class.cs:863 +#: mcs/mcs/class.cs:880 #, csharp-format msgid "" "Inconsistent accessibility: base interface `{0}' is less accessible than " @@ -404,30 +930,56 @@ msgstr "" "Accesibilidad inconsistente: la interface base `{0}' es menos accessible que " "la interface `{1}'" -#: ../mcs/mcs/class.cs:869 +#: mcs/mcs/class.cs:886 #, csharp-format msgid "Type `{0}' in interface list is not an interface" msgstr "El tipo `{0} en la lista de interfaces no es una interface" -#: ../mcs/mcs/class.cs:871 +#: mcs/mcs/class.cs:888 #, csharp-format msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" msgstr "" "`{0}': las clases no pueden tener múltiples clases base (`{1}' y `{2}')" -#: ../mcs/mcs/class.cs:874 +#: mcs/mcs/class.cs:891 #, csharp-format msgid "`{0}': Base class `{1}' must be specified as first" msgstr "`{0}': la clase base `{1}' tiene que ser especificada primero" -#: ../mcs/mcs/class.cs:901 +#: mcs/mcs/class.cs:915 #, csharp-format msgid "Partial declarations of `{0}' must not specify different base classes" msgstr "" "Las declaraciones parciales de `{0}' no deben de especificar clases bases " "distintas" -#: ../mcs/mcs/class.cs:942 +#: mcs/mcs/class.cs:996 +#, csharp-format +msgid "" +"The operator `{0}' requires a matching operator `{1}' to also be defined" +msgstr "" +"El operador `{0}' require que el operador correspondiente `{1}' también sea " +"definido" + +#: mcs/mcs/class.cs:1021 +#, csharp-format +msgid "`{0}' clashes with a predefined namespace" +msgstr "" + +#: mcs/mcs/class.cs:1150 +#, csharp-format +msgid "" +"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" +msgstr "" +"La interface heredada `{0}' produce un ciclo en la jerarquía de la interface " +"`{1}'" + +#: mcs/mcs/class.cs:1156 +#, csharp-format +msgid "Circular base class dependency involving `{0}' and `{1}'" +msgstr "Dependencia circular en la clase base involucrando `{0}' y `{1}'" + +#: mcs/mcs/class.cs:1183 #, csharp-format msgid "" "`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " @@ -436,7 +988,14 @@ msgstr "" "`{0}' no es posible implementar tanto `{1}' como `{2}' por que se pueden " "unificar en algunos casos" -#: ../mcs/mcs/class.cs:1164 +#: mcs/mcs/class.cs:1223 +#, csharp-format +msgid "" +"The type `{0}' is defined in an assembly that is not referenced. Consider " +"adding a reference to assembly `{1}'" +msgstr "" + +#: mcs/mcs/class.cs:1339 #, csharp-format msgid "" "Partial declarations of `{0}' must have the same type parameter names in the " @@ -445,7 +1004,16 @@ msgstr "" "Las declaraciones parciales de `{0} deben de tener los mismos nombres de " "parámetros en el mismo órden." -#: ../mcs/mcs/class.cs:1184 +#: mcs/mcs/class.cs:1346 +#, fuzzy, csharp-format +msgid "" +"Partial declarations of `{0}' must have the same type parameter variance " +"modifiers" +msgstr "" +"Las declaraciones parciales de `{0} deben de tener los mismos nombres de " +"parámetros en el mismo órden." + +#: mcs/mcs/class.cs:1371 #, csharp-format msgid "" "Partial declarations of `{0}' have inconsistent constraints for type " @@ -454,20 +1022,12 @@ msgstr "" "Las declaraciones parciales de `{0}' tienen limitaciones inconsistentes para " "el tipo parametrizado `{1}'" -#: ../mcs/mcs/class.cs:1274 -#, csharp-format -msgid "" -"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" -msgstr "" -"La interface heredada `{0}' produce un ciclo en la jerarquía de la interface " -"`{1}'" - -#: ../mcs/mcs/class.cs:1279 -#, csharp-format -msgid "Circular base class dependency involving `{0}' and `{1}'" -msgstr "Dependencia circular en la clase base involucrando `{0}' y `{1}'" +#: mcs/mcs/class.cs:1510 +#, fuzzy, csharp-format +msgid "`{0}': cannot implement a dynamic interface `{1}'" +msgstr "`{0}': el tipo contenedor no implementa la interface `{1}'" -#: ../mcs/mcs/class.cs:1459 +#: mcs/mcs/class.cs:1623 msgid "" "Two indexers have different names; the IndexerName attribute must be used " "with the same name on every indexer within a type" @@ -475,85 +1035,85 @@ msgstr "" "Hay dos indexadores con nombres distintos; El atributo IndexerName debe " "ser usado con el mismo nombre en todos los indexadores dentro de un tipo" -#: ../mcs/mcs/class.cs:2293 +#: mcs/mcs/class.cs:1957 #, csharp-format msgid "A static member `{0}' cannot be marked as override, virtual or abstract" msgstr "" "El miembro estático `{0}' no puede ser marcado con override, virtual o " "abstract" -#: ../mcs/mcs/class.cs:2307 +#: mcs/mcs/class.cs:1964 #, csharp-format msgid "A member `{0}' marked as override cannot be marked as new or virtual" msgstr "" "El miembro `{0}' está usa `override' y no puede usar `new' o `virtual' " -#: ../mcs/mcs/class.cs:2319 +#: mcs/mcs/class.cs:1976 #, csharp-format msgid "`{0}' cannot be both extern and abstract" msgstr "`{0}' no puede ser tanto externo como abstracto" -#: ../mcs/mcs/class.cs:2324 +#: mcs/mcs/class.cs:1981 #, csharp-format msgid "`{0}' cannot be both abstract and sealed" msgstr "`{0}'' no puede ser tanto sellado como abstracto" -#: ../mcs/mcs/class.cs:2329 +#: mcs/mcs/class.cs:1986 #, csharp-format msgid "The abstract method `{0}' cannot be marked virtual" msgstr "El método abstracto `{0} no puede ser marcado como virtual" -#: ../mcs/mcs/class.cs:2335 +#: mcs/mcs/class.cs:1992 #, csharp-format msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" msgstr "" "`{0}' es abstracto pero ha sido declarado dentro de una clase que no es " "abstracta (`{1}')" -#: ../mcs/mcs/class.cs:2343 +#: mcs/mcs/class.cs:2000 #, csharp-format msgid "`{0}': virtual or abstract members cannot be private" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: ../mcs/mcs/class.cs:2350 +#: mcs/mcs/class.cs:2007 #, csharp-format msgid "`{0}' cannot be sealed because it is not an override" msgstr "`{0}' no puede sellarse por que no es una sobrecarga" -#: ../mcs/mcs/class.cs:2436 +#: mcs/mcs/class.cs:2054 #, csharp-format msgid "`{0}': containing type does not implement interface `{1}'" msgstr "`{0}': el tipo contenedor no implementa la interface `{1}'" -#: ../mcs/mcs/class.cs:2570 +#: mcs/mcs/class.cs:2230 #, csharp-format msgid "Type parameter `{0}' has same name as containing type, or method" msgstr "" "El tipo parametrizado `{0}' tiene el mimo nombre que el tipo contenedor, o " "el método" -#: ../mcs/mcs/class.cs:2576 +#: mcs/mcs/class.cs:2238 #, csharp-format msgid "`{0}': member names cannot be the same as their enclosing type" msgstr "" "`{0}': los nombres de los miembros no pueden ser el mismo que el del tipo " "contenedor" -#: ../mcs/mcs/class.cs:2718 +#: mcs/mcs/class.cs:2404 msgid "" "The class System.Object cannot have a base class or implement an interface." msgstr "" "La clase Syste.Object no puede tener una clase base o implementar una " "interface." -#: ../mcs/mcs/class.cs:2727 +#: mcs/mcs/class.cs:2412 #, csharp-format msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" msgstr "" "El atributo `{0}' solamente es válido en las clases derivadas de System." "Attribute" -#: ../mcs/mcs/class.cs:2732 +#: mcs/mcs/class.cs:2417 msgid "" "Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " "or attribute classes" @@ -561,77 +1121,86 @@ msgstr "" "El atributo `System.Diagnostics.ConditionalAttribute' solamente es válido en " "métodos o en clases derivadas de System.Attribute" -#: ../mcs/mcs/class.cs:2771 +#: mcs/mcs/class.cs:2455 #, csharp-format msgid "`{0}': Static classes cannot contain user-defined operators" msgstr "" "`{0}': las clases estáticas no pueden contener operadores definidos por el " "usuario" -#: ../mcs/mcs/class.cs:2776 +#: mcs/mcs/class.cs:2460 #, csharp-format msgid "`{0}': Static classes cannot contain destructor" msgstr "`{0}': las clases estáticas no pueden contener un destructor" -#: ../mcs/mcs/class.cs:2781 +#: mcs/mcs/class.cs:2465 #, csharp-format msgid "`{0}': cannot declare indexers in a static class" msgstr "`{0}': no es posible declarar indexadores en una clase estática" -#: ../mcs/mcs/class.cs:2789 +#: mcs/mcs/class.cs:2473 #, csharp-format msgid "`{0}': Static classes cannot have instance constructors" msgstr "" "`{0}': las clases estáticas no pueden tener constructores de instancias" -#: ../mcs/mcs/class.cs:2795 +#: mcs/mcs/class.cs:2479 #, csharp-format msgid "`{0}': Extension methods must be declared static" msgstr "`{0}' Los métodos de extensión deben de ser estáticos" -#: ../mcs/mcs/class.cs:2799 +#: mcs/mcs/class.cs:2483 #, csharp-format msgid "`{0}': cannot declare instance members in a static class" msgstr "" "`{0}'L no es posible declarar miembros de instancia en una clase estática" -#: ../mcs/mcs/class.cs:2808 +#: mcs/mcs/class.cs:2492 #, csharp-format msgid "`{0}': an abstract class cannot be sealed or static" msgstr "`{0}': una clase abstracta no puede estar sellada o ser estática" -#: ../mcs/mcs/class.cs:2812 +#: mcs/mcs/class.cs:2496 #, csharp-format msgid "`{0}': a class cannot be both static and sealed" msgstr "`{0}': una clase no puede estar sellada y ser estática al mismo tiempo" -#: ../mcs/mcs/class.cs:2849 -#, csharp-format -msgid "Cannot derive from `{0}' because it is a type parameter" -msgstr "No se puede derivar de `{0}' ya que es un tipo parametrizado" +#: mcs/mcs/class.cs:2526 +#, fuzzy, csharp-format +msgid "`{0}': Cannot derive from type parameter `{1}'" +msgstr "`{0}': no es posible derivar de una clase estática (`{1}')" -#: ../mcs/mcs/class.cs:2856 +#: mcs/mcs/class.cs:2530 #, csharp-format msgid "" "A generic type cannot derive from `{0}' because it is an attribute class" msgstr "Los tipos genericos no pueden derivad de `{0} ya que es un atributo" -#: ../mcs/mcs/class.cs:2863 +#: mcs/mcs/class.cs:2534 #, csharp-format msgid "`{0}': Cannot derive from static class `{1}'" msgstr "`{0}': no es posible derivar de una clase estática (`{1}')" -#: ../mcs/mcs/class.cs:2866 -#, csharp-format -msgid "`{0}': cannot derive from sealed class `{1}'" +#: mcs/mcs/class.cs:2538 +#, fuzzy, csharp-format +msgid "`{0}': cannot derive from sealed type `{1}'" msgstr "`{0}': no es posible derivad de una clase sellada (`{1}')" -#: ../mcs/mcs/class.cs:2873 +#: mcs/mcs/class.cs:2541 +#, csharp-format +msgid "" +"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " +"from object" +msgstr "" +"La clase estática `{0}' no puede derivarse del tipo `{1}'. Las clases " +"estáticas deben derivar de `System.Object'" + +#: mcs/mcs/class.cs:2548 #, csharp-format msgid "`{0}' cannot derive from special class `{1}'" msgstr "`{0}' no es posible derivad de la clase especial `{1}'" -#: ../mcs/mcs/class.cs:2880 +#: mcs/mcs/class.cs:2556 #, csharp-format msgid "" "Inconsistent accessibility: base class `{0}' is less accessible than class `" @@ -640,50 +1209,58 @@ msgstr "" "Accesibilidad inconsistente: la clase base `{0}' es menos accessible que la " "clase `{1}'" -#: ../mcs/mcs/class.cs:2887 -#, csharp-format -msgid "" -"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " -"from object" -msgstr "" -"La clase estática `{0}' no puede derivarse del tipo `{1}'. Las clases " -"estáticas deben derivar de `System.Object'" - -#: ../mcs/mcs/class.cs:2895 +#: mcs/mcs/class.cs:2564 #, csharp-format msgid "Static class `{0}' cannot implement interfaces" msgstr "Las clases estáticas no pueden implementar interfaces (`{0}')" -#: ../mcs/mcs/class.cs:3041 +#: mcs/mcs/class.cs:2683 mcs/mcs/class.cs:2694 +#, csharp-format +msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" +msgstr "" + +#: mcs/mcs/class.cs:2784 #, csharp-format msgid "`{0}': Structs cannot have instance field initializers" msgstr "" "`{0}': las estructuras no pueden tener inicializadores de campos en " "instancias" -#: ../mcs/mcs/class.cs:3362 +#: mcs/mcs/class.cs:2965 +#, fuzzy, csharp-format +msgid "Do not override `{0}'. Use destructor syntax instead" +msgstr "" +"No use `{0}' directamente. Use el modificador de parámetro `this' en su " +"lugar" + +#: mcs/mcs/class.cs:2968 +#, csharp-format +msgid "`{0}' is marked as an override but no suitable {1} found to override" +msgstr "" +"`{0}' está marcado como una sobreescritura pero no es posible encontrar {1} " +"para usar override" + +#: mcs/mcs/class.cs:2974 #, csharp-format msgid "`{0}': cannot override because `{1}' is not an event" msgstr "`{0}': no es posible sobreescribir ya que `{1}' no es un evento" -#: ../mcs/mcs/class.cs:3364 +#: mcs/mcs/class.cs:2977 #, csharp-format msgid "`{0}': cannot override because `{1}' is not a property" msgstr "`{0}': no es posible sobreescribir `{1}' ya que no es una propiedad" -#: ../mcs/mcs/class.cs:3366 +#: mcs/mcs/class.cs:2980 #, csharp-format msgid "`{0}': cannot override because `{1}' is not a method" msgstr "`{0}': no es posible sobreescribir `{1}' ya que no es un método" -#: ../mcs/mcs/class.cs:3368 +#: mcs/mcs/class.cs:3036 mcs/mcs/field.cs:187 #, csharp-format -msgid "`{0}' is marked as an override but no suitable {1} found to override" -msgstr "" -"`{0}' está marcado como una sobreescritura pero no es posible encontrar {1} " -"para usar override" +msgid "`{0}' hides inherited abstract member `{1}'" +msgstr "`{0}' esconde el miembro abstracto heredado `{1}'" -#: ../mcs/mcs/class.cs:3407 +#: mcs/mcs/class.cs:3060 #, csharp-format msgid "" "`{0}': cannot override inherited member `{1}' because it is not marked " @@ -692,33 +1269,38 @@ msgstr "" "`{0}': no es posible sobreescribir el miembro heredado `{1}' ya que este no " "está marcado con `virtual', `abstract' u `override'" -#: ../mcs/mcs/class.cs:3416 +#: mcs/mcs/class.cs:3068 #, csharp-format msgid "`{0}': cannot override inherited member `{1}' because it is sealed" msgstr "" "`{0}': no es posible sobreescribir el miembro heredado `{1}' ya que este " "está sellado" -#: ../mcs/mcs/class.cs:3434 +#: mcs/mcs/class.cs:3077 #, csharp-format msgid "`{0}': type must be `{1}' to match overridden member `{2}'" msgstr "" "`{0}': el tipo debe de ser `{1}' para que corresponda con el miembro " "sobreescrito `{2}'" -#: ../mcs/mcs/class.cs:3438 +#: mcs/mcs/class.cs:3080 #, csharp-format msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" msgstr "" "`{0}': El tipo de regreso debe de ser `{1}' para qu ecorresponda con el " "miembro sobreescrito `{2}'" -#: ../mcs/mcs/class.cs:3460 +#: mcs/mcs/class.cs:3152 #, csharp-format -msgid "`{0}' hides inherited abstract member `{1}'" -msgstr "`{0}' esconde el miembro abstracto heredado `{1}'" +msgid "A partial method `{0}' cannot explicitly implement an interface" +msgstr "" + +#: mcs/mcs/class.cs:3160 +#, fuzzy, csharp-format +msgid "The type `{0}' in explicit interface declaration is not an interface" +msgstr "El tipo `{0} en la lista de interfaces no es una interface" -#: ../mcs/mcs/class.cs:3520 +#: mcs/mcs/class.cs:3191 #, csharp-format msgid "" "Inconsistent accessibility: parameter type `{0}' is less accessible than " @@ -727,7 +1309,7 @@ msgstr "" "Accesibilidad inconsistente: la interface base `{0}' es menos accessible que " "el indexador `{1}'" -#: ../mcs/mcs/class.cs:3524 +#: mcs/mcs/class.cs:3195 #, csharp-format msgid "" "Inconsistent accessibility: parameter type `{0}' is less accessible than " @@ -736,2265 +1318,2161 @@ msgstr "" "Accesibilidad inconsistente: el tipo del parámetro `{0}' es menos accessible " "que el operador `{1}'" -#: ../mcs/mcs/class.cs:3528 +#: mcs/mcs/class.cs:3199 #, csharp-format msgid "" "Inconsistent accessibility: parameter type `{0}' is less accessible than " "method `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:3548 -#, csharp-format -msgid "`{0}' in explicit interface declaration is not an interface" -msgstr "" - -#: ../mcs/mcs/class.cs:3587 -#, csharp-format -msgid "A partial method `{0}' cannot explicitly implement an interface" -msgstr "" - -#: ../mcs/mcs/class.cs:3595 +#: mcs/mcs/class.cs:3213 #, csharp-format -msgid "'{0}' in explicit interface declaration is not an interface" +msgid "" +"Constructor `{0}' is marked `external' but has no external implementation " +"specified" msgstr "" -#: ../mcs/mcs/class.cs:3614 +#: mcs/mcs/class.cs:3216 #, csharp-format msgid "" "`{0}' is marked as an external but has no DllImport attribute. Consider " "adding a DllImport attribute to specify the external implementation" msgstr "" -#: ../mcs/mcs/class.cs:3631 +#: mcs/mcs/class.cs:3245 #, csharp-format msgid "" "`{0}': cannot change access modifiers when overriding `{1}' inherited member " "`{2}'" msgstr "" -#: ../mcs/mcs/class.cs:3724 -msgid "" -"The DllImport attribute must be specified on a method marked `static' and " -"`extern'" -msgstr "" - -#: ../mcs/mcs/class.cs:3787 -#, csharp-format -msgid "`{0}': A partial method parameters cannot use `out' modifier" -msgstr "" - -#: ../mcs/mcs/class.cs:3867 -#, csharp-format -msgid "" -"Conditional not valid on `{0}' because it is a constructor, destructor, " -"operator or explicit interface implementation" -msgstr "" - -#: ../mcs/mcs/class.cs:3924 -msgid "Do not override object.Finalize. Instead, provide a destructor" -msgstr "" - -#: ../mcs/mcs/class.cs:4096 -#, csharp-format -msgid "Program `{0}' has more than one entry point defined: `{1}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4127 -#, csharp-format -msgid "Conditional not valid on `{0}' because its return type is not void" -msgstr "" - -#: ../mcs/mcs/class.cs:4132 -#, csharp-format -msgid "Conditional not valid on `{0}' because it is an override method" -msgstr "" - -#: ../mcs/mcs/class.cs:4137 -msgid "Conditional not valid on interface members" -msgstr "" - -#: ../mcs/mcs/class.cs:4143 -#, csharp-format -msgid "Conditional member `{0}' cannot implement interface member `{1}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4150 -#, csharp-format -msgid "Conditional method `{0}' cannot have an out parameter" -msgstr "" - -#: ../mcs/mcs/class.cs:4218 -#, csharp-format -msgid "`{0}': Extension methods cannot be defined in a nested class" -msgstr "" - -#: ../mcs/mcs/class.cs:4223 -#, csharp-format -msgid "" -"`{0}': Extension methods cannot be declared without a reference to System." -"Core.dll assembly. Add the assembly reference or remove `this' modifer from " -"the first parameter" -msgstr "" - -#: ../mcs/mcs/class.cs:4237 -#, csharp-format -msgid "`{0}': Extension methods must be defined in a non-generic static class" -msgstr "" - -#: ../mcs/mcs/class.cs:4293 -#, csharp-format -msgid "" -"A partial method `{0}' implementation is missing a partial method declaration" -msgstr "" - -#: ../mcs/mcs/class.cs:4327 -#, csharp-format -msgid "Method or delegate cannot return type `{0}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4412 -#, csharp-format -msgid "`{0}': Struct constructors cannot call base constructors" -msgstr "" - -#: ../mcs/mcs/class.cs:4445 -#, csharp-format -msgid "Constructor `{0}' cannot call itself" -msgstr "" - -#: ../mcs/mcs/class.cs:4570 -#, csharp-format -msgid "`{0}': The static constructor must be parameterless" -msgstr "" - -#: ../mcs/mcs/class.cs:4590 -msgid "Structs cannot contain explicit parameterless constructors" -msgstr "" - -#: ../mcs/mcs/class.cs:4642 -#, csharp-format -msgid "" -"`{0}': A class with the ComImport attribute cannot have a user-defined " -"constructor" -msgstr "" - -#: ../mcs/mcs/class.cs:4934 -#, csharp-format -msgid "`{0}' is an accessor not found in interface member `{1}{2}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4940 -#, csharp-format -msgid "" -"`{0}.{1}' in explicit interface declaration is not a member of interface" -msgstr "" - -#: ../mcs/mcs/class.cs:4947 -#, csharp-format -msgid "" -"`{0}' explicit method implementation cannot implement `{1}' because it is an " -"accessor" -msgstr "" - -#: ../mcs/mcs/class.cs:4957 -#, csharp-format -msgid "Method `{0}' cannot implement interface accessor `{1}.{2}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4964 -#, csharp-format -msgid "" -"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " -"an explicit interface implementation" -msgstr "" - -#: ../mcs/mcs/class.cs:4971 -#, csharp-format -msgid "" -"Accessor `{0}' must be declared public to implement interface member `{1}'" -msgstr "" - -#: ../mcs/mcs/class.cs:4995 -#, csharp-format -msgid "" -"`{0}': the explicit interface implementation cannot introduce the params " -"modifier" +#: mcs/mcs/class.cs:3254 +#, fuzzy, csharp-format +msgid "`{0}': static types cannot be used as return types" msgstr "" +"`{0}': las clases estáticas no pueden tener constructores de instancias" -#: ../mcs/mcs/class.cs:5291 +#: mcs/mcs/class.cs:3379 #, csharp-format msgid "New virtual member `{0}' is declared in a sealed class `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:5301 +#: mcs/mcs/class.cs:3394 msgid "Inconsistent accessibility: property type `" msgstr "" -#: ../mcs/mcs/class.cs:5306 +#: mcs/mcs/class.cs:3399 msgid "Inconsistent accessibility: indexer return type `" msgstr "" -#: ../mcs/mcs/class.cs:5312 ../mcs/mcs/class.cs:5317 -#: ../mcs/mcs/delegate.cs:220 +#: mcs/mcs/class.cs:3405 mcs/mcs/class.cs:3410 mcs/mcs/delegate.cs:159 msgid "Inconsistent accessibility: return type `" msgstr "" -#: ../mcs/mcs/class.cs:5322 +#: mcs/mcs/class.cs:3415 msgid "Inconsistent accessibility: field type `" msgstr "" -#: ../mcs/mcs/class.cs:5335 +#: mcs/mcs/class.cs:3428 #, csharp-format msgid "Field or property cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:5363 -msgid "" -"The modifier 'abstract' is not valid on fields. Try using a property instead" -msgstr "" - -#: ../mcs/mcs/class.cs:5378 -msgid "" -"The FieldOffset attribute can only be placed on members of types marked with " -"the StructLayout(LayoutKind.Explicit)" -msgstr "" +#: mcs/mcs/const.cs:103 +#, fuzzy, csharp-format +msgid "Type parameter `{0}' cannot be declared const" +msgstr "El método abstracto `{0} no puede ser marcado como virtual" -#: ../mcs/mcs/class.cs:5383 -msgid "The FieldOffset attribute is not allowed on static or const fields" +#: mcs/mcs/const.cs:106 +#, csharp-format +msgid "The type `{0}' cannot be declared const" msgstr "" -#: ../mcs/mcs/class.cs:5390 +#: mcs/mcs/const.cs:181 +#, csharp-format msgid "" -"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " -"'fixed' field modifier instead" +"The evaluation of the constant value for `{0}' involves a circular definition" msgstr "" -#: ../mcs/mcs/class.cs:5478 +#: mcs/mcs/constant.cs:68 mcs/mcs/constant.cs:319 #, csharp-format -msgid "" -"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " -"must have a FieldOffset attribute" +msgid "Constant value `{0}' cannot be converted to a `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:5487 +#: mcs/mcs/constant.cs:187 #, csharp-format -msgid "`{0}': cannot declare variables of static types" +msgid "" +"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " +"to override)" msgstr "" -#: ../mcs/mcs/class.cs:5605 +#: mcs/mcs/convert.cs:1158 #, csharp-format msgid "" -"`{0}': Fixed size buffers type must be one of the following: bool, byte, " -"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' " +"to `{3}'" msgstr "" -#: ../mcs/mcs/class.cs:5627 +#: mcs/mcs/decl.cs:376 #, csharp-format -msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgid "`{0}' cannot declare a body because it is marked extern" msgstr "" -#: ../mcs/mcs/class.cs:5643 +#: mcs/mcs/decl.cs:382 #, csharp-format -msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgid "`{0}' cannot declare a body because it is marked abstract" msgstr "" -#: ../mcs/mcs/class.cs:5650 +#: mcs/mcs/decl.cs:395 #, csharp-format msgid "" -"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +"`{0}' must have a body because it is not marked abstract or extern. The " +"property can be automatically implemented when you define both accessors" msgstr "" -#: ../mcs/mcs/class.cs:5843 +#: mcs/mcs/decl.cs:401 #, csharp-format -msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" +msgid "" +"`{0}' must have a body because it is not marked abstract, extern, or partial" msgstr "" -#: ../mcs/mcs/class.cs:5855 +#: mcs/mcs/decl.cs:416 #, csharp-format -msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgid "`{0}': Structs cannot contain protected members" msgstr "" -#: ../mcs/mcs/class.cs:5860 +#: mcs/mcs/decl.cs:422 #, csharp-format -msgid "`{0}': A field cannot be both volatile and readonly" +msgid "`{0}': Static classes cannot contain protected members" msgstr "" -#: ../mcs/mcs/class.cs:6049 +#: mcs/mcs/decl.cs:1264 #, csharp-format -msgid "" -"Attribute `{0}' is not valid on property or event accessors. It is valid on `" -"{1}' declarations only" +msgid "The namespace `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6149 ../mcs/mcs/decl.cs:2792 +#: mcs/mcs/decl.cs:1268 #, csharp-format -msgid "A member `{0}' is already reserved" +msgid "Duplicate type parameter `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:6352 +#: mcs/mcs/decl.cs:1271 #, csharp-format -msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgid "The type `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6369 +#: mcs/mcs/decl.cs:1321 #, csharp-format msgid "" -"`{0}': accessibility modifiers may not be used on accessors in an interface" +"Missing partial modifier on declaration of type `{0}'. Another partial " +"declaration of this type exists" msgstr "" -#: ../mcs/mcs/class.cs:6373 -#, csharp-format -msgid "`{0}': abstract properties cannot have private accessors" +#: mcs/mcs/decl.cs:1410 +msgid "Variant type parameters can only be used with interfaces and delegates" msgstr "" -#: ../mcs/mcs/class.cs:6435 +#: mcs/mcs/decl.cs:1422 #, csharp-format -msgid "" -"The accessibility modifier of the `{0}' accessor must be more restrictive " -"than the modifier of the property or indexer `{1}'" +msgid "`{0}': A constraint references nonexistent type parameter `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6500 +#: mcs/mcs/delegate.cs:141 #, csharp-format msgid "" -"`{0}': Cannot specify accessibility modifiers for both accessors of the " -"property or indexer" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"delegate `{1}'" msgstr "" +"Accesibilidad inconsistente: la interface base `{0}' es menos accessible que " +"el delegado `{1}'" -#: ../mcs/mcs/class.cs:6509 +#: mcs/mcs/delegate.cs:487 #, csharp-format msgid "" -"`{0}': accessibility modifiers on accessors may only be used if the property " -"or indexer has both a get and a set accessor" +"Cannot create delegate from method `{0}' because it is a member of System." +"Nullable type" msgstr "" -#: ../mcs/mcs/class.cs:6571 +#: mcs/mcs/delegate.cs:499 #, csharp-format msgid "" -"`{0}.get': cannot override because `{1}' does not have an overridable get " -"accessor" +"Extension method `{0}' of value type `{1}' cannot be used to create delegates" msgstr "" -#: ../mcs/mcs/class.cs:6586 +#: mcs/mcs/delegate.cs:514 #, csharp-format -msgid "" -"`{0}.set': cannot override because `{1}' does not have an overridable set " -"accessor" +msgid "Cannot create delegate from partial method declaration `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:6783 +#: mcs/mcs/delegate.cs:517 #, csharp-format msgid "" -"Automatically implemented property `{0}' cannot be used inside a type with " -"an explicit StructLayout attribute" +"Cannot create delegate with `{0}' because it has a Conditional attribute" msgstr "" -#: ../mcs/mcs/class.cs:7151 +#: mcs/mcs/delegate.cs:560 #, csharp-format -msgid "`{0}': abstract event cannot have an initializer" +msgid "" +"A method or delegate `{0} {1}' parameters and return type must be same as " +"delegate `{2} {3}' parameters and return type" msgstr "" -#: ../mcs/mcs/class.cs:7337 +#: mcs/mcs/delegate.cs:567 #, csharp-format -msgid "`{0}': event must be of a delegate type" +msgid "" +"A method or delegate `{0}' parameters do not match delegate `{1}' parameters" msgstr "" -#: ../mcs/mcs/class.cs:7544 +#: mcs/mcs/delegate.cs:572 +#, csharp-format msgid "" -"The `IndexerName' attribute is valid only on an indexer that is not an " -"explicit interface member declaration" +"A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " +"return type" msgstr "" -#: ../mcs/mcs/class.cs:7551 -msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +#: mcs/mcs/delegate.cs:655 +msgid "Method name expected" msgstr "" -#: ../mcs/mcs/class.cs:7753 +#: mcs/mcs/doc.cs:914 #, csharp-format -msgid "User-defined operator `{0}' must be declared static and public" -msgstr "" - -#: ../mcs/mcs/class.cs:7784 -msgid "" -"User-defined operator cannot take an object of the enclosing type and " -"convert to an object of the enclosing type" +msgid "Error generating XML documentation file `{0}' (`{1}')" msgstr "" -#: ../mcs/mcs/class.cs:7795 -msgid "User-defined conversion must convert to or from the enclosing type" +#: mcs/mcs/driver.cs:96 mcs/mcs/driver.cs:465 mcs/mcs/driver.cs:468 +msgid "Source file `" msgstr "" -#: ../mcs/mcs/class.cs:7804 +#: mcs/mcs/driver.cs:123 #, csharp-format -msgid "" -"User-defined conversion `{0}' cannot convert to or from an interface type" +msgid "Source file `{0}' could not be found" msgstr "" -#: ../mcs/mcs/class.cs:7811 +#: mcs/mcs/driver.cs:129 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a base class" +msgid "Source file `{0}' is a binary file and not a text file" msgstr "" -#: ../mcs/mcs/class.cs:7817 -#, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +#: mcs/mcs/driver.cs:214 +msgid "" +"Invalid target type for -target. Valid options are `exe', `winexe', " +"`library' or `module'" msgstr "" -#: ../mcs/mcs/class.cs:7825 -msgid "" -"Overloaded shift operator must have the type of the first operand be the " -"containing type, and the type of the second operand must be int" +#: mcs/mcs/driver.cs:361 +msgid "Response file `" msgstr "" -#: ../mcs/mcs/class.cs:7834 -msgid "" -"The return type for ++ or -- operator must be the containing type or derived " -"from the containing type" +#: mcs/mcs/driver.cs:370 +msgid "Unable to open response file: " msgstr "" -#: ../mcs/mcs/class.cs:7839 -msgid "The parameter type for ++ or -- operator must be the containing type" +#: mcs/mcs/driver.cs:420 mcs/mcs/driver.cs:430 +msgid "No files to compile were specified" msgstr "" -#: ../mcs/mcs/class.cs:7846 -msgid "The parameter type of a unary operator must be the containing type" +#: mcs/mcs/driver.cs:502 +msgid "Warning level must be in the range 0-4" msgstr "" -#: ../mcs/mcs/class.cs:7854 -msgid "The return type of operator True or False must be bool" +#: mcs/mcs/driver.cs:536 +msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" msgstr "" -#: ../mcs/mcs/class.cs:7867 -msgid "One of the parameters of a binary operator must be the containing type" +#: mcs/mcs/driver.cs:545 +msgid "Compatibility: Use -unsafe instead of --unsafe" msgstr "" -#: ../mcs/mcs/codegen.cs:122 -msgid "Assembly generation failed -- Referenced assembly '" +#: mcs/mcs/driver.cs:556 +msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" msgstr "" -#: ../mcs/mcs/codegen.cs:140 -msgid "Could not access the key inside the container `" +#: mcs/mcs/driver.cs:570 +msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" msgstr "" -#: ../mcs/mcs/codegen.cs:148 -msgid "Could not use the specified key to strongname the assembly." +#: mcs/mcs/driver.cs:579 +msgid "Compatibility: Use -checked instead of --checked" msgstr "" -#: ../mcs/mcs/codegen.cs:176 -msgid "" -"Could not find the symbol writer assembly (Mono.CompilerServices." -"SymbolWriter.dll)" +#: mcs/mcs/driver.cs:589 +msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" msgstr "" -#: ../mcs/mcs/codegen.cs:181 -#, csharp-format -msgid "Unexpected debug information initialization error `{0}'" +#: mcs/mcs/driver.cs:592 +msgid "Missing argument to --linkres" msgstr "" -#: ../mcs/mcs/codegen.cs:199 -msgid "Couldn't delay-sign the assembly with the '" +#: mcs/mcs/driver.cs:601 +msgid "Compatibility: Use -res:VALUE instead of --res VALUE" msgstr "" -#: ../mcs/mcs/codegen.cs:204 ../mcs/mcs/codegen.cs:208 -msgid "Could not write to file `" +#: mcs/mcs/driver.cs:604 +msgid "Missing argument to --resource" msgstr "" -#: ../mcs/mcs/codegen.cs:822 -#, csharp-format -msgid "`{0}': not all code paths return a value" +#: mcs/mcs/driver.cs:612 +msgid "Compatibility: Use -target:KIND instead of --target KIND" msgstr "" -#: ../mcs/mcs/codegen.cs:825 -#, csharp-format -msgid "Not all code paths return a value in anonymous method of type `{0}'" +#: mcs/mcs/driver.cs:644 +msgid "Compatibility: Use -r:LIBRARY instead of -r library" msgstr "" -#: ../mcs/mcs/codegen.cs:1224 ../mcs/mcs/codegen.cs:1237 -#, csharp-format -msgid "" -"Option `{0}' overrides attribute `{1}' given in a source file or added module" +#: mcs/mcs/driver.cs:663 +msgid "Compatibility: Use -lib:ARG instead of --L arg" msgstr "" -#: ../mcs/mcs/codegen.cs:1300 -msgid "" -"Could not sign the assembly. ECMA key can only be used to delay-sign " -"assemblies" +#: mcs/mcs/driver.cs:676 +msgid "Compatibility: Use -nostdlib instead of --nostdlib" msgstr "" -#: ../mcs/mcs/codegen.cs:1320 -msgid "Error during assembly signing. " +#: mcs/mcs/driver.cs:681 +msgid "Compatibility: Use -nowarn instead of --nowarn" msgstr "" -#: ../mcs/mcs/codegen.cs:1345 -msgid "Friend assembly reference `" +#: mcs/mcs/driver.cs:698 +msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" msgstr "" -#: ../mcs/mcs/codegen.cs:1417 -msgid "Invalid type specified as an argument for TypeForwardedTo attribute" +#: mcs/mcs/driver.cs:702 +msgid "--wlevel requires a value from 0 to 4" msgstr "" -#: ../mcs/mcs/codegen.cs:1425 -#, csharp-format -msgid "A duplicate type forward of type `{0}'" +#: mcs/mcs/driver.cs:711 +msgid "--mcs-debug requires an argument" msgstr "" -#: ../mcs/mcs/codegen.cs:1434 -#, csharp-format -msgid "Cannot forward type `{0}' because it is defined in this assembly" +#: mcs/mcs/driver.cs:718 +msgid "Invalid argument to --mcs-debug" msgstr "" -#: ../mcs/mcs/codegen.cs:1440 -#, csharp-format -msgid "Cannot forward type `{0}' because it is a nested type" +#: mcs/mcs/driver.cs:728 +msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" msgstr "" -#: ../mcs/mcs/codegen.cs:1446 -#, csharp-format -msgid "Cannot forward generic type `{0}'" +#: mcs/mcs/driver.cs:730 +msgid "--recurse requires an argument" msgstr "" -#: ../mcs/mcs/codegen.cs:1651 -msgid "" -"Value specified for the argument to 'System.Runtime.InteropServices." -"DefaultCharSetAttribute' is not valid" +#: mcs/mcs/driver.cs:741 +msgid "Compatibility: Use -debug option instead of -g or --debug" msgstr "" -#: ../mcs/mcs/const.cs:177 -#, csharp-format -msgid "The expression being assigned to `{0}' must be constant" +#: mcs/mcs/driver.cs:746 +msgid "Compatibility: Use -noconfig option instead of --noconfig" msgstr "" -#: ../mcs/mcs/const.cs:182 +#: mcs/mcs/driver.cs:910 #, csharp-format -msgid "" -"The evaluation of the constant value for `{0}' involves a circular definition" +msgid "Invalid conditional define symbol `{0}'" msgstr "" -#: ../mcs/mcs/const.cs:188 +#: mcs/mcs/driver.cs:961 #, csharp-format msgid "" -"A constant `{0}' of reference type `{1}' can only be initialized with null" +"Invalid resource visibility option `{0}'. Use either `public' or `private' " +"instead" msgstr "" -#: ../mcs/mcs/const.cs:194 +#: mcs/mcs/driver.cs:967 #, csharp-format -msgid "The type `{0}' cannot be declared const" +msgid "Wrong number of arguments for option `{0}'" msgstr "" -#: ../mcs/mcs/constant.cs:84 ../mcs/mcs/constant.cs:285 -#, csharp-format -msgid "Constant value `{0}' cannot be converted to a `{1}'" +#: mcs/mcs/driver.cs:1005 +msgid "Cannot specify multiple aliases using single /reference option" msgstr "" -#: ../mcs/mcs/constant.cs:192 -#, csharp-format +#: mcs/mcs/driver.cs:1033 mcs/mcs/driver.cs:1045 msgid "" -"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " -"to override)" -msgstr "" - -#: ../mcs/mcs/decl.cs:363 -#, csharp-format -msgid "`{0}' cannot declare a body because it is marked extern" +"Cannot specify the `win32res' and the `win32ico' compiler option at the same " +"time" msgstr "" -#: ../mcs/mcs/decl.cs:369 +#: mcs/mcs/driver.cs:1160 #, csharp-format -msgid "`{0}' cannot declare a body because it is marked abstract" +msgid "`{0}' is not a valid warning number" msgstr "" -#: ../mcs/mcs/decl.cs:377 -#, csharp-format +#: mcs/mcs/driver.cs:1190 msgid "" -"`{0}' must have a body because it is not marked abstract or extern. The " -"property can be automatically implemented when you define both accessors" +"Invalid platform type for -platform. Valid options are `anycpu', `x86', " +"`x64' or `itanium'" msgstr "" -#: ../mcs/mcs/decl.cs:380 +#: mcs/mcs/driver.cs:1288 #, csharp-format msgid "" -"`{0}' must have a body because it is not marked abstract, extern, or partial" +"Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or " +"`Default'" msgstr "" -#: ../mcs/mcs/decl.cs:396 +#: mcs/mcs/driver.cs:1308 #, csharp-format -msgid "`{0}': Structs cannot contain protected members" +msgid "Code page `{0}' is invalid or not installed" msgstr "" -#: ../mcs/mcs/decl.cs:402 +#: mcs/mcs/driver.cs:1323 #, csharp-format -msgid "`{0}': Static classes cannot contain protected members" +msgid "Unrecognized command-line option: `{0}'" msgstr "" -#: ../mcs/mcs/decl.cs:950 +#: mcs/mcs/driver.cs:1328 #, csharp-format -msgid "The namespace `{0}' already contains a definition for `{1}'" +msgid "Missing file specification for `{0}' option" msgstr "" -#: ../mcs/mcs/decl.cs:954 +#: mcs/mcs/driver.cs:1333 #, csharp-format -msgid "Duplicate type parameter `{0}'" +msgid "Missing argument for `{0}' option" msgstr "" -#: ../mcs/mcs/decl.cs:957 +#: mcs/mcs/driver.cs:1368 #, csharp-format -msgid "The type `{0}' already contains a definition for `{1}'" +msgid "Invalid reference alias `{0}='. Missing filename" msgstr "" -#: ../mcs/mcs/decl.cs:1025 +#: mcs/mcs/driver.cs:1373 #, csharp-format msgid "" -"Missing partial modifier on declaration of type `{0}'. Another partial " -"declaration of this type exists" -msgstr "" - -#: ../mcs/mcs/decl.cs:1248 -msgid "The RequiredAttribute attribute is not permitted on C# types" -msgstr "" - -#: ../mcs/mcs/decl.cs:1303 -msgid "Constraints are not allowed on non-generic declarations" +"Invalid extern alias for -reference. Alias `{0}' is not a valid identifier" msgstr "" -#: ../mcs/mcs/decl.cs:1347 +#: mcs/mcs/driver.cs:1389 #, csharp-format -msgid "`{0}': A constraint references nonexistent type parameter `{1}'" -msgstr "" - -#: ../mcs/mcs/decl.cs:2725 -msgid "" -"A partial method declaration and partial method implementation cannot differ " -"on use of `params' modifier" -msgstr "" - -#: ../mcs/mcs/decl.cs:2728 -msgid "" -"A partial method declaration and partial method implementation must be both " -"an extension method or neither" +msgid "The resource identifier `{0}' has already been used in this assembly" msgstr "" -#: ../mcs/mcs/decl.cs:2732 -#, csharp-format +#: mcs/mcs/driver.cs:1450 msgid "" -"An overloaded method `{0}' cannot differ on use of parameter modifiers only" +"If no source files are specified you must specify the output file with -out:" msgstr "" -#: ../mcs/mcs/decl.cs:2760 -msgid "" -"A partial method declaration and partial method implementation must be both " -"`static' or neither" -msgstr "" +#: mcs/mcs/dynamic.cs:272 +#, fuzzy +msgid "An expression tree cannot contain a dynamic operation" +msgstr "Un árbol de expresiones no puede contener un operador de asignación" -#: ../mcs/mcs/decl.cs:2765 +#: mcs/mcs/dynamic.cs:302 msgid "" -"A partial method declaration and partial method implementation must be both " -"`unsafe' or neither" -msgstr "" - -#: ../mcs/mcs/decl.cs:2771 -#, csharp-format -msgid "A partial method `{0}' declaration is already defined" +"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly " +"reference" msgstr "" -#: ../mcs/mcs/decl.cs:2775 +#: mcs/mcs/ecore.cs:242 #, csharp-format -msgid "A partial method `{0}' implementation is already defined" +msgid "`{0}' is inaccessible due to its protection level" msgstr "" -#: ../mcs/mcs/decl.cs:2783 +#: mcs/mcs/ecore.cs:247 #, csharp-format -msgid "Duplicate user-defined conversion in type `{0}'" +msgid "The expression being assigned to `{0}' must be constant" msgstr "" -#: ../mcs/mcs/delegate.cs:204 +#: mcs/mcs/ecore.cs:252 #, csharp-format msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"delegate `{1}'" -msgstr "" -"Accesibilidad inconsistente: la interface base `{0}' es menos accessible que " -"el delegado `{1}'" - -#: ../mcs/mcs/delegate.cs:403 -msgid "Internal error: could not find delegate constructor!" -msgstr "" - -#: ../mcs/mcs/delegate.cs:445 ../mcs/mcs/delegate.cs:553 -msgid "Internal error: could not find Invoke method!" +"A constant `{0}' of reference type `{1}' can only be initialized with null" msgstr "" -#: ../mcs/mcs/delegate.cs:732 -#, csharp-format +#: mcs/mcs/ecore.cs:258 msgid "" -"Cannot create delegate from method `{0}' because it is a member of System." -"Nullable type" +"Only assignment, call, increment, decrement, and new object expressions can " +"be used as a statement" msgstr "" -#: ../mcs/mcs/delegate.cs:744 -#, csharp-format -msgid "" -"Extension method `{0}' of value type `{1}' cannot be used to create delegates" +#: mcs/mcs/ecore.cs:269 +msgid "Keyword `void' cannot be used in this context" msgstr "" -#: ../mcs/mcs/delegate.cs:759 +#: mcs/mcs/ecore.cs:303 #, csharp-format -msgid "Cannot create delegate from partial method declaration `{0}'" +msgid "Cannot convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:762 +#: mcs/mcs/ecore.cs:313 #, csharp-format msgid "" -"Cannot create delegate with `{0}' because it has a Conditional attribute" +"Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " +"(are you missing a cast?)" msgstr "" -#: ../mcs/mcs/delegate.cs:818 +#: mcs/mcs/ecore.cs:319 #, csharp-format -msgid "" -"A method or delegate `{0} {1}' parameters and return type must be same as " -"delegate `{2} {3}' parameters and return type" +msgid "Cannot implicitly convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:824 +#: mcs/mcs/ecore.cs:360 #, csharp-format -msgid "" -"A method or delegate `{0}' parameters do not match delegate `{1}' parameters" +msgid "`{0}' does not contain a definition for `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:829 -#, csharp-format +#: mcs/mcs/ecore.cs:366 msgid "" -"A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " -"return type" -msgstr "" - -#: ../mcs/mcs/delegate.cs:949 -msgid "Method name expected" -msgstr "" - -#: ../mcs/mcs/doc.cs:1007 -#, csharp-format -msgid "Error generating XML documentation file `{0}' (`{1}')" -msgstr "" - -#: ../mcs/mcs/driver.cs:152 ../mcs/mcs/driver.cs:707 ../mcs/mcs/driver.cs:710 -msgid "Source file `" +"The left-hand side of an assignment must be a variable, a property or an " +"indexer" msgstr "" -#: ../mcs/mcs/driver.cs:179 -#, csharp-format -msgid "Source file `{0}' could not be found" +#: mcs/mcs/ecore.cs:371 +msgid "The operation in question is undefined on void pointers" msgstr "" -#: ../mcs/mcs/driver.cs:187 +#: mcs/mcs/ecore.cs:433 mcs/mcs/statement.cs:2558 mcs/mcs/statement.cs:2560 #, csharp-format -msgid "Source file `{0}' is a binary file and not a text file" +msgid "Internal compiler error: {0}" msgstr "" -#: ../mcs/mcs/driver.cs:205 -#, csharp-format -msgid "Compilation aborted in file `{0}', {1}" +#: mcs/mcs/ecore.cs:473 +msgid "A ref or out argument must be an assignable variable" msgstr "" -#: ../mcs/mcs/driver.cs:272 +#: mcs/mcs/ecore.cs:492 msgid "" -"Invalid target type for -target. Valid options are `exe', `winexe', " -"`library' or `module'" +"An attribute argument must be a constant expression, typeof expression or " +"array creation expression" msgstr "" -#: ../mcs/mcs/driver.cs:320 +#: mcs/mcs/ecore.cs:563 #, csharp-format -msgid "cannot find metadata file `{0}'" +msgid "The class `{0}' has no constructors defined" msgstr "" -#: ../mcs/mcs/driver.cs:327 +#: mcs/mcs/ecore.cs:648 #, csharp-format -msgid "file `{0}' has invalid `{1}' metadata" +msgid "Ambiguity between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:347 -#, csharp-format -msgid "" -"Referenced file `{0}' is not an assembly. Consider using `-addmodule' option " -"instead" +#: mcs/mcs/ecore.cs:675 +msgid "An expression tree cannot contain an unsafe pointer operation" msgstr "" -#: ../mcs/mcs/driver.cs:603 -msgid "Response file `" +#: mcs/mcs/ecore.cs:796 +#, csharp-format +msgid "Expression denotes a `{0}', where a `{1}' was expected" msgstr "" -#: ../mcs/mcs/driver.cs:612 -msgid "Unable to open response file: " +#: mcs/mcs/ecore.cs:806 +msgid "Pointers and fixed size buffers may only be used in an unsafe context" msgstr "" -#: ../mcs/mcs/driver.cs:662 ../mcs/mcs/driver.cs:672 -msgid "No files to compile were specified" +#: mcs/mcs/ecore.cs:841 +#, csharp-format +msgid "" +"Members of value type `{0}' cannot be assigned using a property `{1}' object " +"initializer" msgstr "" -#: ../mcs/mcs/driver.cs:802 -msgid "Warning level must be in the range 0-4" +#: mcs/mcs/ecore.cs:844 +#, csharp-format +msgid "" +"Cannot modify a value type return value of `{0}'. Consider storing the value " +"in a temporary variable" msgstr "" -#: ../mcs/mcs/driver.cs:836 -msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" +#: mcs/mcs/ecore.cs:2270 +#, csharp-format +msgid "" +"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core." +"dll assembly reference?" msgstr "" -#: ../mcs/mcs/driver.cs:845 -msgid "Compatibility: Use -unsafe instead of --unsafe" +#: mcs/mcs/ecore.cs:2344 +#, csharp-format +msgid "" +"A local variable `{0}' cannot be used before it is declared. Consider " +"renaming the local variable when it hides the member `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:856 -msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" +#: mcs/mcs/ecore.cs:2359 mcs/mcs/ecore.cs:2403 +#, csharp-format +msgid "`{0}' conflicts with a declaration in a child block" msgstr "" -#: ../mcs/mcs/driver.cs:870 -msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" +#: mcs/mcs/ecore.cs:2412 +#, csharp-format +msgid "A local variable `{0}' cannot be used before it is declared" msgstr "" -#: ../mcs/mcs/driver.cs:879 -msgid "Compatibility: Use -checked instead of --checked" +#: mcs/mcs/ecore.cs:2414 +#, csharp-format +msgid "The name `{0}' does not exist in the current context" msgstr "" -#: ../mcs/mcs/driver.cs:889 -msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" +#: mcs/mcs/ecore.cs:2664 +#, csharp-format +msgid "" +"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " +"qualifier must be of type `{2}' or derived from it" msgstr "" -#: ../mcs/mcs/driver.cs:892 -msgid "Missing argument to --linkres" +#: mcs/mcs/ecore.cs:2708 +#, csharp-format +msgid "Cannot call an abstract base member `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:903 -msgid "Compatibility: Use -res:VALUE instead of --res VALUE" +#: mcs/mcs/ecore.cs:2747 +#, csharp-format +msgid "" +"Static member `{0}' cannot be accessed with an instance reference, qualify " +"it with a type name instead" msgstr "" -#: ../mcs/mcs/driver.cs:906 -msgid "Missing argument to --resource" +#: mcs/mcs/ecore.cs:2762 +#, csharp-format +msgid "" +"A field initializer cannot reference the nonstatic field, method, or " +"property `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:916 -msgid "Compatibility: Use -target:KIND instead of --target KIND" +#: mcs/mcs/ecore.cs:2766 +#, csharp-format +msgid "An object reference is required to access non-static member `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:948 -msgid "Compatibility: Use -r:LIBRARY instead of -r library" +#: mcs/mcs/ecore.cs:2774 +#, csharp-format +msgid "" +"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:967 -msgid "Compatibility: Use -lib:ARG instead of --L arg" +#: mcs/mcs/ecore.cs:2822 +msgid "Cannot modify the result of an unboxing conversion" msgstr "" -#: ../mcs/mcs/driver.cs:976 -msgid "Compatibility: Use -nostdlib instead of --nostdlib" +#: mcs/mcs/ecore.cs:2943 +#, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/driver.cs:985 -msgid "Compatibility: Use -warnaserror: option instead of --werror" +#: mcs/mcs/ecore.cs:2948 +#, csharp-format +msgid "Extension method instance type `{0}' cannot be converted to `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:990 -msgid "Compatibility: Use -nowarn instead of --nowarn" +#: mcs/mcs/ecore.cs:3072 +msgid "An expression tree cannot contain an expression with method group" msgstr "" -#: ../mcs/mcs/driver.cs:1007 -msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" +#: mcs/mcs/ecore.cs:3078 +msgid "" +"Partial methods with only a defining declaration or removed conditional " +"methods cannot be used in an expression tree" msgstr "" -#: ../mcs/mcs/driver.cs:1011 -msgid "--wlevel requires a value from 0 to 4" +#: mcs/mcs/ecore.cs:3108 +#, csharp-format +msgid "" +"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " +"parentheses to invoke the method" msgstr "" -#: ../mcs/mcs/driver.cs:1020 -msgid "--mcs-debug requires an argument" +#: mcs/mcs/ecore.cs:3676 +#, csharp-format +msgid "" +"The type `{0}' does not contain a constructor that takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1027 -msgid "Invalid argument to --mcs-debug" +#: mcs/mcs/ecore.cs:4284 +#, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' cannot be dynamically dispatched. Consider calling the method " +"without the extension method syntax" msgstr "" -#: ../mcs/mcs/driver.cs:1037 -msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" +#: mcs/mcs/ecore.cs:4305 +#, csharp-format +msgid "" +"The call is ambiguous between the following methods or properties: `{0}' and " +"`{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1039 -msgid "--recurse requires an argument" +#: mcs/mcs/ecore.cs:4360 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " +"`out' modifier" msgstr "" -#: ../mcs/mcs/driver.cs:1051 -msgid "Compatibility: Use -debug option instead of -g or --debug" +#: mcs/mcs/ecore.cs:4364 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' has some invalid " +"arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1056 -msgid "Compatibility: Use -noconfig option instead of --noconfig" +#: mcs/mcs/ecore.cs:4367 +#, csharp-format +msgid "Delegate `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1076 -msgid "Couldn't run pkg-config: " +#: mcs/mcs/ecore.cs:4371 +#, csharp-format +msgid "The best overloaded method match for `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1084 -msgid "Specified package did not return any information" +#: mcs/mcs/ecore.cs:4381 +#, csharp-format +msgid "" +"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " +"modifier" msgstr "" -#: ../mcs/mcs/driver.cs:1091 -msgid "Error running pkg-config. Check the above output." +#: mcs/mcs/ecore.cs:4384 +#, csharp-format +msgid "Argument `#{0}' is missing `{1}' modifier" msgstr "" -#: ../mcs/mcs/driver.cs:1187 +#: mcs/mcs/ecore.cs:4397 #, csharp-format -msgid "Invalid conditional define symbol `{0}'" +msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" msgstr "" -#: ../mcs/mcs/driver.cs:1241 +#: mcs/mcs/ecore.cs:4445 #, csharp-format msgid "" -"Invalid resource visibility option `{0}'. Use either `public' or `private' " -"instead" +"The type arguments for method `{0}' cannot be inferred from the usage. Try " +"specifying the type arguments explicitly" msgstr "" -#: ../mcs/mcs/driver.cs:1247 +#: mcs/mcs/ecore.cs:4474 #, csharp-format -msgid "Wrong number of arguments for option `{0}'" +msgid "No overload for method `{0}' takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1255 -msgid "-recurse requires an argument" -msgstr "" +#: mcs/mcs/ecore.cs:4527 +#, fuzzy, csharp-format +msgid "The delegate `{0}' does not contain a parameter named `{1}'" +msgstr "El delegado `{0} no toma {1} argumentos" -#: ../mcs/mcs/driver.cs:1264 -msgid "-reference requires an argument" +#: mcs/mcs/ecore.cs:4532 +#, csharp-format +msgid "" +"The best overloaded method match for `{0}' does not contain a parameter " +"named `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1286 ../mcs/mcs/driver.cs:1298 -#: ../mcs/mcs/driver.cs:1310 ../mcs/mcs/driver.cs:1322 -#: ../mcs/mcs/driver.cs:1431 ../mcs/mcs/driver.cs:1451 -#: ../mcs/mcs/driver.cs:1458 -msgid " requires an argument" +#: mcs/mcs/ecore.cs:4542 +#, csharp-format +msgid "" +"Named argument `{0}' cannot be used for a parameter which has positional " +"argument specified" msgstr "" -#: ../mcs/mcs/driver.cs:1303 ../mcs/mcs/driver.cs:1315 +#: mcs/mcs/ecore.cs:4855 msgid "" -"Cannot specify the `win32res' and the `win32ico' compiler option at the same " -"time" +"You cannot use fixed size buffers contained in unfixed expressions. Try " +"using the fixed statement" msgstr "" -#: ../mcs/mcs/driver.cs:1332 -msgid "/lib requires an argument" +#: mcs/mcs/ecore.cs:4860 +#, csharp-format +msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" msgstr "" -#: ../mcs/mcs/driver.cs:1394 -msgid "/nowarn requires an argument" +#: mcs/mcs/ecore.cs:5255 +#, csharp-format +msgid "Property or event `{0}' is not supported by the C# language" msgstr "" -#: ../mcs/mcs/driver.cs:1488 +#: mcs/mcs/ecore.cs:5416 #, csharp-format -msgid "" -"Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or " -"`Default'" +msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" msgstr "" -#: ../mcs/mcs/driver.cs:1504 +#: mcs/mcs/ecore.cs:5464 #, csharp-format -msgid "Code page `{0}' is invalid or not installed" +msgid "" +"The property or indexer `{0}' cannot be used in this context because it " +"lacks the `get' accessor" msgstr "" -#: ../mcs/mcs/driver.cs:1516 +#: mcs/mcs/ecore.cs:5471 #, csharp-format -msgid "Unrecognized command-line option: `{0}'" +msgid "" +"The property or indexer `{0}' cannot be used in this context because the get " +"accessor is inaccessible" msgstr "" -#: ../mcs/mcs/driver.cs:1546 -msgid "Invalid reference alias '" +#: mcs/mcs/ecore.cs:5490 +#, csharp-format +msgid "Property or indexer `{0}' cannot be assigned to (it is read-only)" msgstr "" -#: ../mcs/mcs/driver.cs:1551 -msgid "Invalid extern alias for /reference. Alias '" +#: mcs/mcs/ecore.cs:5498 +#, csharp-format +msgid "" +"The property or indexer `{0}' cannot be used in this context because the set " +"accessor is inaccessible" msgstr "" -#: ../mcs/mcs/driver.cs:1617 +#: mcs/mcs/ecore.cs:5659 +#, csharp-format msgid "" -"If no source files are specified you must specify the output file with -out:" +"The event `{0}' can only appear on the left hand side of `+=' or `-=' " +"operator" msgstr "" -#: ../mcs/mcs/driver.cs:1739 +#: mcs/mcs/ecore.cs:5663 #, csharp-format -msgid "Could not find `{0}' specified for Main method" +msgid "" +"The event `{0}' can only appear on the left hand side of += or -= when used " +"outside of the type `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1744 +#: mcs/mcs/ecore.cs:5827 #, csharp-format -msgid "`{0}' specified for Main method must be a valid class or struct" +msgid "" +"An implicitly typed local variable declaration cannot be initialized with `" +"{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1748 -#, csharp-format -msgid "`{0}' does not have a suitable static Main method" +#: mcs/mcs/ecore.cs:5841 +msgid "" +"The contextual keyword `var' may only appear within a local variable " +"declaration" msgstr "" -#: ../mcs/mcs/driver.cs:1753 +#: mcs/mcs/enum.cs:125 #, csharp-format msgid "" -"Program `{0}' does not contain a static `Main' method suitable for an entry " -"point" +"The enumerator value `{0}' is outside the range of enumerator underlying " +"type `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1760 -msgid "Cannot specify -main if building a module or library" +#: mcs/mcs/enum.cs:189 +#, csharp-format +msgid "An item in an enumeration cannot have an identifier `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1765 -msgid "Cannot link resource file when building a module" +#: mcs/mcs/enum.cs:200 +msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" msgstr "" -#: ../mcs/mcs/driver.cs:1915 -#, csharp-format -msgid "The resource identifier `{0}' has already been used in this assembly" +#: mcs/mcs/eval.cs:625 +msgid "Detection Parsing Error" msgstr "" -#: ../mcs/mcs/driver.cs:1929 +#: mcs/mcs/expression.cs:542 #, csharp-format -msgid "Error reading resource file `{0}'" +msgid "The `{0}' operator cannot be applied to operand of type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:321 -#, csharp-format -msgid "`{0}' is inaccessible due to its protection level" +#: mcs/mcs/expression.cs:622 +msgid "Cannot take the address of the given expression" msgstr "" -#: ../mcs/mcs/ecore.cs:326 -#, csharp-format +#: mcs/mcs/expression.cs:656 msgid "" -"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " -"qualifier must be of type `{2}' or derived from it" +"You can only take the address of unfixed expression inside of a fixed " +"statement initializer" +msgstr "" + +#: mcs/mcs/expression.cs:745 +#, csharp-format +msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" +msgstr "" + +#: mcs/mcs/expression.cs:868 +msgid "The * or -> operator must be applied to a pointer" msgstr "" -#: ../mcs/mcs/ecore.cs:336 +#: mcs/mcs/expression.cs:1070 msgid "" -"Only assignment, call, increment, decrement, and new object expressions can " -"be used as a statement" +"The operand of an increment or decrement operator must be a variable, " +"property or indexer" msgstr "" -#: ../mcs/mcs/ecore.cs:347 +#: mcs/mcs/expression.cs:1260 #, csharp-format -msgid "Cannot assign to `{0}' because it is a `{1}'" +msgid "The `{0}' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/ecore.cs:353 -msgid "Keyword `void' cannot be used in this context" +#: mcs/mcs/expression.cs:1265 +#, csharp-format +msgid "The `{0}' operator cannot be applied to an operand of pointer type" msgstr "" -#: ../mcs/mcs/ecore.cs:383 ../mcs/mcs/statement.cs:1098 +#: mcs/mcs/expression.cs:1271 #, csharp-format -msgid "Cannot convert type `{0}' to `{1}'" +msgid "" +"The `{0}' operator cannot be applied to a lambda expression or anonymous " +"method" msgstr "" -#: ../mcs/mcs/ecore.cs:393 +#: mcs/mcs/expression.cs:1507 #, csharp-format msgid "" -"Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " -"(are you missing a cast?)" +"The `as' operator cannot be used with a non-reference type parameter `{0}'. " +"Consider adding `class' or a reference type constraint" msgstr "" -#: ../mcs/mcs/ecore.cs:399 +#: mcs/mcs/expression.cs:1511 #, csharp-format -msgid "Cannot implicitly convert type `{0}' to `{1}'" +msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:406 +#: mcs/mcs/expression.cs:1548 #, csharp-format -msgid "A local variable `{0}' cannot be used before it is declared" +msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" msgstr "" -#: ../mcs/mcs/ecore.cs:417 +#: mcs/mcs/expression.cs:1589 #, csharp-format -msgid "`{0}' does not contain a definition for `{1}'" +msgid "Cannot convert to static type `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:423 +#: mcs/mcs/expression.cs:1679 msgid "" -"The left-hand side of an assignment must be a variable, a property or an " -"indexer" +"The `default value' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/ecore.cs:560 -msgid "A ref or out argument must be an assignable variable" +#: mcs/mcs/expression.cs:2184 +#, csharp-format +msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:714 ../mcs/mcs/ecore.cs:730 +#: mcs/mcs/expression.cs:2747 +msgid "To cast a negative value, you must enclose the value in parentheses" +msgstr "" + +#: mcs/mcs/expression.cs:3400 #, csharp-format -msgid "Ambiguity between `{0}' and `{1}'" +msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:831 ../mcs/mcs/ecore.cs:2777 +#: mcs/mcs/expression.cs:4152 #, csharp-format msgid "" -"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +"A user-defined operator `{0}' must have parameters and return values of the " +"same type in order to be applicable as a short circuit operator" msgstr "" -#: ../mcs/mcs/ecore.cs:872 +#: mcs/mcs/expression.cs:4162 #, csharp-format -msgid "The name `{0}' does not exist in the current context" +msgid "" +"The type `{0}' must have operator `true' and operator `false' defined when `" +"{1}' is used as a short circuit operator" msgstr "" -#: ../mcs/mcs/ecore.cs:887 ../mcs/mcs/generic.cs:1398 +#: mcs/mcs/expression.cs:4472 #, csharp-format -msgid "Using the generic type `{0}' requires {1} type arguments" +msgid "" +"Type of conditional expression cannot be determined as `{0}' and `{1}' " +"convert implicitly to each other" msgstr "" -#: ../mcs/mcs/ecore.cs:916 -msgid "An expression tree cannot contain an unsafe pointer operation" +#: mcs/mcs/expression.cs:4482 +#, csharp-format +msgid "" +"Type of conditional expression cannot be determined because there is no " +"implicit conversion between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:1030 +#: mcs/mcs/expression.cs:4934 #, csharp-format -msgid "`{0}' is a `{1}' but a `{2}' was expected" +msgid "Use of unassigned out parameter `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:1064 +#: mcs/mcs/expression.cs:4964 #, csharp-format -msgid "Expression denotes a `{0}', where a `{1}' was expected" +msgid "" +"Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " +"modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:1069 -msgid "Pointers and fixed size buffers may only be used in an unsafe context" -msgstr "" +#: mcs/mcs/expression.cs:5165 +#, fuzzy, csharp-format +msgid "Cannot invoke a non-delegate type `{0}'" +msgstr "No es posible convertir `{0}' a un un tipo que no es un delegado `{1}'" -#: ../mcs/mcs/ecore.cs:1175 +#: mcs/mcs/expression.cs:5176 #, csharp-format -msgid "Cannot call an abstract base member `{0}'" +msgid "The member `{0}' cannot be used as method or delegate" msgstr "" -#: ../mcs/mcs/ecore.cs:1182 -#, csharp-format +#: mcs/mcs/expression.cs:5196 msgid "" -"Members of value type `{0}' cannot be assigned using a property `{1}' object " -"initializer" +"Do not directly call your base class Finalize method. It is called " +"automatically from your destructor" msgstr "" -#: ../mcs/mcs/ecore.cs:1185 -#, csharp-format +#: mcs/mcs/expression.cs:5198 msgid "" -"Cannot modify a value type return value of `{0}'. Consider storing the value " -"in a temporary variable" -msgstr "" - -#: ../mcs/mcs/ecore.cs:1833 -msgid "Cannot modify the result of an unboxing conversion" +"Destructors and object.Finalize cannot be called directly. Consider calling " +"IDisposable.Dispose if available" msgstr "" -#: ../mcs/mcs/ecore.cs:2401 +#: mcs/mcs/expression.cs:5227 #, csharp-format -msgid "" -"A field initializer cannot reference the nonstatic field, method, or " -"property `{0}'" +msgid "" +"The base call to method `{0}' cannot be dynamically dispatched. Consider " +"casting the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/ecore.cs:2405 +#: mcs/mcs/expression.cs:5304 #, csharp-format -msgid "An object reference is required to access non-static member `{0}'" +msgid "`{0}': cannot explicitly call operator or accessor" msgstr "" -#: ../mcs/mcs/ecore.cs:2612 ../mcs/mcs/ecore.cs:2632 +#: mcs/mcs/expression.cs:5631 #, csharp-format -msgid "The variable `{0}' cannot be used with type arguments" +msgid "Unsafe type `{0}' cannot be used in an object creation expression" msgstr "" -#: ../mcs/mcs/ecore.cs:3160 +#: mcs/mcs/expression.cs:5654 #, csharp-format msgid "" -"Static member `{0}' cannot be accessed with an instance reference, qualify " -"it with a type name instead" +"Cannot create an instance of the variable type `{0}' because it does not " +"have the new() constraint" msgstr "" -#: ../mcs/mcs/ecore.cs:3166 -msgid "An expression tree may not contain a base access" +#: mcs/mcs/expression.cs:5660 +#, csharp-format +msgid "" +"`{0}': cannot provide arguments when creating an instance of a variable type" msgstr "" -#: ../mcs/mcs/ecore.cs:3256 +#: mcs/mcs/expression.cs:5669 #, csharp-format -msgid "The property `{0}' cannot be used with type arguments" +msgid "Cannot create an instance of the static class `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3710 -msgid "An expression tree cannot contain an expression with method group" +#: mcs/mcs/expression.cs:5681 +#, csharp-format +msgid "Cannot create an instance of the abstract class or interface `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3720 +#: mcs/mcs/expression.cs:5977 msgid "" -"Partial methods with only a defining declaration or removed conditional " -"methods cannot be used in an expression tree" +"An implicitly typed local variable declarator cannot use an array initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:3738 -msgid "Method `" +#: mcs/mcs/expression.cs:6070 +msgid "Cannot create an array with a negative size" msgstr "" -#: ../mcs/mcs/ecore.cs:3765 -#, csharp-format -msgid "" -"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " -"`out' modifier" +#: mcs/mcs/expression.cs:6102 mcs/mcs/expression.cs:6110 +#: mcs/mcs/statement.cs:1009 mcs/mcs/statement.cs:3055 +msgid "A constant value is expected" msgstr "" -#: ../mcs/mcs/ecore.cs:3769 +#: mcs/mcs/expression.cs:6116 #, csharp-format -msgid "" -"The best overloaded collection initalizer method `{0}' has some invalid " -"arguments" +msgid "An array initializer of length `{0}' was expected" msgstr "" -#: ../mcs/mcs/ecore.cs:3775 -#, csharp-format +#: mcs/mcs/expression.cs:6132 msgid "" -"Type `{0}' does not contain a member `{1}' and the best extension method " -"overload `{2}' has some invalid arguments" +"Array initializers can only be used in a variable or field initializer. Try " +"using a new expression instead" msgstr "" -#: ../mcs/mcs/ecore.cs:3779 -#, csharp-format -msgid "The best overloaded method match for `{0}' has some invalid arguments" +#: mcs/mcs/expression.cs:6140 +msgid "A nested array initializer was expected" msgstr "" -#: ../mcs/mcs/ecore.cs:3783 -#, csharp-format -msgid "Delegate `{0}' has some invalid arguments" +#: mcs/mcs/expression.cs:6177 +msgid "An expression tree cannot contain a multidimensional array initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:3792 -#, csharp-format +#: mcs/mcs/expression.cs:6279 msgid "" -"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " -"modifier" +"Can only use array initializer expressions to assign to array types. Try " +"using a new expression instead" msgstr "" -#: ../mcs/mcs/ecore.cs:3795 -#, csharp-format -msgid "Argument `#{0}' is missing `{1}' modifier" +#: mcs/mcs/expression.cs:6718 +msgid "" +"The type of an implicitly typed array cannot be inferred from the " +"initializer. Try specifying array type explicitly" msgstr "" -#: ../mcs/mcs/ecore.cs:3809 -#, csharp-format -msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +#: mcs/mcs/expression.cs:6855 +msgid "" +"The `this' object cannot be used before all of its fields are assigned to" msgstr "" -#: ../mcs/mcs/ecore.cs:3812 -#, csharp-format -msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" +#: mcs/mcs/expression.cs:6862 +msgid "" +"Keyword `this' is not valid in a static property, static method, or static " +"field initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:3819 -#, csharp-format +#: mcs/mcs/expression.cs:6865 msgid "" -"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " -"parentheses to invoke the method" +"Anonymous methods inside structs cannot access instance members of `this'. " +"Consider copying `this' to a local variable outside the anonymous method and " +"using the local instead" msgstr "" -#: ../mcs/mcs/ecore.cs:4105 -msgid "Invoke cannot be called directly on a delegate" +#: mcs/mcs/expression.cs:6868 +msgid "Keyword `this' is not available in the current context" msgstr "" -#: ../mcs/mcs/ecore.cs:4237 -#, csharp-format -msgid "" -"The type arguments for method `{0}' cannot be inferred from the usage. Try " -"specifying the type arguments explicitly" +#: mcs/mcs/expression.cs:6955 +msgid "Cannot take the address of `this' because it is read-only" msgstr "" -#: ../mcs/mcs/ecore.cs:4246 -#, csharp-format -msgid "Using the generic method `{0}' requires `{1}' type argument(s)" +#: mcs/mcs/expression.cs:6957 +msgid "Cannot pass `this' as a ref or out argument because it is read-only" msgstr "" -#: ../mcs/mcs/ecore.cs:4275 -#, csharp-format -msgid "" -"The type `{0}' does not contain a constructor that takes `{1}' arguments" +#: mcs/mcs/expression.cs:6959 +msgid "Cannot assign to `this' because it is read-only" msgstr "" -#: ../mcs/mcs/ecore.cs:4278 -#, csharp-format -msgid "No overload for method `{0}' takes `{1}' arguments" +#: mcs/mcs/expression.cs:7012 +msgid "The __arglist construct is valid only within a variable argument method" msgstr "" -#: ../mcs/mcs/ecore.cs:4383 -#, csharp-format -msgid "" -"The call is ambiguous between the following methods or properties: `{0}' and " -"`{1}'" +#: mcs/mcs/expression.cs:7062 +msgid "An expression tree cannot contain a method with variable arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:4810 +#: mcs/mcs/expression.cs:7146 msgid "" -"You cannot use fixed size buffers contained in unfixed expressions. Try " -"using the fixed statement" +"System.Void cannot be used from C#. Use typeof (void) to get the void type " +"object" msgstr "" -#: ../mcs/mcs/ecore.cs:4815 -#, csharp-format -msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" +#: mcs/mcs/expression.cs:7149 +msgid "The typeof operator cannot be used on the dynamic type" msgstr "" -#: ../mcs/mcs/ecore.cs:5083 +#: mcs/mcs/expression.cs:7218 #, csharp-format -msgid "" -"A local variable `{0}' cannot be used before it is declared. Consider " -"renaming the local variable when it hides the field `{1}'" +msgid "`{0}': an attribute argument cannot use type parameters" msgstr "" -#: ../mcs/mcs/ecore.cs:5368 +#: mcs/mcs/expression.cs:7472 #, csharp-format msgid "" -"Property `{0}' is not supported by the C# language. Try to call the accessor " -"method `{1}' directly" +"`{0}' does not have a predefined size, therefore sizeof can only be used in " +"an unsafe context (consider using System.Runtime.InteropServices.Marshal." +"SizeOf)" msgstr "" -#: ../mcs/mcs/ecore.cs:5414 +#: mcs/mcs/expression.cs:7528 #, csharp-format -msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks the `get' accessor" +msgid "Alias `{0}' not found" msgstr "" -#: ../mcs/mcs/ecore.cs:5426 +#: mcs/mcs/expression.cs:7539 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because the get " -"accessor is inaccessible" +"Alias `{0}' cannot be used with '::' since it denotes a type. Consider " +"replacing '::' with '.'" msgstr "" -#: ../mcs/mcs/ecore.cs:5470 +#: mcs/mcs/expression.cs:7555 #, csharp-format -msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" +msgid "" +"A namespace alias qualifier `{0}' did not resolve to a namespace or a type" msgstr "" -#: ../mcs/mcs/ecore.cs:5473 -#, csharp-format -msgid "" -"A property or indexer `{0}' may not be passed as `ref' or `out' parameter" +#: mcs/mcs/expression.cs:7712 +msgid "Cannot perform member binding on `null' value" msgstr "" -#: ../mcs/mcs/ecore.cs:5494 +#: mcs/mcs/expression.cs:7779 #, csharp-format -msgid "" -"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " -"store the value" +msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" msgstr "" -#: ../mcs/mcs/ecore.cs:5497 +#: mcs/mcs/expression.cs:7855 #, csharp-format -msgid "Property or indexer `{0}' cannot be assigned to (it is read only)" +msgid "A nested type cannot be specified through a type parameter `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5513 +#: mcs/mcs/expression.cs:7914 #, csharp-format -msgid "" -"The property or indexer `{0}' cannot be used in this context because the set " -"accessor is inaccessible" +msgid "The nested type `{0}' does not exist in the type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5671 +#: mcs/mcs/expression.cs:7923 #, csharp-format msgid "" -"The event `{0}' can only appear on the left hand side of `+=' or `-=' " -"operator" +"Type `{0}' does not contain a definition for `{1}' and no extension method `" +"{1}' of type `{0}' could be found (are you missing a using directive or an " +"assembly reference?)" msgstr "" -#: ../mcs/mcs/ecore.cs:5805 +#: mcs/mcs/expression.cs:8103 #, csharp-format -msgid "" -"The event `{0}' can only appear on the left hand side of += or -= when used " -"outside of the type `{1}'" +msgid "Cannot apply indexing with [] to an expression of type `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5932 -#, csharp-format -msgid "" -"An implicitly typed local variable declaration cannot be initialized with `" -"{0}'" +#: mcs/mcs/expression.cs:8119 +msgid "A pointer must be indexed by only one value" msgstr "" -#: ../mcs/mcs/ecore.cs:5943 -msgid "" -"The contextual keyword `var' may only appear within a local variable " -"declaration" +#: mcs/mcs/expression.cs:8168 +msgid "An element access expression cannot use named argument" msgstr "" -#: ../mcs/mcs/ecore.cs:5957 -msgid "" -"An implicitly typed local variable declaration cannot include multiple " -"declarators" +#: mcs/mcs/expression.cs:8224 +#, csharp-format +msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5964 +#: mcs/mcs/expression.cs:8560 msgid "" -"An implicitly typed local variable declarator must include an initializer" +"The indexer base access cannot be dynamically dispatched. Consider casting " +"the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/enum.cs:112 -#, csharp-format -msgid "The enumerator value `{0}' is too large to fit in its type `{1}'" +#: mcs/mcs/expression.cs:8641 +msgid "An expression tree may not contain a base access" msgstr "" -#: ../mcs/mcs/enum.cs:148 -#, csharp-format -msgid "An item in an enumeration cannot have an identifier `{0}'" +#: mcs/mcs/expression.cs:8658 +#, fuzzy +msgid "Keyword `base' is not available in a static method" msgstr "" +"La palabra reservada `new' no está permitida en los elementos de un espacio " +"de nombres" -#: ../mcs/mcs/enum.cs:158 -msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" +#: mcs/mcs/expression.cs:8660 +#, fuzzy +msgid "Keyword `base' is not available in the current context" msgstr "" +"La palabra reservada `new' no está permitida en los elementos de un espacio " +"de nombres" -#: ../mcs/mcs/eval.cs:496 -msgid "Detection Parsing Error" +#: mcs/mcs/expression.cs:8691 +msgid "" +"A property, indexer or dynamic member access may not be passed as `ref' or " +"`out' parameter" msgstr "" -#: ../mcs/mcs/expression.cs:553 +#: mcs/mcs/expression.cs:8968 #, csharp-format -msgid "The `{0}' operator cannot be applied to operand of type `{1}'" +msgid "Array elements cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:720 +#: mcs/mcs/expression.cs:8971 #, csharp-format -msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" -msgstr "" - -#: ../mcs/mcs/expression.cs:979 -msgid "" -"The operand of an increment or decrement operator must be a variable, " -"property or indexer" +msgid "Array elements cannot be of static type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1146 -#, csharp-format -msgid "The `{0}' operator cannot be applied to an operand of a static type" +#: mcs/mcs/expression.cs:9121 +msgid "Cannot use a negative size with stackalloc" msgstr "" -#: ../mcs/mcs/expression.cs:1151 -#, csharp-format -msgid "The `{0}' operator cannot be applied to an operand of pointer type" +#: mcs/mcs/expression.cs:9125 +msgid "Cannot use stackalloc in finally or catch" msgstr "" -#: ../mcs/mcs/expression.cs:1157 +#: mcs/mcs/expression.cs:9230 #, csharp-format msgid "" -"The `{0}' operator cannot be applied to a lambda expression or anonymous " -"method" +"Member `{0}' cannot be initialized. An object initializer may only be used " +"for fields, or properties" msgstr "" -#: ../mcs/mcs/expression.cs:1395 +#: mcs/mcs/expression.cs:9239 #, csharp-format msgid "" -"The `as' operator cannot be used with a non-reference type parameter `{0}'" +"Static field or property `{0}' cannot be assigned in an object initializer" msgstr "" -#: ../mcs/mcs/expression.cs:1399 +#: mcs/mcs/expression.cs:9414 #, csharp-format -msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" +msgid "" +"A field or property `{0}' cannot be initialized with a collection object " +"initializer because type `{1}' does not implement `{2}' interface" msgstr "" -#: ../mcs/mcs/expression.cs:1431 +#: mcs/mcs/expression.cs:9425 #, csharp-format -msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" +msgid "Inconsistent `{0}' member declaration" msgstr "" -#: ../mcs/mcs/expression.cs:1495 +#: mcs/mcs/expression.cs:9433 #, csharp-format -msgid "Cannot convert to static type `{0}'" -msgstr "" - -#: ../mcs/mcs/expression.cs:1560 msgid "" -"The `default value' operator cannot be applied to an operand of a static type" +"An object initializer includes more than one member `{0}' initialization" msgstr "" -#: ../mcs/mcs/expression.cs:1978 +#: mcs/mcs/expression.cs:9451 #, csharp-format -msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" -msgstr "" - -#: ../mcs/mcs/expression.cs:2487 -msgid "To cast a negative value, you must enclose the value in parentheses" +msgid "Cannot initialize object of type `{0}' with a collection initializer" msgstr "" -#: ../mcs/mcs/expression.cs:2985 -#, csharp-format -msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" +#: mcs/mcs/expression.cs:9688 +#, fuzzy +msgid "Anonymous types cannot be used in this expression" msgstr "" +"Los métodos anónimos no pueden ser convertidos a árboles de expresiones" -#: ../mcs/mcs/expression.cs:3677 +#: mcs/mcs/expression.cs:9776 #, csharp-format -msgid "" -"A user-defined operator `{0}' must have parameters and return values of the " -"same type in order to be applicable as a short circuit operator" +msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:3687 -#, csharp-format +#: mcs/mcs/field.cs:70 msgid "" -"The type `{0}' must have operator `true' and operator `false' defined when `" -"{1}' is used as a short circuit operator" +"The modifier 'abstract' is not valid on fields. Try using a property instead" msgstr "" -#: ../mcs/mcs/expression.cs:3934 -#, csharp-format +#: mcs/mcs/field.cs:121 msgid "" -"Type of conditional expression cannot be determined because there is no " -"implicit conversion between `{0}' and `{1}'" +"The FieldOffset attribute can only be placed on members of types marked with " +"the StructLayout(LayoutKind.Explicit)" msgstr "" -#: ../mcs/mcs/expression.cs:4395 -#, csharp-format -msgid "Use of unassigned out parameter `{0}'" +#: mcs/mcs/field.cs:126 +msgid "The FieldOffset attribute is not allowed on static or const fields" msgstr "" -#: ../mcs/mcs/expression.cs:4423 -#, csharp-format +#: mcs/mcs/field.cs:132 msgid "" -"Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " -"modifier" +"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " +"'fixed' field modifier instead" msgstr "" -#: ../mcs/mcs/expression.cs:4749 +#: mcs/mcs/field.cs:237 #, csharp-format -msgid "The member `{0}' cannot be used as method or delegate" -msgstr "" - -#: ../mcs/mcs/expression.cs:4811 msgid "" -"Do not directly call your base class Finalize method. It is called " -"automatically from your destructor" +"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " +"must have a FieldOffset attribute" msgstr "" -#: ../mcs/mcs/expression.cs:4813 -msgid "" -"Destructors and object.Finalize cannot be called directly. Consider calling " -"IDisposable.Dispose if available" -msgstr "" +#: mcs/mcs/field.cs:246 +#, fuzzy, csharp-format +msgid "`{0}': cannot declare variables of static types" +msgstr "`{0}': no es posible declarar indexadores en una clase estática" -#: ../mcs/mcs/expression.cs:4837 +#: mcs/mcs/field.cs:388 #, csharp-format -msgid "`{0}': cannot explicitly call operator or accessor" +msgid "" +"`{0}': Fixed size buffers type must be one of the following: bool, byte, " +"short, int, long, char, sbyte, ushort, uint, ulong, float or double" msgstr "" -#: ../mcs/mcs/expression.cs:5390 +#: mcs/mcs/field.cs:424 #, csharp-format -msgid "Unsafe type `{0}' cannot be used in an object creation expression" +msgid "`{0}': Fixed size buffer fields may only be members of structs" msgstr "" -#: ../mcs/mcs/expression.cs:5442 +#: mcs/mcs/field.cs:439 #, csharp-format -msgid "Cannot create an instance of the static class `{0}'" +msgid "`{0}': Fixed size buffers must have a length greater than zero" msgstr "" -#: ../mcs/mcs/expression.cs:5454 +#: mcs/mcs/field.cs:446 #, csharp-format -msgid "Cannot create an instance of the abstract class or interface `{0}'" +msgid "" +"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" msgstr "" -#: ../mcs/mcs/expression.cs:5767 -msgid "Cannot create an array with a negative size" -msgstr "" +#: mcs/mcs/field.cs:628 +#, fuzzy, csharp-format +msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgstr "`{0}': no es posible derivad de una clase sellada (`{1}')" -#: ../mcs/mcs/expression.cs:5784 ../mcs/mcs/statement.cs:2991 -msgid "A constant value is expected" -msgstr "" +#: mcs/mcs/field.cs:633 +#, fuzzy, csharp-format +msgid "`{0}': A field cannot be both volatile and readonly" +msgstr "`{0}': una clase no puede estar sellada y ser estática al mismo tiempo" -#: ../mcs/mcs/expression.cs:5871 -msgid "An expression tree cannot contain a multidimensional array initializer" +#: mcs/mcs/flowanalysis.cs:307 +msgid "Control cannot fall through from one case label to another" msgstr "" -#: ../mcs/mcs/expression.cs:5965 +#: mcs/mcs/flowanalysis.cs:536 +#, csharp-format msgid "" -"Can only use array initializer expressions to assign to array types. Try " -"using a new expression instead" +"The label `{0}:' could not be found within the scope of the goto statement" msgstr "" -#: ../mcs/mcs/expression.cs:5970 +#: mcs/mcs/flowanalysis.cs:664 msgid "" -"An implicitly typed local variable declarator cannot use an array initializer" -msgstr "" - -#: ../mcs/mcs/expression.cs:6045 -msgid "New invocation: Can not find a constructor for this argument list" +"A throw statement with no arguments is not allowed outside of a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6488 -msgid "" -"The type of an implicitly typed array cannot be inferred from the " -"initializer. Try specifying array type explicitly" +#: mcs/mcs/flowanalysis.cs:675 mcs/mcs/flowanalysis.cs:681 +msgid "No enclosing loop out of which to break or continue" msgstr "" -#: ../mcs/mcs/expression.cs:6666 -msgid "" -"Anonymous methods inside structs cannot access instance members of `this'. " -"Consider copying `this' to a local variable outside the anonymous method and " -"using the local instead" +#: mcs/mcs/flowanalysis.cs:709 +msgid "Control cannot leave the body of an anonymous method" msgstr "" -#: ../mcs/mcs/expression.cs:6740 -msgid "Cannot take the address of `this' because it is read-only" +#: mcs/mcs/flowanalysis.cs:750 +msgid "Cannot yield a value in the body of a try block with a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6742 -msgid "Cannot pass `this' as a ref or out argument because it is read-only" +#: mcs/mcs/flowanalysis.cs:752 +msgid "Cannot yield a value in the body of a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6744 -msgid "Cannot assign to `this' because it is read-only" +#: mcs/mcs/flowanalysis.cs:904 +msgid "" +"A throw statement with no arguments is not allowed inside of a finally " +"clause nested inside of the innermost catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6856 -msgid "An expression tree cannot contain a method with variable arguments" +#: mcs/mcs/flowanalysis.cs:916 mcs/mcs/iterators.cs:102 +msgid "Cannot yield in the body of a finally clause" msgstr "" -#: ../mcs/mcs/expression.cs:6966 -#, csharp-format -msgid "`{0}': an attribute argument cannot use type parameters" +#: mcs/mcs/flowanalysis.cs:927 mcs/mcs/flowanalysis.cs:943 +#: mcs/mcs/flowanalysis.cs:979 mcs/mcs/statement.cs:694 +msgid "Control cannot leave the body of a finally clause" msgstr "" -#: ../mcs/mcs/expression.cs:7199 +#: mcs/mcs/flowanalysis.cs:1130 #, csharp-format msgid "" -"`{0}' does not have a predefined size, therefore sizeof can only be used in " -"an unsafe context (consider using System.Runtime.InteropServices.Marshal." -"SizeOf)" -msgstr "" - -#: ../mcs/mcs/expression.cs:7254 -#, csharp-format -msgid "Alias `{0}' not found" +"An automatically implemented property `{0}' must be fully assigned before " +"control leaves the constructor. Consider calling the default struct " +"contructor from a constructor initializer" msgstr "" -#: ../mcs/mcs/expression.cs:7265 +#: mcs/mcs/flowanalysis.cs:1134 #, csharp-format msgid "" -"Alias `{0}' cannot be used with '::' since it denotes a type. Consider " -"replacing '::' with '.'" +"Field `{0}' must be fully assigned before control leaves the constructor" msgstr "" -#: ../mcs/mcs/expression.cs:7281 -#, csharp-format -msgid "" -"A namespace alias qualifier `{0}' did not resolve to a namespace or a type" +#: mcs/mcs/flowanalysis.cs:1376 +msgid "Use of unassigned local variable `" msgstr "" -#: ../mcs/mcs/expression.cs:7422 -#, csharp-format -msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" +#: mcs/mcs/flowanalysis.cs:1446 +msgid "Use of possibly unassigned field `" msgstr "" -#: ../mcs/mcs/expression.cs:7519 +#: mcs/mcs/generic.cs:102 mcs/mcs/generic.cs:120 #, csharp-format -msgid "A nested type cannot be specified through a type parameter `{0}'" +msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:7587 +#: mcs/mcs/generic.cs:173 #, csharp-format -msgid "The nested type `{0}' does not exist in the type `{1}'" +msgid "A constraint cannot be the dynamic type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:7599 +#: mcs/mcs/generic.cs:182 #, csharp-format msgid "" -"Type `{0}' does not contain a definition for `{1}' and no extension method `" -"{1}' of type `{0}' could be found (are you missing a using directive or an " -"assembly reference?)" +"Inconsistent accessibility: constraint type `{0}' is less accessible than `" +"{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:7817 -msgid "Cannot apply indexing with [] to an expression of type `System.Array'" +#: mcs/mcs/generic.cs:189 mcs/mcs/generic.cs:203 +#, fuzzy, csharp-format +msgid "Duplicate constraint `{0}' for type parameter `{1}'" msgstr "" +"Las declaraciones parciales de `{0}' tienen limitaciones inconsistentes para " +"el tipo parametrizado `{1}'" -#: ../mcs/mcs/expression.cs:7923 +#: mcs/mcs/generic.cs:218 #, csharp-format -msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" +msgid "Circular constraint dependency involving `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8410 +#: mcs/mcs/generic.cs:249 #, csharp-format msgid "" -"A property or indexer `{0}' may not be passed as an out or ref parameter" +"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " +"constraint for `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8435 +#: mcs/mcs/generic.cs:260 #, csharp-format -msgid "Cannot apply indexing with [] to an expression of type `{0}'" +msgid "" +"The class type constraint `{0}' must be listed before any other constraints. " +"Consider moving type constraint to the beginning of the constraint list" msgstr "" -#: ../mcs/mcs/expression.cs:8465 +#: mcs/mcs/generic.cs:266 #, csharp-format -msgid "The read only property or indexer `{0}' cannot be assigned to" +msgid "" +"`{0}': cannot specify both a constraint class and the `class' or `struct' " +"constraint" msgstr "" -#: ../mcs/mcs/expression.cs:8473 +#: mcs/mcs/generic.cs:271 +msgid "A constraint cannot be the dynamic type" +msgstr "" + +#: mcs/mcs/generic.cs:277 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks a `{1}' accessor" +"`{0}' is not a valid constraint. A constraint must be an interface, a non-" +"sealed class or a type parameter" msgstr "" -#: ../mcs/mcs/expression.cs:8495 +#: mcs/mcs/generic.cs:284 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because a `{1}' " -"accessor is inaccessible" +"`{0}' is not a valid constraint. Static classes cannot be used as constraints" msgstr "" -#: ../mcs/mcs/expression.cs:8958 +#: mcs/mcs/generic.cs:290 #, csharp-format -msgid "Array elements cannot be of type `{0}'" +msgid "A constraint cannot be special class `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:8964 +#: mcs/mcs/generic.cs:538 #, csharp-format -msgid "Array elements cannot be of static type `{0}'" +msgid "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'" msgstr "" -#: ../mcs/mcs/expression.cs:9130 -msgid "Cannot use a negative size with stackalloc" +#: mcs/mcs/generic.cs:1720 +#, csharp-format +msgid "`{0}': static classes cannot be used as generic arguments" msgstr "" -#: ../mcs/mcs/expression.cs:9257 +#: mcs/mcs/generic.cs:1727 #, csharp-format -msgid "" -"Member `{0}' cannot be initialized. An object initializer may only be used " -"for fields, or properties" +msgid "The type `{0}' may not be used as a type argument" msgstr "" -#: ../mcs/mcs/expression.cs:9260 +#: mcs/mcs/generic.cs:1982 #, csharp-format msgid "" -" Static field or property `{0}' cannot be assigned in an object initializer" +"The type `{0}' must be a reference type in order to use it as type parameter " +"`{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9433 +#: mcs/mcs/generic.cs:1992 #, csharp-format msgid "" -"A field or property `{0}' cannot be initialized with a collection object " -"initializer because type `{1}' does not implement `{2}' interface" +"The type `{0}' must be a non-nullable value type in order to use it as type " +"parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9444 +#: mcs/mcs/generic.cs:2022 #, csharp-format -msgid "Inconsistent `{0}' member declaration" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. The nullable type `{0}' never satisfies interface constraint" msgstr "" -#: ../mcs/mcs/expression.cs:9452 +#: mcs/mcs/generic.cs:2061 #, csharp-format msgid "" -"An object initializer includes more than one member `{0}' initialization" +"The type `{0}' must have a public parameterless constructor in order to use " +"it as parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9469 +#: mcs/mcs/generic.cs:2113 #, csharp-format -msgid "Cannot initialize object of type `{0}' with a collection initializer" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing conversion from `{0}' to `{3}'" msgstr "" -#: ../mcs/mcs/expression.cs:9717 -#, fuzzy -msgid "Anonymous types cannot be used in this expression" +#: mcs/mcs/generic.cs:2117 +#, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing or type parameter conversion from `{0}' to `" +"{3}'" msgstr "" -"Los métodos anónimos no pueden ser convertidos a árboles de expresiones" -#: ../mcs/mcs/expression.cs:9824 +#: mcs/mcs/generic.cs:2121 #, csharp-format -msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:310 -msgid "Control cannot fall through from one case label to another" +#: mcs/mcs/iterators.cs:44 +msgid "The yield statement cannot be used inside anonymous method blocks" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:529 +#: mcs/mcs/iterators.cs:856 #, csharp-format msgid "" -"The label `{0}:' could not be found within the scope of the goto statement" -msgstr "" - -#: ../mcs/mcs/flowanalysis.cs:657 -msgid "" -"A throw statement with no arguments is not allowed outside of a catch clause" +"The body of `{0}' cannot be an iterator block because `{1}' is not an " +"iterator interface type" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:668 ../mcs/mcs/flowanalysis.cs:674 -msgid "No enclosing loop out of which to break or continue" +#: mcs/mcs/iterators.cs:869 +msgid "Iterators cannot have ref or out parameters" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:702 -msgid "Control cannot leave the body of an anonymous method" +#: mcs/mcs/iterators.cs:875 +msgid "__arglist is not allowed in parameter list of iterators" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:743 -msgid "Cannot yield a value in the body of a try block with a catch clause" +#: mcs/mcs/iterators.cs:881 +msgid "Iterators cannot have unsafe parameters or yield types" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:745 -msgid "Cannot yield a value in the body of a catch clause" +#: mcs/mcs/iterators.cs:888 mcs/mcs/statement.cs:4324 +msgid "Unsafe code may not appear in iterators" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:897 +#: mcs/mcs/linq.cs:68 +#, csharp-format msgid "" -"A throw statement with no arguments is not allowed inside of a finally " -"clause nested inside of the innermost catch clause" +"An implementation of `{0}' query expression pattern could not be found. Are " +"you missing `System.Linq' using directive or `System.Core.dll' assembly " +"reference?" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:909 ../mcs/mcs/iterators.cs:112 -msgid "Cannot yield in the body of a finally clause" +#: mcs/mcs/linq.cs:93 +#, csharp-format +msgid "" +"Ambiguous implementation of the query pattern `{0}' for source type `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:920 ../mcs/mcs/flowanalysis.cs:936 -#: ../mcs/mcs/flowanalysis.cs:972 ../mcs/mcs/statement.cs:778 -msgid "Control cannot leave the body of a finally clause" +#: mcs/mcs/linq.cs:124 +#, csharp-format +msgid "" +"An implementation of `{0}' query expression pattern for source type `{1}' " +"could not be found" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1140 +#: mcs/mcs/linq.cs:132 #, csharp-format msgid "" -"An automatically implemented property `{0}' must be fully assigned before " -"control leaves the constructor. Consider calling default contructor" +"An expression type is incorrect in a subsequent `from' clause in a query " +"expression with source type `{0}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1144 +#: mcs/mcs/linq.cs:136 #, csharp-format msgid "" -"Field `{0}' must be fully assigned before control leaves the constructor" +"An expression type in `{0}' clause is incorrect. Type inference failed in " +"the call to `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1438 -msgid "Use of unassigned local variable `" +#: mcs/mcs/linq.cs:248 +#, csharp-format +msgid "A range variable `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1508 -msgid "Use of possibly unassigned field `" +#: mcs/mcs/linq.cs:750 +#, csharp-format +msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:191 -msgid "The new() constraint must be the last constraint specified" +#: mcs/mcs/linq.cs:757 +#, csharp-format +msgid "A range variable `{0}' has already been declared in this scope" msgstr "" -#: ../mcs/mcs/generic.cs:204 -msgid "The `new()' constraint cannot be used with the `struct' constraint" +#: mcs/mcs/linq.cs:764 +#, csharp-format +msgid "A range variable `{0}' conflicts with a method type parameter" msgstr "" -#: ../mcs/mcs/generic.cs:210 +#: mcs/mcs/linq.cs:796 +#, csharp-format msgid "" -"The `class' or `struct' constraint must be the first constraint specified" +"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " +"store the value" msgstr "" -#: ../mcs/mcs/generic.cs:249 +#: mcs/mcs/literal.cs:49 #, csharp-format msgid "" -"Inconsistent accessibility: constraint type `{0}' is less accessible than `" -"{1}'" +"Cannot convert null to the type parameter `{0}' because it could be a value " +"type. Consider using `default ({0})' instead" msgstr "" -#: ../mcs/mcs/generic.cs:261 +#: mcs/mcs/literal.cs:55 #, csharp-format -msgid "" -"The class type constraint `{0}' must be listed before any other constraints. " -"Consider moving type constraint to the beginning of the constraint list" +msgid "Cannot convert null to `{0}' because it is a value type" msgstr "" -#: ../mcs/mcs/generic.cs:265 +#: mcs/mcs/literal.cs:204 #, csharp-format msgid "" -"`{0}': cannot specify both a constraint class and the `class' or `struct' " -"constraint" +"Literal of type double cannot be implicitly converted to type `{0}'. Add " +"suffix `{1}' to create a literal of this type" msgstr "" -#: ../mcs/mcs/generic.cs:282 ../mcs/mcs/generic.cs:297 -#, csharp-format -msgid "Duplicate constraint `{0}' for type parameter `{1}'." +#: mcs/mcs/membercache.cs:1261 +msgid "" +"A partial method declaration and partial method implementation cannot differ " +"on use of `params' modifier" msgstr "" -#: ../mcs/mcs/generic.cs:316 -#, csharp-format +#: mcs/mcs/membercache.cs:1264 msgid "" -"`{0}' is not a valid constraint. Static classes cannot be used as constraints" +"A partial method declaration and partial method implementation must be both " +"an extension method or neither" msgstr "" -#: ../mcs/mcs/generic.cs:321 +#: mcs/mcs/membercache.cs:1268 #, csharp-format msgid "" -"`{0}' is not a valid constraint. A constraint must be an interface, a non-" -"sealed class or a type parameter" +"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only" msgstr "" -#: ../mcs/mcs/generic.cs:334 +#: mcs/mcs/membercache.cs:1272 #, csharp-format -msgid "A constraint cannot be special class `{0}'" +msgid "" +"Overloaded method `{0}' cannot differ on use of parameter modifiers only" msgstr "" -#: ../mcs/mcs/generic.cs:364 -#, csharp-format +#: mcs/mcs/membercache.cs:1304 msgid "" -"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " -"constraint for `{1}'" +"A partial method declaration and partial method implementation must be both " +"`static' or neither" msgstr "" -#: ../mcs/mcs/generic.cs:384 -#, csharp-format -msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" +#: mcs/mcs/membercache.cs:1309 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`unsafe' or neither" msgstr "" -#: ../mcs/mcs/generic.cs:398 +#: mcs/mcs/membercache.cs:1315 #, csharp-format -msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgid "A partial method `{0}' declaration is already defined" msgstr "" -#: ../mcs/mcs/generic.cs:702 +#: mcs/mcs/membercache.cs:1319 #, csharp-format -msgid "" -"`{0}': Cannot specify constraints for overrides or explicit interface " -"implementation methods" +msgid "A partial method `{0}' implementation is already defined" msgstr "" -#: ../mcs/mcs/generic.cs:733 +#: mcs/mcs/membercache.cs:1330 mcs/mcs/property.cs:81 #, csharp-format -msgid "" -"The constraints for type parameter `{0}' of method `{1}' must match the " -"constraints for type parameter `{2}' of interface method `{3}'. Consider " -"using an explicit interface implementation instead" +msgid "A member `{0}' is already reserved" msgstr "" -#: ../mcs/mcs/generic.cs:1139 -msgid "Type parameter declaration must be an identifier not a type" +#: mcs/mcs/membercache.cs:1341 +#, csharp-format +msgid "Duplicate user-defined conversion in type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1231 -#, csharp-format -msgid "`{0}': static classes cannot be used as generic arguments" +#: mcs/mcs/method.cs:484 +#, fuzzy +msgid "" +"The DllImport attribute must be specified on a method marked `static' and " +"`extern'" msgstr "" +"El atributo Guid debe de ser especificado junto con el atributo ComImport" + +#: mcs/mcs/method.cs:572 +#, fuzzy, csharp-format +msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: ../mcs/mcs/generic.cs:1238 +#: mcs/mcs/method.cs:631 #, csharp-format -msgid "The type `{0}' may not be used as a type argument" +msgid "" +"Conditional not valid on `{0}' because it is a constructor, destructor, " +"operator or explicit interface implementation" msgstr "" -#: ../mcs/mcs/generic.cs:1368 +#: mcs/mcs/method.cs:844 #, csharp-format -msgid "Cannot find type `{0}'<...>" +msgid "Program `{0}' has more than one entry point defined: `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:1375 +#: mcs/mcs/method.cs:888 +#, fuzzy, csharp-format +msgid "Conditional not valid on `{0}' because it is an override method" +msgstr "No se puede derivar de `{0}' ya que es un tipo parametrizado" + +#: mcs/mcs/method.cs:893 #, csharp-format -msgid "The non-generic type `{0}' cannot be used with type arguments." +msgid "Conditional not valid on `{0}' because its return type is not void" msgstr "" -#: ../mcs/mcs/generic.cs:1531 -#, csharp-format -msgid "" -"The type `{0}' must be a reference type in order to use it as type parameter " -"`{1}' in the generic type or method `{2}'." +#: mcs/mcs/method.cs:898 +msgid "Conditional not valid on interface members" msgstr "" -#: ../mcs/mcs/generic.cs:1540 +#: mcs/mcs/method.cs:904 +#, fuzzy, csharp-format +msgid "Conditional member `{0}' cannot implement interface member `{1}'" +msgstr "`{0}': el tipo contenedor no implementa la interface `{1}'" + +#: mcs/mcs/method.cs:911 #, csharp-format -msgid "" -"The type `{0}' must be a non-nullable value type in order to use it as type " -"parameter `{1}' in the generic type or method `{2}'." +msgid "Conditional method `{0}' cannot have an out parameter" msgstr "" -#: ../mcs/mcs/generic.cs:1583 +#: mcs/mcs/method.cs:1017 #, csharp-format msgid "" -"The type `{0}' must have a public parameterless constructor in order to use " -"it as parameter `{1}' in the generic type or method `{2}'" +"The constraints for type parameter `{0}' of method `{1}' must match the " +"constraints for type parameter `{2}' of interface method `{3}'. Consider " +"using an explicit interface implementation instead" msgstr "" -#: ../mcs/mcs/generic.cs:1628 +#: mcs/mcs/method.cs:1071 +#, fuzzy, csharp-format +msgid "`{0}': Extension methods cannot be defined in a nested class" +msgstr "`{0}' Los métodos de extensión deben de ser estáticos" + +#: mcs/mcs/method.cs:1077 #, csharp-format msgid "" -"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " -"method `{2}'. The nullable type `{0}' never satisfies interface constraint " -"of type `{3}'" +"`{0}': Extension methods cannot be declared without a reference to System." +"Core.dll assembly. Add the assembly reference or remove `this' modifer from " +"the first parameter" msgstr "" -#: ../mcs/mcs/generic.cs:1634 +#: mcs/mcs/method.cs:1086 +#, fuzzy, csharp-format +msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgstr "`{0}' Los métodos de extensión deben de ser estáticos" + +#: mcs/mcs/method.cs:1139 #, csharp-format msgid "" -"The type `{0}' must be convertible to `{1}' in order to use it as parameter `" -"{2}' in the generic type or method `{3}'" +"A partial method `{0}' implementation is missing a partial method declaration" msgstr "" -#: ../mcs/mcs/generic.cs:1827 +#: mcs/mcs/method.cs:1186 #, csharp-format -msgid "The type parameter name `{0}' is the same as `{1}'" +msgid "Method or delegate cannot return type `{0}'" msgstr "" -#: ../mcs/mcs/iterators.cs:42 ../mcs/mcs/iterators.cs:939 -msgid "Unsafe code may not appear in iterators" +#: mcs/mcs/method.cs:1261 +msgid "" +"The constructor call cannot be dynamically dispatched within constructor " +"initializer" msgstr "" -#: ../mcs/mcs/iterators.cs:52 -msgid "The yield statement cannot be used inside anonymous method blocks" +#: mcs/mcs/method.cs:1275 +#, fuzzy, csharp-format +msgid "`{0}': Struct constructors cannot call base constructors" msgstr "" +"`{0}': las clases estáticas no pueden tener constructores de instancias" -#: ../mcs/mcs/iterators.cs:907 +#: mcs/mcs/method.cs:1294 #, csharp-format -msgid "" -"The body of `{0}' cannot be an iterator block because `{1}' is not an " -"iterator interface type" +msgid "Constructor `{0}' cannot call itself" msgstr "" -#: ../mcs/mcs/iterators.cs:920 -msgid "Iterators cannot have ref or out parameters" +#: mcs/mcs/method.cs:1413 +#, csharp-format +msgid "`{0}': The static constructor must be parameterless" msgstr "" -#: ../mcs/mcs/iterators.cs:926 -msgid "__arglist is not allowed in parameter list of iterators" +#: mcs/mcs/method.cs:1431 +msgid "Structs cannot contain explicit parameterless constructors" msgstr "" -#: ../mcs/mcs/iterators.cs:932 -msgid "Iterators cannot have unsafe parameters or yield types" +#: mcs/mcs/method.cs:1487 +#, fuzzy, csharp-format +msgid "" +"`{0}': A class with the ComImport attribute cannot have a user-defined " +"constructor" msgstr "" +"`{0}': las clases estáticas no pueden tener constructores de instancias" + +#: mcs/mcs/method.cs:1730 +#, fuzzy, csharp-format +msgid "`{0}' is an accessor not found in interface member `{1}{2}'" +msgstr "`{0}' esconde el miembro abstracto heredado `{1}'" + +#: mcs/mcs/method.cs:1736 +#, fuzzy, csharp-format +msgid "" +"`{0}.{1}' in explicit interface declaration is not a member of interface" +msgstr "El tipo `{0} en la lista de interfaces no es una interface" -#: ../mcs/mcs/linq.cs:79 +#: mcs/mcs/method.cs:1743 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern could not be found. Are " -"you missing `System.Linq' using directive or `System.Core.dll' assembly " -"reference?" +"`{0}' explicit method implementation cannot implement `{1}' because it is an " +"accessor" msgstr "" -#: ../mcs/mcs/linq.cs:117 +#: mcs/mcs/method.cs:1753 +#, fuzzy, csharp-format +msgid "Method `{0}' cannot implement interface accessor `{1}'" +msgstr "`{0}': el tipo contenedor no implementa la interface `{1}'" + +#: mcs/mcs/method.cs:1759 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern for source type `{1}' " -"could not be found" +"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " +"an explicit interface implementation" msgstr "" -#: ../mcs/mcs/linq.cs:126 -#, csharp-format +#: mcs/mcs/method.cs:1765 +#, fuzzy, csharp-format +msgid "" +"Accessor `{0}' must be declared public to implement interface member `{1}'" +msgstr "`{0}': el tipo contenedor no implementa la interface `{1}'" + +#: mcs/mcs/method.cs:1789 +#, fuzzy, csharp-format msgid "" -"Type inference failed to infer type argument for `{0}' clause. Try " -"specifying the type argument explicitly" +"`{0}': the explicit interface implementation cannot introduce the params " +"modifier" msgstr "" +"`{0}': las declaraciones explícitas de interfaces solamente pueden ser " +"declaradas en una clase o estructura" -#: ../mcs/mcs/linq.cs:525 +#: mcs/mcs/method.cs:2107 #, csharp-format -msgid "A range variable `{0}' cannot be initialized with `{1}'" +msgid "" +"Attribute `{0}' is not valid on property or event accessors. It is valid on `" +"{1}' declarations only" msgstr "" -#: ../mcs/mcs/linq.cs:825 +#: mcs/mcs/method.cs:2318 #, csharp-format -msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" +msgid "User-defined operator `{0}' must be declared static and public" msgstr "" -#: ../mcs/mcs/linq.cs:831 -#, csharp-format -msgid "A range variable `{0}' has already been declared in this scope" +#: mcs/mcs/method.cs:2357 +msgid "" +"User-defined operator cannot take an object of the enclosing type and " +"convert to an object of the enclosing type" msgstr "" -#: ../mcs/mcs/linq.cs:837 -#, csharp-format -msgid "A range variable `{0}' conflicts with a method type parameter" +#: mcs/mcs/method.cs:2368 +msgid "User-defined conversion must convert to or from the enclosing type" msgstr "" -#: ../mcs/mcs/literal.cs:76 +#: mcs/mcs/method.cs:2374 +#, fuzzy, csharp-format +msgid "" +"User-defined conversion `{0}' cannot convert to or from the dynamic type" +msgstr "`{0}' no es posible derivad de la clase especial `{1}'" + +#: mcs/mcs/method.cs:2381 #, csharp-format msgid "" -"Cannot convert null to the type parameter `{0}' because it could be a value " -"type. Consider using `default ({0})' instead" +"User-defined conversion `{0}' cannot convert to or from an interface type" msgstr "" -#: ../mcs/mcs/literal.cs:79 +#: mcs/mcs/method.cs:2388 #, csharp-format -msgid "Cannot convert null to `{0}' because it is a value type" +msgid "User-defined conversion `{0}' cannot convert to or from a base class" msgstr "" -#: ../mcs/mcs/literal.cs:323 +#: mcs/mcs/method.cs:2394 #, csharp-format -msgid "" -"Literal of type double cannot be implicitly converted to type `{0}'. Add " -"suffix `{1}' to create a literal of this type" +msgid "User-defined conversion `{0}' cannot convert to or from a derived class" msgstr "" -#: ../mcs/mcs/location.cs:224 -#, csharp-format -msgid "Source file `{0}' specified multiple times" +#: mcs/mcs/method.cs:2401 +msgid "" +"Overloaded shift operator must have the type of the first operand be the " +"containing type, and the type of the second operand must be int" msgstr "" -#: ../mcs/mcs/location.cs:226 -#, csharp-format -msgid "Source filenames `{0}' and `{1}' both refer to the same file: {2}" +#: mcs/mcs/method.cs:2410 +msgid "" +"The return type for ++ or -- operator must be the containing type or derived " +"from the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:241 -msgid "More than one protection modifier specified" +#: mcs/mcs/method.cs:2415 +msgid "The parameter type for ++ or -- operator must be the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:258 -msgid "The modifier `" +#: mcs/mcs/method.cs:2422 +msgid "The parameter type of a unary operator must be the containing type" msgstr "" -#: ../mcs/mcs/namespace.cs:113 -#, csharp-format -msgid "An assembly `{0}' is used without being referenced" +#: mcs/mcs/method.cs:2430 +msgid "The return type of operator True or False must be bool" msgstr "" -#: ../mcs/mcs/namespace.cs:136 -#, csharp-format -msgid "The imported type `{0}' is defined multiple times" +#: mcs/mcs/method.cs:2445 +msgid "One of the parameters of a binary operator must be the containing type" msgstr "" -#: ../mcs/mcs/namespace.cs:259 +#: mcs/mcs/modifiers.cs:275 +#, fuzzy, csharp-format +msgid "The modifier `{0}' is not valid for this item" +msgstr "El tipo predefinido `{0}.{1}' no está definido o no ha sido importado" + +#: mcs/mcs/namespace.cs:70 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found in the global namespace " "(are you missing an assembly reference?)" msgstr "" -#: ../mcs/mcs/namespace.cs:380 +#: mcs/mcs/namespace.cs:177 #, csharp-format msgid "" "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are " "you missing an assembly reference?" msgstr "" -#: ../mcs/mcs/namespace.cs:387 -#, csharp-format -msgid "Using the generic type `{0}' requires `{1}' type argument(s)" -msgstr "" - -#: ../mcs/mcs/namespace.cs:405 +#: mcs/mcs/namespace.cs:256 #, csharp-format -msgid "The non-generic {0} `{1}' cannot be used with the type arguments" +msgid "The imported type `{0}' is defined multiple times" msgstr "" -#: ../mcs/mcs/namespace.cs:642 +#: mcs/mcs/namespace.cs:583 #, csharp-format msgid "" "`{0}' is a type not a namespace. A using namespace directive can only be " "applied to namespaces" msgstr "" -#: ../mcs/mcs/namespace.cs:669 +#: mcs/mcs/namespace.cs:610 #, csharp-format msgid "The extern alias `{0}' was not specified in -reference option" msgstr "" -#: ../mcs/mcs/namespace.cs:880 ../mcs/mcs/namespace.cs:902 +#: mcs/mcs/namespace.cs:820 mcs/mcs/namespace.cs:842 msgid "" "A using clause must precede all other namespace elements except extern alias " "declarations" msgstr "" -#: ../mcs/mcs/namespace.cs:926 +#: mcs/mcs/namespace.cs:866 msgid "An extern alias declaration must precede all other elements" msgstr "" -#: ../mcs/mcs/namespace.cs:944 +#: mcs/mcs/namespace.cs:884 #, csharp-format msgid "The using alias `{0}' appeared previously in this namespace" msgstr "" -#: ../mcs/mcs/namespace.cs:1017 +#: mcs/mcs/namespace.cs:1005 #, csharp-format -msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" +msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1056 +#: mcs/mcs/namespace.cs:1059 #, csharp-format -msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" +msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1149 -msgid "You cannot redefine the global extern alias" +#: mcs/mcs/namespace.cs:1127 +msgid "The global extern alias cannot be redefined" msgstr "" -#: ../mcs/mcs/namespace.cs:1159 +#: mcs/mcs/namespace.cs:1132 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found. Are you missing a using " "directive or an assembly reference?" msgstr "" -#: ../mcs/mcs/nullable.cs:985 +#: mcs/mcs/nullable.cs:1036 msgid "" "An expression tree cannot contain a coalescing operator with null left side" msgstr "" -#: ../mcs/mcs/parameter.cs:176 +#: mcs/mcs/parameter.cs:156 msgid "The params parameter must be a single dimensional array" msgstr "" -#: ../mcs/mcs/parameter.cs:277 -msgid "Invalid parameter type `void'" -msgstr "" - -#: ../mcs/mcs/parameter.cs:288 +#: mcs/mcs/parameter.cs:288 msgid "An out parameter cannot have the `In' attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:293 +#: mcs/mcs/parameter.cs:293 msgid "" "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead" msgstr "" -#: ../mcs/mcs/parameter.cs:300 +#: mcs/mcs/parameter.cs:300 msgid "" "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and " "`Out' attributes or neither" msgstr "" -#: ../mcs/mcs/parameter.cs:318 +#: mcs/mcs/parameter.cs:310 +#, fuzzy, csharp-format +msgid "Cannot specify `{0}' attribute on optional parameter `{1}'" +msgstr "" +"No puede especificar el atributo `DefaultMember' en un tipo que contiene un " +"indexador" + +#: mcs/mcs/parameter.cs:320 #, csharp-format -msgid "Argument of type `{0}' is not applicable for the DefaultValue attribute" +msgid "" +"Argument of type `{0}' is not applicable for the DefaultParameterValue " +"attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:321 +#: mcs/mcs/parameter.cs:323 #, csharp-format msgid "" -"The DefaultValue attribute is not applicable on parameters of type `{0}'" +"The DefaultParameterValue attribute is not applicable on parameters of type `" +"{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:333 +#: mcs/mcs/parameter.cs:334 msgid "The type of the default value should match the type of the parameter" msgstr "" -#: ../mcs/mcs/parameter.cs:373 +#: mcs/mcs/parameter.cs:376 #, csharp-format msgid "Method or delegate parameter cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:386 +#: mcs/mcs/parameter.cs:386 #, csharp-format msgid "`{0}': static types cannot be used as parameters" msgstr "" -#: ../mcs/mcs/parameter.cs:392 +#: mcs/mcs/parameter.cs:392 #, csharp-format -msgid "The type of extension method cannot be `{0}'" +msgid "The extension method cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:497 -msgid "An expression tree parameter cannot use `ref' or `out' modifier" +#: mcs/mcs/parameter.cs:448 +#, csharp-format +msgid "" +"The expression being assigned to optional parameter `{0}' must be a constant " +"or default value" msgstr "" -#: ../mcs/mcs/parameter.cs:884 +#: mcs/mcs/parameter.cs:464 #, csharp-format -msgid "The parameter name `{0}' is a duplicate" +msgid "" +"The expression being assigned to nullable optional parameter `{0}' must be " +"default value" +msgstr "" + +#: mcs/mcs/parameter.cs:472 +#, csharp-format +msgid "" +"Optional parameter `{0}' of type `{1}' can only be initialized with `null'" +msgstr "" + +#: mcs/mcs/parameter.cs:482 +#, csharp-format +msgid "" +"Optional parameter expression of type `{0}' cannot be converted to parameter " +"type `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:624 +msgid "An expression tree parameter cannot use `ref' or `out' modifier" msgstr "" -#: ../mcs/mcs/parameter.cs:936 +#: mcs/mcs/parameter.cs:1096 #, csharp-format msgid "The parameter name `{0}' conflicts with a compiler generated name" msgstr "" -#: ../mcs/mcs/pending.cs:598 +#: mcs/mcs/pending.cs:443 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' is static" msgstr "" -#: ../mcs/mcs/pending.cs:602 +#: mcs/mcs/pending.cs:447 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' in not public" msgstr "" -#: ../mcs/mcs/pending.cs:606 +#: mcs/mcs/pending.cs:451 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " @@ -3002,88 +3480,171 @@ msgid "" "type `{4}'" msgstr "" -#: ../mcs/mcs/pending.cs:611 +#: mcs/mcs/pending.cs:456 #, csharp-format msgid "`{0}' does not implement interface member `{1}'" msgstr "" -#: ../mcs/mcs/pending.cs:615 +#: mcs/mcs/pending.cs:461 #, csharp-format msgid "`{0}' does not implement inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:574 +#: mcs/mcs/property.cs:352 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers may not be used on accessors in an interface" +msgstr "" + +#: mcs/mcs/property.cs:356 +#, fuzzy, csharp-format +msgid "`{0}': abstract properties cannot have private accessors" +msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" + +#: mcs/mcs/property.cs:401 +#, csharp-format +msgid "" +"The accessibility modifier of the `{0}' accessor must be more restrictive " +"than the modifier of the property or indexer `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:502 +#, csharp-format +msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:521 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable get " +"accessor" +msgstr "`{0}': no es posible sobreescribir ya que `{1}' no es un evento" + +#: mcs/mcs/property.cs:538 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable set " +"accessor" +msgstr "`{0}': no es posible sobreescribir ya que `{1}' no es un evento" + +#: mcs/mcs/property.cs:579 #, csharp-format msgid "" -"Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " -"`gmcs' compiler instead" +"`{0}': Cannot specify accessibility modifiers for both accessors of the " +"property or indexer" msgstr "" -#: ../mcs/mcs/report.cs:582 +#: mcs/mcs/property.cs:586 #, csharp-format msgid "" -"Feature `{0}' cannot be used because it is not part of the C# {1} language " -"specification" +"`{0}': accessibility modifiers on accessors may only be used if the property " +"or indexer has both a get and a set accessor" msgstr "" -#: ../mcs/mcs/report.cs:639 +#: mcs/mcs/property.cs:783 #, csharp-format msgid "" -"Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime " -"instead." +"Automatically implemented property `{0}' cannot be used inside a type with " +"an explicit StructLayout attribute" msgstr "" -#: ../mcs/mcs/rootcontext.cs:410 -msgid "Unsafe code requires the `unsafe' command line option to be specified" +#: mcs/mcs/property.cs:1274 +#, csharp-format +msgid "`{0}': event must be of a delegate type" +msgstr "" + +#: mcs/mcs/property.cs:1482 +#, csharp-format +msgid "" +"The `{0}' attribute is valid only on an indexer that is not an explicit " +"interface member declaration" +msgstr "" + +#: mcs/mcs/property.cs:1516 +#, fuzzy +msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +msgstr "" +"No puede especificar el atributo `DefaultMember' en un tipo que contiene un " +"indexador" + +#: mcs/mcs/reflection.cs:217 +msgid "Could not access the key inside the container `" +msgstr "" + +#: mcs/mcs/roottypes.cs:363 +#, fuzzy +msgid "" +"The compilation may fail due to missing `System.Reflection.Emit." +"AssemblyBuilder.SetCorlibTypeBuilders(...)' method" +msgstr "" +"La compilación puede fallar ya que el método `{0}.SetCorlibTypeBuilders" +"({1})' no existe" + +#: mcs/mcs/roottypes.cs:470 +#, csharp-format +msgid "Value specified for the argument to `{0}' is not valid" msgstr "" -#: ../mcs/mcs/statement.cs:105 +#: mcs/mcs/statement.cs:87 msgid "" "A lambda expression with statement body cannot be converted to an expresion " "tree" msgstr "" -#: ../mcs/mcs/statement.cs:818 +#: mcs/mcs/statement.cs:740 +#, csharp-format msgid "" -"Cannot return a value from iterators. Use the yield return statement to " -"return a value, or yield break to end the iteration" +"An object of a type convertible to `{0}' is required for the return statement" msgstr "" -#: ../mcs/mcs/statement.cs:825 +#: mcs/mcs/statement.cs:753 #, csharp-format msgid "" "`{0}': A return keyword must not be followed by any expression when method " "returns void" msgstr "" -#: ../mcs/mcs/statement.cs:849 +#: mcs/mcs/statement.cs:778 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' because some of the return types " "in the block are not implicitly convertible to the delegate return type" msgstr "" -#: ../mcs/mcs/statement.cs:1041 ../mcs/mcs/statement.cs:1073 +#: mcs/mcs/statement.cs:806 +msgid "" +"Cannot return a value from iterators. Use the yield return statement to " +"return a value, or yield break to end the iteration" +msgstr "" + +#: mcs/mcs/statement.cs:963 mcs/mcs/statement.cs:997 msgid "A goto case is only valid inside a switch statement" msgstr "" -#: ../mcs/mcs/statement.cs:1656 -#, csharp-format -msgid "" -"The label `{0}' shadows another label by the same name in a contained scope" +#: mcs/mcs/statement.cs:1076 mcs/mcs/statement.cs:4726 +msgid "The type caught or thrown must be derived from System.Exception" msgstr "" -#: ../mcs/mcs/statement.cs:1681 -#, csharp-format -msgid "The label `{0}' is a duplicate" +#: mcs/mcs/statement.cs:1298 +msgid "A fixed statement cannot use an implicitly typed local variable" msgstr "" -#: ../mcs/mcs/statement.cs:1776 -#, csharp-format -msgid "`{0}' conflicts with a declaration in a child block" +#: mcs/mcs/statement.cs:1303 +msgid "An implicitly typed local variable cannot be a constant" +msgstr "" + +#: mcs/mcs/statement.cs:1308 +msgid "" +"An implicitly typed local variable declarator must include an initializer" +msgstr "" + +#: mcs/mcs/statement.cs:1313 +msgid "" +"An implicitly typed local variable declaration cannot include multiple " +"declarators" msgstr "" -#: ../mcs/mcs/statement.cs:1877 +#: mcs/mcs/statement.cs:1883 #, csharp-format msgid "" "A local variable named `{0}' cannot be declared in this scope because it " @@ -3091,152 +3652,156 @@ msgid "" "scope to denote something else" msgstr "" -#: ../mcs/mcs/statement.cs:1886 +#: mcs/mcs/statement.cs:1894 +#, csharp-format +msgid "" +"`{0}': An anonymous type cannot have multiple properties with the same name" +msgstr "" +"`{0}' An tipo anónimo no puede tener multiples propiedades con el mismo " +"nombre" + +#: mcs/mcs/statement.cs:1897 +#, csharp-format +msgid "The parameter name `{0}' is a duplicate" +msgstr "" + +#: mcs/mcs/statement.cs:1904 #, csharp-format msgid "A local variable named `{0}' is already defined in this scope" msgstr "" -#: ../mcs/mcs/statement.cs:2041 -msgid "An implicitly typed local variable cannot be a constant" +#: mcs/mcs/statement.cs:1910 +#, fuzzy, csharp-format +msgid "" +"The type parameter name `{0}' is the same as local variable or parameter name" msgstr "" +"El tipo parametrizado `{0}' tiene el mimo nombre que el tipo contenedor, o " +"el método" -#: ../mcs/mcs/statement.cs:2891 +#: mcs/mcs/statement.cs:2482 #, csharp-format msgid "" "The out parameter `{0}' must be assigned to before control leaves the " "current method" msgstr "" -#: ../mcs/mcs/statement.cs:3024 +#: mcs/mcs/statement.cs:2573 #, csharp-format -msgid "The label `case {0}:' already occurs in this switch statement" +msgid "`{0}': not all code paths return a value" msgstr "" -#: ../mcs/mcs/statement.cs:3570 -msgid "A value of an integral type or string expected for switch" +#: mcs/mcs/statement.cs:2577 +#, csharp-format +msgid "Not all code paths return a value in anonymous method of type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4029 +#: mcs/mcs/statement.cs:2748 #, csharp-format -msgid "`{0}' is not a reference type as required by the lock statement" +msgid "The label `{0}' is a duplicate" msgstr "" -#: ../mcs/mcs/statement.cs:4346 -msgid "A fixed statement cannot use an implicitly typed local variable" +#: mcs/mcs/statement.cs:2757 mcs/mcs/statement.cs:2768 +#, csharp-format +msgid "" +"The label `{0}' shadows another label by the same name in a contained scope" +msgstr "" + +#: mcs/mcs/statement.cs:3088 +#, csharp-format +msgid "The label `case {0}:' already occurs in this switch statement" +msgstr "" + +#: mcs/mcs/statement.cs:3629 +#, csharp-format +msgid "" +"A switch expression of type `{0}' cannot be converted to an integral type, " +"bool, char, string, enum or nullable type" msgstr "" -#: ../mcs/mcs/statement.cs:4356 +#: mcs/mcs/statement.cs:4114 +#, csharp-format +msgid "`{0}' is not a reference type as required by the lock statement" +msgstr "" + +#: mcs/mcs/statement.cs:4455 msgid "The type of locals declared in a fixed statement must be a pointer type" msgstr "" -#: ../mcs/mcs/statement.cs:4380 +#: mcs/mcs/statement.cs:4471 msgid "" "The right hand side of a fixed statement assignment may not be a cast " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4457 +#: mcs/mcs/statement.cs:4542 msgid "" "You cannot use the fixed statement to take the address of an already fixed " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4707 -msgid "Try statement already has an empty catch block" -msgstr "" - -#: ../mcs/mcs/statement.cs:4745 +#: mcs/mcs/statement.cs:4856 #, csharp-format msgid "" "A previous catch clause already catches all exceptions of this or a super " "type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4920 ../mcs/mcs/statement.cs:5035 -msgid "Internal error: No Dispose method which takes 0 parameters." -msgstr "" - -#: ../mcs/mcs/statement.cs:4992 +#: mcs/mcs/statement.cs:5029 #, csharp-format msgid "" "`{0}': type used in a using statement must be implicitly convertible to " "`System.IDisposable'" msgstr "" -#: ../mcs/mcs/statement.cs:5115 -msgid "Use of null is not valid in this context" -msgstr "" - -#: ../mcs/mcs/statement.cs:5120 -#, csharp-format -msgid "Foreach statement cannot operate on a `{0}'" -msgstr "El mandato `foreach' no puede operar en un `{0}'" - -#: ../mcs/mcs/statement.cs:5433 +#: mcs/mcs/statement.cs:5451 #, csharp-format msgid "" "foreach statement requires that the return type `{0}' of `{1}' must have a " "suitable public MoveNext method and public Current property" msgstr "" -#: ../mcs/mcs/statement.cs:5518 +#: mcs/mcs/statement.cs:5490 #, csharp-format msgid "" -"foreach statement cannot operate on variables of type `{0}' because it does " -"not contain a definition for `GetEnumerator' or is not accessible" +"foreach statement cannot operate on variables of type `{0}' because it " +"contains multiple implementation of `{1}'. Try casting to a specific " +"implementation" msgstr "" -#: ../mcs/mcs/statement.cs:5570 +#: mcs/mcs/statement.cs:5509 #, csharp-format msgid "" -"foreach statement cannot operate on variables of type `{0}' because it " -"contains multiple implementation of `{1}'. Try casting to a specific " -"implementation" +"foreach statement cannot operate on variables of type `{0}' because it does " +"not contain a definition for `{1}' or is inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:878 +#: mcs/mcs/statement.cs:5715 +msgid "Use of null is not valid in this context" +msgstr "" + +#: mcs/mcs/statement.cs:5725 +#, csharp-format +msgid "Foreach statement cannot operate on a `{0}'" +msgstr "El mandato `foreach' no puede operar en un `{0}'" + +#: mcs/mcs/typemanager.cs:389 #, csharp-format msgid "The predefined type `{0}.{1}' is not defined or imported" msgstr "El tipo predefinido `{0}.{1}' no está definido o no ha sido importado" -#: ../mcs/mcs/typemanager.cs:902 +#: mcs/mcs/typemanager.cs:395 #, csharp-format msgid "The predefined type `{0}.{1}' is not declared correctly" msgstr "El tipo predefinido `{0}.{1}' fue incorrectamente declarado" -#: ../mcs/mcs/typemanager.cs:952 +#: mcs/mcs/typemanager.cs:574 #, csharp-format msgid "" "The compiler required member `{0}.{1}{2}' could not be found or is " "inaccessible" msgstr "El compilador no encuentra el miembro `{0}.{1}{2}' o no es accessible" -#: ../mcs/mcs/typemanager.cs:1161 -#, csharp-format -msgid "" -"The compilation may fail due to missing `{0}.SetCorlibTypeBuilders({1})' " -"method" -msgstr "" -"La compilación puede fallar ya que el método `{0}.SetCorlibTypeBuilders" -"({1})' no existe" - -#: ../mcs/mcs/typemanager.cs:1706 -#, csharp-format -msgid "" -"Friend access was granted to `{0}', but the output assembly is named `{1}'. " -"Try adding a reference to `{0}' or change the output assembly name to match " -"it" -msgstr "" - -#: ../mcs/mcs/typemanager.cs:1961 -#, csharp-format -msgid "" -"Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" -msgstr "" -"El miembro `{0}.{1}' con tipo `{2}' produce un ciclo recursivo en la " -"estructura" - -#: ../mcs/mcs/typemanager.cs:2308 +#: mcs/mcs/typemanager.cs:885 #, csharp-format msgid "" "Cannot take the address of, get the size of, or declare a pointer to a " @@ -3245,10 +3810,18 @@ msgstr "" "No es posible obtener la dirección, el tamaño o declarar un apuntador a un " "tipo gestionado `{0}'" -#~ msgid "Class, struct, or interface method must have a return type" -#~ msgstr "El método debe tener un tipo de retorno" +#~ msgid "Can not use a type parameter in an attribute" +#~ msgstr "No es posible usar un tipo parametrizado en un atributo" + +#~ msgid "" +#~ "`{0}': Any identifier with double underscores cannot be used when ISO " +#~ "language version mode is specified" +#~ msgstr "" +#~ "`{0}': Ningún identificador con dos subrayados contíguos puede ser usado " +#~ "cuando la versión del lenguage seleccionada es ISO" -#~ msgid "Keyword `new' is not allowed on namespace elements" +#~ msgid "" +#~ "Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" #~ msgstr "" -#~ "La palabra reservada `new' no está permitida en los elementos de un " -#~ "espacio de nombres" +#~ "El miembro `{0}.{1}' con tipo `{2}' produce un ciclo recursivo en la " +#~ "estructura" diff --git a/po/mcs/ja.po b/po/mcs/ja.po index 3bc2f0f59a43..1aff9dcb0d14 100644 --- a/po/mcs/ja.po +++ b/po/mcs/ja.po @@ -2,73 +2,74 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2008-09-29 12:41-0300\n" +"POT-Creation-Date: 2010-12-16 13:01+0000\n" "PO-Revision-Date: \n" "Last-Translator: Atsushi Eno \n" "Language-Team: \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Japanese\n" -#: ../mcs/mcs/anonymous.cs:850 +#: mcs/mcs/anonymous.cs:880 #, csharp-format msgid "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'" msgstr "`{0}' をデリゲートでない型 `{1}' の式ツリーに変換できません" -#: ../mcs/mcs/anonymous.cs:856 +#: mcs/mcs/anonymous.cs:885 #, csharp-format msgid "Cannot convert `{0}' to non-delegate type `{1}'" msgstr "`{0}' をデリゲートでない型 `{1}'に変換できません" -#: ../mcs/mcs/anonymous.cs:868 +#: mcs/mcs/anonymous.cs:897 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' since there is a parameter " "mismatch" msgstr "パラメータ不一致のため、`{0}' をデリゲート型 `{1}'に変換できません" -#: ../mcs/mcs/anonymous.cs:880 ../mcs/mcs/delegate.cs:568 +#: mcs/mcs/anonymous.cs:909 mcs/mcs/ecore.cs:4469 #, csharp-format msgid "Delegate `{0}' does not take `{1}' arguments" msgstr "デリゲート `{0}' は `{1}' 個の引数をもちません" -#: ../mcs/mcs/anonymous.cs:895 +#: mcs/mcs/anonymous.cs:924 #, csharp-format msgid "Parameter `{0}' should not be declared with the `{1}' keyword" msgstr "パラメータ `{0}' は `{1}' キーワードで宣言されるべきではありません" -#: ../mcs/mcs/anonymous.cs:898 +#: mcs/mcs/anonymous.cs:927 #, csharp-format msgid "Parameter `{0}' must be declared with the `{1}' keyword" msgstr "パラメータ `{0}' は `{1}' キーワードで宣言されなければなりません" -#: ../mcs/mcs/anonymous.cs:919 +#: mcs/mcs/anonymous.cs:948 #, csharp-format msgid "Parameter `{0}' is declared as type `{1}' but should be `{2}'" msgstr "" "パラメータ `{0}' は型 `{1}' として宣言されていますが、 `{2}' であるはずです" -#: ../mcs/mcs/anonymous.cs:1043 +#: mcs/mcs/anonymous.cs:1103 msgid "An anonymous method cannot be converted to an expression tree" msgstr "匿名メソッドを式ツリーに変換することはできません" -#: ../mcs/mcs/anonymous.cs:1060 -#, csharp-format +#: mcs/mcs/anonymous.cs:1122 +#, fuzzy, csharp-format msgid "" "Cannot convert anonymous method block without a parameter list to delegate " -"type `{0}' because it has one or more `out' parameters." +"type `{0}' because it has one or more `out' parameters" msgstr "" "デリゲート型 `{0}' には引数に`out'パラメータがあるので、パラメータリスト無し" "では匿名メソッドのブロックから変換できません" -#: ../mcs/mcs/anonymous.cs:1085 +#: mcs/mcs/anonymous.cs:1146 msgid "" "Anonymous methods and lambda expressions cannot be used in the current " "context" msgstr "匿名メソッドとラムダ式は現在の文脈では使用できません" -#: ../mcs/mcs/anonymous.cs:1122 +#: mcs/mcs/anonymous.cs:1188 #, csharp-format msgid "" "Local variable or parameter `{0}' cannot have their address taken and be " @@ -77,21 +78,52 @@ msgstr "" "ローカル変数またはパラメータである `{0}' は、そのアドレスを取得して匿名メソッ" "ドあるいはラムダ式の中で使用することができません" -#: ../mcs/mcs/anonymous.cs:1353 +#: mcs/mcs/anonymous.cs:1438 msgid "An expression tree cannot contain an anonymous method expression" msgstr "式ツリーに匿名メソッド式を含むことはできません" -#: ../mcs/mcs/anonymous.cs:1647 +#: mcs/mcs/argument.cs:101 +#, fuzzy +msgid "" +"An expression tree cannot contain an invocation which uses optional parameter" +msgstr "式ツリーは代入オペレータを含むことができません" + +#: mcs/mcs/argument.cs:184 +#, fuzzy +msgid "An expression tree cannot contain named argument" +msgstr "式ツリーは代入オペレータを含むことができません" + +#: mcs/mcs/argument.cs:303 #, csharp-format msgid "" -"`{0}': An anonymous type cannot have multiple properties with the same name" -msgstr "`{0}': 匿名型は同一の名前で複数のプロパティをもつことができません" +"The method group `{0}' cannot be used as an argument of dynamic operation. " +"Consider using parentheses to invoke the method" +msgstr "" + +#: mcs/mcs/argument.cs:307 +#, fuzzy +msgid "" +"An anonymous method or lambda expression cannot be used as an argument of " +"dynamic operation. Consider using a cast" +msgstr "匿名メソッドとラムダ式は現在の文脈では使用できません" + +#: mcs/mcs/argument.cs:310 +#, fuzzy, csharp-format +msgid "" +"An expression of type `{0}' cannot be used as an argument of dynamic " +"operation" +msgstr "式ツリーは代入オペレータを含むことができません" -#: ../mcs/mcs/assign.cs:325 +#: mcs/mcs/assign.cs:299 msgid "An expression tree cannot contain an assignment operator" msgstr "式ツリーは代入オペレータを含むことができません" -#: ../mcs/mcs/attribute.cs:165 +#: mcs/mcs/assign.cs:627 +#, csharp-format +msgid "Cannot assign to `{0}' because it is a `{1}'" +msgstr "" + +#: mcs/mcs/attribute.cs:196 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument. Named attribute arguments " @@ -102,7 +134,7 @@ msgstr "" "み専用ではなくstaticでも定数でもないフィールドか、またはpublicでstaticではな" "い読み書き可能なプロパティでなければなりません" -#: ../mcs/mcs/attribute.cs:173 +#: mcs/mcs/attribute.cs:205 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument because it is not a valid " @@ -111,65 +143,57 @@ msgstr "" "`{0}' は、有効な属性パラメータ型ではないため、有効な名前付き属性の引数ではあ" "りません" -#: ../mcs/mcs/attribute.cs:180 -msgid "" -"An attribute argument must be a constant expression, typeof expression or " -"array creation expression" -msgstr "属性の引数は定数、typeof式または配列生成式でなければなりません" - -#: ../mcs/mcs/attribute.cs:187 -msgid "Can not use a type parameter in an attribute" -msgstr "属性の中で型パラメータを使用することはできません" +#: mcs/mcs/attribute.cs:211 +#, fuzzy +msgid "An attribute argument cannot be dynamic expression" +msgstr "匿名メソッドを式ツリーに変換することはできません" -#: ../mcs/mcs/attribute.cs:192 +#: mcs/mcs/attribute.cs:216 msgid "The Guid attribute must be specified with the ComImport attribute" msgstr "Guid属性はComImport属性とともに指定されなければなりません" -#: ../mcs/mcs/attribute.cs:197 +#: mcs/mcs/attribute.cs:221 #, csharp-format msgid "Do not use `{0}' directly. Use parameter modifier `this' instead" msgstr "" "`{0}' を直接使用せず、代わりにパラメータ修飾子 `this' を使用してください" -#: ../mcs/mcs/attribute.cs:206 +#: mcs/mcs/attribute.cs:226 +#, fuzzy, csharp-format +msgid "Do not use `{0}' directly. Use `dynamic' keyword instead" +msgstr "" +"`{0}' を直接使用せず、代わりにパラメータ修飾子 `this' を使用してください" + +#: mcs/mcs/attribute.cs:235 #, csharp-format msgid "Error during emitting `{0}' attribute. The reason is `{1}'" msgstr "`{0}' の属性の出力中にエラーが発生しました。理由: '{1}'" -#: ../mcs/mcs/attribute.cs:245 +#: mcs/mcs/attribute.cs:266 #, csharp-format msgid "`{0}': is not an attribute class" msgstr "`{0}' は属性クラスではありません" -#: ../mcs/mcs/attribute.cs:263 -#, csharp-format +#: mcs/mcs/attribute.cs:302 +#, fuzzy, csharp-format msgid "" -"`{0}' is ambiguous between `{0}' and `{0}Attribute'. Use either `@{0}' or `" -"{0}Attribute'" +"`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}" +"Attribute'" msgstr "" "`{0} は `{0}' と `{0}Attribute' の間で曖昧です。`@{0}' または `{0}Attribute' " "を使用してください" -#: ../mcs/mcs/attribute.cs:365 +#: mcs/mcs/attribute.cs:385 #, csharp-format msgid "Cannot apply attribute class `{0}' because it is abstract" msgstr "属性クラス `{0}' はabstractなので適用できません" -#: ../mcs/mcs/attribute.cs:490 -msgid "Invalid value for argument to `System.AttributeUsage' attribute" -msgstr "`System.AttributeUsage' 属性への無効な引数値です" - -#: ../mcs/mcs/attribute.cs:498 -#, csharp-format -msgid "The argument to the `{0}' attribute must be a valid identifier" -msgstr "`{0}' 属性への引数は有効な識別子である必要があります" - -#: ../mcs/mcs/attribute.cs:528 -#, csharp-format -msgid "'{0}' duplicate named attribute argument" +#: mcs/mcs/attribute.cs:453 +#, fuzzy, csharp-format +msgid "Duplicate named attribute `{0}' argument" msgstr "属性の引数名 '{0}' が重複しています" -#: ../mcs/mcs/attribute.cs:870 +#: mcs/mcs/attribute.cs:730 #, csharp-format msgid "" "`{0}' is not a valid attribute location for this declaration. Valid " @@ -178,2784 +202,3233 @@ msgstr "" "`{0}' の属性の位置はその宣言からは有効ではありません。宣言されている有効な属" "性の位置は `{1}' です" -#: ../mcs/mcs/attribute.cs:1199 +#: mcs/mcs/attribute.cs:1004 #, csharp-format msgid "" "The attribute `{0}' is not valid on this declaration type. It is valid on `" "{1}' declarations only" msgstr "属性 `{0}' はこの宣言型では無効です。 `{1}' の宣言でのみ有効です" -#: ../mcs/mcs/attribute.cs:1493 +#: mcs/mcs/attribute.cs:1022 +#, csharp-format +msgid "The argument to the `{0}' attribute must be a valid identifier" +msgstr "`{0}' 属性への引数は有効な識別子である必要があります" + +#: mcs/mcs/attribute.cs:1035 +#, fuzzy, csharp-format +msgid "Invalid value for argument to `{0}' attribute" +msgstr "`System.AttributeUsage' 属性への無効な引数値です" + +#: mcs/mcs/attribute.cs:1341 #, csharp-format msgid "The attribute `{0}' cannot be applied multiple times" msgstr "属性 `{0}' は複数回指定することができません" -#: ../mcs/mcs/attribute.cs:1661 -msgid "" -"Added modules must be marked with the CLSCompliant attribute to match the " -"assembly" -msgstr "" -"追加されるモジュールは、アセンブリに適合するCLSCompliant属性でマークされなけ" -"ればなりません" - -#: ../mcs/mcs/attribute.cs:1802 +#: mcs/mcs/attribute.cs:1603 #, csharp-format msgid "`{0}' is obsolete: `{1}'" msgstr "`{0}'は廃止されています: `{1}'" -#: ../mcs/mcs/cs-tokenizer.cs:1276 ../mcs/mcs/cs-tokenizer.cs:1346 -msgid "Invalid number" -msgstr "無効な数値です" - -#: ../mcs/mcs/cs-tokenizer.cs:1532 -#, csharp-format -msgid "Unrecognized escape sequence `\\{0}'" -msgstr "認識できないエスケープシーケンス `\\{0}' です" +#: mcs/mcs/cs-parser.cs:1646 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1551 -msgid "Unrecognized escape sequence" -msgstr "認識できないエスケープシーケンスです" +#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 +msgid "Interfaces cannot contain fields or constants" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1811 +#: mcs/mcs/cs-parser.cs:1952 #, fuzzy -msgid "Missing identifier to pre-processor directive" -msgstr "プリプロセッサ指令の識別子がありません" +msgid "Interfaces cannot contain operators" +msgstr "`{0}': staticクラスにはユーザー定義の演算子を含むことはできません" -#: ../mcs/mcs/cs-tokenizer.cs:1821 ../mcs/mcs/cs-tokenizer.cs:1825 -#, csharp-format -msgid "Identifier expected: {0}" -msgstr "識別子が必要です: {0}" +#: mcs/mcs/cs-parser.cs:1958 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': staticクラスではデストラクタを定義できません" -#: ../mcs/mcs/cs-tokenizer.cs:2201 -msgid "Numeric constant too long" -msgstr "数値定数が長すぎます" +#: mcs/mcs/cs-parser.cs:1964 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2206 -msgid "Invalid preprocessor directive" -msgstr "無効なプリプロセッサ指令です" +#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 +msgid "A const field requires a value to be provided" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2213 -#, csharp-format -msgid "Unexpected processor directive ({0})" -msgstr "予期しないプリプロセッサ指令です({0})" +#: mcs/mcs/cs-parser.cs:3602 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2218 -#, csharp-format -msgid "Expected `{0}'" -msgstr "`{0}' が必要です" +#: mcs/mcs/cs-parser.cs:3884 +msgid "A namespace declaration cannot have modifiers or attributes" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2224 +#: mcs/mcs/cs-parser.cs:3948 msgid "" -"Cannot define or undefine preprocessor symbols after first token in file" +"Namespace elements cannot be explicitly declared as private, protected or " +"protected internal" msgstr "" -"ファイル中の最初のトークンの出現後は、プリプロセッサシンボルを定義または定義" -"解除することはできません" -#: ../mcs/mcs/cs-tokenizer.cs:2230 +#: mcs/mcs/cs-parser.cs:3963 msgid "" -"Preprocessor directives must appear as the first non-whitespace character on " -"a line" +"Assembly and module attributes must precede all other elements except using " +"clauses and extern alias declarations" msgstr "" -"プリプロセッサ指令は、1行の中で、最初の空白でない文字として出現しなければなり" -"ません" - -#: ../mcs/mcs/cs-tokenizer.cs:2235 -msgid "Single-line comment or end-of-line expected" -msgstr "1行コメントまたは行末が必要です" -#: ../mcs/mcs/cs-tokenizer.cs:2280 ../mcs/mcs/cs-tokenizer.cs:3006 -msgid "Expected `#endif' directive" -msgstr "`#endif' 指令が必要です" +#: mcs/mcs/cs-parser.cs:4080 +msgid "'<' unexpected: attributes cannot be generic" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2313 ../mcs/mcs/cs-tokenizer.cs:2334 -#: ../mcs/mcs/cs-tokenizer.cs:2365 ../mcs/mcs/cs-tokenizer.cs:3004 -msgid "#endregion directive expected" -msgstr "#endregion指令が必要です" +#: mcs/mcs/cs-parser.cs:4117 +msgid "Named attribute arguments must appear after the positional arguments" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2420 +#: mcs/mcs/cs-parser.cs:4163 #, csharp-format -msgid "#error: '{0}'" -msgstr "#error: `{0}'" +msgid "" +"Unexpected symbol `{0}' in class, struct, or interface member declaration" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2440 -msgid "The line number specified for #line directive is missing or invalid" -msgstr "#line指令で指定される行番号が無いか、または無効です" +#: mcs/mcs/cs-parser.cs:4220 +#, fuzzy, csharp-format +msgid "The constant `{0}' cannot be marked static" +msgstr "abstractメソッド `{0}' はvirtualとすることはできません" -#: ../mcs/mcs/cs-tokenizer.cs:2444 -msgid "Wrong preprocessor directive" -msgstr "正しくないプリプロセッサ指令です" +#: mcs/mcs/cs-parser.cs:4268 +msgid "Fields cannot have void type" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2474 ../mcs/mcs/cs-tokenizer.cs:2837 -msgid "Newline in constant" -msgstr "定数の中に改行文字が含まれています" +#: mcs/mcs/cs-parser.cs:4369 +msgid "Value or constant expected" +msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2490 -msgid "Unterminated string literal" -msgstr "文字列に終端がありません" +#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 +#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 +#: mcs/mcs/cs-parser.cs:5427 +#, fuzzy, csharp-format +msgid "`{0}': interface members cannot have a definition" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: ../mcs/mcs/cs-tokenizer.cs:2537 -msgid "" -"The `partial' modifier can be used only immediately before `class', " -"`struct', `interface', or `void' keyword" +#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +msgid "Constraints are not allowed on non-generic declarations" msgstr "" -"`partial' 修飾子は `class'、`struct'、`interface'、`void' キーワードの直前で" -"のみ使用できます" - -#: ../mcs/mcs/cs-tokenizer.cs:2568 -msgid "Identifier too long (limit is 512 chars)" -msgstr "識別子が長すぎます(最大512文字)" -#: ../mcs/mcs/cs-tokenizer.cs:2624 +#: mcs/mcs/cs-parser.cs:4429 #, csharp-format msgid "" -"`{0}': Any identifier with double underscores cannot be used when ISO " -"language version mode is specified" +"`{0}': Cannot specify constraints for overrides and explicit interface " +"implementation methods" msgstr "" -"`{0}': ISO言語バージョンモードが指定されている場合は、2文字のアンダーラインで" -"始まる識別子は使用できません" - -#: ../mcs/mcs/cs-tokenizer.cs:2739 -msgid "End-of-file found, '*/' expected" -msgstr "ファイルの終端に到達しましたが、 '*/' が必要です" -#: ../mcs/mcs/cs-tokenizer.cs:2876 -msgid "Keyword, identifier, or string expected after verbatim specifier: @" -msgstr "厳密指定子@の直後には、キーワード、識別子または文字列が必要です" - -#: ../mcs/mcs/cfold.cs:66 -msgid "The operation overflows at compile time in checked mode" -msgstr "チェックモードでコンパイル時オーバーフロー演算を発見しました" - -#: ../mcs/mcs/cfold.cs:693 ../mcs/mcs/cfold.cs:773 -msgid "Division by constant zero" -msgstr "定数0による除算があります" - -#: ../mcs/mcs/class.cs:156 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4470 msgid "" -"The operator `{0}' requires a matching operator `{1}' to also be defined" -msgstr "演算子 `{0}' は対応する演算子 `{1}' の定義も必要とします" +"A partial method cannot define access modifier or any of abstract, extern, " +"new, override, sealed, or virtual modifiers" +msgstr "" -#: ../mcs/mcs/class.cs:351 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4476 msgid "" -"Partial declarations of `{0}' must be all classes, all structs or all " -"interfaces" +"A partial method must be declared within a partial class or partial struct" msgstr "" -"部分的な `{0}' の宣言は全てが、クラス、構造体、インターフェースのいずれかであ" -"ることが必要です" -#: ../mcs/mcs/class.cs:360 +#: mcs/mcs/cs-parser.cs:4499 #, csharp-format -msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" -msgstr "部分的な `{0}' の宣言に、矛盾するアクセス修飾子が含まれています" +msgid "Member modifier `{0}' must precede the member type and name" +msgstr "" -#: ../mcs/mcs/class.cs:416 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 msgid "" -"`{0}': explicit interface declaration can only be declared in a class or " -"struct" +"A params parameter must be the last parameter in a formal parameter list" msgstr "" -"`{0}': インターフェースの明示的な実装は、クラスまたは構造体でのみ宣言できます" -#: ../mcs/mcs/class.cs:455 ../mcs/mcs/decl.cs:2803 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 msgid "" -"A member `{0}' is already defined. Rename this member or use different " -"parameter types" +"An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -"メンバ `{0}' が既に定義されています。このメンバの名前を変更するか、別のパラ" -"メータ型を使用してください" -#: ../mcs/mcs/class.cs:572 -msgid "" -"Cannot specify the `DefaultMember' attribute on type containing an indexer" +#: mcs/mcs/cs-parser.cs:4601 +msgid "The parameter modifier `this' can only be used on the first parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4603 +msgid "Optional parameter cannot precede required parameters" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4625 +msgid "Array type specifier, [], must appear before parameter name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#, fuzzy, csharp-format +msgid "Cannot specify a default value for the `{0}' parameter" msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" -#: ../mcs/mcs/class.cs:855 -#, csharp-format -msgid "`{0}' is already listed in interface list" -msgstr "`{0}'は既にインターフェースのリストに含まれています" +#: mcs/mcs/cs-parser.cs:4666 +msgid "Optional parameter is not valid in this context" +msgstr "" -#: ../mcs/mcs/class.cs:863 -#, csharp-format -msgid "" -"Inconsistent accessibility: base interface `{0}' is less accessible than " -"interface `{1}'" +#: mcs/mcs/cs-parser.cs:4686 +msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -"一貫性の無いアクセス修飾子です: 基底インターフェース `{0}' はインターフェー" -"ス `{1}' よりもアクセスが限定的です" -#: ../mcs/mcs/class.cs:869 -#, csharp-format -msgid "Type `{0}' in interface list is not an interface" +#: mcs/mcs/cs-parser.cs:4689 +msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -"インターフェースリストに含まれる型 `{0}' はインターフェースではありません" -#: ../mcs/mcs/class.cs:871 -#, csharp-format -msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" +#: mcs/mcs/cs-parser.cs:4692 +msgid "A parameter cannot have specified more than one modifier" msgstr "" -"`{0}': クラスには複数の基底クラスを指定することはできません(`{1}' と `{2}')" -#: ../mcs/mcs/class.cs:874 -#, csharp-format -msgid "`{0}': Base class `{1}' must be specified as first" -msgstr "`{0}': 基底クラス `{1}' が先に指定されなければなりません" +#: mcs/mcs/cs-parser.cs:4739 +#, fuzzy +msgid "Cannot specify a default value for a parameter array" +msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" -#: ../mcs/mcs/class.cs:901 -#, csharp-format -msgid "Partial declarations of `{0}' must not specify different base classes" -msgstr "`{0}' の部分的な宣言の間で、別々の基底クラスを指定することはできません" +#: mcs/mcs/cs-parser.cs:4756 +#, fuzzy +msgid "The `params' modifier is not allowed in current context" +msgstr "キーワード `new' は名前空間要素で認められていません" -#: ../mcs/mcs/class.cs:942 -#, csharp-format -msgid "" -"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " -"type parameter substitutions" +#: mcs/mcs/cs-parser.cs:4764 +msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -"`{0}' は `{1}' と `{2}' が型パラメータ置換後に重複する可能性があるため、これ" -"らの両方を実装することはできません" -#: ../mcs/mcs/class.cs:1164 -#, csharp-format -msgid "" -"Partial declarations of `{0}' must have the same type parameter names in the " -"same order" +#: mcs/mcs/cs-parser.cs:4766 +#, fuzzy +msgid "The params parameter cannot be declared as ref or out" +msgstr "abstractメソッド `{0}' はvirtualとすることはできません" + +#: mcs/mcs/cs-parser.cs:4774 +msgid "__arglist is not valid in this context" msgstr "" -"`{0}' の部分的な宣言では、同一の型パラメータ名を同一の順序で定義しなければな" -"りません" -#: ../mcs/mcs/class.cs:1184 +#: mcs/mcs/cs-parser.cs:4791 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer cannot have void type" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" + +#: mcs/mcs/cs-parser.cs:4829 #, csharp-format -msgid "" -"Partial declarations of `{0}' have inconsistent constraints for type " -"parameter `{1}'" +msgid "`{0}': indexer return type cannot be `void'" msgstr "" -"`{0}' の部分的な宣言の間で、型パラメータ `{1}' について一貫性のない制約が含ま" -"れています" -#: ../mcs/mcs/class.cs:1274 -#, csharp-format -msgid "" -"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" +#: mcs/mcs/cs-parser.cs:4832 +msgid "Indexers must have at least one parameter" msgstr "" -"継承されたインターフェース `{0}' で、`{1}' のインターフェース階層構造の循環定" -"義が生じています" -#: ../mcs/mcs/class.cs:1279 -#, csharp-format -msgid "Circular base class dependency involving `{0}' and `{1}'" -msgstr "`{0}' と `{1}' の間で基底クラスの循環依存が生じています" +#: mcs/mcs/cs-parser.cs:4857 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer must have at least one accessor" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: ../mcs/mcs/class.cs:1459 -msgid "" -"Two indexers have different names; the IndexerName attribute must be used " -"with the same name on every indexer within a type" +#: mcs/mcs/cs-parser.cs:4860 +msgid "Semicolon after method or accessor block is not valid" msgstr "" -"2つのインデクサ間で別々の名前が定義されています; 1つの型において、IndexerName" -"属性は全てのインデクサにおいて同一の名前をもたなければなりません" -#: ../mcs/mcs/class.cs:2293 -#, csharp-format -msgid "A static member `{0}' cannot be marked as override, virtual or abstract" +#: mcs/mcs/cs-parser.cs:4862 +msgid "A get or set accessor expected" msgstr "" -"staticメンバ `{0}' はoverride, virtual, abstractとして宣言することはできませ" -"ん" -#: ../mcs/mcs/class.cs:2307 -#, csharp-format -msgid "A member `{0}' marked as override cannot be marked as new or virtual" +#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +msgid "Property accessor already defined" msgstr "" -"overrideとして宣言されたメンバ `{0}' にはnewおよびvirtualを指定できません" -#: ../mcs/mcs/class.cs:2319 -#, csharp-format -msgid "`{0}' cannot be both extern and abstract" -msgstr "`{0}' はexternかつabstractとすることはできません" +#: mcs/mcs/cs-parser.cs:5036 +msgid "User-defined operators cannot return void" +msgstr "" -#: ../mcs/mcs/class.cs:2324 -#, csharp-format -msgid "`{0}' cannot be both abstract and sealed" -msgstr "`{0}' はabstractかつsealedとすることはできません" +#: mcs/mcs/cs-parser.cs:5059 +msgid "Overloadable binary operator expected" +msgstr "" -#: ../mcs/mcs/class.cs:2329 -#, csharp-format -msgid "The abstract method `{0}' cannot be marked virtual" -msgstr "abstractメソッド `{0}' はvirtualとすることはできません" +#: mcs/mcs/cs-parser.cs:5061 +#, fuzzy, csharp-format +msgid "Overloaded unary operator `{0}' takes one parameter" +msgstr "Conditionalメソッド `{0}' ではoutパラメータを指定できません" -#: ../mcs/mcs/class.cs:2335 +#: mcs/mcs/cs-parser.cs:5066 #, csharp-format -msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" +msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -"`{0}' はabstractですが、abstractでないクラス `{1}' の中で宣言されています" -#: ../mcs/mcs/class.cs:2343 -#, csharp-format -msgid "`{0}': virtual or abstract members cannot be private" -msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" +#: mcs/mcs/cs-parser.cs:5069 +msgid "Overloadable unary operator expected" +msgstr "" -#: ../mcs/mcs/class.cs:2350 -#, csharp-format -msgid "`{0}' cannot be sealed because it is not an override" -msgstr "`{0}' はoverrideではないため、sealedとすることはできません" +#: mcs/mcs/cs-parser.cs:5183 +msgid "Class, struct, or interface method must have a return type" +msgstr "クラス、構造体、インターフェースのメソッドには戻り値型が必要です" -#: ../mcs/mcs/class.cs:2436 -#, csharp-format -msgid "`{0}': containing type does not implement interface `{1}'" -msgstr "`{0}' を含む型はインターフェース `{1}' を実装しません" +#: mcs/mcs/cs-parser.cs:5187 +#, fuzzy, csharp-format +msgid "`{0}': static constructor cannot have an access modifier" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: ../mcs/mcs/class.cs:2570 -#, csharp-format -msgid "Type parameter `{0}' has same name as containing type, or method" +#: mcs/mcs/cs-parser.cs:5192 +#, fuzzy, csharp-format +msgid "" +"`{0}': static constructor cannot have an explicit `this' or `base' " +"constructor call" +msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" + +#: mcs/mcs/cs-parser.cs:5241 +msgid "Name of destructor must match name of class" msgstr "" -"型パラメータ `{0}' が、その宣言型あるいはメソッドと同じ名前になっています" -#: ../mcs/mcs/class.cs:2576 -#, csharp-format -msgid "`{0}': member names cannot be the same as their enclosing type" -msgstr "`{0}': メンバ名はその宣言型と同一にはできません" +#: mcs/mcs/cs-parser.cs:5243 +#, fuzzy +msgid "Only class types can contain destructor" +msgstr "`{0}': staticクラスではデストラクタを定義できません" -#: ../mcs/mcs/class.cs:2718 +#: mcs/mcs/cs-parser.cs:5265 +#, fuzzy, csharp-format msgid "" -"The class System.Object cannot have a base class or implement an interface." +"`{0}': An explicit interface implementation of an event must use property " +"syntax" msgstr "" -"クラス System.Object には基底クラスやインターフェースを指定することはできませ" -"ん" +"明示的なインターフェースの宣言で記述された `{0}' は、インターフェースではあり" +"ません" -#: ../mcs/mcs/class.cs:2727 -#, csharp-format -msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" -msgstr "属性 `{0}' はSystem.Attribute から派生したクラスでのみ有効です" +#: mcs/mcs/cs-parser.cs:5298 +msgid "Event in interface cannot have add or remove accessors" +msgstr "" -#: ../mcs/mcs/class.cs:2732 -msgid "" -"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " -"or attribute classes" +#: mcs/mcs/cs-parser.cs:5344 +#, fuzzy, csharp-format +msgid "`{0}': event in interface cannot have an initializer" +msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" + +#: mcs/mcs/cs-parser.cs:5349 +#, fuzzy, csharp-format +msgid "`{0}': abstract event cannot have an initializer" +msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" + +#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#, fuzzy, csharp-format +msgid "`{0}': event property must have both add and remove accessors" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" + +#: mcs/mcs/cs-parser.cs:5371 +msgid "An add or remove accessor expected" msgstr "" -"属性 `System.Diagnostics.ConditionalAttribute' はメソッドまたは属性クラスでの" -"み有効です" -#: ../mcs/mcs/class.cs:2771 -#, csharp-format -msgid "`{0}': Static classes cannot contain user-defined operators" -msgstr "`{0}': staticクラスにはユーザー定義の演算子を含むことはできません" +#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +msgid "Modifiers cannot be placed on event accessor declarations" +msgstr "" -#: ../mcs/mcs/class.cs:2776 -#, csharp-format -msgid "`{0}': Static classes cannot contain destructor" -msgstr "`{0}': staticクラスではデストラクタを定義できません" +#: mcs/mcs/cs-parser.cs:5436 +msgid "An add or remove accessor must have a body" +msgstr "" -#: ../mcs/mcs/class.cs:2781 -#, csharp-format -msgid "`{0}': cannot declare indexers in a static class" -msgstr "`{0}': staticクラスではインデクサを宣言できません" +#: mcs/mcs/cs-parser.cs:5455 +#, fuzzy +msgid "Enums cannot have type parameters" +msgstr "`{0}': staticクラス '{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:2789 -#, csharp-format -msgid "`{0}': Static classes cannot have instance constructors" -msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" +#: mcs/mcs/cs-parser.cs:5755 +msgid "Type parameter declaration must be an identifier not a type" +msgstr "" -#: ../mcs/mcs/class.cs:2795 -#, csharp-format -msgid "`{0}': Extension methods must be declared static" -msgstr "`{0}': 拡張メソッドはstaticで宣言されなければなりません" +#: mcs/mcs/cs-parser.cs:5779 +msgid "Invalid parameter type `void'" +msgstr "" -#: ../mcs/mcs/class.cs:2799 +#: mcs/mcs/cs-parser.cs:5825 #, csharp-format -msgid "`{0}': cannot declare instance members in a static class" -msgstr "`{0}': インスタンス メンバをstaticクラスで宣言することはできません" +msgid "Invalid base type `{0}'" +msgstr "" -#: ../mcs/mcs/class.cs:2808 -#, csharp-format -msgid "`{0}': an abstract class cannot be sealed or static" -msgstr "`{0}': abstractクラスはsealedまたはstaticにはできません" +#: mcs/mcs/cs-parser.cs:5984 +msgid "An element initializer cannot be empty" +msgstr "" -#: ../mcs/mcs/class.cs:2812 -#, csharp-format -msgid "`{0}': a class cannot be both static and sealed" -msgstr "`{0}': クラスはstaticかつsealedとすることはできません" +#: mcs/mcs/cs-parser.cs:6015 +#, fuzzy, csharp-format +msgid "Named argument `{0}' specified multiple times" +msgstr "属性 `{0}' は複数回指定することができません" -#: ../mcs/mcs/class.cs:2849 -#, csharp-format -msgid "Cannot derive from `{0}' because it is a type parameter" -msgstr "`{0}' は型パラメータであるため、ここから派生することはできません" +#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +msgid "An argument is missing" +msgstr "" -#: ../mcs/mcs/class.cs:2856 -#, csharp-format +#: mcs/mcs/cs-parser.cs:6166 +msgid "Array creation must have array size or array initializer" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6183 +msgid "Invalid rank specifier, expecting `,' or `]'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6256 msgid "" -"A generic type cannot derive from `{0}' because it is an attribute class" +"Invalid anonymous type member declarator. Anonymous type members must be a " +"member assignment, simple name or member access expression" msgstr "" -"`{0}' は属性クラスなので、ここからジェネリック型を派生することはできません" -#: ../mcs/mcs/class.cs:2863 -#, csharp-format -msgid "`{0}': Cannot derive from static class `{1}'" -msgstr "`{0}': staticクラス '{1}' から派生することはできません" +#: mcs/mcs/cs-parser.cs:6658 +msgid "All lambda parameters must be typed either explicitly or implicitly" +msgstr "" -#: ../mcs/mcs/class.cs:2866 +#: mcs/mcs/cs-parser.cs:6799 #, csharp-format -msgid "`{0}': cannot derive from sealed class `{1}'" -msgstr "`{0}': sealedクラス `{1}' から派生することはできません" +msgid "Duplicate `{0}' modifier" +msgstr "" -#: ../mcs/mcs/class.cs:2873 -#, csharp-format -msgid "`{0}' cannot derive from special class `{1}'" -msgstr "`{0}' は特別なクラス `{1}' から派生することはできません" +#: mcs/mcs/cs-parser.cs:6803 +msgid "More than one protection modifier specified" +msgstr "" -#: ../mcs/mcs/class.cs:2880 +#: mcs/mcs/cs-parser.cs:6816 +#, fuzzy +msgid "Keyword `new' is not allowed on namespace elements" +msgstr "キーワード `new' は名前空間要素で認められていません" + +#: mcs/mcs/cs-parser.cs:6936 #, csharp-format +msgid "A constraint clause has already been specified for type parameter `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6966 +msgid "The `new()' constraint must be the last constraint specified" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6972 msgid "" -"Inconsistent accessibility: base class `{0}' is less accessible than class `" -"{1}'" +"The `class' or `struct' constraint must be the first constraint specified" msgstr "" -"一貫性の無いアクセス修飾子: 基底クラス `{0}' はクラス `{1}' よりもアクセスが" -"限定的です" -#: ../mcs/mcs/class.cs:2887 +#: mcs/mcs/cs-parser.cs:6976 +msgid "The `new()' constraint cannot be used with the `struct' constraint" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6989 #, csharp-format +msgid "Invalid constraint type `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +msgid "An embedded statement may not be a declaration or labeled statement" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7213 msgid "" -"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " -"from object" +"Syntax error, bad array declarator. To declare a managed array the rank " +"specifier precedes the variable's identifier. To declare a fixed size buffer " +"field, use the fixed keyword before the field type" msgstr "" -"staticクラス `{0}' は型 `{1}' から派生できません。staticクラスはobjectから派" -"生しなければなりません" -#: ../mcs/mcs/class.cs:2895 -#, csharp-format -msgid "Static class `{0}' cannot implement interfaces" -msgstr "staticクラス `{0}' はインターフェースを実装できません" +#: mcs/mcs/cs-parser.cs:7262 +msgid "A stackalloc expression requires [] after type" +msgstr "" -#: ../mcs/mcs/class.cs:3041 -#, csharp-format -msgid "`{0}': Structs cannot have instance field initializers" -msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" +#: mcs/mcs/cs-parser.cs:7468 +msgid "Type and identifier are both required in a foreach statement" +msgstr "" -#: ../mcs/mcs/class.cs:3362 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not an event" -msgstr "`{0}': `{1}' はイベントではないため、オーバーライドできません" +#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +msgid "; expected" +msgstr "" -#: ../mcs/mcs/class.cs:3364 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not a property" -msgstr "`{0}': `{1}' はプロパティではないため、オーバーライドできません" +#: mcs/mcs/cs-parser.cs:7555 +msgid "Expression expected after yield return" +msgstr "" -#: ../mcs/mcs/class.cs:3366 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not a method" -msgstr "`{0}': `{1}' はメソッドではないため、オーバーライドできません" +#: mcs/mcs/cs-parser.cs:7598 +msgid "Expected catch or finally" +msgstr "" -#: ../mcs/mcs/class.cs:3368 -#, csharp-format -msgid "`{0}' is marked as an override but no suitable {1} found to override" +#: mcs/mcs/cs-parser.cs:7618 +msgid "Try statement already has an empty catch block" msgstr "" -"`{0}' はoverrideとして宣言されていますが、オーバーライドすべき{1}が見つかりま" -"せん" -#: ../mcs/mcs/class.cs:3407 -#, csharp-format +#: mcs/mcs/cs-parser.cs:7651 msgid "" -"`{0}': cannot override inherited member `{1}' because it is not marked " -"virtual, abstract or override" +"A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -"`{0}': 継承しようとするメンバ `{1}' は、virtual, abstractあるいはoverrideとし" -"て宣言されていないので、オーバーライドすることはできません" -#: ../mcs/mcs/class.cs:3416 -#, csharp-format -msgid "`{0}': cannot override inherited member `{1}' because it is sealed" +#: mcs/mcs/cs-parser.cs:11367 +msgid "Expecting `;'" msgstr "" -"`{0}': 継承しようとするメンバ `{1}' はsealedであるため、オーバーライドできま" -"せん" -#: ../mcs/mcs/class.cs:3434 +#: mcs/mcs/cs-parser.cs:11375 #, csharp-format -msgid "`{0}': type must be `{1}' to match overridden member `{2}'" -msgstr "`{0}': オーバーライドされたメンバ `{2}' に適合するためには、型が `{1}' でなければなりません" +msgid "The parameter modifier `{0}' is not valid in this context" +msgstr "" -#: ../mcs/mcs/class.cs:3438 -#, csharp-format -msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" -msgstr "`{0}': オーバーライドされたメンバ `{2}' に適合するには、戻り値型は `{1}' でなければなりません" +#: mcs/mcs/cs-parser.cs:11381 +#, fuzzy, csharp-format +msgid "Duplicate parameter modifier `{0}'" +msgstr "属性の引数名 '{0}' が重複しています" -#: ../mcs/mcs/class.cs:3460 -#, csharp-format -msgid "`{0}' hides inherited abstract member `{1}'" -msgstr "`{0}' は継承されるabstractメンバ `{1}' を隠蔽してしまいます" +#: mcs/mcs/cs-parser.cs:11387 +msgid "Type expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11392 +msgid "Unsafe code requires the `unsafe' command line option to be specified" +msgstr "" -#: ../mcs/mcs/class.cs:3520 +#: mcs/mcs/cs-parser.cs:11402 +msgid "Named arguments must appear after the positional arguments" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11493 +msgid "Syntax error, " +msgstr "" + +#: mcs/mcs/cs-parser.cs:11547 +msgid "Parsing error" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11553 +msgid "Internal compiler error during parsing" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11564 #, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"indexer `{1}'" -msgstr "一貫性の無いアクセス制限: パラメータ型 `{0}' はインデクサ '{1}' よりもアクセスが限られています" +msgid "{0}: `{1}' is a keyword" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11690 +#, fuzzy, csharp-format +msgid "Identifier expected, `{0}' is a keyword" +msgstr "識別子が必要です: {0}" -#: ../mcs/mcs/class.cs:3524 +#: mcs/mcs/cs-parser.cs:11704 #, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"operator `{1}'" -msgstr "一貫性の無いアクセス制限: パラメータ型 `{0}' は演算子 '{1}' よりもアクセスが限られています" +msgid "{1} `{0}'" +msgstr "" -#: ../mcs/mcs/class.cs:3528 +#: mcs/mcs/cs-parser.cs:11706 #, csharp-format +msgid "{2} `{0}', expecting {1}" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:760 msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"method `{1}'" -msgstr "一貫性の無いアクセス制限: パラメータ型 `{0}' はメソッド '{1}' よりもアクセスが限られています" +"The `partial' modifier can be used only immediately before `class', " +"`struct', `interface', or `void' keyword" +msgstr "" +"`partial' 修飾子は `class'、`struct'、`interface'、`void' キーワードの直前で" +"のみ使用できます" -#: ../mcs/mcs/class.cs:3548 -#, csharp-format -msgid "`{0}' in explicit interface declaration is not an interface" -msgstr "明示的なインターフェース実装で記述された `{0}' は、インターフェースではありません" +#: mcs/mcs/cs-tokenizer.cs:1395 mcs/mcs/cs-tokenizer.cs:1462 +msgid "Invalid number" +msgstr "無効な数値です" -#: ../mcs/mcs/class.cs:3587 +#: mcs/mcs/cs-tokenizer.cs:1647 #, csharp-format -msgid "A partial method `{0}' cannot explicitly implement an interface" -msgstr "部分メソッド `{0}' はインターフェースを明示的に実装できません" +msgid "Unrecognized escape sequence `\\{0}'" +msgstr "認識できないエスケープシーケンス `\\{0}' です" -#: ../mcs/mcs/class.cs:3595 -#, csharp-format -msgid "'{0}' in explicit interface declaration is not an interface" -msgstr "明示的なインターフェースの宣言で記述された `{0}' は、インターフェースではありません" +#: mcs/mcs/cs-tokenizer.cs:1666 +msgid "Unrecognized escape sequence" +msgstr "認識できないエスケープシーケンスです" + +#: mcs/mcs/cs-tokenizer.cs:1887 +#, fuzzy +msgid "Missing identifier to pre-processor directive" +msgstr "プリプロセッサ指令の識別子がありません" -#: ../mcs/mcs/class.cs:3614 +#: mcs/mcs/cs-tokenizer.cs:1897 mcs/mcs/cs-tokenizer.cs:1901 #, csharp-format -msgid "" -"`{0}' is marked as an external but has no DllImport attribute. Consider " -"adding a DllImport attribute to specify the external implementation" -msgstr "`{0}' はexternalとして宣言されていますが、DllImport属性をもちません。DllImport属性を追加して、外部実装を指定するようにしてください" +msgid "Identifier expected: {0}" +msgstr "識別子が必要です: {0}" + +#: mcs/mcs/cs-tokenizer.cs:2373 +#, fuzzy +msgid "Integral constant is too large" +msgstr "数値定数が長すぎます" -#: ../mcs/mcs/class.cs:3631 +#: mcs/mcs/cs-tokenizer.cs:2378 +msgid "Invalid preprocessor directive" +msgstr "無効なプリプロセッサ指令です" + +#: mcs/mcs/cs-tokenizer.cs:2385 #, csharp-format +msgid "Unexpected processor directive ({0})" +msgstr "予期しないプリプロセッサ指令です({0})" + +#: mcs/mcs/cs-tokenizer.cs:2391 msgid "" -"`{0}': cannot change access modifiers when overriding `{1}' inherited member " -"`{2}'" -msgstr "`{0}': `{1}' の継承されたメンバー `{2}' をオーバーライドするとき、アクセス修飾子は変更できません" +"Cannot define or undefine preprocessor symbols after first token in file" +msgstr "" +"ファイル中の最初のトークンの出現後は、プリプロセッサシンボルを定義または定義" +"解除することはできません" -#: ../mcs/mcs/class.cs:3724 +#: mcs/mcs/cs-tokenizer.cs:2397 msgid "" -"The DllImport attribute must be specified on a method marked `static' and " -"`extern'" -msgstr "`static'かつ`extern'で宣言されたメソッドには、DllImport属性が指定されなければなりません" +"Preprocessor directives must appear as the first non-whitespace character on " +"a line" +msgstr "" +"プリプロセッサ指令は、1行の中で、最初の空白でない文字として出現しなければなり" +"ません" -#: ../mcs/mcs/class.cs:3787 -#, csharp-format -msgid "`{0}': A partial method parameters cannot use `out' modifier" -msgstr "`{0}': 部分メソッドのパラメータで`out'修飾子は使用できません" +#: mcs/mcs/cs-tokenizer.cs:2402 +msgid "Single-line comment or end-of-line expected" +msgstr "1行コメントまたは行末が必要です" -#: ../mcs/mcs/class.cs:3867 -#, csharp-format -msgid "" -"Conditional not valid on `{0}' because it is a constructor, destructor, " -"operator or explicit interface implementation" -msgstr "Conditionalは コンストラクタ、デストラクタ、演算子または明示的なインターフェースの実装である `{0}' では無効です" +#: mcs/mcs/cs-tokenizer.cs:2435 mcs/mcs/cs-tokenizer.cs:3431 +msgid "Expected `#endif' directive" +msgstr "`#endif' 指令が必要です" -#: ../mcs/mcs/class.cs:3924 -msgid "Do not override object.Finalize. Instead, provide a destructor" -msgstr "object.Finalizeをオーバーライドせず、代わりにデストラクタを提供してください" +#: mcs/mcs/cs-tokenizer.cs:2468 mcs/mcs/cs-tokenizer.cs:2489 +#: mcs/mcs/cs-tokenizer.cs:2520 mcs/mcs/cs-tokenizer.cs:3429 +msgid "#endregion directive expected" +msgstr "#endregion指令が必要です" -#: ../mcs/mcs/class.cs:4096 -#, csharp-format -msgid "Program `{0}' has more than one entry point defined: `{1}'" -msgstr "プログラム `{0}' には複数のエントリポイントが定義されています: `{1}'" +#: mcs/mcs/cs-tokenizer.cs:2567 +msgid "Wrong preprocessor directive" +msgstr "正しくないプリプロセッサ指令です" -#: ../mcs/mcs/class.cs:4127 +#: mcs/mcs/cs-tokenizer.cs:2579 #, csharp-format -msgid "Conditional not valid on `{0}' because its return type is not void" -msgstr "Conditionalは戻り値型がvoidでない `{0}' では無効です" +msgid "#error: '{0}'" +msgstr "#error: `{0}'" -#: ../mcs/mcs/class.cs:4132 -#, csharp-format -msgid "Conditional not valid on `{0}' because it is an override method" -msgstr "Conditionalはオーバーライドメソッドである `{0}' では無効です" +#: mcs/mcs/cs-tokenizer.cs:2598 +msgid "The line number specified for #line directive is missing or invalid" +msgstr "#line指令で指定される行番号が無いか、または無効です" -#: ../mcs/mcs/class.cs:4137 -msgid "Conditional not valid on interface members" -msgstr "Conditionalはインターフェースメンバでは無効です" +#: mcs/mcs/cs-tokenizer.cs:2625 mcs/mcs/cs-tokenizer.cs:3243 +msgid "Newline in constant" +msgstr "定数の中に改行文字が含まれています" -#: ../mcs/mcs/class.cs:4143 -#, csharp-format -msgid "Conditional member `{0}' cannot implement interface member `{1}'" -msgstr "Conditionalメンバ `{0}' はインターフェースメンバ `{1}' を実装できません" +#: mcs/mcs/cs-tokenizer.cs:2636 +msgid "Unterminated string literal" +msgstr "文字列に終端がありません" -#: ../mcs/mcs/class.cs:4150 -#, csharp-format -msgid "Conditional method `{0}' cannot have an out parameter" -msgstr "Conditionalメソッド `{0}' ではoutパラメータを指定できません" +#: mcs/mcs/cs-tokenizer.cs:2705 +msgid "Identifier too long (limit is 512 chars)" +msgstr "識別子が長すぎます(最大512文字)" -#: ../mcs/mcs/class.cs:4218 -#, csharp-format -msgid "`{0}': Extension methods cannot be defined in a nested class" -msgstr "`{0}': 拡張メソッドはネストしたクラスの中では定義できません" +#: mcs/mcs/cs-tokenizer.cs:3092 +msgid "End-of-file found, '*/' expected" +msgstr "ファイルの終端に到達しましたが、 '*/' が必要です" + +#: mcs/mcs/cs-tokenizer.cs:3201 +msgid "Keyword, identifier, or string expected after verbatim specifier: @" +msgstr "厳密指定子@の直後には、キーワード、識別子または文字列が必要です" + +#: mcs/mcs/cs-tokenizer.cs:3217 +#, fuzzy, csharp-format +msgid "Unexpected character `{0}'" +msgstr "`{0}' が必要です" -#: ../mcs/mcs/class.cs:4223 -#, csharp-format -msgid "" -"`{0}': Extension methods cannot be declared without a reference to System." -"Core.dll assembly. Add the assembly reference or remove `this' modifer from " -"the first parameter" -msgstr "`{0}': 拡張メソッドはSystem.Core.dllアセンブリへの参照なしでは宣言できません。アセンブリ参照を追加するか、または最初のパラメータから `this' 修飾子を取り除いてください。" +#: mcs/mcs/cs-tokenizer.cs:3238 +msgid "Empty character literal" +msgstr "" -#: ../mcs/mcs/class.cs:4237 -#, csharp-format -msgid "`{0}': Extension methods must be defined in a non-generic static class" +#: mcs/mcs/cs-tokenizer.cs:3258 +msgid "Too many characters in character literal" msgstr "" -#: ../mcs/mcs/class.cs:4293 +#: mcs/mcs/cfold.cs:84 +msgid "The operation overflows at compile time in checked mode" +msgstr "チェックモードでコンパイル時オーバーフロー演算を発見しました" + +#: mcs/mcs/cfold.cs:764 mcs/mcs/cfold.cs:849 +msgid "Division by constant zero" +msgstr "定数0による除算があります" + +#: mcs/mcs/class.cs:371 #, csharp-format msgid "" -"A partial method `{0}' implementation is missing a partial method declaration" +"Partial declarations of `{0}' must be all classes, all structs or all " +"interfaces" msgstr "" +"部分的な `{0}' の宣言は全てが、クラス、構造体、インターフェースのいずれかであ" +"ることが必要です" -#: ../mcs/mcs/class.cs:4327 +#: mcs/mcs/class.cs:380 #, csharp-format -msgid "Method or delegate cannot return type `{0}'" -msgstr "" +msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" +msgstr "部分的な `{0}' の宣言に、矛盾するアクセス修飾子が含まれています" -#: ../mcs/mcs/class.cs:4412 +#: mcs/mcs/class.cs:433 #, csharp-format -msgid "`{0}': Struct constructors cannot call base constructors" +msgid "" +"`{0}': explicit interface declaration can only be declared in a class or " +"struct" msgstr "" +"`{0}': インターフェースの明示的な実装は、クラスまたは構造体でのみ宣言できます" -#: ../mcs/mcs/class.cs:4445 +#: mcs/mcs/class.cs:470 mcs/mcs/membercache.cs:1347 #, csharp-format -msgid "Constructor `{0}' cannot call itself" +msgid "" +"A member `{0}' is already defined. Rename this member or use different " +"parameter types" msgstr "" +"メンバ `{0}' が既に定義されています。このメンバの名前を変更するか、別のパラ" +"メータ型を使用してください" -#: ../mcs/mcs/class.cs:4570 -#, csharp-format -msgid "`{0}': The static constructor must be parameterless" -msgstr "" +#: mcs/mcs/class.cs:578 +msgid "" +"Cannot specify the `DefaultMember' attribute on type containing an indexer" +msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" -#: ../mcs/mcs/class.cs:4590 -msgid "Structs cannot contain explicit parameterless constructors" +#: mcs/mcs/class.cs:584 +msgid "The RequiredAttribute attribute is not permitted on C# types" msgstr "" -#: ../mcs/mcs/class.cs:4642 -#, csharp-format -msgid "" -"`{0}': A class with the ComImport attribute cannot have a user-defined " -"constructor" -msgstr "" +#: mcs/mcs/class.cs:855 +#, fuzzy, csharp-format +msgid "Class `{0}' cannot derive from the dynamic type" +msgstr "`{0}' は特別なクラス `{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:4934 +#: mcs/mcs/class.cs:872 #, csharp-format -msgid "`{0}' is an accessor not found in interface member `{1}{2}'" -msgstr "" +msgid "`{0}' is already listed in interface list" +msgstr "`{0}'は既にインターフェースのリストに含まれています" -#: ../mcs/mcs/class.cs:4940 +#: mcs/mcs/class.cs:880 #, csharp-format msgid "" -"`{0}.{1}' in explicit interface declaration is not a member of interface" +"Inconsistent accessibility: base interface `{0}' is less accessible than " +"interface `{1}'" msgstr "" +"一貫性の無いアクセス修飾子です: 基底インターフェース `{0}' はインターフェー" +"ス `{1}' よりもアクセスが限定的です" -#: ../mcs/mcs/class.cs:4947 +#: mcs/mcs/class.cs:886 #, csharp-format -msgid "" -"`{0}' explicit method implementation cannot implement `{1}' because it is an " -"accessor" +msgid "Type `{0}' in interface list is not an interface" msgstr "" +"インターフェースリストに含まれる型 `{0}' はインターフェースではありません" -#: ../mcs/mcs/class.cs:4957 +#: mcs/mcs/class.cs:888 #, csharp-format -msgid "Method `{0}' cannot implement interface accessor `{1}.{2}'" +msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" msgstr "" +"`{0}': クラスには複数の基底クラスを指定することはできません(`{1}' と `{2}')" -#: ../mcs/mcs/class.cs:4964 +#: mcs/mcs/class.cs:891 #, csharp-format -msgid "" -"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " -"an explicit interface implementation" -msgstr "" +msgid "`{0}': Base class `{1}' must be specified as first" +msgstr "`{0}': 基底クラス `{1}' が先に指定されなければなりません" -#: ../mcs/mcs/class.cs:4971 +#: mcs/mcs/class.cs:915 #, csharp-format -msgid "" -"Accessor `{0}' must be declared public to implement interface member `{1}'" -msgstr "" +msgid "Partial declarations of `{0}' must not specify different base classes" +msgstr "`{0}' の部分的な宣言の間で、別々の基底クラスを指定することはできません" -#: ../mcs/mcs/class.cs:4995 +#: mcs/mcs/class.cs:996 #, csharp-format msgid "" -"`{0}': the explicit interface implementation cannot introduce the params " -"modifier" -msgstr "" +"The operator `{0}' requires a matching operator `{1}' to also be defined" +msgstr "演算子 `{0}' は対応する演算子 `{1}' の定義も必要とします" -#: ../mcs/mcs/class.cs:5291 +#: mcs/mcs/class.cs:1021 #, csharp-format -msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgid "`{0}' clashes with a predefined namespace" msgstr "" -#: ../mcs/mcs/class.cs:5301 -msgid "Inconsistent accessibility: property type `" +#: mcs/mcs/class.cs:1150 +#, csharp-format +msgid "" +"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" msgstr "" +"継承されたインターフェース `{0}' で、`{1}' のインターフェース階層構造の循環定" +"義が生じています" -#: ../mcs/mcs/class.cs:5306 -msgid "Inconsistent accessibility: indexer return type `" -msgstr "" +#: mcs/mcs/class.cs:1156 +#, csharp-format +msgid "Circular base class dependency involving `{0}' and `{1}'" +msgstr "`{0}' と `{1}' の間で基底クラスの循環依存が生じています" -#: ../mcs/mcs/class.cs:5312 ../mcs/mcs/class.cs:5317 -#: ../mcs/mcs/delegate.cs:220 -msgid "Inconsistent accessibility: return type `" +#: mcs/mcs/class.cs:1183 +#, csharp-format +msgid "" +"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " +"type parameter substitutions" msgstr "" +"`{0}' は `{1}' と `{2}' が型パラメータ置換後に重複する可能性があるため、これ" +"らの両方を実装することはできません" -#: ../mcs/mcs/class.cs:5322 -msgid "Inconsistent accessibility: field type `" +#: mcs/mcs/class.cs:1223 +#, csharp-format +msgid "" +"The type `{0}' is defined in an assembly that is not referenced. Consider " +"adding a reference to assembly `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:5335 +#: mcs/mcs/class.cs:1339 #, csharp-format -msgid "Field or property cannot be of type `{0}'" +msgid "" +"Partial declarations of `{0}' must have the same type parameter names in the " +"same order" msgstr "" +"`{0}' の部分的な宣言では、同一の型パラメータ名を同一の順序で定義しなければな" +"りません" -#: ../mcs/mcs/class.cs:5363 +#: mcs/mcs/class.cs:1346 +#, fuzzy, csharp-format msgid "" -"The modifier 'abstract' is not valid on fields. Try using a property instead" +"Partial declarations of `{0}' must have the same type parameter variance " +"modifiers" msgstr "" +"`{0}' の部分的な宣言では、同一の型パラメータ名を同一の順序で定義しなければな" +"りません" -#: ../mcs/mcs/class.cs:5378 +#: mcs/mcs/class.cs:1371 +#, csharp-format msgid "" -"The FieldOffset attribute can only be placed on members of types marked with " -"the StructLayout(LayoutKind.Explicit)" +"Partial declarations of `{0}' have inconsistent constraints for type " +"parameter `{1}'" msgstr "" +"`{0}' の部分的な宣言の間で、型パラメータ `{1}' について一貫性のない制約が含ま" +"れています" -#: ../mcs/mcs/class.cs:5383 -msgid "The FieldOffset attribute is not allowed on static or const fields" -msgstr "" +#: mcs/mcs/class.cs:1510 +#, fuzzy, csharp-format +msgid "`{0}': cannot implement a dynamic interface `{1}'" +msgstr "`{0}' を含む型はインターフェース `{1}' を実装しません" -#: ../mcs/mcs/class.cs:5390 +#: mcs/mcs/class.cs:1623 msgid "" -"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " -"'fixed' field modifier instead" +"Two indexers have different names; the IndexerName attribute must be used " +"with the same name on every indexer within a type" msgstr "" +"2つのインデクサ間で別々の名前が定義されています; 1つの型において、IndexerName" +"属性は全てのインデクサにおいて同一の名前をもたなければなりません" -#: ../mcs/mcs/class.cs:5478 +#: mcs/mcs/class.cs:1957 #, csharp-format -msgid "" -"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " -"must have a FieldOffset attribute" +msgid "A static member `{0}' cannot be marked as override, virtual or abstract" msgstr "" +"staticメンバ `{0}' はoverride, virtual, abstractとして宣言することはできませ" +"ん" -#: ../mcs/mcs/class.cs:5487 +#: mcs/mcs/class.cs:1964 #, csharp-format -msgid "`{0}': cannot declare variables of static types" +msgid "A member `{0}' marked as override cannot be marked as new or virtual" msgstr "" +"overrideとして宣言されたメンバ `{0}' にはnewおよびvirtualを指定できません" -#: ../mcs/mcs/class.cs:5605 +#: mcs/mcs/class.cs:1976 #, csharp-format -msgid "" -"`{0}': Fixed size buffers type must be one of the following: bool, byte, " -"short, int, long, char, sbyte, ushort, uint, ulong, float or double" -msgstr "" +msgid "`{0}' cannot be both extern and abstract" +msgstr "`{0}' はexternかつabstractとすることはできません" -#: ../mcs/mcs/class.cs:5627 +#: mcs/mcs/class.cs:1981 #, csharp-format -msgid "`{0}': Fixed size buffer fields may only be members of structs" -msgstr "" +msgid "`{0}' cannot be both abstract and sealed" +msgstr "`{0}' はabstractかつsealedとすることはできません" -#: ../mcs/mcs/class.cs:5643 +#: mcs/mcs/class.cs:1986 #, csharp-format -msgid "`{0}': Fixed size buffers must have a length greater than zero" -msgstr "" +msgid "The abstract method `{0}' cannot be marked virtual" +msgstr "abstractメソッド `{0}' はvirtualとすることはできません" -#: ../mcs/mcs/class.cs:5650 +#: mcs/mcs/class.cs:1992 #, csharp-format -msgid "" -"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" msgstr "" +"`{0}' はabstractですが、abstractでないクラス `{1}' の中で宣言されています" -#: ../mcs/mcs/class.cs:5843 +#: mcs/mcs/class.cs:2000 #, csharp-format -msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" -msgstr "" +msgid "`{0}': virtual or abstract members cannot be private" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: ../mcs/mcs/class.cs:5855 +#: mcs/mcs/class.cs:2007 #, csharp-format -msgid "`{0}': A volatile field cannot be of the type `{1}'" -msgstr "" +msgid "`{0}' cannot be sealed because it is not an override" +msgstr "`{0}' はoverrideではないため、sealedとすることはできません" -#: ../mcs/mcs/class.cs:5860 +#: mcs/mcs/class.cs:2054 #, csharp-format -msgid "`{0}': A field cannot be both volatile and readonly" -msgstr "" +msgid "`{0}': containing type does not implement interface `{1}'" +msgstr "`{0}' を含む型はインターフェース `{1}' を実装しません" -#: ../mcs/mcs/class.cs:6049 +#: mcs/mcs/class.cs:2230 #, csharp-format -msgid "" -"Attribute `{0}' is not valid on property or event accessors. It is valid on `" -"{1}' declarations only" +msgid "Type parameter `{0}' has same name as containing type, or method" msgstr "" +"型パラメータ `{0}' が、その宣言型あるいはメソッドと同じ名前になっています" -#: ../mcs/mcs/class.cs:6149 ../mcs/mcs/decl.cs:2792 +#: mcs/mcs/class.cs:2238 #, csharp-format -msgid "A member `{0}' is already reserved" -msgstr "" +msgid "`{0}': member names cannot be the same as their enclosing type" +msgstr "`{0}': メンバ名はその宣言型と同一にはできません" -#: ../mcs/mcs/class.cs:6352 -#, csharp-format -msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +#: mcs/mcs/class.cs:2404 +msgid "" +"The class System.Object cannot have a base class or implement an interface." msgstr "" +"クラス System.Object には基底クラスやインターフェースを指定することはできませ" +"ん" -#: ../mcs/mcs/class.cs:6369 +#: mcs/mcs/class.cs:2412 #, csharp-format +msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" +msgstr "属性 `{0}' はSystem.Attribute から派生したクラスでのみ有効です" + +#: mcs/mcs/class.cs:2417 msgid "" -"`{0}': accessibility modifiers may not be used on accessors in an interface" +"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " +"or attribute classes" msgstr "" +"属性 `System.Diagnostics.ConditionalAttribute' はメソッドまたは属性クラスでの" +"み有効です" -#: ../mcs/mcs/class.cs:6373 +#: mcs/mcs/class.cs:2455 #, csharp-format -msgid "`{0}': abstract properties cannot have private accessors" -msgstr "" +msgid "`{0}': Static classes cannot contain user-defined operators" +msgstr "`{0}': staticクラスにはユーザー定義の演算子を含むことはできません" -#: ../mcs/mcs/class.cs:6435 +#: mcs/mcs/class.cs:2460 #, csharp-format -msgid "" -"The accessibility modifier of the `{0}' accessor must be more restrictive " -"than the modifier of the property or indexer `{1}'" -msgstr "" +msgid "`{0}': Static classes cannot contain destructor" +msgstr "`{0}': staticクラスではデストラクタを定義できません" -#: ../mcs/mcs/class.cs:6500 +#: mcs/mcs/class.cs:2465 #, csharp-format -msgid "" -"`{0}': Cannot specify accessibility modifiers for both accessors of the " -"property or indexer" -msgstr "" +msgid "`{0}': cannot declare indexers in a static class" +msgstr "`{0}': staticクラスではインデクサを宣言できません" -#: ../mcs/mcs/class.cs:6509 +#: mcs/mcs/class.cs:2473 #, csharp-format -msgid "" -"`{0}': accessibility modifiers on accessors may only be used if the property " -"or indexer has both a get and a set accessor" -msgstr "" +msgid "`{0}': Static classes cannot have instance constructors" +msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" -#: ../mcs/mcs/class.cs:6571 +#: mcs/mcs/class.cs:2479 #, csharp-format -msgid "" -"`{0}.get': cannot override because `{1}' does not have an overridable get " -"accessor" -msgstr "" +msgid "`{0}': Extension methods must be declared static" +msgstr "`{0}': 拡張メソッドはstaticで宣言されなければなりません" -#: ../mcs/mcs/class.cs:6586 +#: mcs/mcs/class.cs:2483 #, csharp-format -msgid "" -"`{0}.set': cannot override because `{1}' does not have an overridable set " -"accessor" -msgstr "" +msgid "`{0}': cannot declare instance members in a static class" +msgstr "`{0}': インスタンス メンバをstaticクラスで宣言することはできません" -#: ../mcs/mcs/class.cs:6783 +#: mcs/mcs/class.cs:2492 #, csharp-format -msgid "" -"Automatically implemented property `{0}' cannot be used inside a type with " -"an explicit StructLayout attribute" -msgstr "" +msgid "`{0}': an abstract class cannot be sealed or static" +msgstr "`{0}': abstractクラスはsealedまたはstaticにはできません" -#: ../mcs/mcs/class.cs:7151 +#: mcs/mcs/class.cs:2496 #, csharp-format -msgid "`{0}': abstract event cannot have an initializer" -msgstr "" +msgid "`{0}': a class cannot be both static and sealed" +msgstr "`{0}': クラスはstaticかつsealedとすることはできません" -#: ../mcs/mcs/class.cs:7337 -#, csharp-format -msgid "`{0}': event must be of a delegate type" -msgstr "" +#: mcs/mcs/class.cs:2526 +#, fuzzy, csharp-format +msgid "`{0}': Cannot derive from type parameter `{1}'" +msgstr "`{0}': staticクラス '{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:7544 +#: mcs/mcs/class.cs:2530 +#, csharp-format msgid "" -"The `IndexerName' attribute is valid only on an indexer that is not an " -"explicit interface member declaration" -msgstr "" - -#: ../mcs/mcs/class.cs:7551 -msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +"A generic type cannot derive from `{0}' because it is an attribute class" msgstr "" +"`{0}' は属性クラスなので、ここからジェネリック型を派生することはできません" -#: ../mcs/mcs/class.cs:7753 +#: mcs/mcs/class.cs:2534 #, csharp-format -msgid "User-defined operator `{0}' must be declared static and public" -msgstr "" +msgid "`{0}': Cannot derive from static class `{1}'" +msgstr "`{0}': staticクラス '{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:7784 -msgid "" -"User-defined operator cannot take an object of the enclosing type and " -"convert to an object of the enclosing type" -msgstr "" +#: mcs/mcs/class.cs:2538 +#, fuzzy, csharp-format +msgid "`{0}': cannot derive from sealed type `{1}'" +msgstr "`{0}': sealedクラス `{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:7795 -msgid "User-defined conversion must convert to or from the enclosing type" +#: mcs/mcs/class.cs:2541 +#, csharp-format +msgid "" +"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " +"from object" msgstr "" +"staticクラス `{0}' は型 `{1}' から派生できません。staticクラスはobjectから派" +"生しなければなりません" + +#: mcs/mcs/class.cs:2548 +#, csharp-format +msgid "`{0}' cannot derive from special class `{1}'" +msgstr "`{0}' は特別なクラス `{1}' から派生することはできません" -#: ../mcs/mcs/class.cs:7804 +#: mcs/mcs/class.cs:2556 #, csharp-format msgid "" -"User-defined conversion `{0}' cannot convert to or from an interface type" +"Inconsistent accessibility: base class `{0}' is less accessible than class `" +"{1}'" msgstr "" +"一貫性の無いアクセス修飾子: 基底クラス `{0}' はクラス `{1}' よりもアクセスが" +"限定的です" -#: ../mcs/mcs/class.cs:7811 +#: mcs/mcs/class.cs:2564 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a base class" -msgstr "" +msgid "Static class `{0}' cannot implement interfaces" +msgstr "staticクラス `{0}' はインターフェースを実装できません" -#: ../mcs/mcs/class.cs:7817 +#: mcs/mcs/class.cs:2683 mcs/mcs/class.cs:2694 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" msgstr "" -#: ../mcs/mcs/class.cs:7825 -msgid "" -"Overloaded shift operator must have the type of the first operand be the " -"containing type, and the type of the second operand must be int" -msgstr "" +#: mcs/mcs/class.cs:2784 +#, csharp-format +msgid "`{0}': Structs cannot have instance field initializers" +msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" -#: ../mcs/mcs/class.cs:7834 -msgid "" -"The return type for ++ or -- operator must be the containing type or derived " -"from the containing type" +#: mcs/mcs/class.cs:2965 +#, fuzzy, csharp-format +msgid "Do not override `{0}'. Use destructor syntax instead" msgstr "" +"`{0}' を直接使用せず、代わりにパラメータ修飾子 `this' を使用してください" -#: ../mcs/mcs/class.cs:7839 -msgid "The parameter type for ++ or -- operator must be the containing type" +#: mcs/mcs/class.cs:2968 +#, csharp-format +msgid "`{0}' is marked as an override but no suitable {1} found to override" msgstr "" +"`{0}' はoverrideとして宣言されていますが、オーバーライドすべき{1}が見つかりま" +"せん" -#: ../mcs/mcs/class.cs:7846 -msgid "The parameter type of a unary operator must be the containing type" -msgstr "" +#: mcs/mcs/class.cs:2974 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not an event" +msgstr "`{0}': `{1}' はイベントではないため、オーバーライドできません" -#: ../mcs/mcs/class.cs:7854 -msgid "The return type of operator True or False must be bool" -msgstr "" +#: mcs/mcs/class.cs:2977 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not a property" +msgstr "`{0}': `{1}' はプロパティではないため、オーバーライドできません" -#: ../mcs/mcs/class.cs:7867 -msgid "One of the parameters of a binary operator must be the containing type" -msgstr "" +#: mcs/mcs/class.cs:2980 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not a method" +msgstr "`{0}': `{1}' はメソッドではないため、オーバーライドできません" -#: ../mcs/mcs/codegen.cs:122 -msgid "Assembly generation failed -- Referenced assembly '" -msgstr "" +#: mcs/mcs/class.cs:3036 mcs/mcs/field.cs:187 +#, csharp-format +msgid "`{0}' hides inherited abstract member `{1}'" +msgstr "`{0}' は継承されるabstractメンバ `{1}' を隠蔽してしまいます" -#: ../mcs/mcs/codegen.cs:140 -msgid "Could not access the key inside the container `" +#: mcs/mcs/class.cs:3060 +#, csharp-format +msgid "" +"`{0}': cannot override inherited member `{1}' because it is not marked " +"virtual, abstract or override" msgstr "" +"`{0}': 継承しようとするメンバ `{1}' は、virtual, abstractあるいはoverrideとし" +"て宣言されていないので、オーバーライドすることはできません" -#: ../mcs/mcs/codegen.cs:148 -msgid "Could not use the specified key to strongname the assembly." +#: mcs/mcs/class.cs:3068 +#, csharp-format +msgid "`{0}': cannot override inherited member `{1}' because it is sealed" msgstr "" +"`{0}': 継承しようとするメンバ `{1}' はsealedであるため、オーバーライドできま" +"せん" -#: ../mcs/mcs/codegen.cs:176 -msgid "" -"Could not find the symbol writer assembly (Mono.CompilerServices." -"SymbolWriter.dll)" +#: mcs/mcs/class.cs:3077 +#, csharp-format +msgid "`{0}': type must be `{1}' to match overridden member `{2}'" msgstr "" +"`{0}': オーバーライドされたメンバ `{2}' に適合するためには、型が `{1}' でなけ" +"ればなりません" -#: ../mcs/mcs/codegen.cs:181 +#: mcs/mcs/class.cs:3080 #, csharp-format -msgid "Unexpected debug information initialization error `{0}'" +msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" msgstr "" +"`{0}': オーバーライドされたメンバ `{2}' に適合するには、戻り値型は `{1}' でな" +"ければなりません" -#: ../mcs/mcs/codegen.cs:199 -msgid "Couldn't delay-sign the assembly with the '" -msgstr "" +#: mcs/mcs/class.cs:3152 +#, csharp-format +msgid "A partial method `{0}' cannot explicitly implement an interface" +msgstr "部分メソッド `{0}' はインターフェースを明示的に実装できません" -#: ../mcs/mcs/codegen.cs:204 ../mcs/mcs/codegen.cs:208 -msgid "Could not write to file `" +#: mcs/mcs/class.cs:3160 +#, fuzzy, csharp-format +msgid "The type `{0}' in explicit interface declaration is not an interface" msgstr "" +"明示的なインターフェース実装で記述された `{0}' は、インターフェースではありま" +"せん" -#: ../mcs/mcs/codegen.cs:822 +#: mcs/mcs/class.cs:3191 #, csharp-format -msgid "`{0}': not all code paths return a value" +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"indexer `{1}'" msgstr "" +"一貫性の無いアクセス制限: パラメータ型 `{0}' はインデクサ '{1}' よりもアクセ" +"スが限られています" -#: ../mcs/mcs/codegen.cs:825 +#: mcs/mcs/class.cs:3195 #, csharp-format -msgid "Not all code paths return a value in anonymous method of type `{0}'" +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"operator `{1}'" msgstr "" +"一貫性の無いアクセス制限: パラメータ型 `{0}' は演算子 '{1}' よりもアクセスが" +"限られています" -#: ../mcs/mcs/codegen.cs:1224 ../mcs/mcs/codegen.cs:1237 +#: mcs/mcs/class.cs:3199 #, csharp-format msgid "" -"Option `{0}' overrides attribute `{1}' given in a source file or added module" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"method `{1}'" msgstr "" +"一貫性の無いアクセス制限: パラメータ型 `{0}' はメソッド '{1}' よりもアクセス" +"が限られています" -#: ../mcs/mcs/codegen.cs:1300 +#: mcs/mcs/class.cs:3213 +#, csharp-format msgid "" -"Could not sign the assembly. ECMA key can only be used to delay-sign " -"assemblies" +"Constructor `{0}' is marked `external' but has no external implementation " +"specified" msgstr "" -#: ../mcs/mcs/codegen.cs:1320 -msgid "Error during assembly signing. " +#: mcs/mcs/class.cs:3216 +#, csharp-format +msgid "" +"`{0}' is marked as an external but has no DllImport attribute. Consider " +"adding a DllImport attribute to specify the external implementation" msgstr "" +"`{0}' はexternalとして宣言されていますが、DllImport属性をもちません。" +"DllImport属性を追加して、外部実装を指定するようにしてください" -#: ../mcs/mcs/codegen.cs:1345 -msgid "Friend assembly reference `" +#: mcs/mcs/class.cs:3245 +#, csharp-format +msgid "" +"`{0}': cannot change access modifiers when overriding `{1}' inherited member " +"`{2}'" msgstr "" +"`{0}': `{1}' の継承されたメンバー `{2}' をオーバーライドするとき、アクセス修" +"飾子は変更できません" -#: ../mcs/mcs/codegen.cs:1417 -msgid "Invalid type specified as an argument for TypeForwardedTo attribute" -msgstr "" +#: mcs/mcs/class.cs:3254 +#, fuzzy, csharp-format +msgid "`{0}': static types cannot be used as return types" +msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" -#: ../mcs/mcs/codegen.cs:1425 +#: mcs/mcs/class.cs:3379 #, csharp-format -msgid "A duplicate type forward of type `{0}'" +msgid "New virtual member `{0}' is declared in a sealed class `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1434 -#, csharp-format -msgid "Cannot forward type `{0}' because it is defined in this assembly" +#: mcs/mcs/class.cs:3394 +msgid "Inconsistent accessibility: property type `" msgstr "" -#: ../mcs/mcs/codegen.cs:1440 -#, csharp-format -msgid "Cannot forward type `{0}' because it is a nested type" +#: mcs/mcs/class.cs:3399 +msgid "Inconsistent accessibility: indexer return type `" msgstr "" -#: ../mcs/mcs/codegen.cs:1446 -#, csharp-format -msgid "Cannot forward generic type `{0}'" +#: mcs/mcs/class.cs:3405 mcs/mcs/class.cs:3410 mcs/mcs/delegate.cs:159 +msgid "Inconsistent accessibility: return type `" msgstr "" -#: ../mcs/mcs/codegen.cs:1651 -msgid "" -"Value specified for the argument to 'System.Runtime.InteropServices." -"DefaultCharSetAttribute' is not valid" +#: mcs/mcs/class.cs:3415 +msgid "Inconsistent accessibility: field type `" msgstr "" -#: ../mcs/mcs/const.cs:177 +#: mcs/mcs/class.cs:3428 #, csharp-format -msgid "The expression being assigned to `{0}' must be constant" +msgid "Field or property cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/const.cs:182 -#, csharp-format -msgid "" -"The evaluation of the constant value for `{0}' involves a circular definition" -msgstr "" +#: mcs/mcs/const.cs:103 +#, fuzzy, csharp-format +msgid "Type parameter `{0}' cannot be declared const" +msgstr "abstractメソッド `{0}' はvirtualとすることはできません" -#: ../mcs/mcs/const.cs:188 +#: mcs/mcs/const.cs:106 #, csharp-format -msgid "" -"A constant `{0}' of reference type `{1}' can only be initialized with null" +msgid "The type `{0}' cannot be declared const" msgstr "" -#: ../mcs/mcs/const.cs:194 +#: mcs/mcs/const.cs:181 #, csharp-format -msgid "The type `{0}' cannot be declared const" +msgid "" +"The evaluation of the constant value for `{0}' involves a circular definition" msgstr "" -#: ../mcs/mcs/constant.cs:84 ../mcs/mcs/constant.cs:285 +#: mcs/mcs/constant.cs:68 mcs/mcs/constant.cs:319 #, csharp-format msgid "Constant value `{0}' cannot be converted to a `{1}'" msgstr "" -#: ../mcs/mcs/constant.cs:192 +#: mcs/mcs/constant.cs:187 #, csharp-format msgid "" "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " "to override)" msgstr "" -#: ../mcs/mcs/decl.cs:363 +#: mcs/mcs/convert.cs:1158 +#, csharp-format +msgid "" +"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' " +"to `{3}'" +msgstr "" + +#: mcs/mcs/decl.cs:376 #, csharp-format msgid "`{0}' cannot declare a body because it is marked extern" msgstr "" -#: ../mcs/mcs/decl.cs:369 +#: mcs/mcs/decl.cs:382 #, csharp-format msgid "`{0}' cannot declare a body because it is marked abstract" msgstr "" -#: ../mcs/mcs/decl.cs:377 +#: mcs/mcs/decl.cs:395 #, csharp-format msgid "" "`{0}' must have a body because it is not marked abstract or extern. The " "property can be automatically implemented when you define both accessors" msgstr "" -#: ../mcs/mcs/decl.cs:380 +#: mcs/mcs/decl.cs:401 #, csharp-format msgid "" "`{0}' must have a body because it is not marked abstract, extern, or partial" msgstr "" -#: ../mcs/mcs/decl.cs:396 +#: mcs/mcs/decl.cs:416 #, csharp-format msgid "`{0}': Structs cannot contain protected members" msgstr "" -#: ../mcs/mcs/decl.cs:402 +#: mcs/mcs/decl.cs:422 #, csharp-format msgid "`{0}': Static classes cannot contain protected members" msgstr "" -#: ../mcs/mcs/decl.cs:950 +#: mcs/mcs/decl.cs:1264 #, csharp-format msgid "The namespace `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:954 +#: mcs/mcs/decl.cs:1268 #, csharp-format msgid "Duplicate type parameter `{0}'" msgstr "" -#: ../mcs/mcs/decl.cs:957 +#: mcs/mcs/decl.cs:1271 #, csharp-format msgid "The type `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:1025 +#: mcs/mcs/decl.cs:1321 #, csharp-format msgid "" "Missing partial modifier on declaration of type `{0}'. Another partial " "declaration of this type exists" msgstr "" -#: ../mcs/mcs/decl.cs:1248 -msgid "The RequiredAttribute attribute is not permitted on C# types" -msgstr "" - -#: ../mcs/mcs/decl.cs:1303 -msgid "Constraints are not allowed on non-generic declarations" +#: mcs/mcs/decl.cs:1410 +msgid "Variant type parameters can only be used with interfaces and delegates" msgstr "" -#: ../mcs/mcs/decl.cs:1347 +#: mcs/mcs/decl.cs:1422 #, csharp-format msgid "`{0}': A constraint references nonexistent type parameter `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:2725 -msgid "" -"A partial method declaration and partial method implementation cannot differ " -"on use of `params' modifier" -msgstr "" - -#: ../mcs/mcs/decl.cs:2728 -msgid "" -"A partial method declaration and partial method implementation must be both " -"an extension method or neither" -msgstr "" - -#: ../mcs/mcs/decl.cs:2732 -#, csharp-format -msgid "" -"An overloaded method `{0}' cannot differ on use of parameter modifiers only" -msgstr "" - -#: ../mcs/mcs/decl.cs:2760 -msgid "" -"A partial method declaration and partial method implementation must be both " -"`static' or neither" -msgstr "" - -#: ../mcs/mcs/decl.cs:2765 -msgid "" -"A partial method declaration and partial method implementation must be both " -"`unsafe' or neither" -msgstr "" - -#: ../mcs/mcs/decl.cs:2771 -#, csharp-format -msgid "A partial method `{0}' declaration is already defined" -msgstr "" - -#: ../mcs/mcs/decl.cs:2775 -#, csharp-format -msgid "A partial method `{0}' implementation is already defined" -msgstr "" - -#: ../mcs/mcs/decl.cs:2783 -#, csharp-format -msgid "Duplicate user-defined conversion in type `{0}'" -msgstr "" - -#: ../mcs/mcs/delegate.cs:204 +#: mcs/mcs/delegate.cs:141 #, csharp-format msgid "" "Inconsistent accessibility: parameter type `{0}' is less accessible than " "delegate `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:403 -msgid "Internal error: could not find delegate constructor!" -msgstr "" - -#: ../mcs/mcs/delegate.cs:445 ../mcs/mcs/delegate.cs:553 -msgid "Internal error: could not find Invoke method!" -msgstr "" - -#: ../mcs/mcs/delegate.cs:732 +#: mcs/mcs/delegate.cs:487 #, csharp-format msgid "" "Cannot create delegate from method `{0}' because it is a member of System." "Nullable type" msgstr "" -#: ../mcs/mcs/delegate.cs:744 +#: mcs/mcs/delegate.cs:499 #, csharp-format msgid "" "Extension method `{0}' of value type `{1}' cannot be used to create delegates" msgstr "" -#: ../mcs/mcs/delegate.cs:759 +#: mcs/mcs/delegate.cs:514 #, csharp-format msgid "Cannot create delegate from partial method declaration `{0}'" msgstr "" -#: ../mcs/mcs/delegate.cs:762 +#: mcs/mcs/delegate.cs:517 #, csharp-format msgid "" "Cannot create delegate with `{0}' because it has a Conditional attribute" msgstr "" -#: ../mcs/mcs/delegate.cs:818 +#: mcs/mcs/delegate.cs:560 #, csharp-format msgid "" "A method or delegate `{0} {1}' parameters and return type must be same as " "delegate `{2} {3}' parameters and return type" msgstr "" -#: ../mcs/mcs/delegate.cs:824 +#: mcs/mcs/delegate.cs:567 #, csharp-format msgid "" "A method or delegate `{0}' parameters do not match delegate `{1}' parameters" msgstr "" -#: ../mcs/mcs/delegate.cs:829 +#: mcs/mcs/delegate.cs:572 #, csharp-format msgid "" "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " "return type" msgstr "" -#: ../mcs/mcs/delegate.cs:949 +#: mcs/mcs/delegate.cs:655 msgid "Method name expected" msgstr "" -#: ../mcs/mcs/doc.cs:1007 +#: mcs/mcs/doc.cs:914 #, csharp-format msgid "Error generating XML documentation file `{0}' (`{1}')" msgstr "" -#: ../mcs/mcs/driver.cs:152 ../mcs/mcs/driver.cs:707 ../mcs/mcs/driver.cs:710 +#: mcs/mcs/driver.cs:96 mcs/mcs/driver.cs:465 mcs/mcs/driver.cs:468 msgid "Source file `" msgstr "" -#: ../mcs/mcs/driver.cs:179 +#: mcs/mcs/driver.cs:123 #, csharp-format msgid "Source file `{0}' could not be found" msgstr "" -#: ../mcs/mcs/driver.cs:187 +#: mcs/mcs/driver.cs:129 #, csharp-format msgid "Source file `{0}' is a binary file and not a text file" msgstr "" -#: ../mcs/mcs/driver.cs:205 -#, csharp-format -msgid "Compilation aborted in file `{0}', {1}" -msgstr "" - -#: ../mcs/mcs/driver.cs:272 +#: mcs/mcs/driver.cs:214 msgid "" "Invalid target type for -target. Valid options are `exe', `winexe', " "`library' or `module'" msgstr "" -#: ../mcs/mcs/driver.cs:320 -#, csharp-format -msgid "cannot find metadata file `{0}'" -msgstr "" - -#: ../mcs/mcs/driver.cs:327 -#, csharp-format -msgid "file `{0}' has invalid `{1}' metadata" -msgstr "" - -#: ../mcs/mcs/driver.cs:347 -#, csharp-format -msgid "" -"Referenced file `{0}' is not an assembly. Consider using `-addmodule' option " -"instead" -msgstr "" -"参照ファイル `{0}' はアセンブリではありません。代わりに`-addmodule' オプショ" -"ンを使用してみてください" - -#: ../mcs/mcs/driver.cs:603 +#: mcs/mcs/driver.cs:361 msgid "Response file `" msgstr "レスポンスファイル `" -#: ../mcs/mcs/driver.cs:612 +#: mcs/mcs/driver.cs:370 msgid "Unable to open response file: " msgstr "レスポンスファイルが開けません" -#: ../mcs/mcs/driver.cs:662 ../mcs/mcs/driver.cs:672 +#: mcs/mcs/driver.cs:420 mcs/mcs/driver.cs:430 msgid "No files to compile were specified" msgstr "コンパイルするファイルが指定されていません" -#: ../mcs/mcs/driver.cs:802 +#: mcs/mcs/driver.cs:502 msgid "Warning level must be in the range 0-4" msgstr "" -#: ../mcs/mcs/driver.cs:836 +#: mcs/mcs/driver.cs:536 msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" msgstr "" -#: ../mcs/mcs/driver.cs:845 +#: mcs/mcs/driver.cs:545 msgid "Compatibility: Use -unsafe instead of --unsafe" msgstr "" -#: ../mcs/mcs/driver.cs:856 +#: mcs/mcs/driver.cs:556 msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" msgstr "" -#: ../mcs/mcs/driver.cs:870 -msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" +#: mcs/mcs/driver.cs:570 +msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" +msgstr "" + +#: mcs/mcs/driver.cs:579 +msgid "Compatibility: Use -checked instead of --checked" +msgstr "" + +#: mcs/mcs/driver.cs:589 +msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" +msgstr "" + +#: mcs/mcs/driver.cs:592 +msgid "Missing argument to --linkres" +msgstr "" + +#: mcs/mcs/driver.cs:601 +msgid "Compatibility: Use -res:VALUE instead of --res VALUE" +msgstr "" + +#: mcs/mcs/driver.cs:604 +msgid "Missing argument to --resource" +msgstr "" + +#: mcs/mcs/driver.cs:612 +msgid "Compatibility: Use -target:KIND instead of --target KIND" +msgstr "" + +#: mcs/mcs/driver.cs:644 +msgid "Compatibility: Use -r:LIBRARY instead of -r library" +msgstr "" + +#: mcs/mcs/driver.cs:663 +msgid "Compatibility: Use -lib:ARG instead of --L arg" +msgstr "" + +#: mcs/mcs/driver.cs:676 +msgid "Compatibility: Use -nostdlib instead of --nostdlib" +msgstr "" + +#: mcs/mcs/driver.cs:681 +msgid "Compatibility: Use -nowarn instead of --nowarn" +msgstr "" + +#: mcs/mcs/driver.cs:698 +msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" +msgstr "" + +#: mcs/mcs/driver.cs:702 +msgid "--wlevel requires a value from 0 to 4" +msgstr "" + +#: mcs/mcs/driver.cs:711 +msgid "--mcs-debug requires an argument" +msgstr "" + +#: mcs/mcs/driver.cs:718 +msgid "Invalid argument to --mcs-debug" +msgstr "" + +#: mcs/mcs/driver.cs:728 +msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" +msgstr "" + +#: mcs/mcs/driver.cs:730 +msgid "--recurse requires an argument" +msgstr "" + +#: mcs/mcs/driver.cs:741 +msgid "Compatibility: Use -debug option instead of -g or --debug" +msgstr "" + +#: mcs/mcs/driver.cs:746 +msgid "Compatibility: Use -noconfig option instead of --noconfig" +msgstr "" + +#: mcs/mcs/driver.cs:910 +#, csharp-format +msgid "Invalid conditional define symbol `{0}'" +msgstr "" + +#: mcs/mcs/driver.cs:961 +#, csharp-format +msgid "" +"Invalid resource visibility option `{0}'. Use either `public' or `private' " +"instead" +msgstr "" + +#: mcs/mcs/driver.cs:967 +#, csharp-format +msgid "Wrong number of arguments for option `{0}'" +msgstr "" + +#: mcs/mcs/driver.cs:1005 +msgid "Cannot specify multiple aliases using single /reference option" +msgstr "" + +#: mcs/mcs/driver.cs:1033 mcs/mcs/driver.cs:1045 +msgid "" +"Cannot specify the `win32res' and the `win32ico' compiler option at the same " +"time" +msgstr "" + +#: mcs/mcs/driver.cs:1160 +#, csharp-format +msgid "`{0}' is not a valid warning number" msgstr "" -#: ../mcs/mcs/driver.cs:879 -msgid "Compatibility: Use -checked instead of --checked" +#: mcs/mcs/driver.cs:1190 +msgid "" +"Invalid platform type for -platform. Valid options are `anycpu', `x86', " +"`x64' or `itanium'" msgstr "" -#: ../mcs/mcs/driver.cs:889 -msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" +#: mcs/mcs/driver.cs:1288 +#, csharp-format +msgid "" +"Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or " +"`Default'" msgstr "" -#: ../mcs/mcs/driver.cs:892 -msgid "Missing argument to --linkres" +#: mcs/mcs/driver.cs:1308 +#, csharp-format +msgid "Code page `{0}' is invalid or not installed" msgstr "" -#: ../mcs/mcs/driver.cs:903 -msgid "Compatibility: Use -res:VALUE instead of --res VALUE" +#: mcs/mcs/driver.cs:1323 +#, csharp-format +msgid "Unrecognized command-line option: `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:906 -msgid "Missing argument to --resource" +#: mcs/mcs/driver.cs:1328 +#, csharp-format +msgid "Missing file specification for `{0}' option" msgstr "" -#: ../mcs/mcs/driver.cs:916 -msgid "Compatibility: Use -target:KIND instead of --target KIND" +#: mcs/mcs/driver.cs:1333 +#, csharp-format +msgid "Missing argument for `{0}' option" msgstr "" -#: ../mcs/mcs/driver.cs:948 -msgid "Compatibility: Use -r:LIBRARY instead of -r library" +#: mcs/mcs/driver.cs:1368 +#, csharp-format +msgid "Invalid reference alias `{0}='. Missing filename" msgstr "" -#: ../mcs/mcs/driver.cs:967 -msgid "Compatibility: Use -lib:ARG instead of --L arg" +#: mcs/mcs/driver.cs:1373 +#, csharp-format +msgid "" +"Invalid extern alias for -reference. Alias `{0}' is not a valid identifier" msgstr "" -#: ../mcs/mcs/driver.cs:976 -msgid "Compatibility: Use -nostdlib instead of --nostdlib" +#: mcs/mcs/driver.cs:1389 +#, csharp-format +msgid "The resource identifier `{0}' has already been used in this assembly" msgstr "" -#: ../mcs/mcs/driver.cs:985 -msgid "Compatibility: Use -warnaserror: option instead of --werror" +#: mcs/mcs/driver.cs:1450 +msgid "" +"If no source files are specified you must specify the output file with -out:" msgstr "" -#: ../mcs/mcs/driver.cs:990 -msgid "Compatibility: Use -nowarn instead of --nowarn" +#: mcs/mcs/dynamic.cs:272 +#, fuzzy +msgid "An expression tree cannot contain a dynamic operation" +msgstr "式ツリーは代入オペレータを含むことができません" + +#: mcs/mcs/dynamic.cs:302 +msgid "" +"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly " +"reference" msgstr "" -#: ../mcs/mcs/driver.cs:1007 -msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" +#: mcs/mcs/ecore.cs:242 +#, csharp-format +msgid "`{0}' is inaccessible due to its protection level" msgstr "" -#: ../mcs/mcs/driver.cs:1011 -msgid "--wlevel requires a value from 0 to 4" +#: mcs/mcs/ecore.cs:247 +#, csharp-format +msgid "The expression being assigned to `{0}' must be constant" msgstr "" -#: ../mcs/mcs/driver.cs:1020 -msgid "--mcs-debug requires an argument" +#: mcs/mcs/ecore.cs:252 +#, csharp-format +msgid "" +"A constant `{0}' of reference type `{1}' can only be initialized with null" msgstr "" -#: ../mcs/mcs/driver.cs:1027 -msgid "Invalid argument to --mcs-debug" +#: mcs/mcs/ecore.cs:258 +msgid "" +"Only assignment, call, increment, decrement, and new object expressions can " +"be used as a statement" msgstr "" -#: ../mcs/mcs/driver.cs:1037 -msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" +#: mcs/mcs/ecore.cs:269 +msgid "Keyword `void' cannot be used in this context" msgstr "" -#: ../mcs/mcs/driver.cs:1039 -msgid "--recurse requires an argument" +#: mcs/mcs/ecore.cs:303 +#, csharp-format +msgid "Cannot convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1051 -msgid "Compatibility: Use -debug option instead of -g or --debug" +#: mcs/mcs/ecore.cs:313 +#, csharp-format +msgid "" +"Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " +"(are you missing a cast?)" msgstr "" -#: ../mcs/mcs/driver.cs:1056 -msgid "Compatibility: Use -noconfig option instead of --noconfig" +#: mcs/mcs/ecore.cs:319 +#, csharp-format +msgid "Cannot implicitly convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1076 -msgid "Couldn't run pkg-config: " +#: mcs/mcs/ecore.cs:360 +#, csharp-format +msgid "`{0}' does not contain a definition for `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1084 -msgid "Specified package did not return any information" +#: mcs/mcs/ecore.cs:366 +msgid "" +"The left-hand side of an assignment must be a variable, a property or an " +"indexer" msgstr "" -#: ../mcs/mcs/driver.cs:1091 -msgid "Error running pkg-config. Check the above output." +#: mcs/mcs/ecore.cs:371 +msgid "The operation in question is undefined on void pointers" msgstr "" -#: ../mcs/mcs/driver.cs:1187 +#: mcs/mcs/ecore.cs:433 mcs/mcs/statement.cs:2558 mcs/mcs/statement.cs:2560 #, csharp-format -msgid "Invalid conditional define symbol `{0}'" +msgid "Internal compiler error: {0}" msgstr "" -#: ../mcs/mcs/driver.cs:1241 -#, csharp-format +#: mcs/mcs/ecore.cs:473 +msgid "A ref or out argument must be an assignable variable" +msgstr "" + +#: mcs/mcs/ecore.cs:492 msgid "" -"Invalid resource visibility option `{0}'. Use either `public' or `private' " -"instead" +"An attribute argument must be a constant expression, typeof expression or " +"array creation expression" +msgstr "属性の引数は定数、typeof式または配列生成式でなければなりません" + +#: mcs/mcs/ecore.cs:563 +#, csharp-format +msgid "The class `{0}' has no constructors defined" msgstr "" -#: ../mcs/mcs/driver.cs:1247 +#: mcs/mcs/ecore.cs:648 #, csharp-format -msgid "Wrong number of arguments for option `{0}'" +msgid "Ambiguity between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1255 -msgid "-recurse requires an argument" +#: mcs/mcs/ecore.cs:675 +msgid "An expression tree cannot contain an unsafe pointer operation" msgstr "" -#: ../mcs/mcs/driver.cs:1264 -msgid "-reference requires an argument" +#: mcs/mcs/ecore.cs:796 +#, csharp-format +msgid "Expression denotes a `{0}', where a `{1}' was expected" msgstr "" -#: ../mcs/mcs/driver.cs:1286 ../mcs/mcs/driver.cs:1298 -#: ../mcs/mcs/driver.cs:1310 ../mcs/mcs/driver.cs:1322 -#: ../mcs/mcs/driver.cs:1431 ../mcs/mcs/driver.cs:1451 -#: ../mcs/mcs/driver.cs:1458 -msgid " requires an argument" +#: mcs/mcs/ecore.cs:806 +msgid "Pointers and fixed size buffers may only be used in an unsafe context" msgstr "" -#: ../mcs/mcs/driver.cs:1303 ../mcs/mcs/driver.cs:1315 +#: mcs/mcs/ecore.cs:841 +#, csharp-format msgid "" -"Cannot specify the `win32res' and the `win32ico' compiler option at the same " -"time" +"Members of value type `{0}' cannot be assigned using a property `{1}' object " +"initializer" msgstr "" -#: ../mcs/mcs/driver.cs:1332 -msgid "/lib requires an argument" +#: mcs/mcs/ecore.cs:844 +#, csharp-format +msgid "" +"Cannot modify a value type return value of `{0}'. Consider storing the value " +"in a temporary variable" msgstr "" -#: ../mcs/mcs/driver.cs:1394 -msgid "/nowarn requires an argument" +#: mcs/mcs/ecore.cs:2270 +#, csharp-format +msgid "" +"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core." +"dll assembly reference?" msgstr "" -#: ../mcs/mcs/driver.cs:1488 +#: mcs/mcs/ecore.cs:2344 #, csharp-format msgid "" -"Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or " -"`Default'" +"A local variable `{0}' cannot be used before it is declared. Consider " +"renaming the local variable when it hides the member `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1504 +#: mcs/mcs/ecore.cs:2359 mcs/mcs/ecore.cs:2403 #, csharp-format -msgid "Code page `{0}' is invalid or not installed" +msgid "`{0}' conflicts with a declaration in a child block" msgstr "" -#: ../mcs/mcs/driver.cs:1516 +#: mcs/mcs/ecore.cs:2412 #, csharp-format -msgid "Unrecognized command-line option: `{0}'" +msgid "A local variable `{0}' cannot be used before it is declared" msgstr "" -#: ../mcs/mcs/driver.cs:1546 -msgid "Invalid reference alias '" +#: mcs/mcs/ecore.cs:2414 +#, csharp-format +msgid "The name `{0}' does not exist in the current context" msgstr "" -#: ../mcs/mcs/driver.cs:1551 -msgid "Invalid extern alias for /reference. Alias '" +#: mcs/mcs/ecore.cs:2664 +#, csharp-format +msgid "" +"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " +"qualifier must be of type `{2}' or derived from it" msgstr "" -#: ../mcs/mcs/driver.cs:1617 -msgid "" -"If no source files are specified you must specify the output file with -out:" +#: mcs/mcs/ecore.cs:2708 +#, csharp-format +msgid "Cannot call an abstract base member `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1739 +#: mcs/mcs/ecore.cs:2747 #, csharp-format -msgid "Could not find `{0}' specified for Main method" +msgid "" +"Static member `{0}' cannot be accessed with an instance reference, qualify " +"it with a type name instead" msgstr "" -#: ../mcs/mcs/driver.cs:1744 +#: mcs/mcs/ecore.cs:2762 #, csharp-format -msgid "`{0}' specified for Main method must be a valid class or struct" +msgid "" +"A field initializer cannot reference the nonstatic field, method, or " +"property `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1748 +#: mcs/mcs/ecore.cs:2766 #, csharp-format -msgid "`{0}' does not have a suitable static Main method" +msgid "An object reference is required to access non-static member `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1753 +#: mcs/mcs/ecore.cs:2774 #, csharp-format msgid "" -"Program `{0}' does not contain a static `Main' method suitable for an entry " -"point" +"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" msgstr "" -#: ../mcs/mcs/driver.cs:1760 -msgid "Cannot specify -main if building a module or library" +#: mcs/mcs/ecore.cs:2822 +msgid "Cannot modify the result of an unboxing conversion" msgstr "" -#: ../mcs/mcs/driver.cs:1765 -msgid "Cannot link resource file when building a module" +#: mcs/mcs/ecore.cs:2943 +#, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/driver.cs:1915 +#: mcs/mcs/ecore.cs:2948 #, csharp-format -msgid "The resource identifier `{0}' has already been used in this assembly" +msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +msgstr "" + +#: mcs/mcs/ecore.cs:3072 +msgid "An expression tree cannot contain an expression with method group" msgstr "" -#: ../mcs/mcs/driver.cs:1929 +#: mcs/mcs/ecore.cs:3078 +msgid "" +"Partial methods with only a defining declaration or removed conditional " +"methods cannot be used in an expression tree" +msgstr "" + +#: mcs/mcs/ecore.cs:3108 #, csharp-format -msgid "Error reading resource file `{0}'" +msgid "" +"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " +"parentheses to invoke the method" msgstr "" -#: ../mcs/mcs/ecore.cs:321 +#: mcs/mcs/ecore.cs:3676 #, csharp-format -msgid "`{0}' is inaccessible due to its protection level" +msgid "" +"The type `{0}' does not contain a constructor that takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:326 +#: mcs/mcs/ecore.cs:4284 #, csharp-format msgid "" -"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " -"qualifier must be of type `{2}' or derived from it" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' cannot be dynamically dispatched. Consider calling the method " +"without the extension method syntax" msgstr "" -#: ../mcs/mcs/ecore.cs:336 +#: mcs/mcs/ecore.cs:4305 +#, csharp-format msgid "" -"Only assignment, call, increment, decrement, and new object expressions can " -"be used as a statement" +"The call is ambiguous between the following methods or properties: `{0}' and " +"`{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:347 +#: mcs/mcs/ecore.cs:4360 #, csharp-format -msgid "Cannot assign to `{0}' because it is a `{1}'" +msgid "" +"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " +"`out' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:353 -msgid "Keyword `void' cannot be used in this context" +#: mcs/mcs/ecore.cs:4364 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' has some invalid " +"arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:383 ../mcs/mcs/statement.cs:1098 +#: mcs/mcs/ecore.cs:4367 #, csharp-format -msgid "Cannot convert type `{0}' to `{1}'" +msgid "Delegate `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:393 +#: mcs/mcs/ecore.cs:4371 #, csharp-format -msgid "" -"Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " -"(are you missing a cast?)" +msgid "The best overloaded method match for `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:399 +#: mcs/mcs/ecore.cs:4381 #, csharp-format -msgid "Cannot implicitly convert type `{0}' to `{1}'" +msgid "" +"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " +"modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:406 +#: mcs/mcs/ecore.cs:4384 #, csharp-format -msgid "A local variable `{0}' cannot be used before it is declared" +msgid "Argument `#{0}' is missing `{1}' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:417 +#: mcs/mcs/ecore.cs:4397 #, csharp-format -msgid "`{0}' does not contain a definition for `{1}'" +msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:423 +#: mcs/mcs/ecore.cs:4445 +#, csharp-format msgid "" -"The left-hand side of an assignment must be a variable, a property or an " -"indexer" +"The type arguments for method `{0}' cannot be inferred from the usage. Try " +"specifying the type arguments explicitly" msgstr "" -#: ../mcs/mcs/ecore.cs:560 -msgid "A ref or out argument must be an assignable variable" +#: mcs/mcs/ecore.cs:4474 +#, csharp-format +msgid "No overload for method `{0}' takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:714 ../mcs/mcs/ecore.cs:730 +#: mcs/mcs/ecore.cs:4527 +#, fuzzy, csharp-format +msgid "The delegate `{0}' does not contain a parameter named `{1}'" +msgstr "デリゲート `{0}' は `{1}' 個の引数をもちません" + +#: mcs/mcs/ecore.cs:4532 #, csharp-format -msgid "Ambiguity between `{0}' and `{1}'" +msgid "" +"The best overloaded method match for `{0}' does not contain a parameter " +"named `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:831 ../mcs/mcs/ecore.cs:2777 +#: mcs/mcs/ecore.cs:4542 #, csharp-format msgid "" -"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +"Named argument `{0}' cannot be used for a parameter which has positional " +"argument specified" msgstr "" -#: ../mcs/mcs/ecore.cs:872 -#, csharp-format -msgid "The name `{0}' does not exist in the current context" +#: mcs/mcs/ecore.cs:4855 +msgid "" +"You cannot use fixed size buffers contained in unfixed expressions. Try " +"using the fixed statement" msgstr "" -#: ../mcs/mcs/ecore.cs:887 ../mcs/mcs/generic.cs:1398 +#: mcs/mcs/ecore.cs:4860 #, csharp-format -msgid "Using the generic type `{0}' requires {1} type arguments" +msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" msgstr "" -#: ../mcs/mcs/ecore.cs:916 -msgid "An expression tree cannot contain an unsafe pointer operation" +#: mcs/mcs/ecore.cs:5255 +#, csharp-format +msgid "Property or event `{0}' is not supported by the C# language" msgstr "" -#: ../mcs/mcs/ecore.cs:1030 +#: mcs/mcs/ecore.cs:5416 #, csharp-format -msgid "`{0}' is a `{1}' but a `{2}' was expected" +msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" msgstr "" -#: ../mcs/mcs/ecore.cs:1064 +#: mcs/mcs/ecore.cs:5464 #, csharp-format -msgid "Expression denotes a `{0}', where a `{1}' was expected" +msgid "" +"The property or indexer `{0}' cannot be used in this context because it " +"lacks the `get' accessor" msgstr "" -#: ../mcs/mcs/ecore.cs:1069 -msgid "Pointers and fixed size buffers may only be used in an unsafe context" +#: mcs/mcs/ecore.cs:5471 +#, csharp-format +msgid "" +"The property or indexer `{0}' cannot be used in this context because the get " +"accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:1175 +#: mcs/mcs/ecore.cs:5490 #, csharp-format -msgid "Cannot call an abstract base member `{0}'" +msgid "Property or indexer `{0}' cannot be assigned to (it is read-only)" msgstr "" -#: ../mcs/mcs/ecore.cs:1182 +#: mcs/mcs/ecore.cs:5498 #, csharp-format msgid "" -"Members of value type `{0}' cannot be assigned using a property `{1}' object " -"initializer" +"The property or indexer `{0}' cannot be used in this context because the set " +"accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:1185 +#: mcs/mcs/ecore.cs:5659 #, csharp-format msgid "" -"Cannot modify a value type return value of `{0}'. Consider storing the value " -"in a temporary variable" +"The event `{0}' can only appear on the left hand side of `+=' or `-=' " +"operator" msgstr "" -#: ../mcs/mcs/ecore.cs:1833 -msgid "Cannot modify the result of an unboxing conversion" +#: mcs/mcs/ecore.cs:5663 +#, csharp-format +msgid "" +"The event `{0}' can only appear on the left hand side of += or -= when used " +"outside of the type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:2401 +#: mcs/mcs/ecore.cs:5827 #, csharp-format msgid "" -"A field initializer cannot reference the nonstatic field, method, or " -"property `{0}'" +"An implicitly typed local variable declaration cannot be initialized with `" +"{0}'" +msgstr "" + +#: mcs/mcs/ecore.cs:5841 +msgid "" +"The contextual keyword `var' may only appear within a local variable " +"declaration" msgstr "" -#: ../mcs/mcs/ecore.cs:2405 +#: mcs/mcs/enum.cs:125 #, csharp-format -msgid "An object reference is required to access non-static member `{0}'" +msgid "" +"The enumerator value `{0}' is outside the range of enumerator underlying " +"type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:2612 ../mcs/mcs/ecore.cs:2632 +#: mcs/mcs/enum.cs:189 #, csharp-format -msgid "The variable `{0}' cannot be used with type arguments" +msgid "An item in an enumeration cannot have an identifier `{0}'" +msgstr "" + +#: mcs/mcs/enum.cs:200 +msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" +msgstr "" + +#: mcs/mcs/eval.cs:625 +msgid "Detection Parsing Error" msgstr "" -#: ../mcs/mcs/ecore.cs:3160 +#: mcs/mcs/expression.cs:542 #, csharp-format -msgid "" -"Static member `{0}' cannot be accessed with an instance reference, qualify " -"it with a type name instead" +msgid "The `{0}' operator cannot be applied to operand of type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3166 -msgid "An expression tree may not contain a base access" +#: mcs/mcs/expression.cs:622 +msgid "Cannot take the address of the given expression" +msgstr "" + +#: mcs/mcs/expression.cs:656 +msgid "" +"You can only take the address of unfixed expression inside of a fixed " +"statement initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:3256 +#: mcs/mcs/expression.cs:745 #, csharp-format -msgid "The property `{0}' cannot be used with type arguments" +msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3710 -msgid "An expression tree cannot contain an expression with method group" +#: mcs/mcs/expression.cs:868 +msgid "The * or -> operator must be applied to a pointer" msgstr "" -#: ../mcs/mcs/ecore.cs:3720 +#: mcs/mcs/expression.cs:1070 msgid "" -"Partial methods with only a defining declaration or removed conditional " -"methods cannot be used in an expression tree" +"The operand of an increment or decrement operator must be a variable, " +"property or indexer" +msgstr "" + +#: mcs/mcs/expression.cs:1260 +#, csharp-format +msgid "The `{0}' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/ecore.cs:3738 -msgid "Method `" +#: mcs/mcs/expression.cs:1265 +#, csharp-format +msgid "The `{0}' operator cannot be applied to an operand of pointer type" msgstr "" -#: ../mcs/mcs/ecore.cs:3765 +#: mcs/mcs/expression.cs:1271 #, csharp-format msgid "" -"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " -"`out' modifier" +"The `{0}' operator cannot be applied to a lambda expression or anonymous " +"method" msgstr "" -#: ../mcs/mcs/ecore.cs:3769 +#: mcs/mcs/expression.cs:1507 #, csharp-format msgid "" -"The best overloaded collection initalizer method `{0}' has some invalid " -"arguments" +"The `as' operator cannot be used with a non-reference type parameter `{0}'. " +"Consider adding `class' or a reference type constraint" msgstr "" -#: ../mcs/mcs/ecore.cs:3775 +#: mcs/mcs/expression.cs:1511 #, csharp-format -msgid "" -"Type `{0}' does not contain a member `{1}' and the best extension method " -"overload `{2}' has some invalid arguments" +msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3779 +#: mcs/mcs/expression.cs:1548 #, csharp-format -msgid "The best overloaded method match for `{0}' has some invalid arguments" +msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" msgstr "" -#: ../mcs/mcs/ecore.cs:3783 +#: mcs/mcs/expression.cs:1589 #, csharp-format -msgid "Delegate `{0}' has some invalid arguments" +msgid "Cannot convert to static type `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3792 -#, csharp-format +#: mcs/mcs/expression.cs:1679 msgid "" -"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " -"modifier" +"The `default value' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/ecore.cs:3795 +#: mcs/mcs/expression.cs:2184 #, csharp-format -msgid "Argument `#{0}' is missing `{1}' modifier" +msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3809 -#, csharp-format -msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +#: mcs/mcs/expression.cs:2747 +msgid "To cast a negative value, you must enclose the value in parentheses" msgstr "" -#: ../mcs/mcs/ecore.cs:3812 +#: mcs/mcs/expression.cs:3400 #, csharp-format -msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" +msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3819 +#: mcs/mcs/expression.cs:4152 #, csharp-format msgid "" -"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " -"parentheses to invoke the method" -msgstr "" - -#: ../mcs/mcs/ecore.cs:4105 -msgid "Invoke cannot be called directly on a delegate" +"A user-defined operator `{0}' must have parameters and return values of the " +"same type in order to be applicable as a short circuit operator" msgstr "" -#: ../mcs/mcs/ecore.cs:4237 +#: mcs/mcs/expression.cs:4162 #, csharp-format msgid "" -"The type arguments for method `{0}' cannot be inferred from the usage. Try " -"specifying the type arguments explicitly" +"The type `{0}' must have operator `true' and operator `false' defined when `" +"{1}' is used as a short circuit operator" msgstr "" -#: ../mcs/mcs/ecore.cs:4246 +#: mcs/mcs/expression.cs:4472 #, csharp-format -msgid "Using the generic method `{0}' requires `{1}' type argument(s)" +msgid "" +"Type of conditional expression cannot be determined as `{0}' and `{1}' " +"convert implicitly to each other" msgstr "" -#: ../mcs/mcs/ecore.cs:4275 +#: mcs/mcs/expression.cs:4482 #, csharp-format msgid "" -"The type `{0}' does not contain a constructor that takes `{1}' arguments" +"Type of conditional expression cannot be determined because there is no " +"implicit conversion between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4278 +#: mcs/mcs/expression.cs:4934 #, csharp-format -msgid "No overload for method `{0}' takes `{1}' arguments" +msgid "Use of unassigned out parameter `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4383 +#: mcs/mcs/expression.cs:4964 #, csharp-format msgid "" -"The call is ambiguous between the following methods or properties: `{0}' and " -"`{1}'" +"Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " +"modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:4810 -msgid "" -"You cannot use fixed size buffers contained in unfixed expressions. Try " -"using the fixed statement" -msgstr "" +#: mcs/mcs/expression.cs:5165 +#, fuzzy, csharp-format +msgid "Cannot invoke a non-delegate type `{0}'" +msgstr "`{0}' をデリゲートでない型 `{1}'に変換できません" -#: ../mcs/mcs/ecore.cs:4815 +#: mcs/mcs/expression.cs:5176 #, csharp-format -msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" +msgid "The member `{0}' cannot be used as method or delegate" msgstr "" -#: ../mcs/mcs/ecore.cs:5083 -#, csharp-format +#: mcs/mcs/expression.cs:5196 msgid "" -"A local variable `{0}' cannot be used before it is declared. Consider " -"renaming the local variable when it hides the field `{1}'" +"Do not directly call your base class Finalize method. It is called " +"automatically from your destructor" msgstr "" -#: ../mcs/mcs/ecore.cs:5368 -#, csharp-format +#: mcs/mcs/expression.cs:5198 msgid "" -"Property `{0}' is not supported by the C# language. Try to call the accessor " -"method `{1}' directly" +"Destructors and object.Finalize cannot be called directly. Consider calling " +"IDisposable.Dispose if available" msgstr "" -#: ../mcs/mcs/ecore.cs:5414 +#: mcs/mcs/expression.cs:5227 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks the `get' accessor" +"The base call to method `{0}' cannot be dynamically dispatched. Consider " +"casting the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/ecore.cs:5426 +#: mcs/mcs/expression.cs:5304 #, csharp-format -msgid "" -"The property or indexer `{0}' cannot be used in this context because the get " -"accessor is inaccessible" +msgid "`{0}': cannot explicitly call operator or accessor" msgstr "" -#: ../mcs/mcs/ecore.cs:5470 +#: mcs/mcs/expression.cs:5631 #, csharp-format -msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" +msgid "Unsafe type `{0}' cannot be used in an object creation expression" msgstr "" -#: ../mcs/mcs/ecore.cs:5473 +#: mcs/mcs/expression.cs:5654 #, csharp-format msgid "" -"A property or indexer `{0}' may not be passed as `ref' or `out' parameter" +"Cannot create an instance of the variable type `{0}' because it does not " +"have the new() constraint" msgstr "" -#: ../mcs/mcs/ecore.cs:5494 +#: mcs/mcs/expression.cs:5660 #, csharp-format msgid "" -"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " -"store the value" +"`{0}': cannot provide arguments when creating an instance of a variable type" msgstr "" -#: ../mcs/mcs/ecore.cs:5497 +#: mcs/mcs/expression.cs:5669 #, csharp-format -msgid "Property or indexer `{0}' cannot be assigned to (it is read only)" +msgid "Cannot create an instance of the static class `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5513 +#: mcs/mcs/expression.cs:5681 #, csharp-format +msgid "Cannot create an instance of the abstract class or interface `{0}'" +msgstr "" + +#: mcs/mcs/expression.cs:5977 msgid "" -"The property or indexer `{0}' cannot be used in this context because the set " -"accessor is inaccessible" +"An implicitly typed local variable declarator cannot use an array initializer" +msgstr "" + +#: mcs/mcs/expression.cs:6070 +msgid "Cannot create an array with a negative size" msgstr "" -#: ../mcs/mcs/ecore.cs:5671 +#: mcs/mcs/expression.cs:6102 mcs/mcs/expression.cs:6110 +#: mcs/mcs/statement.cs:1009 mcs/mcs/statement.cs:3055 +msgid "A constant value is expected" +msgstr "" + +#: mcs/mcs/expression.cs:6116 #, csharp-format +msgid "An array initializer of length `{0}' was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6132 msgid "" -"The event `{0}' can only appear on the left hand side of `+=' or `-=' " -"operator" +"Array initializers can only be used in a variable or field initializer. Try " +"using a new expression instead" msgstr "" -#: ../mcs/mcs/ecore.cs:5805 -#, csharp-format +#: mcs/mcs/expression.cs:6140 +msgid "A nested array initializer was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6177 +msgid "An expression tree cannot contain a multidimensional array initializer" +msgstr "" + +#: mcs/mcs/expression.cs:6279 msgid "" -"The event `{0}' can only appear on the left hand side of += or -= when used " -"outside of the type `{1}'" +"Can only use array initializer expressions to assign to array types. Try " +"using a new expression instead" msgstr "" -#: ../mcs/mcs/ecore.cs:5932 -#, csharp-format +#: mcs/mcs/expression.cs:6718 msgid "" -"An implicitly typed local variable declaration cannot be initialized with `" -"{0}'" +"The type of an implicitly typed array cannot be inferred from the " +"initializer. Try specifying array type explicitly" msgstr "" -#: ../mcs/mcs/ecore.cs:5943 +#: mcs/mcs/expression.cs:6855 msgid "" -"The contextual keyword `var' may only appear within a local variable " -"declaration" +"The `this' object cannot be used before all of its fields are assigned to" msgstr "" -#: ../mcs/mcs/ecore.cs:5957 +#: mcs/mcs/expression.cs:6862 msgid "" -"An implicitly typed local variable declaration cannot include multiple " -"declarators" +"Keyword `this' is not valid in a static property, static method, or static " +"field initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:5964 +#: mcs/mcs/expression.cs:6865 msgid "" -"An implicitly typed local variable declarator must include an initializer" +"Anonymous methods inside structs cannot access instance members of `this'. " +"Consider copying `this' to a local variable outside the anonymous method and " +"using the local instead" msgstr "" -#: ../mcs/mcs/enum.cs:112 -#, csharp-format -msgid "The enumerator value `{0}' is too large to fit in its type `{1}'" +#: mcs/mcs/expression.cs:6868 +msgid "Keyword `this' is not available in the current context" msgstr "" -#: ../mcs/mcs/enum.cs:148 -#, csharp-format -msgid "An item in an enumeration cannot have an identifier `{0}'" +#: mcs/mcs/expression.cs:6955 +msgid "Cannot take the address of `this' because it is read-only" msgstr "" -#: ../mcs/mcs/enum.cs:158 -msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" +#: mcs/mcs/expression.cs:6957 +msgid "Cannot pass `this' as a ref or out argument because it is read-only" msgstr "" -#: ../mcs/mcs/eval.cs:496 -msgid "Detection Parsing Error" +#: mcs/mcs/expression.cs:6959 +msgid "Cannot assign to `this' because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:553 -#, csharp-format -msgid "The `{0}' operator cannot be applied to operand of type `{1}'" +#: mcs/mcs/expression.cs:7012 +msgid "The __arglist construct is valid only within a variable argument method" msgstr "" -#: ../mcs/mcs/expression.cs:720 -#, csharp-format -msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" +#: mcs/mcs/expression.cs:7062 +msgid "An expression tree cannot contain a method with variable arguments" msgstr "" -#: ../mcs/mcs/expression.cs:979 +#: mcs/mcs/expression.cs:7146 msgid "" -"The operand of an increment or decrement operator must be a variable, " -"property or indexer" +"System.Void cannot be used from C#. Use typeof (void) to get the void type " +"object" +msgstr "" + +#: mcs/mcs/expression.cs:7149 +msgid "The typeof operator cannot be used on the dynamic type" msgstr "" -#: ../mcs/mcs/expression.cs:1146 +#: mcs/mcs/expression.cs:7218 #, csharp-format -msgid "The `{0}' operator cannot be applied to an operand of a static type" +msgid "`{0}': an attribute argument cannot use type parameters" msgstr "" -#: ../mcs/mcs/expression.cs:1151 +#: mcs/mcs/expression.cs:7472 #, csharp-format -msgid "The `{0}' operator cannot be applied to an operand of pointer type" +msgid "" +"`{0}' does not have a predefined size, therefore sizeof can only be used in " +"an unsafe context (consider using System.Runtime.InteropServices.Marshal." +"SizeOf)" +msgstr "" + +#: mcs/mcs/expression.cs:7528 +#, csharp-format +msgid "Alias `{0}' not found" msgstr "" -#: ../mcs/mcs/expression.cs:1157 +#: mcs/mcs/expression.cs:7539 #, csharp-format msgid "" -"The `{0}' operator cannot be applied to a lambda expression or anonymous " -"method" +"Alias `{0}' cannot be used with '::' since it denotes a type. Consider " +"replacing '::' with '.'" msgstr "" -#: ../mcs/mcs/expression.cs:1395 +#: mcs/mcs/expression.cs:7555 #, csharp-format msgid "" -"The `as' operator cannot be used with a non-reference type parameter `{0}'" +"A namespace alias qualifier `{0}' did not resolve to a namespace or a type" msgstr "" -#: ../mcs/mcs/expression.cs:1399 +#: mcs/mcs/expression.cs:7712 +msgid "Cannot perform member binding on `null' value" +msgstr "" + +#: mcs/mcs/expression.cs:7779 #, csharp-format -msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" +msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" msgstr "" -#: ../mcs/mcs/expression.cs:1431 +#: mcs/mcs/expression.cs:7855 #, csharp-format -msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" +msgid "A nested type cannot be specified through a type parameter `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1495 +#: mcs/mcs/expression.cs:7914 #, csharp-format -msgid "Cannot convert to static type `{0}'" +msgid "The nested type `{0}' does not exist in the type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:1560 +#: mcs/mcs/expression.cs:7923 +#, csharp-format msgid "" -"The `default value' operator cannot be applied to an operand of a static type" +"Type `{0}' does not contain a definition for `{1}' and no extension method `" +"{1}' of type `{0}' could be found (are you missing a using directive or an " +"assembly reference?)" msgstr "" -#: ../mcs/mcs/expression.cs:1978 +#: mcs/mcs/expression.cs:8103 #, csharp-format -msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" +msgid "Cannot apply indexing with [] to an expression of type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:2487 -msgid "To cast a negative value, you must enclose the value in parentheses" +#: mcs/mcs/expression.cs:8119 +msgid "A pointer must be indexed by only one value" msgstr "" -#: ../mcs/mcs/expression.cs:2985 -#, csharp-format -msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" +#: mcs/mcs/expression.cs:8168 +msgid "An element access expression cannot use named argument" msgstr "" -#: ../mcs/mcs/expression.cs:3677 +#: mcs/mcs/expression.cs:8224 #, csharp-format -msgid "" -"A user-defined operator `{0}' must have parameters and return values of the " -"same type in order to be applicable as a short circuit operator" +msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:3687 -#, csharp-format +#: mcs/mcs/expression.cs:8560 msgid "" -"The type `{0}' must have operator `true' and operator `false' defined when `" -"{1}' is used as a short circuit operator" +"The indexer base access cannot be dynamically dispatched. Consider casting " +"the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/expression.cs:3934 -#, csharp-format +#: mcs/mcs/expression.cs:8641 +msgid "An expression tree may not contain a base access" +msgstr "" + +#: mcs/mcs/expression.cs:8658 +#, fuzzy +msgid "Keyword `base' is not available in a static method" +msgstr "キーワード `new' は名前空間要素で認められていません" + +#: mcs/mcs/expression.cs:8660 +#, fuzzy +msgid "Keyword `base' is not available in the current context" +msgstr "キーワード `new' は名前空間要素で認められていません" + +#: mcs/mcs/expression.cs:8691 msgid "" -"Type of conditional expression cannot be determined because there is no " -"implicit conversion between `{0}' and `{1}'" +"A property, indexer or dynamic member access may not be passed as `ref' or " +"`out' parameter" msgstr "" -#: ../mcs/mcs/expression.cs:4395 +#: mcs/mcs/expression.cs:8968 #, csharp-format -msgid "Use of unassigned out parameter `{0}'" +msgid "Array elements cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:4423 +#: mcs/mcs/expression.cs:8971 #, csharp-format -msgid "" -"Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " -"modifier" +msgid "Array elements cannot be of static type `{0}'" +msgstr "" + +#: mcs/mcs/expression.cs:9121 +msgid "Cannot use a negative size with stackalloc" msgstr "" -#: ../mcs/mcs/expression.cs:4749 +#: mcs/mcs/expression.cs:9125 +msgid "Cannot use stackalloc in finally or catch" +msgstr "" + +#: mcs/mcs/expression.cs:9230 #, csharp-format -msgid "The member `{0}' cannot be used as method or delegate" +msgid "" +"Member `{0}' cannot be initialized. An object initializer may only be used " +"for fields, or properties" msgstr "" -#: ../mcs/mcs/expression.cs:4811 +#: mcs/mcs/expression.cs:9239 +#, csharp-format msgid "" -"Do not directly call your base class Finalize method. It is called " -"automatically from your destructor" +"Static field or property `{0}' cannot be assigned in an object initializer" msgstr "" -#: ../mcs/mcs/expression.cs:4813 +#: mcs/mcs/expression.cs:9414 +#, csharp-format msgid "" -"Destructors and object.Finalize cannot be called directly. Consider calling " -"IDisposable.Dispose if available" +"A field or property `{0}' cannot be initialized with a collection object " +"initializer because type `{1}' does not implement `{2}' interface" msgstr "" -#: ../mcs/mcs/expression.cs:4837 +#: mcs/mcs/expression.cs:9425 #, csharp-format -msgid "`{0}': cannot explicitly call operator or accessor" +msgid "Inconsistent `{0}' member declaration" msgstr "" -#: ../mcs/mcs/expression.cs:5390 +#: mcs/mcs/expression.cs:9433 #, csharp-format -msgid "Unsafe type `{0}' cannot be used in an object creation expression" +msgid "" +"An object initializer includes more than one member `{0}' initialization" msgstr "" -#: ../mcs/mcs/expression.cs:5442 +#: mcs/mcs/expression.cs:9451 #, csharp-format -msgid "Cannot create an instance of the static class `{0}'" +msgid "Cannot initialize object of type `{0}' with a collection initializer" msgstr "" -#: ../mcs/mcs/expression.cs:5454 +#: mcs/mcs/expression.cs:9688 +#, fuzzy +msgid "Anonymous types cannot be used in this expression" +msgstr "匿名メソッドを式ツリーに変換することはできません" + +#: mcs/mcs/expression.cs:9776 #, csharp-format -msgid "Cannot create an instance of the abstract class or interface `{0}'" +msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:5767 -msgid "Cannot create an array with a negative size" +#: mcs/mcs/field.cs:70 +msgid "" +"The modifier 'abstract' is not valid on fields. Try using a property instead" msgstr "" -#: ../mcs/mcs/expression.cs:5784 ../mcs/mcs/statement.cs:2991 -msgid "A constant value is expected" +#: mcs/mcs/field.cs:121 +msgid "" +"The FieldOffset attribute can only be placed on members of types marked with " +"the StructLayout(LayoutKind.Explicit)" msgstr "" -#: ../mcs/mcs/expression.cs:5871 -msgid "An expression tree cannot contain a multidimensional array initializer" +#: mcs/mcs/field.cs:126 +msgid "The FieldOffset attribute is not allowed on static or const fields" msgstr "" -#: ../mcs/mcs/expression.cs:5965 +#: mcs/mcs/field.cs:132 msgid "" -"Can only use array initializer expressions to assign to array types. Try " -"using a new expression instead" +"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " +"'fixed' field modifier instead" msgstr "" -#: ../mcs/mcs/expression.cs:5970 +#: mcs/mcs/field.cs:237 +#, csharp-format msgid "" -"An implicitly typed local variable declarator cannot use an array initializer" +"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " +"must have a FieldOffset attribute" +msgstr "" + +#: mcs/mcs/field.cs:246 +#, fuzzy, csharp-format +msgid "`{0}': cannot declare variables of static types" +msgstr "`{0}': staticクラスではインデクサを宣言できません" + +#: mcs/mcs/field.cs:388 +#, csharp-format +msgid "" +"`{0}': Fixed size buffers type must be one of the following: bool, byte, " +"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +msgstr "" + +#: mcs/mcs/field.cs:424 +#, csharp-format +msgid "`{0}': Fixed size buffer fields may only be members of structs" msgstr "" -#: ../mcs/mcs/expression.cs:6045 -msgid "New invocation: Can not find a constructor for this argument list" +#: mcs/mcs/field.cs:439 +#, csharp-format +msgid "`{0}': Fixed size buffers must have a length greater than zero" msgstr "" -#: ../mcs/mcs/expression.cs:6488 +#: mcs/mcs/field.cs:446 +#, csharp-format msgid "" -"The type of an implicitly typed array cannot be inferred from the " -"initializer. Try specifying array type explicitly" +"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +msgstr "" + +#: mcs/mcs/field.cs:628 +#, fuzzy, csharp-format +msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgstr "`{0}': sealedクラス `{1}' から派生することはできません" + +#: mcs/mcs/field.cs:633 +#, fuzzy, csharp-format +msgid "`{0}': A field cannot be both volatile and readonly" +msgstr "`{0}': クラスはstaticかつsealedとすることはできません" + +#: mcs/mcs/flowanalysis.cs:307 +msgid "Control cannot fall through from one case label to another" msgstr "" -#: ../mcs/mcs/expression.cs:6666 +#: mcs/mcs/flowanalysis.cs:536 +#, csharp-format msgid "" -"Anonymous methods inside structs cannot access instance members of `this'. " -"Consider copying `this' to a local variable outside the anonymous method and " -"using the local instead" +"The label `{0}:' could not be found within the scope of the goto statement" msgstr "" -#: ../mcs/mcs/expression.cs:6740 -msgid "Cannot take the address of `this' because it is read-only" +#: mcs/mcs/flowanalysis.cs:664 +msgid "" +"A throw statement with no arguments is not allowed outside of a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6742 -msgid "Cannot pass `this' as a ref or out argument because it is read-only" +#: mcs/mcs/flowanalysis.cs:675 mcs/mcs/flowanalysis.cs:681 +msgid "No enclosing loop out of which to break or continue" msgstr "" -#: ../mcs/mcs/expression.cs:6744 -msgid "Cannot assign to `this' because it is read-only" +#: mcs/mcs/flowanalysis.cs:709 +msgid "Control cannot leave the body of an anonymous method" msgstr "" -#: ../mcs/mcs/expression.cs:6856 -msgid "An expression tree cannot contain a method with variable arguments" +#: mcs/mcs/flowanalysis.cs:750 +msgid "Cannot yield a value in the body of a try block with a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:6966 -#, csharp-format -msgid "`{0}': an attribute argument cannot use type parameters" +#: mcs/mcs/flowanalysis.cs:752 +msgid "Cannot yield a value in the body of a catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:7199 -#, csharp-format +#: mcs/mcs/flowanalysis.cs:904 msgid "" -"`{0}' does not have a predefined size, therefore sizeof can only be used in " -"an unsafe context (consider using System.Runtime.InteropServices.Marshal." -"SizeOf)" +"A throw statement with no arguments is not allowed inside of a finally " +"clause nested inside of the innermost catch clause" msgstr "" -#: ../mcs/mcs/expression.cs:7254 -#, csharp-format -msgid "Alias `{0}' not found" +#: mcs/mcs/flowanalysis.cs:916 mcs/mcs/iterators.cs:102 +msgid "Cannot yield in the body of a finally clause" +msgstr "" + +#: mcs/mcs/flowanalysis.cs:927 mcs/mcs/flowanalysis.cs:943 +#: mcs/mcs/flowanalysis.cs:979 mcs/mcs/statement.cs:694 +msgid "Control cannot leave the body of a finally clause" msgstr "" -#: ../mcs/mcs/expression.cs:7265 +#: mcs/mcs/flowanalysis.cs:1130 #, csharp-format msgid "" -"Alias `{0}' cannot be used with '::' since it denotes a type. Consider " -"replacing '::' with '.'" +"An automatically implemented property `{0}' must be fully assigned before " +"control leaves the constructor. Consider calling the default struct " +"contructor from a constructor initializer" msgstr "" -#: ../mcs/mcs/expression.cs:7281 +#: mcs/mcs/flowanalysis.cs:1134 #, csharp-format msgid "" -"A namespace alias qualifier `{0}' did not resolve to a namespace or a type" +"Field `{0}' must be fully assigned before control leaves the constructor" msgstr "" -#: ../mcs/mcs/expression.cs:7422 -#, csharp-format -msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" +#: mcs/mcs/flowanalysis.cs:1376 +msgid "Use of unassigned local variable `" +msgstr "" + +#: mcs/mcs/flowanalysis.cs:1446 +msgid "Use of possibly unassigned field `" msgstr "" -#: ../mcs/mcs/expression.cs:7519 +#: mcs/mcs/generic.cs:102 mcs/mcs/generic.cs:120 #, csharp-format -msgid "A nested type cannot be specified through a type parameter `{0}'" +msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:7587 +#: mcs/mcs/generic.cs:173 #, csharp-format -msgid "The nested type `{0}' does not exist in the type `{1}'" +msgid "A constraint cannot be the dynamic type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:7599 +#: mcs/mcs/generic.cs:182 #, csharp-format msgid "" -"Type `{0}' does not contain a definition for `{1}' and no extension method `" -"{1}' of type `{0}' could be found (are you missing a using directive or an " -"assembly reference?)" +"Inconsistent accessibility: constraint type `{0}' is less accessible than `" +"{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:7817 -msgid "Cannot apply indexing with [] to an expression of type `System.Array'" +#: mcs/mcs/generic.cs:189 mcs/mcs/generic.cs:203 +#, fuzzy, csharp-format +msgid "Duplicate constraint `{0}' for type parameter `{1}'" msgstr "" +"`{0}' の部分的な宣言の間で、型パラメータ `{1}' について一貫性のない制約が含ま" +"れています" -#: ../mcs/mcs/expression.cs:7923 +#: mcs/mcs/generic.cs:218 #, csharp-format -msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" +msgid "Circular constraint dependency involving `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8410 +#: mcs/mcs/generic.cs:249 #, csharp-format msgid "" -"A property or indexer `{0}' may not be passed as an out or ref parameter" +"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " +"constraint for `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8435 +#: mcs/mcs/generic.cs:260 #, csharp-format -msgid "Cannot apply indexing with [] to an expression of type `{0}'" +msgid "" +"The class type constraint `{0}' must be listed before any other constraints. " +"Consider moving type constraint to the beginning of the constraint list" msgstr "" -#: ../mcs/mcs/expression.cs:8465 +#: mcs/mcs/generic.cs:266 #, csharp-format -msgid "The read only property or indexer `{0}' cannot be assigned to" +msgid "" +"`{0}': cannot specify both a constraint class and the `class' or `struct' " +"constraint" +msgstr "" + +#: mcs/mcs/generic.cs:271 +msgid "A constraint cannot be the dynamic type" msgstr "" -#: ../mcs/mcs/expression.cs:8473 +#: mcs/mcs/generic.cs:277 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks a `{1}' accessor" +"`{0}' is not a valid constraint. A constraint must be an interface, a non-" +"sealed class or a type parameter" msgstr "" -#: ../mcs/mcs/expression.cs:8495 +#: mcs/mcs/generic.cs:284 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because a `{1}' " -"accessor is inaccessible" +"`{0}' is not a valid constraint. Static classes cannot be used as constraints" msgstr "" -#: ../mcs/mcs/expression.cs:8958 +#: mcs/mcs/generic.cs:290 #, csharp-format -msgid "Array elements cannot be of type `{0}'" +msgid "A constraint cannot be special class `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:8964 +#: mcs/mcs/generic.cs:538 #, csharp-format -msgid "Array elements cannot be of static type `{0}'" +msgid "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'" msgstr "" -#: ../mcs/mcs/expression.cs:9130 -msgid "Cannot use a negative size with stackalloc" +#: mcs/mcs/generic.cs:1720 +#, csharp-format +msgid "`{0}': static classes cannot be used as generic arguments" msgstr "" -#: ../mcs/mcs/expression.cs:9257 +#: mcs/mcs/generic.cs:1727 #, csharp-format -msgid "" -"Member `{0}' cannot be initialized. An object initializer may only be used " -"for fields, or properties" +msgid "The type `{0}' may not be used as a type argument" msgstr "" -#: ../mcs/mcs/expression.cs:9260 +#: mcs/mcs/generic.cs:1982 #, csharp-format msgid "" -" Static field or property `{0}' cannot be assigned in an object initializer" +"The type `{0}' must be a reference type in order to use it as type parameter " +"`{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9433 +#: mcs/mcs/generic.cs:1992 #, csharp-format msgid "" -"A field or property `{0}' cannot be initialized with a collection object " -"initializer because type `{1}' does not implement `{2}' interface" +"The type `{0}' must be a non-nullable value type in order to use it as type " +"parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9444 +#: mcs/mcs/generic.cs:2022 #, csharp-format -msgid "Inconsistent `{0}' member declaration" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. The nullable type `{0}' never satisfies interface constraint" msgstr "" -#: ../mcs/mcs/expression.cs:9452 +#: mcs/mcs/generic.cs:2061 #, csharp-format msgid "" -"An object initializer includes more than one member `{0}' initialization" +"The type `{0}' must have a public parameterless constructor in order to use " +"it as parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:9469 +#: mcs/mcs/generic.cs:2113 #, csharp-format -msgid "Cannot initialize object of type `{0}' with a collection initializer" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing conversion from `{0}' to `{3}'" msgstr "" -#: ../mcs/mcs/expression.cs:9717 -#, fuzzy -msgid "Anonymous types cannot be used in this expression" -msgstr "匿名メソッドを式ツリーに変換することはできません" - -#: ../mcs/mcs/expression.cs:9824 +#: mcs/mcs/generic.cs:2117 #, csharp-format -msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" -msgstr "" - -#: ../mcs/mcs/flowanalysis.cs:310 -msgid "Control cannot fall through from one case label to another" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing or type parameter conversion from `{0}' to `" +"{3}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:529 +#: mcs/mcs/generic.cs:2121 #, csharp-format msgid "" -"The label `{0}:' could not be found within the scope of the goto statement" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'" +msgstr "" + +#: mcs/mcs/iterators.cs:44 +msgid "The yield statement cannot be used inside anonymous method blocks" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:657 +#: mcs/mcs/iterators.cs:856 +#, csharp-format msgid "" -"A throw statement with no arguments is not allowed outside of a catch clause" +"The body of `{0}' cannot be an iterator block because `{1}' is not an " +"iterator interface type" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:668 ../mcs/mcs/flowanalysis.cs:674 -msgid "No enclosing loop out of which to break or continue" +#: mcs/mcs/iterators.cs:869 +msgid "Iterators cannot have ref or out parameters" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:702 -msgid "Control cannot leave the body of an anonymous method" +#: mcs/mcs/iterators.cs:875 +msgid "__arglist is not allowed in parameter list of iterators" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:743 -msgid "Cannot yield a value in the body of a try block with a catch clause" +#: mcs/mcs/iterators.cs:881 +msgid "Iterators cannot have unsafe parameters or yield types" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:745 -msgid "Cannot yield a value in the body of a catch clause" +#: mcs/mcs/iterators.cs:888 mcs/mcs/statement.cs:4324 +msgid "Unsafe code may not appear in iterators" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:897 +#: mcs/mcs/linq.cs:68 +#, csharp-format msgid "" -"A throw statement with no arguments is not allowed inside of a finally " -"clause nested inside of the innermost catch clause" +"An implementation of `{0}' query expression pattern could not be found. Are " +"you missing `System.Linq' using directive or `System.Core.dll' assembly " +"reference?" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:909 ../mcs/mcs/iterators.cs:112 -msgid "Cannot yield in the body of a finally clause" +#: mcs/mcs/linq.cs:93 +#, csharp-format +msgid "" +"Ambiguous implementation of the query pattern `{0}' for source type `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:920 ../mcs/mcs/flowanalysis.cs:936 -#: ../mcs/mcs/flowanalysis.cs:972 ../mcs/mcs/statement.cs:778 -msgid "Control cannot leave the body of a finally clause" +#: mcs/mcs/linq.cs:124 +#, csharp-format +msgid "" +"An implementation of `{0}' query expression pattern for source type `{1}' " +"could not be found" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1140 +#: mcs/mcs/linq.cs:132 #, csharp-format msgid "" -"An automatically implemented property `{0}' must be fully assigned before " -"control leaves the constructor. Consider calling default contructor" +"An expression type is incorrect in a subsequent `from' clause in a query " +"expression with source type `{0}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1144 +#: mcs/mcs/linq.cs:136 #, csharp-format msgid "" -"Field `{0}' must be fully assigned before control leaves the constructor" +"An expression type in `{0}' clause is incorrect. Type inference failed in " +"the call to `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1438 -msgid "Use of unassigned local variable `" +#: mcs/mcs/linq.cs:248 +#, csharp-format +msgid "A range variable `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1508 -msgid "Use of possibly unassigned field `" +#: mcs/mcs/linq.cs:750 +#, csharp-format +msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:191 -msgid "The new() constraint must be the last constraint specified" +#: mcs/mcs/linq.cs:757 +#, csharp-format +msgid "A range variable `{0}' has already been declared in this scope" msgstr "" -#: ../mcs/mcs/generic.cs:204 -msgid "The `new()' constraint cannot be used with the `struct' constraint" +#: mcs/mcs/linq.cs:764 +#, csharp-format +msgid "A range variable `{0}' conflicts with a method type parameter" msgstr "" -#: ../mcs/mcs/generic.cs:210 +#: mcs/mcs/linq.cs:796 +#, csharp-format msgid "" -"The `class' or `struct' constraint must be the first constraint specified" +"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " +"store the value" msgstr "" -#: ../mcs/mcs/generic.cs:249 +#: mcs/mcs/literal.cs:49 #, csharp-format msgid "" -"Inconsistent accessibility: constraint type `{0}' is less accessible than `" -"{1}'" +"Cannot convert null to the type parameter `{0}' because it could be a value " +"type. Consider using `default ({0})' instead" msgstr "" -#: ../mcs/mcs/generic.cs:261 +#: mcs/mcs/literal.cs:55 #, csharp-format -msgid "" -"The class type constraint `{0}' must be listed before any other constraints. " -"Consider moving type constraint to the beginning of the constraint list" +msgid "Cannot convert null to `{0}' because it is a value type" msgstr "" -#: ../mcs/mcs/generic.cs:265 +#: mcs/mcs/literal.cs:204 #, csharp-format msgid "" -"`{0}': cannot specify both a constraint class and the `class' or `struct' " -"constraint" +"Literal of type double cannot be implicitly converted to type `{0}'. Add " +"suffix `{1}' to create a literal of this type" msgstr "" -#: ../mcs/mcs/generic.cs:282 ../mcs/mcs/generic.cs:297 -#, csharp-format -msgid "Duplicate constraint `{0}' for type parameter `{1}'." +#: mcs/mcs/membercache.cs:1261 +msgid "" +"A partial method declaration and partial method implementation cannot differ " +"on use of `params' modifier" msgstr "" -#: ../mcs/mcs/generic.cs:316 -#, csharp-format +#: mcs/mcs/membercache.cs:1264 msgid "" -"`{0}' is not a valid constraint. Static classes cannot be used as constraints" +"A partial method declaration and partial method implementation must be both " +"an extension method or neither" msgstr "" -#: ../mcs/mcs/generic.cs:321 +#: mcs/mcs/membercache.cs:1268 #, csharp-format msgid "" -"`{0}' is not a valid constraint. A constraint must be an interface, a non-" -"sealed class or a type parameter" +"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only" msgstr "" -#: ../mcs/mcs/generic.cs:334 -#, csharp-format -msgid "A constraint cannot be special class `{0}'" +#: mcs/mcs/membercache.cs:1272 +#, fuzzy, csharp-format +msgid "" +"Overloaded method `{0}' cannot differ on use of parameter modifiers only" +msgstr "Conditionalメソッド `{0}' ではoutパラメータを指定できません" + +#: mcs/mcs/membercache.cs:1304 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`static' or neither" msgstr "" -#: ../mcs/mcs/generic.cs:364 -#, csharp-format +#: mcs/mcs/membercache.cs:1309 msgid "" -"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " -"constraint for `{1}'" +"A partial method declaration and partial method implementation must be both " +"`unsafe' or neither" msgstr "" -#: ../mcs/mcs/generic.cs:384 +#: mcs/mcs/membercache.cs:1315 +#, fuzzy, csharp-format +msgid "A partial method `{0}' declaration is already defined" +msgstr "部分メソッド `{0}' はインターフェースを明示的に実装できません" + +#: mcs/mcs/membercache.cs:1319 +#, fuzzy, csharp-format +msgid "A partial method `{0}' implementation is already defined" +msgstr "部分メソッド `{0}' はインターフェースを明示的に実装できません" + +#: mcs/mcs/membercache.cs:1330 mcs/mcs/property.cs:81 #, csharp-format -msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" +msgid "A member `{0}' is already reserved" msgstr "" -#: ../mcs/mcs/generic.cs:398 +#: mcs/mcs/membercache.cs:1341 #, csharp-format -msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgid "Duplicate user-defined conversion in type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:702 -#, csharp-format +#: mcs/mcs/method.cs:484 msgid "" -"`{0}': Cannot specify constraints for overrides or explicit interface " -"implementation methods" +"The DllImport attribute must be specified on a method marked `static' and " +"`extern'" msgstr "" +"`static'かつ`extern'で宣言されたメソッドには、DllImport属性が指定されなければ" +"なりません" + +#: mcs/mcs/method.cs:572 +#, csharp-format +msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgstr "`{0}': 部分メソッドのパラメータで`out'修飾子は使用できません" -#: ../mcs/mcs/generic.cs:733 +#: mcs/mcs/method.cs:631 #, csharp-format msgid "" -"The constraints for type parameter `{0}' of method `{1}' must match the " -"constraints for type parameter `{2}' of interface method `{3}'. Consider " -"using an explicit interface implementation instead" +"Conditional not valid on `{0}' because it is a constructor, destructor, " +"operator or explicit interface implementation" msgstr "" +"Conditionalは コンストラクタ、デストラクタ、演算子または明示的なインター" +"フェースの実装である `{0}' では無効です" -#: ../mcs/mcs/generic.cs:1139 -msgid "Type parameter declaration must be an identifier not a type" -msgstr "" +#: mcs/mcs/method.cs:844 +#, csharp-format +msgid "Program `{0}' has more than one entry point defined: `{1}'" +msgstr "プログラム `{0}' には複数のエントリポイントが定義されています: `{1}'" -#: ../mcs/mcs/generic.cs:1231 +#: mcs/mcs/method.cs:888 #, csharp-format -msgid "`{0}': static classes cannot be used as generic arguments" -msgstr "" +msgid "Conditional not valid on `{0}' because it is an override method" +msgstr "Conditionalはオーバーライドメソッドである `{0}' では無効です" -#: ../mcs/mcs/generic.cs:1238 +#: mcs/mcs/method.cs:893 #, csharp-format -msgid "The type `{0}' may not be used as a type argument" -msgstr "" +msgid "Conditional not valid on `{0}' because its return type is not void" +msgstr "Conditionalは戻り値型がvoidでない `{0}' では無効です" -#: ../mcs/mcs/generic.cs:1368 +#: mcs/mcs/method.cs:898 +msgid "Conditional not valid on interface members" +msgstr "Conditionalはインターフェースメンバでは無効です" + +#: mcs/mcs/method.cs:904 #, csharp-format -msgid "Cannot find type `{0}'<...>" +msgid "Conditional member `{0}' cannot implement interface member `{1}'" msgstr "" +"Conditionalメンバ `{0}' はインターフェースメンバ `{1}' を実装できません" -#: ../mcs/mcs/generic.cs:1375 +#: mcs/mcs/method.cs:911 #, csharp-format -msgid "The non-generic type `{0}' cannot be used with type arguments." -msgstr "" +msgid "Conditional method `{0}' cannot have an out parameter" +msgstr "Conditionalメソッド `{0}' ではoutパラメータを指定できません" -#: ../mcs/mcs/generic.cs:1531 +#: mcs/mcs/method.cs:1017 #, csharp-format msgid "" -"The type `{0}' must be a reference type in order to use it as type parameter " -"`{1}' in the generic type or method `{2}'." +"The constraints for type parameter `{0}' of method `{1}' must match the " +"constraints for type parameter `{2}' of interface method `{3}'. Consider " +"using an explicit interface implementation instead" msgstr "" -#: ../mcs/mcs/generic.cs:1540 +#: mcs/mcs/method.cs:1071 +#, fuzzy, csharp-format +msgid "`{0}': Extension methods cannot be defined in a nested class" +msgstr "`{0}': 拡張メソッドはstaticで宣言されなければなりません" + +#: mcs/mcs/method.cs:1077 #, csharp-format msgid "" -"The type `{0}' must be a non-nullable value type in order to use it as type " -"parameter `{1}' in the generic type or method `{2}'." +"`{0}': Extension methods cannot be declared without a reference to System." +"Core.dll assembly. Add the assembly reference or remove `this' modifer from " +"the first parameter" msgstr "" +"`{0}': 拡張メソッドはSystem.Core.dllアセンブリへの参照なしでは宣言できませ" +"ん。アセンブリ参照を追加するか、または最初のパラメータから `this' 修飾子を取" +"り除いてください。" + +#: mcs/mcs/method.cs:1086 +#, fuzzy, csharp-format +msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgstr "`{0}': 拡張メソッドはstaticで宣言されなければなりません" -#: ../mcs/mcs/generic.cs:1583 +#: mcs/mcs/method.cs:1139 #, csharp-format msgid "" -"The type `{0}' must have a public parameterless constructor in order to use " -"it as parameter `{1}' in the generic type or method `{2}'" +"A partial method `{0}' implementation is missing a partial method declaration" msgstr "" -#: ../mcs/mcs/generic.cs:1628 +#: mcs/mcs/method.cs:1186 #, csharp-format -msgid "" -"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " -"method `{2}'. The nullable type `{0}' never satisfies interface constraint " -"of type `{3}'" +msgid "Method or delegate cannot return type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1634 -#, csharp-format +#: mcs/mcs/method.cs:1261 msgid "" -"The type `{0}' must be convertible to `{1}' in order to use it as parameter `" -"{2}' in the generic type or method `{3}'" +"The constructor call cannot be dynamically dispatched within constructor " +"initializer" msgstr "" -#: ../mcs/mcs/generic.cs:1827 +#: mcs/mcs/method.cs:1275 +#, fuzzy, csharp-format +msgid "`{0}': Struct constructors cannot call base constructors" +msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" + +#: mcs/mcs/method.cs:1294 #, csharp-format -msgid "The type parameter name `{0}' is the same as `{1}'" +msgid "Constructor `{0}' cannot call itself" msgstr "" -#: ../mcs/mcs/iterators.cs:42 ../mcs/mcs/iterators.cs:939 -msgid "Unsafe code may not appear in iterators" +#: mcs/mcs/method.cs:1413 +#, csharp-format +msgid "`{0}': The static constructor must be parameterless" msgstr "" -#: ../mcs/mcs/iterators.cs:52 -msgid "The yield statement cannot be used inside anonymous method blocks" +#: mcs/mcs/method.cs:1431 +msgid "Structs cannot contain explicit parameterless constructors" msgstr "" -#: ../mcs/mcs/iterators.cs:907 -#, csharp-format +#: mcs/mcs/method.cs:1487 +#, fuzzy, csharp-format msgid "" -"The body of `{0}' cannot be an iterator block because `{1}' is not an " -"iterator interface type" -msgstr "" +"`{0}': A class with the ComImport attribute cannot have a user-defined " +"constructor" +msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" -#: ../mcs/mcs/iterators.cs:920 -msgid "Iterators cannot have ref or out parameters" +#: mcs/mcs/method.cs:1730 +#, fuzzy, csharp-format +msgid "`{0}' is an accessor not found in interface member `{1}{2}'" +msgstr "`{0}' は継承されるabstractメンバ `{1}' を隠蔽してしまいます" + +#: mcs/mcs/method.cs:1736 +#, fuzzy, csharp-format +msgid "" +"`{0}.{1}' in explicit interface declaration is not a member of interface" msgstr "" +"明示的なインターフェースの宣言で記述された `{0}' は、インターフェースではあり" +"ません" -#: ../mcs/mcs/iterators.cs:926 -msgid "__arglist is not allowed in parameter list of iterators" +#: mcs/mcs/method.cs:1743 +#, csharp-format +msgid "" +"`{0}' explicit method implementation cannot implement `{1}' because it is an " +"accessor" msgstr "" -#: ../mcs/mcs/iterators.cs:932 -msgid "Iterators cannot have unsafe parameters or yield types" +#: mcs/mcs/method.cs:1753 +#, fuzzy, csharp-format +msgid "Method `{0}' cannot implement interface accessor `{1}'" msgstr "" +"Conditionalメンバ `{0}' はインターフェースメンバ `{1}' を実装できません" -#: ../mcs/mcs/linq.cs:79 +#: mcs/mcs/method.cs:1759 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern could not be found. Are " -"you missing `System.Linq' using directive or `System.Core.dll' assembly " -"reference?" +"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " +"an explicit interface implementation" msgstr "" -#: ../mcs/mcs/linq.cs:117 -#, csharp-format +#: mcs/mcs/method.cs:1765 +#, fuzzy, csharp-format msgid "" -"An implementation of `{0}' query expression pattern for source type `{1}' " -"could not be found" +"Accessor `{0}' must be declared public to implement interface member `{1}'" msgstr "" +"Conditionalメンバ `{0}' はインターフェースメンバ `{1}' を実装できません" -#: ../mcs/mcs/linq.cs:126 -#, csharp-format +#: mcs/mcs/method.cs:1789 +#, fuzzy, csharp-format msgid "" -"Type inference failed to infer type argument for `{0}' clause. Try " -"specifying the type argument explicitly" +"`{0}': the explicit interface implementation cannot introduce the params " +"modifier" msgstr "" +"明示的なインターフェースの宣言で記述された `{0}' は、インターフェースではあり" +"ません" -#: ../mcs/mcs/linq.cs:525 -#, csharp-format -msgid "A range variable `{0}' cannot be initialized with `{1}'" -msgstr "" +#: mcs/mcs/method.cs:2107 +#, fuzzy, csharp-format +msgid "" +"Attribute `{0}' is not valid on property or event accessors. It is valid on `" +"{1}' declarations only" +msgstr "属性 `{0}' はこの宣言型では無効です。 `{1}' の宣言でのみ有効です" -#: ../mcs/mcs/linq.cs:825 +#: mcs/mcs/method.cs:2318 #, csharp-format -msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" +msgid "User-defined operator `{0}' must be declared static and public" msgstr "" -#: ../mcs/mcs/linq.cs:831 -#, csharp-format -msgid "A range variable `{0}' has already been declared in this scope" +#: mcs/mcs/method.cs:2357 +msgid "" +"User-defined operator cannot take an object of the enclosing type and " +"convert to an object of the enclosing type" msgstr "" -#: ../mcs/mcs/linq.cs:837 -#, csharp-format -msgid "A range variable `{0}' conflicts with a method type parameter" +#: mcs/mcs/method.cs:2368 +msgid "User-defined conversion must convert to or from the enclosing type" msgstr "" -#: ../mcs/mcs/literal.cs:76 +#: mcs/mcs/method.cs:2374 +#, fuzzy, csharp-format +msgid "" +"User-defined conversion `{0}' cannot convert to or from the dynamic type" +msgstr "`{0}' は特別なクラス `{1}' から派生することはできません" + +#: mcs/mcs/method.cs:2381 #, csharp-format msgid "" -"Cannot convert null to the type parameter `{0}' because it could be a value " -"type. Consider using `default ({0})' instead" +"User-defined conversion `{0}' cannot convert to or from an interface type" msgstr "" -#: ../mcs/mcs/literal.cs:79 +#: mcs/mcs/method.cs:2388 #, csharp-format -msgid "Cannot convert null to `{0}' because it is a value type" +msgid "User-defined conversion `{0}' cannot convert to or from a base class" msgstr "" -#: ../mcs/mcs/literal.cs:323 +#: mcs/mcs/method.cs:2394 #, csharp-format +msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgstr "" + +#: mcs/mcs/method.cs:2401 msgid "" -"Literal of type double cannot be implicitly converted to type `{0}'. Add " -"suffix `{1}' to create a literal of this type" +"Overloaded shift operator must have the type of the first operand be the " +"containing type, and the type of the second operand must be int" msgstr "" -#: ../mcs/mcs/location.cs:224 -#, csharp-format -msgid "Source file `{0}' specified multiple times" +#: mcs/mcs/method.cs:2410 +msgid "" +"The return type for ++ or -- operator must be the containing type or derived " +"from the containing type" msgstr "" -#: ../mcs/mcs/location.cs:226 -#, csharp-format -msgid "Source filenames `{0}' and `{1}' both refer to the same file: {2}" +#: mcs/mcs/method.cs:2415 +msgid "The parameter type for ++ or -- operator must be the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:241 -msgid "More than one protection modifier specified" +#: mcs/mcs/method.cs:2422 +msgid "The parameter type of a unary operator must be the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:258 -msgid "The modifier `" +#: mcs/mcs/method.cs:2430 +msgid "The return type of operator True or False must be bool" msgstr "" -#: ../mcs/mcs/namespace.cs:113 -#, csharp-format -msgid "An assembly `{0}' is used without being referenced" +#: mcs/mcs/method.cs:2445 +msgid "One of the parameters of a binary operator must be the containing type" msgstr "" -#: ../mcs/mcs/namespace.cs:136 +#: mcs/mcs/modifiers.cs:275 #, csharp-format -msgid "The imported type `{0}' is defined multiple times" +msgid "The modifier `{0}' is not valid for this item" msgstr "" -#: ../mcs/mcs/namespace.cs:259 +#: mcs/mcs/namespace.cs:70 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found in the global namespace " "(are you missing an assembly reference?)" msgstr "" -#: ../mcs/mcs/namespace.cs:380 +#: mcs/mcs/namespace.cs:177 #, csharp-format msgid "" "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are " "you missing an assembly reference?" msgstr "" -#: ../mcs/mcs/namespace.cs:387 -#, csharp-format -msgid "Using the generic type `{0}' requires `{1}' type argument(s)" -msgstr "" - -#: ../mcs/mcs/namespace.cs:405 +#: mcs/mcs/namespace.cs:256 #, csharp-format -msgid "The non-generic {0} `{1}' cannot be used with the type arguments" +msgid "The imported type `{0}' is defined multiple times" msgstr "" -#: ../mcs/mcs/namespace.cs:642 +#: mcs/mcs/namespace.cs:583 #, csharp-format msgid "" "`{0}' is a type not a namespace. A using namespace directive can only be " "applied to namespaces" msgstr "" -#: ../mcs/mcs/namespace.cs:669 +#: mcs/mcs/namespace.cs:610 #, csharp-format msgid "The extern alias `{0}' was not specified in -reference option" msgstr "" -#: ../mcs/mcs/namespace.cs:880 ../mcs/mcs/namespace.cs:902 +#: mcs/mcs/namespace.cs:820 mcs/mcs/namespace.cs:842 msgid "" "A using clause must precede all other namespace elements except extern alias " "declarations" msgstr "" -#: ../mcs/mcs/namespace.cs:926 +#: mcs/mcs/namespace.cs:866 msgid "An extern alias declaration must precede all other elements" msgstr "" -#: ../mcs/mcs/namespace.cs:944 +#: mcs/mcs/namespace.cs:884 #, csharp-format msgid "The using alias `{0}' appeared previously in this namespace" msgstr "" -#: ../mcs/mcs/namespace.cs:1017 +#: mcs/mcs/namespace.cs:1005 #, csharp-format -msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" +msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1056 +#: mcs/mcs/namespace.cs:1059 #, csharp-format -msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" +msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1149 -msgid "You cannot redefine the global extern alias" +#: mcs/mcs/namespace.cs:1127 +msgid "The global extern alias cannot be redefined" msgstr "" -#: ../mcs/mcs/namespace.cs:1159 +#: mcs/mcs/namespace.cs:1132 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found. Are you missing a using " "directive or an assembly reference?" msgstr "" -#: ../mcs/mcs/nullable.cs:985 +#: mcs/mcs/nullable.cs:1036 msgid "" "An expression tree cannot contain a coalescing operator with null left side" msgstr "" -#: ../mcs/mcs/parameter.cs:176 +#: mcs/mcs/parameter.cs:156 msgid "The params parameter must be a single dimensional array" msgstr "" -#: ../mcs/mcs/parameter.cs:277 -msgid "Invalid parameter type `void'" -msgstr "" - -#: ../mcs/mcs/parameter.cs:288 +#: mcs/mcs/parameter.cs:288 msgid "An out parameter cannot have the `In' attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:293 +#: mcs/mcs/parameter.cs:293 msgid "" "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead" msgstr "" -#: ../mcs/mcs/parameter.cs:300 +#: mcs/mcs/parameter.cs:300 msgid "" "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and " "`Out' attributes or neither" msgstr "" -#: ../mcs/mcs/parameter.cs:318 +#: mcs/mcs/parameter.cs:310 +#, fuzzy, csharp-format +msgid "Cannot specify `{0}' attribute on optional parameter `{1}'" +msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" + +#: mcs/mcs/parameter.cs:320 #, csharp-format -msgid "Argument of type `{0}' is not applicable for the DefaultValue attribute" +msgid "" +"Argument of type `{0}' is not applicable for the DefaultParameterValue " +"attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:321 +#: mcs/mcs/parameter.cs:323 #, csharp-format msgid "" -"The DefaultValue attribute is not applicable on parameters of type `{0}'" +"The DefaultParameterValue attribute is not applicable on parameters of type `" +"{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:333 +#: mcs/mcs/parameter.cs:334 msgid "The type of the default value should match the type of the parameter" msgstr "" -#: ../mcs/mcs/parameter.cs:373 +#: mcs/mcs/parameter.cs:376 #, csharp-format msgid "Method or delegate parameter cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:386 +#: mcs/mcs/parameter.cs:386 #, csharp-format msgid "`{0}': static types cannot be used as parameters" msgstr "" -#: ../mcs/mcs/parameter.cs:392 +#: mcs/mcs/parameter.cs:392 +#, fuzzy, csharp-format +msgid "The extension method cannot be of type `{0}'" +msgstr "`{0}': 拡張メソッドはネストしたクラスの中では定義できません" + +#: mcs/mcs/parameter.cs:448 +#, csharp-format +msgid "" +"The expression being assigned to optional parameter `{0}' must be a constant " +"or default value" +msgstr "" + +#: mcs/mcs/parameter.cs:464 #, csharp-format -msgid "The type of extension method cannot be `{0}'" +msgid "" +"The expression being assigned to nullable optional parameter `{0}' must be " +"default value" msgstr "" -#: ../mcs/mcs/parameter.cs:497 -msgid "An expression tree parameter cannot use `ref' or `out' modifier" +#: mcs/mcs/parameter.cs:472 +#, csharp-format +msgid "" +"Optional parameter `{0}' of type `{1}' can only be initialized with `null'" msgstr "" -#: ../mcs/mcs/parameter.cs:884 +#: mcs/mcs/parameter.cs:482 #, csharp-format -msgid "The parameter name `{0}' is a duplicate" +msgid "" +"Optional parameter expression of type `{0}' cannot be converted to parameter " +"type `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:624 +msgid "An expression tree parameter cannot use `ref' or `out' modifier" msgstr "" -#: ../mcs/mcs/parameter.cs:936 +#: mcs/mcs/parameter.cs:1096 #, csharp-format msgid "The parameter name `{0}' conflicts with a compiler generated name" msgstr "" -#: ../mcs/mcs/pending.cs:598 +#: mcs/mcs/pending.cs:443 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' is static" msgstr "" -#: ../mcs/mcs/pending.cs:602 +#: mcs/mcs/pending.cs:447 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' in not public" msgstr "" -#: ../mcs/mcs/pending.cs:606 +#: mcs/mcs/pending.cs:451 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " @@ -2963,88 +3436,166 @@ msgid "" "type `{4}'" msgstr "" -#: ../mcs/mcs/pending.cs:611 +#: mcs/mcs/pending.cs:456 #, csharp-format msgid "`{0}' does not implement interface member `{1}'" msgstr "" -#: ../mcs/mcs/pending.cs:615 +#: mcs/mcs/pending.cs:461 #, csharp-format msgid "`{0}' does not implement inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:574 +#: mcs/mcs/property.cs:352 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers may not be used on accessors in an interface" +msgstr "" + +#: mcs/mcs/property.cs:356 +#, fuzzy, csharp-format +msgid "`{0}': abstract properties cannot have private accessors" +msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" + +#: mcs/mcs/property.cs:401 +#, csharp-format +msgid "" +"The accessibility modifier of the `{0}' accessor must be more restrictive " +"than the modifier of the property or indexer `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:502 +#, csharp-format +msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:521 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable get " +"accessor" +msgstr "`{0}': `{1}' はイベントではないため、オーバーライドできません" + +#: mcs/mcs/property.cs:538 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable set " +"accessor" +msgstr "`{0}': `{1}' はイベントではないため、オーバーライドできません" + +#: mcs/mcs/property.cs:579 +#, csharp-format +msgid "" +"`{0}': Cannot specify accessibility modifiers for both accessors of the " +"property or indexer" +msgstr "" + +#: mcs/mcs/property.cs:586 #, csharp-format msgid "" -"Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " -"`gmcs' compiler instead" +"`{0}': accessibility modifiers on accessors may only be used if the property " +"or indexer has both a get and a set accessor" msgstr "" -#: ../mcs/mcs/report.cs:582 +#: mcs/mcs/property.cs:783 #, csharp-format msgid "" -"Feature `{0}' cannot be used because it is not part of the C# {1} language " -"specification" +"Automatically implemented property `{0}' cannot be used inside a type with " +"an explicit StructLayout attribute" +msgstr "" + +#: mcs/mcs/property.cs:1274 +#, csharp-format +msgid "`{0}': event must be of a delegate type" msgstr "" -#: ../mcs/mcs/report.cs:639 +#: mcs/mcs/property.cs:1482 #, csharp-format msgid "" -"Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime " -"instead." +"The `{0}' attribute is valid only on an indexer that is not an explicit " +"interface member declaration" msgstr "" -#: ../mcs/mcs/rootcontext.cs:410 -msgid "Unsafe code requires the `unsafe' command line option to be specified" +#: mcs/mcs/property.cs:1516 +#, fuzzy +msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" + +#: mcs/mcs/reflection.cs:217 +msgid "Could not access the key inside the container `" +msgstr "" + +#: mcs/mcs/roottypes.cs:363 +msgid "" +"The compilation may fail due to missing `System.Reflection.Emit." +"AssemblyBuilder.SetCorlibTypeBuilders(...)' method" +msgstr "" + +#: mcs/mcs/roottypes.cs:470 +#, csharp-format +msgid "Value specified for the argument to `{0}' is not valid" msgstr "" -#: ../mcs/mcs/statement.cs:105 +#: mcs/mcs/statement.cs:87 msgid "" "A lambda expression with statement body cannot be converted to an expresion " "tree" msgstr "" -#: ../mcs/mcs/statement.cs:818 +#: mcs/mcs/statement.cs:740 +#, csharp-format msgid "" -"Cannot return a value from iterators. Use the yield return statement to " -"return a value, or yield break to end the iteration" +"An object of a type convertible to `{0}' is required for the return statement" msgstr "" -#: ../mcs/mcs/statement.cs:825 +#: mcs/mcs/statement.cs:753 #, csharp-format msgid "" "`{0}': A return keyword must not be followed by any expression when method " "returns void" msgstr "" -#: ../mcs/mcs/statement.cs:849 +#: mcs/mcs/statement.cs:778 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' because some of the return types " "in the block are not implicitly convertible to the delegate return type" msgstr "" -#: ../mcs/mcs/statement.cs:1041 ../mcs/mcs/statement.cs:1073 +#: mcs/mcs/statement.cs:806 +msgid "" +"Cannot return a value from iterators. Use the yield return statement to " +"return a value, or yield break to end the iteration" +msgstr "" + +#: mcs/mcs/statement.cs:963 mcs/mcs/statement.cs:997 msgid "A goto case is only valid inside a switch statement" msgstr "" -#: ../mcs/mcs/statement.cs:1656 -#, csharp-format -msgid "" -"The label `{0}' shadows another label by the same name in a contained scope" +#: mcs/mcs/statement.cs:1076 mcs/mcs/statement.cs:4726 +msgid "The type caught or thrown must be derived from System.Exception" msgstr "" -#: ../mcs/mcs/statement.cs:1681 -#, csharp-format -msgid "The label `{0}' is a duplicate" +#: mcs/mcs/statement.cs:1298 +msgid "A fixed statement cannot use an implicitly typed local variable" msgstr "" -#: ../mcs/mcs/statement.cs:1776 -#, csharp-format -msgid "`{0}' conflicts with a declaration in a child block" +#: mcs/mcs/statement.cs:1303 +msgid "An implicitly typed local variable cannot be a constant" +msgstr "" + +#: mcs/mcs/statement.cs:1308 +msgid "" +"An implicitly typed local variable declarator must include an initializer" +msgstr "" + +#: mcs/mcs/statement.cs:1313 +msgid "" +"An implicitly typed local variable declaration cannot include multiple " +"declarators" msgstr "" -#: ../mcs/mcs/statement.cs:1877 +#: mcs/mcs/statement.cs:1883 #, csharp-format msgid "" "A local variable named `{0}' cannot be declared in this scope because it " @@ -3052,102 +3603,112 @@ msgid "" "scope to denote something else" msgstr "" -#: ../mcs/mcs/statement.cs:1886 +#: mcs/mcs/statement.cs:1894 +#, csharp-format +msgid "" +"`{0}': An anonymous type cannot have multiple properties with the same name" +msgstr "`{0}': 匿名型は同一の名前で複数のプロパティをもつことができません" + +#: mcs/mcs/statement.cs:1897 +#, csharp-format +msgid "The parameter name `{0}' is a duplicate" +msgstr "" + +#: mcs/mcs/statement.cs:1904 #, csharp-format msgid "A local variable named `{0}' is already defined in this scope" msgstr "" -#: ../mcs/mcs/statement.cs:2041 -msgid "An implicitly typed local variable cannot be a constant" +#: mcs/mcs/statement.cs:1910 +#, fuzzy, csharp-format +msgid "" +"The type parameter name `{0}' is the same as local variable or parameter name" msgstr "" +"型パラメータ `{0}' が、その宣言型あるいはメソッドと同じ名前になっています" -#: ../mcs/mcs/statement.cs:2891 +#: mcs/mcs/statement.cs:2482 #, csharp-format msgid "" "The out parameter `{0}' must be assigned to before control leaves the " "current method" msgstr "" -#: ../mcs/mcs/statement.cs:3024 +#: mcs/mcs/statement.cs:2573 #, csharp-format -msgid "The label `case {0}:' already occurs in this switch statement" +msgid "`{0}': not all code paths return a value" msgstr "" -#: ../mcs/mcs/statement.cs:3570 -msgid "A value of an integral type or string expected for switch" +#: mcs/mcs/statement.cs:2577 +#, csharp-format +msgid "Not all code paths return a value in anonymous method of type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4029 +#: mcs/mcs/statement.cs:2748 #, csharp-format -msgid "`{0}' is not a reference type as required by the lock statement" +msgid "The label `{0}' is a duplicate" msgstr "" -#: ../mcs/mcs/statement.cs:4346 -msgid "A fixed statement cannot use an implicitly typed local variable" +#: mcs/mcs/statement.cs:2757 mcs/mcs/statement.cs:2768 +#, csharp-format +msgid "" +"The label `{0}' shadows another label by the same name in a contained scope" +msgstr "" + +#: mcs/mcs/statement.cs:3088 +#, csharp-format +msgid "The label `case {0}:' already occurs in this switch statement" +msgstr "" + +#: mcs/mcs/statement.cs:3629 +#, csharp-format +msgid "" +"A switch expression of type `{0}' cannot be converted to an integral type, " +"bool, char, string, enum or nullable type" +msgstr "" + +#: mcs/mcs/statement.cs:4114 +#, csharp-format +msgid "`{0}' is not a reference type as required by the lock statement" msgstr "" -#: ../mcs/mcs/statement.cs:4356 +#: mcs/mcs/statement.cs:4455 msgid "The type of locals declared in a fixed statement must be a pointer type" msgstr "" -#: ../mcs/mcs/statement.cs:4380 +#: mcs/mcs/statement.cs:4471 msgid "" "The right hand side of a fixed statement assignment may not be a cast " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4457 +#: mcs/mcs/statement.cs:4542 msgid "" "You cannot use the fixed statement to take the address of an already fixed " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4707 -msgid "Try statement already has an empty catch block" -msgstr "" - -#: ../mcs/mcs/statement.cs:4745 +#: mcs/mcs/statement.cs:4856 #, csharp-format msgid "" "A previous catch clause already catches all exceptions of this or a super " "type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4920 ../mcs/mcs/statement.cs:5035 -msgid "Internal error: No Dispose method which takes 0 parameters." -msgstr "" - -#: ../mcs/mcs/statement.cs:4992 +#: mcs/mcs/statement.cs:5029 #, csharp-format msgid "" "`{0}': type used in a using statement must be implicitly convertible to " "`System.IDisposable'" msgstr "" -#: ../mcs/mcs/statement.cs:5115 -msgid "Use of null is not valid in this context" -msgstr "" - -#: ../mcs/mcs/statement.cs:5120 -#, csharp-format -msgid "Foreach statement cannot operate on a `{0}'" -msgstr "" - -#: ../mcs/mcs/statement.cs:5433 +#: mcs/mcs/statement.cs:5451 #, csharp-format msgid "" "foreach statement requires that the return type `{0}' of `{1}' must have a " "suitable public MoveNext method and public Current property" msgstr "" -#: ../mcs/mcs/statement.cs:5518 -#, csharp-format -msgid "" -"foreach statement cannot operate on variables of type `{0}' because it does " -"not contain a definition for `GetEnumerator' or is not accessible" -msgstr "" - -#: ../mcs/mcs/statement.cs:5570 +#: mcs/mcs/statement.cs:5490 #, csharp-format msgid "" "foreach statement cannot operate on variables of type `{0}' because it " @@ -3155,53 +3716,74 @@ msgid "" "implementation" msgstr "" -#: ../mcs/mcs/typemanager.cs:878 +#: mcs/mcs/statement.cs:5509 #, csharp-format -msgid "The predefined type `{0}.{1}' is not defined or imported" +msgid "" +"foreach statement cannot operate on variables of type `{0}' because it does " +"not contain a definition for `{1}' or is inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:902 -#, csharp-format -msgid "The predefined type `{0}.{1}' is not declared correctly" +#: mcs/mcs/statement.cs:5715 +msgid "Use of null is not valid in this context" msgstr "" -#: ../mcs/mcs/typemanager.cs:952 +#: mcs/mcs/statement.cs:5725 #, csharp-format -msgid "" -"The compiler required member `{0}.{1}{2}' could not be found or is " -"inaccessible" +msgid "Foreach statement cannot operate on a `{0}'" msgstr "" -#: ../mcs/mcs/typemanager.cs:1161 +#: mcs/mcs/typemanager.cs:389 #, csharp-format -msgid "" -"The compilation may fail due to missing `{0}.SetCorlibTypeBuilders({1})' " -"method" +msgid "The predefined type `{0}.{1}' is not defined or imported" msgstr "" -#: ../mcs/mcs/typemanager.cs:1706 +#: mcs/mcs/typemanager.cs:395 #, csharp-format -msgid "" -"Friend access was granted to `{0}', but the output assembly is named `{1}'. " -"Try adding a reference to `{0}' or change the output assembly name to match " -"it" +msgid "The predefined type `{0}.{1}' is not declared correctly" msgstr "" -#: ../mcs/mcs/typemanager.cs:1961 +#: mcs/mcs/typemanager.cs:574 #, csharp-format msgid "" -"Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" +"The compiler required member `{0}.{1}{2}' could not be found or is " +"inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:2308 +#: mcs/mcs/typemanager.cs:885 #, csharp-format msgid "" "Cannot take the address of, get the size of, or declare a pointer to a " "managed type `{0}'" msgstr "" -#~ msgid "Class, struct, or interface method must have a return type" -#~ msgstr "クラス、構造体、インターフェースのメソッドには戻り値型が必要です" - -#~ msgid "Keyword `new' is not allowed on namespace elements" -#~ msgstr "キーワード `new' は名前空間要素で認められていません" +#~ msgid "Can not use a type parameter in an attribute" +#~ msgstr "属性の中で型パラメータを使用することはできません" + +#~ msgid "" +#~ "Added modules must be marked with the CLSCompliant attribute to match the " +#~ "assembly" +#~ msgstr "" +#~ "追加されるモジュールは、アセンブリに適合するCLSCompliant属性でマークされな" +#~ "ければなりません" + +#~ msgid "" +#~ "`{0}': Any identifier with double underscores cannot be used when ISO " +#~ "language version mode is specified" +#~ msgstr "" +#~ "`{0}': ISO言語バージョンモードが指定されている場合は、2文字のアンダーライ" +#~ "ンで始まる識別子は使用できません" + +#~ msgid "Cannot derive from `{0}' because it is a type parameter" +#~ msgstr "`{0}' は型パラメータであるため、ここから派生することはできません" + +#~ msgid "Do not override object.Finalize. Instead, provide a destructor" +#~ msgstr "" +#~ "object.Finalizeをオーバーライドせず、代わりにデストラクタを提供してくださ" +#~ "い" + +#~ msgid "" +#~ "Referenced file `{0}' is not an assembly. Consider using `-addmodule' " +#~ "option instead" +#~ msgstr "" +#~ "参照ファイル `{0}' はアセンブリではありません。代わりに`-addmodule' オプ" +#~ "ションを使用してみてください" diff --git a/po/mcs/mcs.pot b/po/mcs/mcs.pot index 604b5dae6fd5..edf46e95c92a 100644 --- a/po/mcs/mcs.pot +++ b/po/mcs/mcs.pot @@ -6,92 +6,121 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: mono 2.9\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2008-09-29 12:41-0300\n" +"POT-Creation-Date: 2010-12-16 13:01+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../mcs/mcs/anonymous.cs:850 +#: mcs/mcs/anonymous.cs:880 #, csharp-format msgid "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:856 +#: mcs/mcs/anonymous.cs:885 #, csharp-format msgid "Cannot convert `{0}' to non-delegate type `{1}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:868 +#: mcs/mcs/anonymous.cs:897 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' since there is a parameter " "mismatch" msgstr "" -#: ../mcs/mcs/anonymous.cs:880 ../mcs/mcs/delegate.cs:568 +#: mcs/mcs/anonymous.cs:909 mcs/mcs/ecore.cs:4469 #, csharp-format msgid "Delegate `{0}' does not take `{1}' arguments" msgstr "" -#: ../mcs/mcs/anonymous.cs:895 +#: mcs/mcs/anonymous.cs:924 #, csharp-format msgid "Parameter `{0}' should not be declared with the `{1}' keyword" msgstr "" -#: ../mcs/mcs/anonymous.cs:898 +#: mcs/mcs/anonymous.cs:927 #, csharp-format msgid "Parameter `{0}' must be declared with the `{1}' keyword" msgstr "" -#: ../mcs/mcs/anonymous.cs:919 +#: mcs/mcs/anonymous.cs:948 #, csharp-format msgid "Parameter `{0}' is declared as type `{1}' but should be `{2}'" msgstr "" -#: ../mcs/mcs/anonymous.cs:1043 +#: mcs/mcs/anonymous.cs:1103 msgid "An anonymous method cannot be converted to an expression tree" msgstr "" -#: ../mcs/mcs/anonymous.cs:1060 +#: mcs/mcs/anonymous.cs:1122 #, csharp-format msgid "" "Cannot convert anonymous method block without a parameter list to delegate " -"type `{0}' because it has one or more `out' parameters." +"type `{0}' because it has one or more `out' parameters" msgstr "" -#: ../mcs/mcs/anonymous.cs:1085 +#: mcs/mcs/anonymous.cs:1146 msgid "" "Anonymous methods and lambda expressions cannot be used in the current " "context" msgstr "" -#: ../mcs/mcs/anonymous.cs:1122 +#: mcs/mcs/anonymous.cs:1188 #, csharp-format msgid "" "Local variable or parameter `{0}' cannot have their address taken and be " "used inside an anonymous method or lambda expression" msgstr "" -#: ../mcs/mcs/anonymous.cs:1353 +#: mcs/mcs/anonymous.cs:1438 msgid "An expression tree cannot contain an anonymous method expression" msgstr "" -#: ../mcs/mcs/anonymous.cs:1647 +#: mcs/mcs/argument.cs:101 +msgid "" +"An expression tree cannot contain an invocation which uses optional parameter" +msgstr "" + +#: mcs/mcs/argument.cs:184 +msgid "An expression tree cannot contain named argument" +msgstr "" + +#: mcs/mcs/argument.cs:303 #, csharp-format msgid "" -"`{0}': An anonymous type cannot have multiple properties with the same name" +"The method group `{0}' cannot be used as an argument of dynamic operation. " +"Consider using parentheses to invoke the method" +msgstr "" + +#: mcs/mcs/argument.cs:307 +msgid "" +"An anonymous method or lambda expression cannot be used as an argument of " +"dynamic operation. Consider using a cast" +msgstr "" + +#: mcs/mcs/argument.cs:310 +#, csharp-format +msgid "" +"An expression of type `{0}' cannot be used as an argument of dynamic " +"operation" msgstr "" -#: ../mcs/mcs/assign.cs:325 +#: mcs/mcs/assign.cs:299 msgid "An expression tree cannot contain an assignment operator" msgstr "" -#: ../mcs/mcs/attribute.cs:165 +#: mcs/mcs/assign.cs:627 +#, csharp-format +msgid "Cannot assign to `{0}' because it is a `{1}'" +msgstr "" + +#: mcs/mcs/attribute.cs:196 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument. Named attribute arguments " @@ -99,2158 +128,2190 @@ msgid "" "properties which are public and not static" msgstr "" -#: ../mcs/mcs/attribute.cs:173 +#: mcs/mcs/attribute.cs:205 #, csharp-format msgid "" "`{0}' is not a valid named attribute argument because it is not a valid " "attribute parameter type" msgstr "" -#: ../mcs/mcs/attribute.cs:180 -msgid "" -"An attribute argument must be a constant expression, typeof expression or " -"array creation expression" -msgstr "" - -#: ../mcs/mcs/attribute.cs:187 -msgid "Can not use a type parameter in an attribute" +#: mcs/mcs/attribute.cs:211 +msgid "An attribute argument cannot be dynamic expression" msgstr "" -#: ../mcs/mcs/attribute.cs:192 +#: mcs/mcs/attribute.cs:216 msgid "The Guid attribute must be specified with the ComImport attribute" msgstr "" -#: ../mcs/mcs/attribute.cs:197 +#: mcs/mcs/attribute.cs:221 #, csharp-format msgid "Do not use `{0}' directly. Use parameter modifier `this' instead" msgstr "" -#: ../mcs/mcs/attribute.cs:206 +#: mcs/mcs/attribute.cs:226 +#, csharp-format +msgid "Do not use `{0}' directly. Use `dynamic' keyword instead" +msgstr "" + +#: mcs/mcs/attribute.cs:235 #, csharp-format msgid "Error during emitting `{0}' attribute. The reason is `{1}'" msgstr "" -#: ../mcs/mcs/attribute.cs:245 +#: mcs/mcs/attribute.cs:266 #, csharp-format msgid "`{0}': is not an attribute class" msgstr "" -#: ../mcs/mcs/attribute.cs:263 +#: mcs/mcs/attribute.cs:302 #, csharp-format msgid "" -"`{0}' is ambiguous between `{0}' and `{0}Attribute'. Use either `@{0}' or `" -"{0}Attribute'" +"`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}" +"Attribute'" msgstr "" -#: ../mcs/mcs/attribute.cs:365 +#: mcs/mcs/attribute.cs:385 #, csharp-format msgid "Cannot apply attribute class `{0}' because it is abstract" msgstr "" -#: ../mcs/mcs/attribute.cs:490 -msgid "Invalid value for argument to `System.AttributeUsage' attribute" -msgstr "" - -#: ../mcs/mcs/attribute.cs:498 -#, csharp-format -msgid "The argument to the `{0}' attribute must be a valid identifier" -msgstr "" - -#: ../mcs/mcs/attribute.cs:528 +#: mcs/mcs/attribute.cs:453 #, csharp-format -msgid "'{0}' duplicate named attribute argument" +msgid "Duplicate named attribute `{0}' argument" msgstr "" -#: ../mcs/mcs/attribute.cs:870 +#: mcs/mcs/attribute.cs:730 #, csharp-format msgid "" "`{0}' is not a valid attribute location for this declaration. Valid " "attribute locations for this declaration are `{1}'" msgstr "" -#: ../mcs/mcs/attribute.cs:1199 +#: mcs/mcs/attribute.cs:1004 #, csharp-format msgid "" "The attribute `{0}' is not valid on this declaration type. It is valid on `" "{1}' declarations only" msgstr "" -#: ../mcs/mcs/attribute.cs:1493 +#: mcs/mcs/attribute.cs:1022 #, csharp-format -msgid "The attribute `{0}' cannot be applied multiple times" +msgid "The argument to the `{0}' attribute must be a valid identifier" msgstr "" -#: ../mcs/mcs/attribute.cs:1661 -msgid "" -"Added modules must be marked with the CLSCompliant attribute to match the " -"assembly" +#: mcs/mcs/attribute.cs:1035 +#, csharp-format +msgid "Invalid value for argument to `{0}' attribute" msgstr "" -#: ../mcs/mcs/attribute.cs:1802 +#: mcs/mcs/attribute.cs:1341 #, csharp-format -msgid "`{0}' is obsolete: `{1}'" +msgid "The attribute `{0}' cannot be applied multiple times" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1276 ../mcs/mcs/cs-tokenizer.cs:1346 -msgid "Invalid number" +#: mcs/mcs/attribute.cs:1603 +#, csharp-format +msgid "`{0}' is obsolete: `{1}'" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1532 -#, csharp-format -msgid "Unrecognized escape sequence `\\{0}'" +#: mcs/mcs/cs-parser.cs:1646 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1551 -msgid "Unrecognized escape sequence" +#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 +msgid "Interfaces cannot contain fields or constants" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1811 -msgid "Missing identifier to pre-processor directive" +#: mcs/mcs/cs-parser.cs:1952 +msgid "Interfaces cannot contain operators" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:1821 ../mcs/mcs/cs-tokenizer.cs:1825 -#, csharp-format -msgid "Identifier expected: {0}" +#: mcs/mcs/cs-parser.cs:1958 +msgid "Interfaces cannot contain contructors" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2201 -msgid "Numeric constant too long" +#: mcs/mcs/cs-parser.cs:1964 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2206 -msgid "Invalid preprocessor directive" +#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 +msgid "A const field requires a value to be provided" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2213 -#, csharp-format -msgid "Unexpected processor directive ({0})" +#: mcs/mcs/cs-parser.cs:3602 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2218 -#, csharp-format -msgid "Expected `{0}'" +#: mcs/mcs/cs-parser.cs:3884 +msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2224 +#: mcs/mcs/cs-parser.cs:3948 msgid "" -"Cannot define or undefine preprocessor symbols after first token in file" +"Namespace elements cannot be explicitly declared as private, protected or " +"protected internal" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2230 +#: mcs/mcs/cs-parser.cs:3963 msgid "" -"Preprocessor directives must appear as the first non-whitespace character on " -"a line" +"Assembly and module attributes must precede all other elements except using " +"clauses and extern alias declarations" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2235 -msgid "Single-line comment or end-of-line expected" +#: mcs/mcs/cs-parser.cs:4080 +msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2280 ../mcs/mcs/cs-tokenizer.cs:3006 -msgid "Expected `#endif' directive" +#: mcs/mcs/cs-parser.cs:4117 +msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2313 ../mcs/mcs/cs-tokenizer.cs:2334 -#: ../mcs/mcs/cs-tokenizer.cs:2365 ../mcs/mcs/cs-tokenizer.cs:3004 -msgid "#endregion directive expected" +#: mcs/mcs/cs-parser.cs:4163 +#, csharp-format +msgid "" +"Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2420 +#: mcs/mcs/cs-parser.cs:4220 #, csharp-format -msgid "#error: '{0}'" +msgid "The constant `{0}' cannot be marked static" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2440 -msgid "The line number specified for #line directive is missing or invalid" +#: mcs/mcs/cs-parser.cs:4268 +msgid "Fields cannot have void type" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2444 -msgid "Wrong preprocessor directive" +#: mcs/mcs/cs-parser.cs:4369 +msgid "Value or constant expected" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2474 ../mcs/mcs/cs-tokenizer.cs:2837 -msgid "Newline in constant" +#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 +#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 +#: mcs/mcs/cs-parser.cs:5427 +#, csharp-format +msgid "`{0}': interface members cannot have a definition" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2490 -msgid "Unterminated string literal" +#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +msgid "Constraints are not allowed on non-generic declarations" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2537 +#: mcs/mcs/cs-parser.cs:4429 +#, csharp-format msgid "" -"The `partial' modifier can be used only immediately before `class', " -"`struct', `interface', or `void' keyword" +"`{0}': Cannot specify constraints for overrides and explicit interface " +"implementation methods" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2568 -msgid "Identifier too long (limit is 512 chars)" +#: mcs/mcs/cs-parser.cs:4470 +msgid "" +"A partial method cannot define access modifier or any of abstract, extern, " +"new, override, sealed, or virtual modifiers" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2624 -#, csharp-format +#: mcs/mcs/cs-parser.cs:4476 msgid "" -"`{0}': Any identifier with double underscores cannot be used when ISO " -"language version mode is specified" +"A partial method must be declared within a partial class or partial struct" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2739 -msgid "End-of-file found, '*/' expected" +#: mcs/mcs/cs-parser.cs:4499 +#, csharp-format +msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: ../mcs/mcs/cs-tokenizer.cs:2876 -msgid "Keyword, identifier, or string expected after verbatim specifier: @" +#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +msgid "" +"A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: ../mcs/mcs/cfold.cs:66 -msgid "The operation overflows at compile time in checked mode" +#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +msgid "" +"An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: ../mcs/mcs/cfold.cs:693 ../mcs/mcs/cfold.cs:773 -msgid "Division by constant zero" +#: mcs/mcs/cs-parser.cs:4601 +msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: ../mcs/mcs/class.cs:156 -#, csharp-format -msgid "" -"The operator `{0}' requires a matching operator `{1}' to also be defined" +#: mcs/mcs/cs-parser.cs:4603 +msgid "Optional parameter cannot precede required parameters" msgstr "" -#: ../mcs/mcs/class.cs:351 -#, csharp-format -msgid "" -"Partial declarations of `{0}' must be all classes, all structs or all " -"interfaces" +#: mcs/mcs/cs-parser.cs:4625 +msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: ../mcs/mcs/class.cs:360 +#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 #, csharp-format -msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" +msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" -#: ../mcs/mcs/class.cs:416 -#, csharp-format -msgid "" -"`{0}': explicit interface declaration can only be declared in a class or " -"struct" +#: mcs/mcs/cs-parser.cs:4666 +msgid "Optional parameter is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:455 ../mcs/mcs/decl.cs:2803 -#, csharp-format -msgid "" -"A member `{0}' is already defined. Rename this member or use different " -"parameter types" +#: mcs/mcs/cs-parser.cs:4686 +msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:572 -msgid "" -"Cannot specify the `DefaultMember' attribute on type containing an indexer" +#: mcs/mcs/cs-parser.cs:4689 +msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:855 -#, csharp-format -msgid "`{0}' is already listed in interface list" +#: mcs/mcs/cs-parser.cs:4692 +msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: ../mcs/mcs/class.cs:863 -#, csharp-format -msgid "" -"Inconsistent accessibility: base interface `{0}' is less accessible than " -"interface `{1}'" +#: mcs/mcs/cs-parser.cs:4739 +msgid "Cannot specify a default value for a parameter array" msgstr "" -#: ../mcs/mcs/class.cs:869 -#, csharp-format -msgid "Type `{0}' in interface list is not an interface" +#: mcs/mcs/cs-parser.cs:4756 +msgid "The `params' modifier is not allowed in current context" msgstr "" -#: ../mcs/mcs/class.cs:871 -#, csharp-format -msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" +#: mcs/mcs/cs-parser.cs:4764 +msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: ../mcs/mcs/class.cs:874 -#, csharp-format -msgid "`{0}': Base class `{1}' must be specified as first" +#: mcs/mcs/cs-parser.cs:4766 +msgid "The params parameter cannot be declared as ref or out" msgstr "" -#: ../mcs/mcs/class.cs:901 -#, csharp-format -msgid "Partial declarations of `{0}' must not specify different base classes" +#: mcs/mcs/cs-parser.cs:4774 +msgid "__arglist is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:942 +#: mcs/mcs/cs-parser.cs:4791 #, csharp-format -msgid "" -"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " -"type parameter substitutions" +msgid "`{0}': property or indexer cannot have void type" msgstr "" -#: ../mcs/mcs/class.cs:1164 +#: mcs/mcs/cs-parser.cs:4829 #, csharp-format -msgid "" -"Partial declarations of `{0}' must have the same type parameter names in the " -"same order" +msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: ../mcs/mcs/class.cs:1184 -#, csharp-format -msgid "" -"Partial declarations of `{0}' have inconsistent constraints for type " -"parameter `{1}'" +#: mcs/mcs/cs-parser.cs:4832 +msgid "Indexers must have at least one parameter" msgstr "" -#: ../mcs/mcs/class.cs:1274 +#: mcs/mcs/cs-parser.cs:4857 #, csharp-format -msgid "" -"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" +msgid "`{0}': property or indexer must have at least one accessor" msgstr "" -#: ../mcs/mcs/class.cs:1279 -#, csharp-format -msgid "Circular base class dependency involving `{0}' and `{1}'" +#: mcs/mcs/cs-parser.cs:4860 +msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: ../mcs/mcs/class.cs:1459 -msgid "" -"Two indexers have different names; the IndexerName attribute must be used " -"with the same name on every indexer within a type" +#: mcs/mcs/cs-parser.cs:4862 +msgid "A get or set accessor expected" msgstr "" -#: ../mcs/mcs/class.cs:2293 -#, csharp-format -msgid "A static member `{0}' cannot be marked as override, virtual or abstract" +#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +msgid "Property accessor already defined" msgstr "" -#: ../mcs/mcs/class.cs:2307 -#, csharp-format -msgid "A member `{0}' marked as override cannot be marked as new or virtual" +#: mcs/mcs/cs-parser.cs:5036 +msgid "User-defined operators cannot return void" msgstr "" -#: ../mcs/mcs/class.cs:2319 -#, csharp-format -msgid "`{0}' cannot be both extern and abstract" +#: mcs/mcs/cs-parser.cs:5059 +msgid "Overloadable binary operator expected" msgstr "" -#: ../mcs/mcs/class.cs:2324 +#: mcs/mcs/cs-parser.cs:5061 #, csharp-format -msgid "`{0}' cannot be both abstract and sealed" +msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "" -#: ../mcs/mcs/class.cs:2329 +#: mcs/mcs/cs-parser.cs:5066 #, csharp-format -msgid "The abstract method `{0}' cannot be marked virtual" +msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: ../mcs/mcs/class.cs:2335 -#, csharp-format -msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" +#: mcs/mcs/cs-parser.cs:5069 +msgid "Overloadable unary operator expected" msgstr "" -#: ../mcs/mcs/class.cs:2343 -#, csharp-format -msgid "`{0}': virtual or abstract members cannot be private" +#: mcs/mcs/cs-parser.cs:5183 +msgid "Class, struct, or interface method must have a return type" msgstr "" -#: ../mcs/mcs/class.cs:2350 +#: mcs/mcs/cs-parser.cs:5187 #, csharp-format -msgid "`{0}' cannot be sealed because it is not an override" +msgid "`{0}': static constructor cannot have an access modifier" msgstr "" -#: ../mcs/mcs/class.cs:2436 +#: mcs/mcs/cs-parser.cs:5192 #, csharp-format -msgid "`{0}': containing type does not implement interface `{1}'" +msgid "" +"`{0}': static constructor cannot have an explicit `this' or `base' " +"constructor call" msgstr "" -#: ../mcs/mcs/class.cs:2570 -#, csharp-format -msgid "Type parameter `{0}' has same name as containing type, or method" +#: mcs/mcs/cs-parser.cs:5241 +msgid "Name of destructor must match name of class" msgstr "" -#: ../mcs/mcs/class.cs:2576 -#, csharp-format -msgid "`{0}': member names cannot be the same as their enclosing type" +#: mcs/mcs/cs-parser.cs:5243 +msgid "Only class types can contain destructor" msgstr "" -#: ../mcs/mcs/class.cs:2718 +#: mcs/mcs/cs-parser.cs:5265 +#, csharp-format msgid "" -"The class System.Object cannot have a base class or implement an interface." +"`{0}': An explicit interface implementation of an event must use property " +"syntax" msgstr "" -#: ../mcs/mcs/class.cs:2727 -#, csharp-format -msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" +#: mcs/mcs/cs-parser.cs:5298 +msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: ../mcs/mcs/class.cs:2732 -msgid "" -"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " -"or attribute classes" +#: mcs/mcs/cs-parser.cs:5344 +#, csharp-format +msgid "`{0}': event in interface cannot have an initializer" msgstr "" -#: ../mcs/mcs/class.cs:2771 +#: mcs/mcs/cs-parser.cs:5349 #, csharp-format -msgid "`{0}': Static classes cannot contain user-defined operators" +msgid "`{0}': abstract event cannot have an initializer" msgstr "" -#: ../mcs/mcs/class.cs:2776 +#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 #, csharp-format -msgid "`{0}': Static classes cannot contain destructor" +msgid "`{0}': event property must have both add and remove accessors" msgstr "" -#: ../mcs/mcs/class.cs:2781 -#, csharp-format -msgid "`{0}': cannot declare indexers in a static class" +#: mcs/mcs/cs-parser.cs:5371 +msgid "An add or remove accessor expected" msgstr "" -#: ../mcs/mcs/class.cs:2789 -#, csharp-format -msgid "`{0}': Static classes cannot have instance constructors" +#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: ../mcs/mcs/class.cs:2795 -#, csharp-format -msgid "`{0}': Extension methods must be declared static" +#: mcs/mcs/cs-parser.cs:5436 +msgid "An add or remove accessor must have a body" msgstr "" -#: ../mcs/mcs/class.cs:2799 -#, csharp-format -msgid "`{0}': cannot declare instance members in a static class" +#: mcs/mcs/cs-parser.cs:5455 +msgid "Enums cannot have type parameters" msgstr "" -#: ../mcs/mcs/class.cs:2808 -#, csharp-format -msgid "`{0}': an abstract class cannot be sealed or static" +#: mcs/mcs/cs-parser.cs:5755 +msgid "Type parameter declaration must be an identifier not a type" msgstr "" -#: ../mcs/mcs/class.cs:2812 -#, csharp-format -msgid "`{0}': a class cannot be both static and sealed" +#: mcs/mcs/cs-parser.cs:5779 +msgid "Invalid parameter type `void'" msgstr "" -#: ../mcs/mcs/class.cs:2849 +#: mcs/mcs/cs-parser.cs:5825 #, csharp-format -msgid "Cannot derive from `{0}' because it is a type parameter" +msgid "Invalid base type `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:2856 -#, csharp-format -msgid "" -"A generic type cannot derive from `{0}' because it is an attribute class" +#: mcs/mcs/cs-parser.cs:5984 +msgid "An element initializer cannot be empty" msgstr "" -#: ../mcs/mcs/class.cs:2863 +#: mcs/mcs/cs-parser.cs:6015 #, csharp-format -msgid "`{0}': Cannot derive from static class `{1}'" +msgid "Named argument `{0}' specified multiple times" msgstr "" -#: ../mcs/mcs/class.cs:2866 -#, csharp-format -msgid "`{0}': cannot derive from sealed class `{1}'" +#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +msgid "An argument is missing" msgstr "" -#: ../mcs/mcs/class.cs:2873 -#, csharp-format -msgid "`{0}' cannot derive from special class `{1}'" +#: mcs/mcs/cs-parser.cs:6166 +msgid "Array creation must have array size or array initializer" msgstr "" -#: ../mcs/mcs/class.cs:2880 -#, csharp-format -msgid "" -"Inconsistent accessibility: base class `{0}' is less accessible than class `" -"{1}'" +#: mcs/mcs/cs-parser.cs:6183 +msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: ../mcs/mcs/class.cs:2887 -#, csharp-format +#: mcs/mcs/cs-parser.cs:6256 msgid "" -"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " -"from object" +"Invalid anonymous type member declarator. Anonymous type members must be a " +"member assignment, simple name or member access expression" msgstr "" -#: ../mcs/mcs/class.cs:2895 -#, csharp-format -msgid "Static class `{0}' cannot implement interfaces" +#: mcs/mcs/cs-parser.cs:6658 +msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: ../mcs/mcs/class.cs:3041 +#: mcs/mcs/cs-parser.cs:6799 #, csharp-format -msgid "`{0}': Structs cannot have instance field initializers" +msgid "Duplicate `{0}' modifier" msgstr "" -#: ../mcs/mcs/class.cs:3362 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not an event" +#: mcs/mcs/cs-parser.cs:6803 +msgid "More than one protection modifier specified" msgstr "" -#: ../mcs/mcs/class.cs:3364 -#, csharp-format -msgid "`{0}': cannot override because `{1}' is not a property" +#: mcs/mcs/cs-parser.cs:6816 +msgid "Keyword `new' is not allowed on namespace elements" msgstr "" -#: ../mcs/mcs/class.cs:3366 +#: mcs/mcs/cs-parser.cs:6936 #, csharp-format -msgid "`{0}': cannot override because `{1}' is not a method" +msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:3368 -#, csharp-format -msgid "`{0}' is marked as an override but no suitable {1} found to override" +#: mcs/mcs/cs-parser.cs:6966 +msgid "The `new()' constraint must be the last constraint specified" msgstr "" -#: ../mcs/mcs/class.cs:3407 -#, csharp-format +#: mcs/mcs/cs-parser.cs:6972 msgid "" -"`{0}': cannot override inherited member `{1}' because it is not marked " -"virtual, abstract or override" -msgstr "" - -#: ../mcs/mcs/class.cs:3416 -#, csharp-format -msgid "`{0}': cannot override inherited member `{1}' because it is sealed" +"The `class' or `struct' constraint must be the first constraint specified" msgstr "" -#: ../mcs/mcs/class.cs:3434 -#, csharp-format -msgid "`{0}': type must be `{1}' to match overridden member `{2}'" +#: mcs/mcs/cs-parser.cs:6976 +msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" -#: ../mcs/mcs/class.cs:3438 +#: mcs/mcs/cs-parser.cs:6989 #, csharp-format -msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" +msgid "Invalid constraint type `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:3460 -#, csharp-format -msgid "`{0}' hides inherited abstract member `{1}'" +#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: ../mcs/mcs/class.cs:3520 -#, csharp-format +#: mcs/mcs/cs-parser.cs:7213 msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"indexer `{1}'" +"Syntax error, bad array declarator. To declare a managed array the rank " +"specifier precedes the variable's identifier. To declare a fixed size buffer " +"field, use the fixed keyword before the field type" msgstr "" -#: ../mcs/mcs/class.cs:3524 -#, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"operator `{1}'" +#: mcs/mcs/cs-parser.cs:7262 +msgid "A stackalloc expression requires [] after type" msgstr "" -#: ../mcs/mcs/class.cs:3528 -#, csharp-format -msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"method `{1}'" +#: mcs/mcs/cs-parser.cs:7468 +msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: ../mcs/mcs/class.cs:3548 -#, csharp-format -msgid "`{0}' in explicit interface declaration is not an interface" +#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +msgid "; expected" msgstr "" -#: ../mcs/mcs/class.cs:3587 -#, csharp-format -msgid "A partial method `{0}' cannot explicitly implement an interface" +#: mcs/mcs/cs-parser.cs:7555 +msgid "Expression expected after yield return" msgstr "" -#: ../mcs/mcs/class.cs:3595 -#, csharp-format -msgid "'{0}' in explicit interface declaration is not an interface" +#: mcs/mcs/cs-parser.cs:7598 +msgid "Expected catch or finally" msgstr "" -#: ../mcs/mcs/class.cs:3614 -#, csharp-format -msgid "" -"`{0}' is marked as an external but has no DllImport attribute. Consider " -"adding a DllImport attribute to specify the external implementation" +#: mcs/mcs/cs-parser.cs:7618 +msgid "Try statement already has an empty catch block" msgstr "" -#: ../mcs/mcs/class.cs:3631 -#, csharp-format +#: mcs/mcs/cs-parser.cs:7651 msgid "" -"`{0}': cannot change access modifiers when overriding `{1}' inherited member " -"`{2}'" +"A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: ../mcs/mcs/class.cs:3724 -msgid "" -"The DllImport attribute must be specified on a method marked `static' and " -"`extern'" +#: mcs/mcs/cs-parser.cs:11367 +msgid "Expecting `;'" msgstr "" -#: ../mcs/mcs/class.cs:3787 +#: mcs/mcs/cs-parser.cs:11375 #, csharp-format -msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgid "The parameter modifier `{0}' is not valid in this context" msgstr "" -#: ../mcs/mcs/class.cs:3867 +#: mcs/mcs/cs-parser.cs:11381 #, csharp-format -msgid "" -"Conditional not valid on `{0}' because it is a constructor, destructor, " -"operator or explicit interface implementation" +msgid "Duplicate parameter modifier `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:3924 -msgid "Do not override object.Finalize. Instead, provide a destructor" +#: mcs/mcs/cs-parser.cs:11387 +msgid "Type expected" msgstr "" -#: ../mcs/mcs/class.cs:4096 -#, csharp-format -msgid "Program `{0}' has more than one entry point defined: `{1}'" +#: mcs/mcs/cs-parser.cs:11392 +msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: ../mcs/mcs/class.cs:4127 -#, csharp-format -msgid "Conditional not valid on `{0}' because its return type is not void" +#: mcs/mcs/cs-parser.cs:11402 +msgid "Named arguments must appear after the positional arguments" msgstr "" -#: ../mcs/mcs/class.cs:4132 -#, csharp-format -msgid "Conditional not valid on `{0}' because it is an override method" +#: mcs/mcs/cs-parser.cs:11493 +msgid "Syntax error, " msgstr "" -#: ../mcs/mcs/class.cs:4137 -msgid "Conditional not valid on interface members" +#: mcs/mcs/cs-parser.cs:11547 +msgid "Parsing error" msgstr "" -#: ../mcs/mcs/class.cs:4143 -#, csharp-format -msgid "Conditional member `{0}' cannot implement interface member `{1}'" +#: mcs/mcs/cs-parser.cs:11553 +msgid "Internal compiler error during parsing" msgstr "" -#: ../mcs/mcs/class.cs:4150 +#: mcs/mcs/cs-parser.cs:11564 #, csharp-format -msgid "Conditional method `{0}' cannot have an out parameter" +msgid "{0}: `{1}' is a keyword" msgstr "" -#: ../mcs/mcs/class.cs:4218 +#: mcs/mcs/cs-parser.cs:11690 #, csharp-format -msgid "`{0}': Extension methods cannot be defined in a nested class" +msgid "Identifier expected, `{0}' is a keyword" msgstr "" -#: ../mcs/mcs/class.cs:4223 +#: mcs/mcs/cs-parser.cs:11704 #, csharp-format -msgid "" -"`{0}': Extension methods cannot be declared without a reference to System." -"Core.dll assembly. Add the assembly reference or remove `this' modifer from " -"the first parameter" +msgid "{1} `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:4237 +#: mcs/mcs/cs-parser.cs:11706 #, csharp-format -msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgid "{2} `{0}', expecting {1}" msgstr "" -#: ../mcs/mcs/class.cs:4293 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:760 msgid "" -"A partial method `{0}' implementation is missing a partial method declaration" +"The `partial' modifier can be used only immediately before `class', " +"`struct', `interface', or `void' keyword" msgstr "" -#: ../mcs/mcs/class.cs:4327 -#, csharp-format -msgid "Method or delegate cannot return type `{0}'" +#: mcs/mcs/cs-tokenizer.cs:1395 mcs/mcs/cs-tokenizer.cs:1462 +msgid "Invalid number" msgstr "" -#: ../mcs/mcs/class.cs:4412 +#: mcs/mcs/cs-tokenizer.cs:1647 #, csharp-format -msgid "`{0}': Struct constructors cannot call base constructors" +msgid "Unrecognized escape sequence `\\{0}'" msgstr "" -#: ../mcs/mcs/class.cs:4445 -#, csharp-format -msgid "Constructor `{0}' cannot call itself" +#: mcs/mcs/cs-tokenizer.cs:1666 +msgid "Unrecognized escape sequence" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:1887 +msgid "Missing identifier to pre-processor directive" msgstr "" -#: ../mcs/mcs/class.cs:4570 +#: mcs/mcs/cs-tokenizer.cs:1897 mcs/mcs/cs-tokenizer.cs:1901 #, csharp-format -msgid "`{0}': The static constructor must be parameterless" +msgid "Identifier expected: {0}" msgstr "" -#: ../mcs/mcs/class.cs:4590 -msgid "Structs cannot contain explicit parameterless constructors" +#: mcs/mcs/cs-tokenizer.cs:2373 +msgid "Integral constant is too large" msgstr "" -#: ../mcs/mcs/class.cs:4642 -#, csharp-format -msgid "" -"`{0}': A class with the ComImport attribute cannot have a user-defined " -"constructor" +#: mcs/mcs/cs-tokenizer.cs:2378 +msgid "Invalid preprocessor directive" msgstr "" -#: ../mcs/mcs/class.cs:4934 +#: mcs/mcs/cs-tokenizer.cs:2385 #, csharp-format -msgid "`{0}' is an accessor not found in interface member `{1}{2}'" +msgid "Unexpected processor directive ({0})" msgstr "" -#: ../mcs/mcs/class.cs:4940 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:2391 msgid "" -"`{0}.{1}' in explicit interface declaration is not a member of interface" +"Cannot define or undefine preprocessor symbols after first token in file" msgstr "" -#: ../mcs/mcs/class.cs:4947 -#, csharp-format +#: mcs/mcs/cs-tokenizer.cs:2397 msgid "" -"`{0}' explicit method implementation cannot implement `{1}' because it is an " -"accessor" +"Preprocessor directives must appear as the first non-whitespace character on " +"a line" msgstr "" -#: ../mcs/mcs/class.cs:4957 -#, csharp-format -msgid "Method `{0}' cannot implement interface accessor `{1}.{2}'" +#: mcs/mcs/cs-tokenizer.cs:2402 +msgid "Single-line comment or end-of-line expected" msgstr "" -#: ../mcs/mcs/class.cs:4964 -#, csharp-format -msgid "" -"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " -"an explicit interface implementation" +#: mcs/mcs/cs-tokenizer.cs:2435 mcs/mcs/cs-tokenizer.cs:3431 +msgid "Expected `#endif' directive" msgstr "" -#: ../mcs/mcs/class.cs:4971 -#, csharp-format -msgid "" -"Accessor `{0}' must be declared public to implement interface member `{1}'" +#: mcs/mcs/cs-tokenizer.cs:2468 mcs/mcs/cs-tokenizer.cs:2489 +#: mcs/mcs/cs-tokenizer.cs:2520 mcs/mcs/cs-tokenizer.cs:3429 +msgid "#endregion directive expected" msgstr "" -#: ../mcs/mcs/class.cs:4995 -#, csharp-format -msgid "" -"`{0}': the explicit interface implementation cannot introduce the params " -"modifier" +#: mcs/mcs/cs-tokenizer.cs:2567 +msgid "Wrong preprocessor directive" msgstr "" -#: ../mcs/mcs/class.cs:5291 +#: mcs/mcs/cs-tokenizer.cs:2579 #, csharp-format -msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgid "#error: '{0}'" msgstr "" -#: ../mcs/mcs/class.cs:5301 -msgid "Inconsistent accessibility: property type `" +#: mcs/mcs/cs-tokenizer.cs:2598 +msgid "The line number specified for #line directive is missing or invalid" msgstr "" -#: ../mcs/mcs/class.cs:5306 -msgid "Inconsistent accessibility: indexer return type `" +#: mcs/mcs/cs-tokenizer.cs:2625 mcs/mcs/cs-tokenizer.cs:3243 +msgid "Newline in constant" msgstr "" -#: ../mcs/mcs/class.cs:5312 ../mcs/mcs/class.cs:5317 -#: ../mcs/mcs/delegate.cs:220 -msgid "Inconsistent accessibility: return type `" +#: mcs/mcs/cs-tokenizer.cs:2636 +msgid "Unterminated string literal" msgstr "" -#: ../mcs/mcs/class.cs:5322 -msgid "Inconsistent accessibility: field type `" +#: mcs/mcs/cs-tokenizer.cs:2705 +msgid "Identifier too long (limit is 512 chars)" msgstr "" -#: ../mcs/mcs/class.cs:5335 -#, csharp-format -msgid "Field or property cannot be of type `{0}'" +#: mcs/mcs/cs-tokenizer.cs:3092 +msgid "End-of-file found, '*/' expected" msgstr "" -#: ../mcs/mcs/class.cs:5363 -msgid "" -"The modifier 'abstract' is not valid on fields. Try using a property instead" +#: mcs/mcs/cs-tokenizer.cs:3201 +msgid "Keyword, identifier, or string expected after verbatim specifier: @" msgstr "" -#: ../mcs/mcs/class.cs:5378 -msgid "" -"The FieldOffset attribute can only be placed on members of types marked with " -"the StructLayout(LayoutKind.Explicit)" +#: mcs/mcs/cs-tokenizer.cs:3217 +#, csharp-format +msgid "Unexpected character `{0}'" msgstr "" -#: ../mcs/mcs/class.cs:5383 -msgid "The FieldOffset attribute is not allowed on static or const fields" +#: mcs/mcs/cs-tokenizer.cs:3238 +msgid "Empty character literal" msgstr "" -#: ../mcs/mcs/class.cs:5390 -msgid "" -"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " -"'fixed' field modifier instead" +#: mcs/mcs/cs-tokenizer.cs:3258 +msgid "Too many characters in character literal" msgstr "" -#: ../mcs/mcs/class.cs:5478 -#, csharp-format -msgid "" -"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " -"must have a FieldOffset attribute" +#: mcs/mcs/cfold.cs:84 +msgid "The operation overflows at compile time in checked mode" msgstr "" -#: ../mcs/mcs/class.cs:5487 -#, csharp-format -msgid "`{0}': cannot declare variables of static types" +#: mcs/mcs/cfold.cs:764 mcs/mcs/cfold.cs:849 +msgid "Division by constant zero" msgstr "" -#: ../mcs/mcs/class.cs:5605 +#: mcs/mcs/class.cs:371 #, csharp-format msgid "" -"`{0}': Fixed size buffers type must be one of the following: bool, byte, " -"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +"Partial declarations of `{0}' must be all classes, all structs or all " +"interfaces" msgstr "" -#: ../mcs/mcs/class.cs:5627 +#: mcs/mcs/class.cs:380 #, csharp-format -msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" msgstr "" -#: ../mcs/mcs/class.cs:5643 +#: mcs/mcs/class.cs:433 #, csharp-format -msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgid "" +"`{0}': explicit interface declaration can only be declared in a class or " +"struct" msgstr "" -#: ../mcs/mcs/class.cs:5650 +#: mcs/mcs/class.cs:470 mcs/mcs/membercache.cs:1347 #, csharp-format msgid "" -"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +"A member `{0}' is already defined. Rename this member or use different " +"parameter types" msgstr "" -#: ../mcs/mcs/class.cs:5843 -#, csharp-format -msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" +#: mcs/mcs/class.cs:578 +msgid "" +"Cannot specify the `DefaultMember' attribute on type containing an indexer" +msgstr "" + +#: mcs/mcs/class.cs:584 +msgid "The RequiredAttribute attribute is not permitted on C# types" msgstr "" -#: ../mcs/mcs/class.cs:5855 +#: mcs/mcs/class.cs:855 #, csharp-format -msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgid "Class `{0}' cannot derive from the dynamic type" msgstr "" -#: ../mcs/mcs/class.cs:5860 +#: mcs/mcs/class.cs:872 #, csharp-format -msgid "`{0}': A field cannot be both volatile and readonly" +msgid "`{0}' is already listed in interface list" msgstr "" -#: ../mcs/mcs/class.cs:6049 +#: mcs/mcs/class.cs:880 #, csharp-format msgid "" -"Attribute `{0}' is not valid on property or event accessors. It is valid on `" -"{1}' declarations only" +"Inconsistent accessibility: base interface `{0}' is less accessible than " +"interface `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6149 ../mcs/mcs/decl.cs:2792 +#: mcs/mcs/class.cs:886 #, csharp-format -msgid "A member `{0}' is already reserved" +msgid "Type `{0}' in interface list is not an interface" msgstr "" -#: ../mcs/mcs/class.cs:6352 +#: mcs/mcs/class.cs:888 #, csharp-format -msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" msgstr "" -#: ../mcs/mcs/class.cs:6369 +#: mcs/mcs/class.cs:891 #, csharp-format -msgid "" -"`{0}': accessibility modifiers may not be used on accessors in an interface" +msgid "`{0}': Base class `{1}' must be specified as first" msgstr "" -#: ../mcs/mcs/class.cs:6373 +#: mcs/mcs/class.cs:915 #, csharp-format -msgid "`{0}': abstract properties cannot have private accessors" +msgid "Partial declarations of `{0}' must not specify different base classes" msgstr "" -#: ../mcs/mcs/class.cs:6435 +#: mcs/mcs/class.cs:996 #, csharp-format msgid "" -"The accessibility modifier of the `{0}' accessor must be more restrictive " -"than the modifier of the property or indexer `{1}'" +"The operator `{0}' requires a matching operator `{1}' to also be defined" msgstr "" -#: ../mcs/mcs/class.cs:6500 +#: mcs/mcs/class.cs:1021 #, csharp-format -msgid "" -"`{0}': Cannot specify accessibility modifiers for both accessors of the " -"property or indexer" +msgid "`{0}' clashes with a predefined namespace" msgstr "" -#: ../mcs/mcs/class.cs:6509 +#: mcs/mcs/class.cs:1150 #, csharp-format msgid "" -"`{0}': accessibility modifiers on accessors may only be used if the property " -"or indexer has both a get and a set accessor" +"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6571 +#: mcs/mcs/class.cs:1156 #, csharp-format -msgid "" -"`{0}.get': cannot override because `{1}' does not have an overridable get " -"accessor" +msgid "Circular base class dependency involving `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:6586 +#: mcs/mcs/class.cs:1183 #, csharp-format msgid "" -"`{0}.set': cannot override because `{1}' does not have an overridable set " -"accessor" +"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " +"type parameter substitutions" msgstr "" -#: ../mcs/mcs/class.cs:6783 +#: mcs/mcs/class.cs:1223 #, csharp-format msgid "" -"Automatically implemented property `{0}' cannot be used inside a type with " -"an explicit StructLayout attribute" +"The type `{0}' is defined in an assembly that is not referenced. Consider " +"adding a reference to assembly `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7151 +#: mcs/mcs/class.cs:1339 #, csharp-format -msgid "`{0}': abstract event cannot have an initializer" +msgid "" +"Partial declarations of `{0}' must have the same type parameter names in the " +"same order" msgstr "" -#: ../mcs/mcs/class.cs:7337 +#: mcs/mcs/class.cs:1346 #, csharp-format -msgid "`{0}': event must be of a delegate type" -msgstr "" - -#: ../mcs/mcs/class.cs:7544 msgid "" -"The `IndexerName' attribute is valid only on an indexer that is not an " -"explicit interface member declaration" +"Partial declarations of `{0}' must have the same type parameter variance " +"modifiers" msgstr "" -#: ../mcs/mcs/class.cs:7551 -msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +#: mcs/mcs/class.cs:1371 +#, csharp-format +msgid "" +"Partial declarations of `{0}' have inconsistent constraints for type " +"parameter `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7753 +#: mcs/mcs/class.cs:1510 #, csharp-format -msgid "User-defined operator `{0}' must be declared static and public" +msgid "`{0}': cannot implement a dynamic interface `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7784 +#: mcs/mcs/class.cs:1623 msgid "" -"User-defined operator cannot take an object of the enclosing type and " -"convert to an object of the enclosing type" +"Two indexers have different names; the IndexerName attribute must be used " +"with the same name on every indexer within a type" msgstr "" -#: ../mcs/mcs/class.cs:7795 -msgid "User-defined conversion must convert to or from the enclosing type" +#: mcs/mcs/class.cs:1957 +#, csharp-format +msgid "A static member `{0}' cannot be marked as override, virtual or abstract" msgstr "" -#: ../mcs/mcs/class.cs:7804 +#: mcs/mcs/class.cs:1964 #, csharp-format -msgid "" -"User-defined conversion `{0}' cannot convert to or from an interface type" +msgid "A member `{0}' marked as override cannot be marked as new or virtual" msgstr "" -#: ../mcs/mcs/class.cs:7811 +#: mcs/mcs/class.cs:1976 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a base class" +msgid "`{0}' cannot be both extern and abstract" msgstr "" -#: ../mcs/mcs/class.cs:7817 +#: mcs/mcs/class.cs:1981 #, csharp-format -msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgid "`{0}' cannot be both abstract and sealed" msgstr "" -#: ../mcs/mcs/class.cs:7825 -msgid "" -"Overloaded shift operator must have the type of the first operand be the " -"containing type, and the type of the second operand must be int" +#: mcs/mcs/class.cs:1986 +#, csharp-format +msgid "The abstract method `{0}' cannot be marked virtual" msgstr "" -#: ../mcs/mcs/class.cs:7834 -msgid "" -"The return type for ++ or -- operator must be the containing type or derived " -"from the containing type" +#: mcs/mcs/class.cs:1992 +#, csharp-format +msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7839 -msgid "The parameter type for ++ or -- operator must be the containing type" +#: mcs/mcs/class.cs:2000 +#, csharp-format +msgid "`{0}': virtual or abstract members cannot be private" msgstr "" -#: ../mcs/mcs/class.cs:7846 -msgid "The parameter type of a unary operator must be the containing type" +#: mcs/mcs/class.cs:2007 +#, csharp-format +msgid "`{0}' cannot be sealed because it is not an override" msgstr "" -#: ../mcs/mcs/class.cs:7854 -msgid "The return type of operator True or False must be bool" +#: mcs/mcs/class.cs:2054 +#, csharp-format +msgid "`{0}': containing type does not implement interface `{1}'" msgstr "" -#: ../mcs/mcs/class.cs:7867 -msgid "One of the parameters of a binary operator must be the containing type" +#: mcs/mcs/class.cs:2230 +#, csharp-format +msgid "Type parameter `{0}' has same name as containing type, or method" msgstr "" -#: ../mcs/mcs/codegen.cs:122 -msgid "Assembly generation failed -- Referenced assembly '" +#: mcs/mcs/class.cs:2238 +#, csharp-format +msgid "`{0}': member names cannot be the same as their enclosing type" msgstr "" -#: ../mcs/mcs/codegen.cs:140 -msgid "Could not access the key inside the container `" +#: mcs/mcs/class.cs:2404 +msgid "" +"The class System.Object cannot have a base class or implement an interface." msgstr "" -#: ../mcs/mcs/codegen.cs:148 -msgid "Could not use the specified key to strongname the assembly." +#: mcs/mcs/class.cs:2412 +#, csharp-format +msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" msgstr "" -#: ../mcs/mcs/codegen.cs:176 +#: mcs/mcs/class.cs:2417 msgid "" -"Could not find the symbol writer assembly (Mono.CompilerServices." -"SymbolWriter.dll)" +"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " +"or attribute classes" msgstr "" -#: ../mcs/mcs/codegen.cs:181 +#: mcs/mcs/class.cs:2455 #, csharp-format -msgid "Unexpected debug information initialization error `{0}'" +msgid "`{0}': Static classes cannot contain user-defined operators" msgstr "" -#: ../mcs/mcs/codegen.cs:199 -msgid "Couldn't delay-sign the assembly with the '" +#: mcs/mcs/class.cs:2460 +#, csharp-format +msgid "`{0}': Static classes cannot contain destructor" msgstr "" -#: ../mcs/mcs/codegen.cs:204 ../mcs/mcs/codegen.cs:208 -msgid "Could not write to file `" +#: mcs/mcs/class.cs:2465 +#, csharp-format +msgid "`{0}': cannot declare indexers in a static class" msgstr "" -#: ../mcs/mcs/codegen.cs:822 +#: mcs/mcs/class.cs:2473 #, csharp-format -msgid "`{0}': not all code paths return a value" +msgid "`{0}': Static classes cannot have instance constructors" msgstr "" -#: ../mcs/mcs/codegen.cs:825 +#: mcs/mcs/class.cs:2479 #, csharp-format -msgid "Not all code paths return a value in anonymous method of type `{0}'" +msgid "`{0}': Extension methods must be declared static" msgstr "" -#: ../mcs/mcs/codegen.cs:1224 ../mcs/mcs/codegen.cs:1237 +#: mcs/mcs/class.cs:2483 #, csharp-format -msgid "" -"Option `{0}' overrides attribute `{1}' given in a source file or added module" +msgid "`{0}': cannot declare instance members in a static class" msgstr "" -#: ../mcs/mcs/codegen.cs:1300 -msgid "" -"Could not sign the assembly. ECMA key can only be used to delay-sign " -"assemblies" +#: mcs/mcs/class.cs:2492 +#, csharp-format +msgid "`{0}': an abstract class cannot be sealed or static" msgstr "" -#: ../mcs/mcs/codegen.cs:1320 -msgid "Error during assembly signing. " +#: mcs/mcs/class.cs:2496 +#, csharp-format +msgid "`{0}': a class cannot be both static and sealed" msgstr "" -#: ../mcs/mcs/codegen.cs:1345 -msgid "Friend assembly reference `" +#: mcs/mcs/class.cs:2526 +#, csharp-format +msgid "`{0}': Cannot derive from type parameter `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1417 -msgid "Invalid type specified as an argument for TypeForwardedTo attribute" +#: mcs/mcs/class.cs:2530 +#, csharp-format +msgid "" +"A generic type cannot derive from `{0}' because it is an attribute class" msgstr "" -#: ../mcs/mcs/codegen.cs:1425 +#: mcs/mcs/class.cs:2534 #, csharp-format -msgid "A duplicate type forward of type `{0}'" +msgid "`{0}': Cannot derive from static class `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1434 +#: mcs/mcs/class.cs:2538 #, csharp-format -msgid "Cannot forward type `{0}' because it is defined in this assembly" +msgid "`{0}': cannot derive from sealed type `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1440 +#: mcs/mcs/class.cs:2541 #, csharp-format -msgid "Cannot forward type `{0}' because it is a nested type" +msgid "" +"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " +"from object" msgstr "" -#: ../mcs/mcs/codegen.cs:1446 +#: mcs/mcs/class.cs:2548 #, csharp-format -msgid "Cannot forward generic type `{0}'" +msgid "`{0}' cannot derive from special class `{1}'" msgstr "" -#: ../mcs/mcs/codegen.cs:1651 +#: mcs/mcs/class.cs:2556 +#, csharp-format msgid "" -"Value specified for the argument to 'System.Runtime.InteropServices." -"DefaultCharSetAttribute' is not valid" +"Inconsistent accessibility: base class `{0}' is less accessible than class `" +"{1}'" msgstr "" -#: ../mcs/mcs/const.cs:177 +#: mcs/mcs/class.cs:2564 #, csharp-format -msgid "The expression being assigned to `{0}' must be constant" +msgid "Static class `{0}' cannot implement interfaces" msgstr "" -#: ../mcs/mcs/const.cs:182 +#: mcs/mcs/class.cs:2683 mcs/mcs/class.cs:2694 #, csharp-format -msgid "" -"The evaluation of the constant value for `{0}' involves a circular definition" +msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" msgstr "" -#: ../mcs/mcs/const.cs:188 +#: mcs/mcs/class.cs:2784 #, csharp-format -msgid "" -"A constant `{0}' of reference type `{1}' can only be initialized with null" +msgid "`{0}': Structs cannot have instance field initializers" msgstr "" -#: ../mcs/mcs/const.cs:194 +#: mcs/mcs/class.cs:2965 #, csharp-format -msgid "The type `{0}' cannot be declared const" +msgid "Do not override `{0}'. Use destructor syntax instead" msgstr "" -#: ../mcs/mcs/constant.cs:84 ../mcs/mcs/constant.cs:285 +#: mcs/mcs/class.cs:2968 #, csharp-format -msgid "Constant value `{0}' cannot be converted to a `{1}'" +msgid "`{0}' is marked as an override but no suitable {1} found to override" msgstr "" -#: ../mcs/mcs/constant.cs:192 +#: mcs/mcs/class.cs:2974 #, csharp-format -msgid "" -"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " -"to override)" +msgid "`{0}': cannot override because `{1}' is not an event" msgstr "" -#: ../mcs/mcs/decl.cs:363 +#: mcs/mcs/class.cs:2977 #, csharp-format -msgid "`{0}' cannot declare a body because it is marked extern" +msgid "`{0}': cannot override because `{1}' is not a property" msgstr "" -#: ../mcs/mcs/decl.cs:369 +#: mcs/mcs/class.cs:2980 #, csharp-format -msgid "`{0}' cannot declare a body because it is marked abstract" +msgid "`{0}': cannot override because `{1}' is not a method" msgstr "" -#: ../mcs/mcs/decl.cs:377 +#: mcs/mcs/class.cs:3036 mcs/mcs/field.cs:187 #, csharp-format -msgid "" -"`{0}' must have a body because it is not marked abstract or extern. The " -"property can be automatically implemented when you define both accessors" +msgid "`{0}' hides inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:380 +#: mcs/mcs/class.cs:3060 #, csharp-format msgid "" -"`{0}' must have a body because it is not marked abstract, extern, or partial" +"`{0}': cannot override inherited member `{1}' because it is not marked " +"virtual, abstract or override" msgstr "" -#: ../mcs/mcs/decl.cs:396 +#: mcs/mcs/class.cs:3068 #, csharp-format -msgid "`{0}': Structs cannot contain protected members" +msgid "`{0}': cannot override inherited member `{1}' because it is sealed" msgstr "" -#: ../mcs/mcs/decl.cs:402 +#: mcs/mcs/class.cs:3077 #, csharp-format -msgid "`{0}': Static classes cannot contain protected members" +msgid "`{0}': type must be `{1}' to match overridden member `{2}'" msgstr "" -#: ../mcs/mcs/decl.cs:950 +#: mcs/mcs/class.cs:3080 #, csharp-format -msgid "The namespace `{0}' already contains a definition for `{1}'" +msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" msgstr "" -#: ../mcs/mcs/decl.cs:954 +#: mcs/mcs/class.cs:3152 #, csharp-format -msgid "Duplicate type parameter `{0}'" +msgid "A partial method `{0}' cannot explicitly implement an interface" msgstr "" -#: ../mcs/mcs/decl.cs:957 +#: mcs/mcs/class.cs:3160 #, csharp-format -msgid "The type `{0}' already contains a definition for `{1}'" +msgid "The type `{0}' in explicit interface declaration is not an interface" msgstr "" -#: ../mcs/mcs/decl.cs:1025 +#: mcs/mcs/class.cs:3191 #, csharp-format msgid "" -"Missing partial modifier on declaration of type `{0}'. Another partial " -"declaration of this type exists" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"indexer `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:1248 -msgid "The RequiredAttribute attribute is not permitted on C# types" +#: mcs/mcs/class.cs:3195 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"operator `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:1303 -msgid "Constraints are not allowed on non-generic declarations" +#: mcs/mcs/class.cs:3199 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"method `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:1347 +#: mcs/mcs/class.cs:3213 #, csharp-format -msgid "`{0}': A constraint references nonexistent type parameter `{1}'" +msgid "" +"Constructor `{0}' is marked `external' but has no external implementation " +"specified" msgstr "" -#: ../mcs/mcs/decl.cs:2725 +#: mcs/mcs/class.cs:3216 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation cannot differ " -"on use of `params' modifier" +"`{0}' is marked as an external but has no DllImport attribute. Consider " +"adding a DllImport attribute to specify the external implementation" msgstr "" -#: ../mcs/mcs/decl.cs:2728 +#: mcs/mcs/class.cs:3245 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation must be both " -"an extension method or neither" +"`{0}': cannot change access modifiers when overriding `{1}' inherited member " +"`{2}'" +msgstr "" + +#: mcs/mcs/class.cs:3254 +#, csharp-format +msgid "`{0}': static types cannot be used as return types" +msgstr "" + +#: mcs/mcs/class.cs:3379 +#, csharp-format +msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgstr "" + +#: mcs/mcs/class.cs:3394 +msgid "Inconsistent accessibility: property type `" +msgstr "" + +#: mcs/mcs/class.cs:3399 +msgid "Inconsistent accessibility: indexer return type `" +msgstr "" + +#: mcs/mcs/class.cs:3405 mcs/mcs/class.cs:3410 mcs/mcs/delegate.cs:159 +msgid "Inconsistent accessibility: return type `" +msgstr "" + +#: mcs/mcs/class.cs:3415 +msgid "Inconsistent accessibility: field type `" +msgstr "" + +#: mcs/mcs/class.cs:3428 +#, csharp-format +msgid "Field or property cannot be of type `{0}'" +msgstr "" + +#: mcs/mcs/const.cs:103 +#, csharp-format +msgid "Type parameter `{0}' cannot be declared const" +msgstr "" + +#: mcs/mcs/const.cs:106 +#, csharp-format +msgid "The type `{0}' cannot be declared const" +msgstr "" + +#: mcs/mcs/const.cs:181 +#, csharp-format +msgid "" +"The evaluation of the constant value for `{0}' involves a circular definition" +msgstr "" + +#: mcs/mcs/constant.cs:68 mcs/mcs/constant.cs:319 +#, csharp-format +msgid "Constant value `{0}' cannot be converted to a `{1}'" msgstr "" -#: ../mcs/mcs/decl.cs:2732 +#: mcs/mcs/constant.cs:187 #, csharp-format msgid "" -"An overloaded method `{0}' cannot differ on use of parameter modifiers only" +"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " +"to override)" msgstr "" -#: ../mcs/mcs/decl.cs:2760 +#: mcs/mcs/convert.cs:1158 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation must be both " -"`static' or neither" +"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' " +"to `{3}'" +msgstr "" + +#: mcs/mcs/decl.cs:376 +#, csharp-format +msgid "`{0}' cannot declare a body because it is marked extern" +msgstr "" + +#: mcs/mcs/decl.cs:382 +#, csharp-format +msgid "`{0}' cannot declare a body because it is marked abstract" msgstr "" -#: ../mcs/mcs/decl.cs:2765 +#: mcs/mcs/decl.cs:395 +#, csharp-format msgid "" -"A partial method declaration and partial method implementation must be both " -"`unsafe' or neither" +"`{0}' must have a body because it is not marked abstract or extern. The " +"property can be automatically implemented when you define both accessors" msgstr "" -#: ../mcs/mcs/decl.cs:2771 +#: mcs/mcs/decl.cs:401 #, csharp-format -msgid "A partial method `{0}' declaration is already defined" +msgid "" +"`{0}' must have a body because it is not marked abstract, extern, or partial" msgstr "" -#: ../mcs/mcs/decl.cs:2775 +#: mcs/mcs/decl.cs:416 #, csharp-format -msgid "A partial method `{0}' implementation is already defined" +msgid "`{0}': Structs cannot contain protected members" msgstr "" -#: ../mcs/mcs/decl.cs:2783 +#: mcs/mcs/decl.cs:422 #, csharp-format -msgid "Duplicate user-defined conversion in type `{0}'" +msgid "`{0}': Static classes cannot contain protected members" +msgstr "" + +#: mcs/mcs/decl.cs:1264 +#, csharp-format +msgid "The namespace `{0}' already contains a definition for `{1}'" +msgstr "" + +#: mcs/mcs/decl.cs:1268 +#, csharp-format +msgid "Duplicate type parameter `{0}'" +msgstr "" + +#: mcs/mcs/decl.cs:1271 +#, csharp-format +msgid "The type `{0}' already contains a definition for `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:204 +#: mcs/mcs/decl.cs:1321 #, csharp-format msgid "" -"Inconsistent accessibility: parameter type `{0}' is less accessible than " -"delegate `{1}'" +"Missing partial modifier on declaration of type `{0}'. Another partial " +"declaration of this type exists" +msgstr "" + +#: mcs/mcs/decl.cs:1410 +msgid "Variant type parameters can only be used with interfaces and delegates" msgstr "" -#: ../mcs/mcs/delegate.cs:403 -msgid "Internal error: could not find delegate constructor!" +#: mcs/mcs/decl.cs:1422 +#, csharp-format +msgid "`{0}': A constraint references nonexistent type parameter `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:445 ../mcs/mcs/delegate.cs:553 -msgid "Internal error: could not find Invoke method!" +#: mcs/mcs/delegate.cs:141 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"delegate `{1}'" msgstr "" -#: ../mcs/mcs/delegate.cs:732 +#: mcs/mcs/delegate.cs:487 #, csharp-format msgid "" "Cannot create delegate from method `{0}' because it is a member of System." "Nullable type" msgstr "" -#: ../mcs/mcs/delegate.cs:744 +#: mcs/mcs/delegate.cs:499 #, csharp-format msgid "" "Extension method `{0}' of value type `{1}' cannot be used to create delegates" msgstr "" -#: ../mcs/mcs/delegate.cs:759 +#: mcs/mcs/delegate.cs:514 #, csharp-format msgid "Cannot create delegate from partial method declaration `{0}'" msgstr "" -#: ../mcs/mcs/delegate.cs:762 +#: mcs/mcs/delegate.cs:517 #, csharp-format msgid "" "Cannot create delegate with `{0}' because it has a Conditional attribute" msgstr "" -#: ../mcs/mcs/delegate.cs:818 +#: mcs/mcs/delegate.cs:560 #, csharp-format msgid "" "A method or delegate `{0} {1}' parameters and return type must be same as " "delegate `{2} {3}' parameters and return type" msgstr "" -#: ../mcs/mcs/delegate.cs:824 +#: mcs/mcs/delegate.cs:567 #, csharp-format msgid "" "A method or delegate `{0}' parameters do not match delegate `{1}' parameters" msgstr "" -#: ../mcs/mcs/delegate.cs:829 +#: mcs/mcs/delegate.cs:572 #, csharp-format msgid "" "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " "return type" msgstr "" -#: ../mcs/mcs/delegate.cs:949 +#: mcs/mcs/delegate.cs:655 msgid "Method name expected" msgstr "" -#: ../mcs/mcs/doc.cs:1007 +#: mcs/mcs/doc.cs:914 #, csharp-format msgid "Error generating XML documentation file `{0}' (`{1}')" msgstr "" -#: ../mcs/mcs/driver.cs:152 ../mcs/mcs/driver.cs:707 ../mcs/mcs/driver.cs:710 +#: mcs/mcs/driver.cs:96 mcs/mcs/driver.cs:465 mcs/mcs/driver.cs:468 msgid "Source file `" msgstr "" -#: ../mcs/mcs/driver.cs:179 +#: mcs/mcs/driver.cs:123 #, csharp-format msgid "Source file `{0}' could not be found" msgstr "" -#: ../mcs/mcs/driver.cs:187 +#: mcs/mcs/driver.cs:129 #, csharp-format msgid "Source file `{0}' is a binary file and not a text file" msgstr "" -#: ../mcs/mcs/driver.cs:205 -#, csharp-format -msgid "Compilation aborted in file `{0}', {1}" -msgstr "" - -#: ../mcs/mcs/driver.cs:272 +#: mcs/mcs/driver.cs:214 msgid "" "Invalid target type for -target. Valid options are `exe', `winexe', " "`library' or `module'" msgstr "" -#: ../mcs/mcs/driver.cs:320 -#, csharp-format -msgid "cannot find metadata file `{0}'" -msgstr "" - -#: ../mcs/mcs/driver.cs:327 -#, csharp-format -msgid "file `{0}' has invalid `{1}' metadata" -msgstr "" - -#: ../mcs/mcs/driver.cs:347 -#, csharp-format -msgid "" -"Referenced file `{0}' is not an assembly. Consider using `-addmodule' option " -"instead" -msgstr "" - -#: ../mcs/mcs/driver.cs:603 +#: mcs/mcs/driver.cs:361 msgid "Response file `" msgstr "" -#: ../mcs/mcs/driver.cs:612 +#: mcs/mcs/driver.cs:370 msgid "Unable to open response file: " msgstr "" -#: ../mcs/mcs/driver.cs:662 ../mcs/mcs/driver.cs:672 +#: mcs/mcs/driver.cs:420 mcs/mcs/driver.cs:430 msgid "No files to compile were specified" msgstr "" -#: ../mcs/mcs/driver.cs:802 +#: mcs/mcs/driver.cs:502 msgid "Warning level must be in the range 0-4" msgstr "" -#: ../mcs/mcs/driver.cs:836 +#: mcs/mcs/driver.cs:536 msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" msgstr "" -#: ../mcs/mcs/driver.cs:845 +#: mcs/mcs/driver.cs:545 msgid "Compatibility: Use -unsafe instead of --unsafe" msgstr "" -#: ../mcs/mcs/driver.cs:856 +#: mcs/mcs/driver.cs:556 msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" msgstr "" -#: ../mcs/mcs/driver.cs:870 +#: mcs/mcs/driver.cs:570 msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" msgstr "" -#: ../mcs/mcs/driver.cs:879 +#: mcs/mcs/driver.cs:579 msgid "Compatibility: Use -checked instead of --checked" msgstr "" -#: ../mcs/mcs/driver.cs:889 +#: mcs/mcs/driver.cs:589 msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" msgstr "" -#: ../mcs/mcs/driver.cs:892 +#: mcs/mcs/driver.cs:592 msgid "Missing argument to --linkres" msgstr "" -#: ../mcs/mcs/driver.cs:903 +#: mcs/mcs/driver.cs:601 msgid "Compatibility: Use -res:VALUE instead of --res VALUE" msgstr "" -#: ../mcs/mcs/driver.cs:906 +#: mcs/mcs/driver.cs:604 msgid "Missing argument to --resource" msgstr "" -#: ../mcs/mcs/driver.cs:916 +#: mcs/mcs/driver.cs:612 msgid "Compatibility: Use -target:KIND instead of --target KIND" msgstr "" -#: ../mcs/mcs/driver.cs:948 +#: mcs/mcs/driver.cs:644 msgid "Compatibility: Use -r:LIBRARY instead of -r library" msgstr "" -#: ../mcs/mcs/driver.cs:967 +#: mcs/mcs/driver.cs:663 msgid "Compatibility: Use -lib:ARG instead of --L arg" msgstr "" -#: ../mcs/mcs/driver.cs:976 +#: mcs/mcs/driver.cs:676 msgid "Compatibility: Use -nostdlib instead of --nostdlib" msgstr "" -#: ../mcs/mcs/driver.cs:985 -msgid "Compatibility: Use -warnaserror: option instead of --werror" -msgstr "" - -#: ../mcs/mcs/driver.cs:990 +#: mcs/mcs/driver.cs:681 msgid "Compatibility: Use -nowarn instead of --nowarn" msgstr "" -#: ../mcs/mcs/driver.cs:1007 +#: mcs/mcs/driver.cs:698 msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" msgstr "" -#: ../mcs/mcs/driver.cs:1011 +#: mcs/mcs/driver.cs:702 msgid "--wlevel requires a value from 0 to 4" msgstr "" -#: ../mcs/mcs/driver.cs:1020 +#: mcs/mcs/driver.cs:711 msgid "--mcs-debug requires an argument" msgstr "" -#: ../mcs/mcs/driver.cs:1027 +#: mcs/mcs/driver.cs:718 msgid "Invalid argument to --mcs-debug" msgstr "" -#: ../mcs/mcs/driver.cs:1037 +#: mcs/mcs/driver.cs:728 msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" msgstr "" -#: ../mcs/mcs/driver.cs:1039 +#: mcs/mcs/driver.cs:730 msgid "--recurse requires an argument" msgstr "" -#: ../mcs/mcs/driver.cs:1051 +#: mcs/mcs/driver.cs:741 msgid "Compatibility: Use -debug option instead of -g or --debug" msgstr "" -#: ../mcs/mcs/driver.cs:1056 +#: mcs/mcs/driver.cs:746 msgid "Compatibility: Use -noconfig option instead of --noconfig" msgstr "" -#: ../mcs/mcs/driver.cs:1076 -msgid "Couldn't run pkg-config: " -msgstr "" - -#: ../mcs/mcs/driver.cs:1084 -msgid "Specified package did not return any information" -msgstr "" - -#: ../mcs/mcs/driver.cs:1091 -msgid "Error running pkg-config. Check the above output." -msgstr "" - -#: ../mcs/mcs/driver.cs:1187 +#: mcs/mcs/driver.cs:910 #, csharp-format msgid "Invalid conditional define symbol `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1241 +#: mcs/mcs/driver.cs:961 #, csharp-format msgid "" "Invalid resource visibility option `{0}'. Use either `public' or `private' " "instead" msgstr "" -#: ../mcs/mcs/driver.cs:1247 +#: mcs/mcs/driver.cs:967 #, csharp-format msgid "Wrong number of arguments for option `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1255 -msgid "-recurse requires an argument" -msgstr "" - -#: ../mcs/mcs/driver.cs:1264 -msgid "-reference requires an argument" -msgstr "" - -#: ../mcs/mcs/driver.cs:1286 ../mcs/mcs/driver.cs:1298 -#: ../mcs/mcs/driver.cs:1310 ../mcs/mcs/driver.cs:1322 -#: ../mcs/mcs/driver.cs:1431 ../mcs/mcs/driver.cs:1451 -#: ../mcs/mcs/driver.cs:1458 -msgid " requires an argument" +#: mcs/mcs/driver.cs:1005 +msgid "Cannot specify multiple aliases using single /reference option" msgstr "" -#: ../mcs/mcs/driver.cs:1303 ../mcs/mcs/driver.cs:1315 +#: mcs/mcs/driver.cs:1033 mcs/mcs/driver.cs:1045 msgid "" "Cannot specify the `win32res' and the `win32ico' compiler option at the same " "time" msgstr "" -#: ../mcs/mcs/driver.cs:1332 -msgid "/lib requires an argument" +#: mcs/mcs/driver.cs:1160 +#, csharp-format +msgid "`{0}' is not a valid warning number" msgstr "" -#: ../mcs/mcs/driver.cs:1394 -msgid "/nowarn requires an argument" +#: mcs/mcs/driver.cs:1190 +msgid "" +"Invalid platform type for -platform. Valid options are `anycpu', `x86', " +"`x64' or `itanium'" msgstr "" -#: ../mcs/mcs/driver.cs:1488 +#: mcs/mcs/driver.cs:1288 #, csharp-format msgid "" -"Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or " +"Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or " "`Default'" msgstr "" -#: ../mcs/mcs/driver.cs:1504 +#: mcs/mcs/driver.cs:1308 #, csharp-format msgid "Code page `{0}' is invalid or not installed" msgstr "" -#: ../mcs/mcs/driver.cs:1516 +#: mcs/mcs/driver.cs:1323 #, csharp-format msgid "Unrecognized command-line option: `{0}'" msgstr "" -#: ../mcs/mcs/driver.cs:1546 -msgid "Invalid reference alias '" -msgstr "" - -#: ../mcs/mcs/driver.cs:1551 -msgid "Invalid extern alias for /reference. Alias '" -msgstr "" - -#: ../mcs/mcs/driver.cs:1617 -msgid "" -"If no source files are specified you must specify the output file with -out:" +#: mcs/mcs/driver.cs:1328 +#, csharp-format +msgid "Missing file specification for `{0}' option" msgstr "" -#: ../mcs/mcs/driver.cs:1739 +#: mcs/mcs/driver.cs:1333 #, csharp-format -msgid "Could not find `{0}' specified for Main method" +msgid "Missing argument for `{0}' option" msgstr "" -#: ../mcs/mcs/driver.cs:1744 +#: mcs/mcs/driver.cs:1368 #, csharp-format -msgid "`{0}' specified for Main method must be a valid class or struct" +msgid "Invalid reference alias `{0}='. Missing filename" msgstr "" -#: ../mcs/mcs/driver.cs:1748 +#: mcs/mcs/driver.cs:1373 #, csharp-format -msgid "`{0}' does not have a suitable static Main method" +msgid "" +"Invalid extern alias for -reference. Alias `{0}' is not a valid identifier" msgstr "" -#: ../mcs/mcs/driver.cs:1753 +#: mcs/mcs/driver.cs:1389 #, csharp-format -msgid "" -"Program `{0}' does not contain a static `Main' method suitable for an entry " -"point" +msgid "The resource identifier `{0}' has already been used in this assembly" msgstr "" -#: ../mcs/mcs/driver.cs:1760 -msgid "Cannot specify -main if building a module or library" +#: mcs/mcs/driver.cs:1450 +msgid "" +"If no source files are specified you must specify the output file with -out:" msgstr "" -#: ../mcs/mcs/driver.cs:1765 -msgid "Cannot link resource file when building a module" +#: mcs/mcs/dynamic.cs:272 +msgid "An expression tree cannot contain a dynamic operation" msgstr "" -#: ../mcs/mcs/driver.cs:1915 -#, csharp-format -msgid "The resource identifier `{0}' has already been used in this assembly" +#: mcs/mcs/dynamic.cs:302 +msgid "" +"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly " +"reference" msgstr "" -#: ../mcs/mcs/driver.cs:1929 +#: mcs/mcs/ecore.cs:242 #, csharp-format -msgid "Error reading resource file `{0}'" +msgid "`{0}' is inaccessible due to its protection level" msgstr "" -#: ../mcs/mcs/ecore.cs:321 +#: mcs/mcs/ecore.cs:247 #, csharp-format -msgid "`{0}' is inaccessible due to its protection level" +msgid "The expression being assigned to `{0}' must be constant" msgstr "" -#: ../mcs/mcs/ecore.cs:326 +#: mcs/mcs/ecore.cs:252 #, csharp-format msgid "" -"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " -"qualifier must be of type `{2}' or derived from it" +"A constant `{0}' of reference type `{1}' can only be initialized with null" msgstr "" -#: ../mcs/mcs/ecore.cs:336 +#: mcs/mcs/ecore.cs:258 msgid "" "Only assignment, call, increment, decrement, and new object expressions can " "be used as a statement" msgstr "" -#: ../mcs/mcs/ecore.cs:347 -#, csharp-format -msgid "Cannot assign to `{0}' because it is a `{1}'" -msgstr "" - -#: ../mcs/mcs/ecore.cs:353 +#: mcs/mcs/ecore.cs:269 msgid "Keyword `void' cannot be used in this context" msgstr "" -#: ../mcs/mcs/ecore.cs:383 ../mcs/mcs/statement.cs:1098 +#: mcs/mcs/ecore.cs:303 #, csharp-format msgid "Cannot convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:393 +#: mcs/mcs/ecore.cs:313 #, csharp-format msgid "" "Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " "(are you missing a cast?)" msgstr "" -#: ../mcs/mcs/ecore.cs:399 +#: mcs/mcs/ecore.cs:319 #, csharp-format msgid "Cannot implicitly convert type `{0}' to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:406 -#, csharp-format -msgid "A local variable `{0}' cannot be used before it is declared" -msgstr "" - -#: ../mcs/mcs/ecore.cs:417 +#: mcs/mcs/ecore.cs:360 #, csharp-format msgid "`{0}' does not contain a definition for `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:423 +#: mcs/mcs/ecore.cs:366 msgid "" "The left-hand side of an assignment must be a variable, a property or an " "indexer" msgstr "" -#: ../mcs/mcs/ecore.cs:560 -msgid "A ref or out argument must be an assignable variable" +#: mcs/mcs/ecore.cs:371 +msgid "The operation in question is undefined on void pointers" msgstr "" -#: ../mcs/mcs/ecore.cs:714 ../mcs/mcs/ecore.cs:730 +#: mcs/mcs/ecore.cs:433 mcs/mcs/statement.cs:2558 mcs/mcs/statement.cs:2560 #, csharp-format -msgid "Ambiguity between `{0}' and `{1}'" +msgid "Internal compiler error: {0}" msgstr "" -#: ../mcs/mcs/ecore.cs:831 ../mcs/mcs/ecore.cs:2777 -#, csharp-format +#: mcs/mcs/ecore.cs:473 +msgid "A ref or out argument must be an assignable variable" +msgstr "" + +#: mcs/mcs/ecore.cs:492 msgid "" -"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +"An attribute argument must be a constant expression, typeof expression or " +"array creation expression" msgstr "" -#: ../mcs/mcs/ecore.cs:872 +#: mcs/mcs/ecore.cs:563 #, csharp-format -msgid "The name `{0}' does not exist in the current context" +msgid "The class `{0}' has no constructors defined" msgstr "" -#: ../mcs/mcs/ecore.cs:887 ../mcs/mcs/generic.cs:1398 +#: mcs/mcs/ecore.cs:648 #, csharp-format -msgid "Using the generic type `{0}' requires {1} type arguments" +msgid "Ambiguity between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:916 +#: mcs/mcs/ecore.cs:675 msgid "An expression tree cannot contain an unsafe pointer operation" msgstr "" -#: ../mcs/mcs/ecore.cs:1030 -#, csharp-format -msgid "`{0}' is a `{1}' but a `{2}' was expected" -msgstr "" - -#: ../mcs/mcs/ecore.cs:1064 +#: mcs/mcs/ecore.cs:796 #, csharp-format msgid "Expression denotes a `{0}', where a `{1}' was expected" msgstr "" -#: ../mcs/mcs/ecore.cs:1069 +#: mcs/mcs/ecore.cs:806 msgid "Pointers and fixed size buffers may only be used in an unsafe context" msgstr "" -#: ../mcs/mcs/ecore.cs:1175 -#, csharp-format -msgid "Cannot call an abstract base member `{0}'" -msgstr "" - -#: ../mcs/mcs/ecore.cs:1182 +#: mcs/mcs/ecore.cs:841 #, csharp-format msgid "" "Members of value type `{0}' cannot be assigned using a property `{1}' object " "initializer" msgstr "" -#: ../mcs/mcs/ecore.cs:1185 +#: mcs/mcs/ecore.cs:844 #, csharp-format msgid "" "Cannot modify a value type return value of `{0}'. Consider storing the value " "in a temporary variable" msgstr "" -#: ../mcs/mcs/ecore.cs:1833 -msgid "Cannot modify the result of an unboxing conversion" +#: mcs/mcs/ecore.cs:2270 +#, csharp-format +msgid "" +"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core." +"dll assembly reference?" msgstr "" -#: ../mcs/mcs/ecore.cs:2401 +#: mcs/mcs/ecore.cs:2344 #, csharp-format msgid "" -"A field initializer cannot reference the nonstatic field, method, or " -"property `{0}'" +"A local variable `{0}' cannot be used before it is declared. Consider " +"renaming the local variable when it hides the member `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:2405 +#: mcs/mcs/ecore.cs:2359 mcs/mcs/ecore.cs:2403 #, csharp-format -msgid "An object reference is required to access non-static member `{0}'" +msgid "`{0}' conflicts with a declaration in a child block" msgstr "" -#: ../mcs/mcs/ecore.cs:2612 ../mcs/mcs/ecore.cs:2632 +#: mcs/mcs/ecore.cs:2412 #, csharp-format -msgid "The variable `{0}' cannot be used with type arguments" +msgid "A local variable `{0}' cannot be used before it is declared" msgstr "" -#: ../mcs/mcs/ecore.cs:3160 +#: mcs/mcs/ecore.cs:2414 #, csharp-format -msgid "" -"Static member `{0}' cannot be accessed with an instance reference, qualify " -"it with a type name instead" +msgid "The name `{0}' does not exist in the current context" msgstr "" -#: ../mcs/mcs/ecore.cs:3166 -msgid "An expression tree may not contain a base access" +#: mcs/mcs/ecore.cs:2664 +#, csharp-format +msgid "" +"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " +"qualifier must be of type `{2}' or derived from it" msgstr "" -#: ../mcs/mcs/ecore.cs:3256 +#: mcs/mcs/ecore.cs:2708 #, csharp-format -msgid "The property `{0}' cannot be used with type arguments" +msgid "Cannot call an abstract base member `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3710 -msgid "An expression tree cannot contain an expression with method group" +#: mcs/mcs/ecore.cs:2747 +#, csharp-format +msgid "" +"Static member `{0}' cannot be accessed with an instance reference, qualify " +"it with a type name instead" msgstr "" -#: ../mcs/mcs/ecore.cs:3720 +#: mcs/mcs/ecore.cs:2762 +#, csharp-format msgid "" -"Partial methods with only a defining declaration or removed conditional " -"methods cannot be used in an expression tree" +"A field initializer cannot reference the nonstatic field, method, or " +"property `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3738 -msgid "Method `" +#: mcs/mcs/ecore.cs:2766 +#, csharp-format +msgid "An object reference is required to access non-static member `{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3765 +#: mcs/mcs/ecore.cs:2774 #, csharp-format msgid "" -"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " -"`out' modifier" +"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3769 -#, csharp-format -msgid "" -"The best overloaded collection initalizer method `{0}' has some invalid " -"arguments" +#: mcs/mcs/ecore.cs:2822 +msgid "Cannot modify the result of an unboxing conversion" msgstr "" -#: ../mcs/mcs/ecore.cs:3775 +#: mcs/mcs/ecore.cs:2943 #, csharp-format msgid "" "Type `{0}' does not contain a member `{1}' and the best extension method " "overload `{2}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3779 +#: mcs/mcs/ecore.cs:2948 #, csharp-format -msgid "The best overloaded method match for `{0}' has some invalid arguments" +msgid "Extension method instance type `{0}' cannot be converted to `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:3783 -#, csharp-format -msgid "Delegate `{0}' has some invalid arguments" +#: mcs/mcs/ecore.cs:3072 +msgid "An expression tree cannot contain an expression with method group" msgstr "" -#: ../mcs/mcs/ecore.cs:3792 -#, csharp-format +#: mcs/mcs/ecore.cs:3078 msgid "" -"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " -"modifier" +"Partial methods with only a defining declaration or removed conditional " +"methods cannot be used in an expression tree" msgstr "" -#: ../mcs/mcs/ecore.cs:3795 +#: mcs/mcs/ecore.cs:3108 #, csharp-format -msgid "Argument `#{0}' is missing `{1}' modifier" +msgid "" +"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " +"parentheses to invoke the method" msgstr "" -#: ../mcs/mcs/ecore.cs:3809 +#: mcs/mcs/ecore.cs:3676 #, csharp-format -msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +msgid "" +"The type `{0}' does not contain a constructor that takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:3812 +#: mcs/mcs/ecore.cs:4284 #, csharp-format -msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' cannot be dynamically dispatched. Consider calling the method " +"without the extension method syntax" msgstr "" -#: ../mcs/mcs/ecore.cs:3819 +#: mcs/mcs/ecore.cs:4305 #, csharp-format msgid "" -"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " -"parentheses to invoke the method" +"The call is ambiguous between the following methods or properties: `{0}' and " +"`{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4105 -msgid "Invoke cannot be called directly on a delegate" +#: mcs/mcs/ecore.cs:4360 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " +"`out' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:4237 +#: mcs/mcs/ecore.cs:4364 #, csharp-format msgid "" -"The type arguments for method `{0}' cannot be inferred from the usage. Try " -"specifying the type arguments explicitly" +"The best overloaded collection initalizer method `{0}' has some invalid " +"arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:4246 +#: mcs/mcs/ecore.cs:4367 #, csharp-format -msgid "Using the generic method `{0}' requires `{1}' type argument(s)" +msgid "Delegate `{0}' has some invalid arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:4275 +#: mcs/mcs/ecore.cs:4371 +#, csharp-format +msgid "The best overloaded method match for `{0}' has some invalid arguments" +msgstr "" + +#: mcs/mcs/ecore.cs:4381 #, csharp-format msgid "" -"The type `{0}' does not contain a constructor that takes `{1}' arguments" +"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " +"modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:4278 +#: mcs/mcs/ecore.cs:4384 #, csharp-format -msgid "No overload for method `{0}' takes `{1}' arguments" +msgid "Argument `#{0}' is missing `{1}' modifier" msgstr "" -#: ../mcs/mcs/ecore.cs:4383 +#: mcs/mcs/ecore.cs:4397 #, csharp-format -msgid "" -"The call is ambiguous between the following methods or properties: `{0}' and " -"`{1}'" +msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" msgstr "" -#: ../mcs/mcs/ecore.cs:4810 +#: mcs/mcs/ecore.cs:4445 +#, csharp-format msgid "" -"You cannot use fixed size buffers contained in unfixed expressions. Try " -"using the fixed statement" +"The type arguments for method `{0}' cannot be inferred from the usage. Try " +"specifying the type arguments explicitly" msgstr "" -#: ../mcs/mcs/ecore.cs:4815 +#: mcs/mcs/ecore.cs:4474 #, csharp-format -msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" +msgid "No overload for method `{0}' takes `{1}' arguments" msgstr "" -#: ../mcs/mcs/ecore.cs:5083 +#: mcs/mcs/ecore.cs:4527 #, csharp-format -msgid "" -"A local variable `{0}' cannot be used before it is declared. Consider " -"renaming the local variable when it hides the field `{1}'" +msgid "The delegate `{0}' does not contain a parameter named `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5368 +#: mcs/mcs/ecore.cs:4532 #, csharp-format msgid "" -"Property `{0}' is not supported by the C# language. Try to call the accessor " -"method `{1}' directly" +"The best overloaded method match for `{0}' does not contain a parameter " +"named `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5414 +#: mcs/mcs/ecore.cs:4542 #, csharp-format msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks the `get' accessor" +"Named argument `{0}' cannot be used for a parameter which has positional " +"argument specified" msgstr "" -#: ../mcs/mcs/ecore.cs:5426 -#, csharp-format +#: mcs/mcs/ecore.cs:4855 msgid "" -"The property or indexer `{0}' cannot be used in this context because the get " -"accessor is inaccessible" +"You cannot use fixed size buffers contained in unfixed expressions. Try " +"using the fixed statement" +msgstr "" + +#: mcs/mcs/ecore.cs:4860 +#, csharp-format +msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" msgstr "" -#: ../mcs/mcs/ecore.cs:5470 +#: mcs/mcs/ecore.cs:5255 +#, csharp-format +msgid "Property or event `{0}' is not supported by the C# language" +msgstr "" + +#: mcs/mcs/ecore.cs:5416 #, csharp-format msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" msgstr "" -#: ../mcs/mcs/ecore.cs:5473 +#: mcs/mcs/ecore.cs:5464 #, csharp-format msgid "" -"A property or indexer `{0}' may not be passed as `ref' or `out' parameter" +"The property or indexer `{0}' cannot be used in this context because it " +"lacks the `get' accessor" msgstr "" -#: ../mcs/mcs/ecore.cs:5494 +#: mcs/mcs/ecore.cs:5471 #, csharp-format msgid "" -"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " -"store the value" +"The property or indexer `{0}' cannot be used in this context because the get " +"accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:5497 +#: mcs/mcs/ecore.cs:5490 #, csharp-format -msgid "Property or indexer `{0}' cannot be assigned to (it is read only)" +msgid "Property or indexer `{0}' cannot be assigned to (it is read-only)" msgstr "" -#: ../mcs/mcs/ecore.cs:5513 +#: mcs/mcs/ecore.cs:5498 #, csharp-format msgid "" "The property or indexer `{0}' cannot be used in this context because the set " "accessor is inaccessible" msgstr "" -#: ../mcs/mcs/ecore.cs:5671 +#: mcs/mcs/ecore.cs:5659 #, csharp-format msgid "" "The event `{0}' can only appear on the left hand side of `+=' or `-=' " "operator" msgstr "" -#: ../mcs/mcs/ecore.cs:5805 +#: mcs/mcs/ecore.cs:5663 #, csharp-format msgid "" "The event `{0}' can only appear on the left hand side of += or -= when used " "outside of the type `{1}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5932 +#: mcs/mcs/ecore.cs:5827 #, csharp-format msgid "" "An implicitly typed local variable declaration cannot be initialized with `" "{0}'" msgstr "" -#: ../mcs/mcs/ecore.cs:5943 +#: mcs/mcs/ecore.cs:5841 msgid "" "The contextual keyword `var' may only appear within a local variable " "declaration" msgstr "" -#: ../mcs/mcs/ecore.cs:5957 -msgid "" -"An implicitly typed local variable declaration cannot include multiple " -"declarators" -msgstr "" - -#: ../mcs/mcs/ecore.cs:5964 -msgid "" -"An implicitly typed local variable declarator must include an initializer" -msgstr "" - -#: ../mcs/mcs/enum.cs:112 +#: mcs/mcs/enum.cs:125 #, csharp-format -msgid "The enumerator value `{0}' is too large to fit in its type `{1}'" +msgid "" +"The enumerator value `{0}' is outside the range of enumerator underlying " +"type `{1}'" msgstr "" -#: ../mcs/mcs/enum.cs:148 +#: mcs/mcs/enum.cs:189 #, csharp-format msgid "An item in an enumeration cannot have an identifier `{0}'" msgstr "" -#: ../mcs/mcs/enum.cs:158 +#: mcs/mcs/enum.cs:200 msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" msgstr "" -#: ../mcs/mcs/eval.cs:496 +#: mcs/mcs/eval.cs:625 msgid "Detection Parsing Error" msgstr "" -#: ../mcs/mcs/expression.cs:553 +#: mcs/mcs/expression.cs:542 #, csharp-format msgid "The `{0}' operator cannot be applied to operand of type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:720 +#: mcs/mcs/expression.cs:622 +msgid "Cannot take the address of the given expression" +msgstr "" + +#: mcs/mcs/expression.cs:656 +msgid "" +"You can only take the address of unfixed expression inside of a fixed " +"statement initializer" +msgstr "" + +#: mcs/mcs/expression.cs:745 #, csharp-format msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:979 +#: mcs/mcs/expression.cs:868 +msgid "The * or -> operator must be applied to a pointer" +msgstr "" + +#: mcs/mcs/expression.cs:1070 msgid "" "The operand of an increment or decrement operator must be a variable, " "property or indexer" msgstr "" -#: ../mcs/mcs/expression.cs:1146 +#: mcs/mcs/expression.cs:1260 #, csharp-format msgid "The `{0}' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/expression.cs:1151 +#: mcs/mcs/expression.cs:1265 #, csharp-format msgid "The `{0}' operator cannot be applied to an operand of pointer type" msgstr "" -#: ../mcs/mcs/expression.cs:1157 +#: mcs/mcs/expression.cs:1271 #, csharp-format msgid "" "The `{0}' operator cannot be applied to a lambda expression or anonymous " "method" msgstr "" -#: ../mcs/mcs/expression.cs:1395 +#: mcs/mcs/expression.cs:1507 #, csharp-format msgid "" -"The `as' operator cannot be used with a non-reference type parameter `{0}'" +"The `as' operator cannot be used with a non-reference type parameter `{0}'. " +"Consider adding `class' or a reference type constraint" msgstr "" -#: ../mcs/mcs/expression.cs:1399 +#: mcs/mcs/expression.cs:1511 #, csharp-format msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1431 +#: mcs/mcs/expression.cs:1548 #, csharp-format msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" msgstr "" -#: ../mcs/mcs/expression.cs:1495 +#: mcs/mcs/expression.cs:1589 #, csharp-format msgid "Cannot convert to static type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:1560 +#: mcs/mcs/expression.cs:1679 msgid "" "The `default value' operator cannot be applied to an operand of a static type" msgstr "" -#: ../mcs/mcs/expression.cs:1978 +#: mcs/mcs/expression.cs:2184 #, csharp-format msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:2487 +#: mcs/mcs/expression.cs:2747 msgid "To cast a negative value, you must enclose the value in parentheses" msgstr "" -#: ../mcs/mcs/expression.cs:2985 +#: mcs/mcs/expression.cs:3400 #, csharp-format msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/expression.cs:3677 +#: mcs/mcs/expression.cs:4152 #, csharp-format msgid "" "A user-defined operator `{0}' must have parameters and return values of the " "same type in order to be applicable as a short circuit operator" msgstr "" -#: ../mcs/mcs/expression.cs:3687 +#: mcs/mcs/expression.cs:4162 #, csharp-format msgid "" "The type `{0}' must have operator `true' and operator `false' defined when `" "{1}' is used as a short circuit operator" msgstr "" -#: ../mcs/mcs/expression.cs:3934 +#: mcs/mcs/expression.cs:4472 +#, csharp-format +msgid "" +"Type of conditional expression cannot be determined as `{0}' and `{1}' " +"convert implicitly to each other" +msgstr "" + +#: mcs/mcs/expression.cs:4482 #, csharp-format msgid "" "Type of conditional expression cannot be determined because there is no " "implicit conversion between `{0}' and `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:4395 +#: mcs/mcs/expression.cs:4934 #, csharp-format msgid "Use of unassigned out parameter `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:4423 +#: mcs/mcs/expression.cs:4964 #, csharp-format msgid "" "Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " "modifier" msgstr "" -#: ../mcs/mcs/expression.cs:4749 +#: mcs/mcs/expression.cs:5165 +#, csharp-format +msgid "Cannot invoke a non-delegate type `{0}'" +msgstr "" + +#: mcs/mcs/expression.cs:5176 #, csharp-format msgid "The member `{0}' cannot be used as method or delegate" msgstr "" -#: ../mcs/mcs/expression.cs:4811 +#: mcs/mcs/expression.cs:5196 msgid "" "Do not directly call your base class Finalize method. It is called " "automatically from your destructor" msgstr "" -#: ../mcs/mcs/expression.cs:4813 +#: mcs/mcs/expression.cs:5198 msgid "" "Destructors and object.Finalize cannot be called directly. Consider calling " "IDisposable.Dispose if available" msgstr "" -#: ../mcs/mcs/expression.cs:4837 +#: mcs/mcs/expression.cs:5227 +#, csharp-format +msgid "" +"The base call to method `{0}' cannot be dynamically dispatched. Consider " +"casting the dynamic arguments or eliminating the base access" +msgstr "" + +#: mcs/mcs/expression.cs:5304 #, csharp-format msgid "`{0}': cannot explicitly call operator or accessor" msgstr "" -#: ../mcs/mcs/expression.cs:5390 +#: mcs/mcs/expression.cs:5631 #, csharp-format msgid "Unsafe type `{0}' cannot be used in an object creation expression" msgstr "" -#: ../mcs/mcs/expression.cs:5442 +#: mcs/mcs/expression.cs:5654 +#, csharp-format +msgid "" +"Cannot create an instance of the variable type `{0}' because it does not " +"have the new() constraint" +msgstr "" + +#: mcs/mcs/expression.cs:5660 +#, csharp-format +msgid "" +"`{0}': cannot provide arguments when creating an instance of a variable type" +msgstr "" + +#: mcs/mcs/expression.cs:5669 #, csharp-format msgid "Cannot create an instance of the static class `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:5454 +#: mcs/mcs/expression.cs:5681 #, csharp-format msgid "Cannot create an instance of the abstract class or interface `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:5767 +#: mcs/mcs/expression.cs:5977 +msgid "" +"An implicitly typed local variable declarator cannot use an array initializer" +msgstr "" + +#: mcs/mcs/expression.cs:6070 msgid "Cannot create an array with a negative size" msgstr "" -#: ../mcs/mcs/expression.cs:5784 ../mcs/mcs/statement.cs:2991 +#: mcs/mcs/expression.cs:6102 mcs/mcs/expression.cs:6110 +#: mcs/mcs/statement.cs:1009 mcs/mcs/statement.cs:3055 msgid "A constant value is expected" msgstr "" -#: ../mcs/mcs/expression.cs:5871 +#: mcs/mcs/expression.cs:6116 +#, csharp-format +msgid "An array initializer of length `{0}' was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6132 +msgid "" +"Array initializers can only be used in a variable or field initializer. Try " +"using a new expression instead" +msgstr "" + +#: mcs/mcs/expression.cs:6140 +msgid "A nested array initializer was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6177 msgid "An expression tree cannot contain a multidimensional array initializer" msgstr "" -#: ../mcs/mcs/expression.cs:5965 +#: mcs/mcs/expression.cs:6279 msgid "" "Can only use array initializer expressions to assign to array types. Try " "using a new expression instead" msgstr "" -#: ../mcs/mcs/expression.cs:5970 +#: mcs/mcs/expression.cs:6718 msgid "" -"An implicitly typed local variable declarator cannot use an array initializer" +"The type of an implicitly typed array cannot be inferred from the " +"initializer. Try specifying array type explicitly" msgstr "" -#: ../mcs/mcs/expression.cs:6045 -msgid "New invocation: Can not find a constructor for this argument list" +#: mcs/mcs/expression.cs:6855 +msgid "" +"The `this' object cannot be used before all of its fields are assigned to" msgstr "" -#: ../mcs/mcs/expression.cs:6488 +#: mcs/mcs/expression.cs:6862 msgid "" -"The type of an implicitly typed array cannot be inferred from the " -"initializer. Try specifying array type explicitly" +"Keyword `this' is not valid in a static property, static method, or static " +"field initializer" msgstr "" -#: ../mcs/mcs/expression.cs:6666 +#: mcs/mcs/expression.cs:6865 msgid "" "Anonymous methods inside structs cannot access instance members of `this'. " "Consider copying `this' to a local variable outside the anonymous method and " "using the local instead" msgstr "" -#: ../mcs/mcs/expression.cs:6740 +#: mcs/mcs/expression.cs:6868 +msgid "Keyword `this' is not available in the current context" +msgstr "" + +#: mcs/mcs/expression.cs:6955 msgid "Cannot take the address of `this' because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6742 +#: mcs/mcs/expression.cs:6957 msgid "Cannot pass `this' as a ref or out argument because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6744 +#: mcs/mcs/expression.cs:6959 msgid "Cannot assign to `this' because it is read-only" msgstr "" -#: ../mcs/mcs/expression.cs:6856 +#: mcs/mcs/expression.cs:7012 +msgid "The __arglist construct is valid only within a variable argument method" +msgstr "" + +#: mcs/mcs/expression.cs:7062 msgid "An expression tree cannot contain a method with variable arguments" msgstr "" -#: ../mcs/mcs/expression.cs:6966 +#: mcs/mcs/expression.cs:7146 +msgid "" +"System.Void cannot be used from C#. Use typeof (void) to get the void type " +"object" +msgstr "" + +#: mcs/mcs/expression.cs:7149 +msgid "The typeof operator cannot be used on the dynamic type" +msgstr "" + +#: mcs/mcs/expression.cs:7218 #, csharp-format msgid "`{0}': an attribute argument cannot use type parameters" msgstr "" -#: ../mcs/mcs/expression.cs:7199 +#: mcs/mcs/expression.cs:7472 #, csharp-format msgid "" "`{0}' does not have a predefined size, therefore sizeof can only be used in " @@ -2258,40 +2319,44 @@ msgid "" "SizeOf)" msgstr "" -#: ../mcs/mcs/expression.cs:7254 +#: mcs/mcs/expression.cs:7528 #, csharp-format msgid "Alias `{0}' not found" msgstr "" -#: ../mcs/mcs/expression.cs:7265 +#: mcs/mcs/expression.cs:7539 #, csharp-format msgid "" "Alias `{0}' cannot be used with '::' since it denotes a type. Consider " "replacing '::' with '.'" msgstr "" -#: ../mcs/mcs/expression.cs:7281 +#: mcs/mcs/expression.cs:7555 #, csharp-format msgid "" "A namespace alias qualifier `{0}' did not resolve to a namespace or a type" msgstr "" -#: ../mcs/mcs/expression.cs:7422 +#: mcs/mcs/expression.cs:7712 +msgid "Cannot perform member binding on `null' value" +msgstr "" + +#: mcs/mcs/expression.cs:7779 #, csharp-format msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" msgstr "" -#: ../mcs/mcs/expression.cs:7519 +#: mcs/mcs/expression.cs:7855 #, csharp-format msgid "A nested type cannot be specified through a type parameter `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:7587 +#: mcs/mcs/expression.cs:7914 #, csharp-format msgid "The nested type `{0}' does not exist in the type `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:7599 +#: mcs/mcs/expression.cs:7923 #, csharp-format msgid "" "Type `{0}' does not contain a definition for `{1}' and no extension method `" @@ -2299,600 +2364,960 @@ msgid "" "assembly reference?)" msgstr "" -#: ../mcs/mcs/expression.cs:7817 -msgid "Cannot apply indexing with [] to an expression of type `System.Array'" +#: mcs/mcs/expression.cs:8103 +#, csharp-format +msgid "Cannot apply indexing with [] to an expression of type `{0}'" +msgstr "" + +#: mcs/mcs/expression.cs:8119 +msgid "A pointer must be indexed by only one value" +msgstr "" + +#: mcs/mcs/expression.cs:8168 +msgid "An element access expression cannot use named argument" msgstr "" -#: ../mcs/mcs/expression.cs:7923 +#: mcs/mcs/expression.cs:8224 #, csharp-format msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" msgstr "" -#: ../mcs/mcs/expression.cs:8410 -#, csharp-format +#: mcs/mcs/expression.cs:8560 msgid "" -"A property or indexer `{0}' may not be passed as an out or ref parameter" +"The indexer base access cannot be dynamically dispatched. Consider casting " +"the dynamic arguments or eliminating the base access" msgstr "" -#: ../mcs/mcs/expression.cs:8435 -#, csharp-format -msgid "Cannot apply indexing with [] to an expression of type `{0}'" +#: mcs/mcs/expression.cs:8641 +msgid "An expression tree may not contain a base access" msgstr "" -#: ../mcs/mcs/expression.cs:8465 -#, csharp-format -msgid "The read only property or indexer `{0}' cannot be assigned to" +#: mcs/mcs/expression.cs:8658 +msgid "Keyword `base' is not available in a static method" msgstr "" -#: ../mcs/mcs/expression.cs:8473 -#, csharp-format -msgid "" -"The property or indexer `{0}' cannot be used in this context because it " -"lacks a `{1}' accessor" +#: mcs/mcs/expression.cs:8660 +msgid "Keyword `base' is not available in the current context" msgstr "" -#: ../mcs/mcs/expression.cs:8495 -#, csharp-format +#: mcs/mcs/expression.cs:8691 msgid "" -"The property or indexer `{0}' cannot be used in this context because a `{1}' " -"accessor is inaccessible" +"A property, indexer or dynamic member access may not be passed as `ref' or " +"`out' parameter" msgstr "" -#: ../mcs/mcs/expression.cs:8958 +#: mcs/mcs/expression.cs:8968 #, csharp-format msgid "Array elements cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:8964 +#: mcs/mcs/expression.cs:8971 #, csharp-format msgid "Array elements cannot be of static type `{0}'" msgstr "" -#: ../mcs/mcs/expression.cs:9130 +#: mcs/mcs/expression.cs:9121 msgid "Cannot use a negative size with stackalloc" msgstr "" -#: ../mcs/mcs/expression.cs:9257 +#: mcs/mcs/expression.cs:9125 +msgid "Cannot use stackalloc in finally or catch" +msgstr "" + +#: mcs/mcs/expression.cs:9230 #, csharp-format msgid "" "Member `{0}' cannot be initialized. An object initializer may only be used " "for fields, or properties" msgstr "" -#: ../mcs/mcs/expression.cs:9260 +#: mcs/mcs/expression.cs:9239 #, csharp-format msgid "" -" Static field or property `{0}' cannot be assigned in an object initializer" +"Static field or property `{0}' cannot be assigned in an object initializer" msgstr "" -#: ../mcs/mcs/expression.cs:9433 +#: mcs/mcs/expression.cs:9414 #, csharp-format msgid "" "A field or property `{0}' cannot be initialized with a collection object " "initializer because type `{1}' does not implement `{2}' interface" msgstr "" -#: ../mcs/mcs/expression.cs:9444 +#: mcs/mcs/expression.cs:9425 #, csharp-format msgid "Inconsistent `{0}' member declaration" msgstr "" -#: ../mcs/mcs/expression.cs:9452 +#: mcs/mcs/expression.cs:9433 #, csharp-format msgid "" "An object initializer includes more than one member `{0}' initialization" msgstr "" -#: ../mcs/mcs/expression.cs:9469 +#: mcs/mcs/expression.cs:9451 #, csharp-format msgid "Cannot initialize object of type `{0}' with a collection initializer" msgstr "" -#: ../mcs/mcs/expression.cs:9717 +#: mcs/mcs/expression.cs:9688 msgid "Anonymous types cannot be used in this expression" msgstr "" -#: ../mcs/mcs/expression.cs:9824 +#: mcs/mcs/expression.cs:9776 #, csharp-format msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:310 +#: mcs/mcs/field.cs:70 +msgid "" +"The modifier 'abstract' is not valid on fields. Try using a property instead" +msgstr "" + +#: mcs/mcs/field.cs:121 +msgid "" +"The FieldOffset attribute can only be placed on members of types marked with " +"the StructLayout(LayoutKind.Explicit)" +msgstr "" + +#: mcs/mcs/field.cs:126 +msgid "The FieldOffset attribute is not allowed on static or const fields" +msgstr "" + +#: mcs/mcs/field.cs:132 +msgid "" +"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " +"'fixed' field modifier instead" +msgstr "" + +#: mcs/mcs/field.cs:237 +#, csharp-format +msgid "" +"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " +"must have a FieldOffset attribute" +msgstr "" + +#: mcs/mcs/field.cs:246 +#, csharp-format +msgid "`{0}': cannot declare variables of static types" +msgstr "" + +#: mcs/mcs/field.cs:388 +#, csharp-format +msgid "" +"`{0}': Fixed size buffers type must be one of the following: bool, byte, " +"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +msgstr "" + +#: mcs/mcs/field.cs:424 +#, csharp-format +msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgstr "" + +#: mcs/mcs/field.cs:439 +#, csharp-format +msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgstr "" + +#: mcs/mcs/field.cs:446 +#, csharp-format +msgid "" +"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +msgstr "" + +#: mcs/mcs/field.cs:628 +#, csharp-format +msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgstr "" + +#: mcs/mcs/field.cs:633 +#, csharp-format +msgid "`{0}': A field cannot be both volatile and readonly" +msgstr "" + +#: mcs/mcs/flowanalysis.cs:307 msgid "Control cannot fall through from one case label to another" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:529 +#: mcs/mcs/flowanalysis.cs:536 #, csharp-format msgid "" "The label `{0}:' could not be found within the scope of the goto statement" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:657 +#: mcs/mcs/flowanalysis.cs:664 msgid "" "A throw statement with no arguments is not allowed outside of a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:668 ../mcs/mcs/flowanalysis.cs:674 +#: mcs/mcs/flowanalysis.cs:675 mcs/mcs/flowanalysis.cs:681 msgid "No enclosing loop out of which to break or continue" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:702 +#: mcs/mcs/flowanalysis.cs:709 msgid "Control cannot leave the body of an anonymous method" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:743 +#: mcs/mcs/flowanalysis.cs:750 msgid "Cannot yield a value in the body of a try block with a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:745 +#: mcs/mcs/flowanalysis.cs:752 msgid "Cannot yield a value in the body of a catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:897 +#: mcs/mcs/flowanalysis.cs:904 msgid "" "A throw statement with no arguments is not allowed inside of a finally " "clause nested inside of the innermost catch clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:909 ../mcs/mcs/iterators.cs:112 +#: mcs/mcs/flowanalysis.cs:916 mcs/mcs/iterators.cs:102 msgid "Cannot yield in the body of a finally clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:920 ../mcs/mcs/flowanalysis.cs:936 -#: ../mcs/mcs/flowanalysis.cs:972 ../mcs/mcs/statement.cs:778 +#: mcs/mcs/flowanalysis.cs:927 mcs/mcs/flowanalysis.cs:943 +#: mcs/mcs/flowanalysis.cs:979 mcs/mcs/statement.cs:694 msgid "Control cannot leave the body of a finally clause" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1140 +#: mcs/mcs/flowanalysis.cs:1130 #, csharp-format msgid "" "An automatically implemented property `{0}' must be fully assigned before " -"control leaves the constructor. Consider calling default contructor" +"control leaves the constructor. Consider calling the default struct " +"contructor from a constructor initializer" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1144 +#: mcs/mcs/flowanalysis.cs:1134 #, csharp-format msgid "" "Field `{0}' must be fully assigned before control leaves the constructor" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1438 +#: mcs/mcs/flowanalysis.cs:1376 msgid "Use of unassigned local variable `" msgstr "" -#: ../mcs/mcs/flowanalysis.cs:1508 +#: mcs/mcs/flowanalysis.cs:1446 msgid "Use of possibly unassigned field `" msgstr "" -#: ../mcs/mcs/generic.cs:191 -msgid "The new() constraint must be the last constraint specified" +#: mcs/mcs/generic.cs:102 mcs/mcs/generic.cs:120 +#, csharp-format +msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/generic.cs:204 -msgid "The `new()' constraint cannot be used with the `struct' constraint" +#: mcs/mcs/generic.cs:173 +#, csharp-format +msgid "A constraint cannot be the dynamic type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:210 +#: mcs/mcs/generic.cs:182 +#, csharp-format msgid "" -"The `class' or `struct' constraint must be the first constraint specified" +"Inconsistent accessibility: constraint type `{0}' is less accessible than `" +"{1}'" +msgstr "" + +#: mcs/mcs/generic.cs:189 mcs/mcs/generic.cs:203 +#, csharp-format +msgid "Duplicate constraint `{0}' for type parameter `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:249 +#: mcs/mcs/generic.cs:218 +#, csharp-format +msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgstr "" + +#: mcs/mcs/generic.cs:249 #, csharp-format msgid "" -"Inconsistent accessibility: constraint type `{0}' is less accessible than `" -"{1}'" +"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " +"constraint for `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:261 +#: mcs/mcs/generic.cs:260 #, csharp-format msgid "" "The class type constraint `{0}' must be listed before any other constraints. " "Consider moving type constraint to the beginning of the constraint list" msgstr "" -#: ../mcs/mcs/generic.cs:265 +#: mcs/mcs/generic.cs:266 #, csharp-format msgid "" "`{0}': cannot specify both a constraint class and the `class' or `struct' " "constraint" msgstr "" -#: ../mcs/mcs/generic.cs:282 ../mcs/mcs/generic.cs:297 +#: mcs/mcs/generic.cs:271 +msgid "A constraint cannot be the dynamic type" +msgstr "" + +#: mcs/mcs/generic.cs:277 #, csharp-format -msgid "Duplicate constraint `{0}' for type parameter `{1}'." +msgid "" +"`{0}' is not a valid constraint. A constraint must be an interface, a non-" +"sealed class or a type parameter" msgstr "" -#: ../mcs/mcs/generic.cs:316 +#: mcs/mcs/generic.cs:284 #, csharp-format msgid "" "`{0}' is not a valid constraint. Static classes cannot be used as constraints" msgstr "" -#: ../mcs/mcs/generic.cs:321 +#: mcs/mcs/generic.cs:290 +#, csharp-format +msgid "A constraint cannot be special class `{0}'" +msgstr "" + +#: mcs/mcs/generic.cs:538 +#, csharp-format +msgid "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'" +msgstr "" + +#: mcs/mcs/generic.cs:1720 +#, csharp-format +msgid "`{0}': static classes cannot be used as generic arguments" +msgstr "" + +#: mcs/mcs/generic.cs:1727 +#, csharp-format +msgid "The type `{0}' may not be used as a type argument" +msgstr "" + +#: mcs/mcs/generic.cs:1982 #, csharp-format msgid "" -"`{0}' is not a valid constraint. A constraint must be an interface, a non-" -"sealed class or a type parameter" +"The type `{0}' must be a reference type in order to use it as type parameter " +"`{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/generic.cs:334 +#: mcs/mcs/generic.cs:1992 #, csharp-format -msgid "A constraint cannot be special class `{0}'" +msgid "" +"The type `{0}' must be a non-nullable value type in order to use it as type " +"parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/generic.cs:364 +#: mcs/mcs/generic.cs:2022 #, csharp-format msgid "" -"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " -"constraint for `{1}'" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. The nullable type `{0}' never satisfies interface constraint" msgstr "" -#: ../mcs/mcs/generic.cs:384 +#: mcs/mcs/generic.cs:2061 #, csharp-format -msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" +msgid "" +"The type `{0}' must have a public parameterless constructor in order to use " +"it as parameter `{1}' in the generic type or method `{2}'" msgstr "" -#: ../mcs/mcs/generic.cs:398 +#: mcs/mcs/generic.cs:2113 #, csharp-format -msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing conversion from `{0}' to `{3}'" msgstr "" -#: ../mcs/mcs/generic.cs:702 +#: mcs/mcs/generic.cs:2117 #, csharp-format msgid "" -"`{0}': Cannot specify constraints for overrides or explicit interface " -"implementation methods" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing or type parameter conversion from `{0}' to `" +"{3}'" msgstr "" -#: ../mcs/mcs/generic.cs:733 +#: mcs/mcs/generic.cs:2121 #, csharp-format msgid "" -"The constraints for type parameter `{0}' of method `{1}' must match the " -"constraints for type parameter `{2}' of interface method `{3}'. Consider " -"using an explicit interface implementation instead" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'" msgstr "" -#: ../mcs/mcs/generic.cs:1139 -msgid "Type parameter declaration must be an identifier not a type" +#: mcs/mcs/iterators.cs:44 +msgid "The yield statement cannot be used inside anonymous method blocks" msgstr "" -#: ../mcs/mcs/generic.cs:1231 +#: mcs/mcs/iterators.cs:856 #, csharp-format -msgid "`{0}': static classes cannot be used as generic arguments" +msgid "" +"The body of `{0}' cannot be an iterator block because `{1}' is not an " +"iterator interface type" msgstr "" -#: ../mcs/mcs/generic.cs:1238 +#: mcs/mcs/iterators.cs:869 +msgid "Iterators cannot have ref or out parameters" +msgstr "" + +#: mcs/mcs/iterators.cs:875 +msgid "__arglist is not allowed in parameter list of iterators" +msgstr "" + +#: mcs/mcs/iterators.cs:881 +msgid "Iterators cannot have unsafe parameters or yield types" +msgstr "" + +#: mcs/mcs/iterators.cs:888 mcs/mcs/statement.cs:4324 +msgid "Unsafe code may not appear in iterators" +msgstr "" + +#: mcs/mcs/linq.cs:68 #, csharp-format -msgid "The type `{0}' may not be used as a type argument" +msgid "" +"An implementation of `{0}' query expression pattern could not be found. Are " +"you missing `System.Linq' using directive or `System.Core.dll' assembly " +"reference?" msgstr "" -#: ../mcs/mcs/generic.cs:1368 +#: mcs/mcs/linq.cs:93 #, csharp-format -msgid "Cannot find type `{0}'<...>" +msgid "" +"Ambiguous implementation of the query pattern `{0}' for source type `{1}'" msgstr "" -#: ../mcs/mcs/generic.cs:1375 +#: mcs/mcs/linq.cs:124 #, csharp-format -msgid "The non-generic type `{0}' cannot be used with type arguments." +msgid "" +"An implementation of `{0}' query expression pattern for source type `{1}' " +"could not be found" msgstr "" -#: ../mcs/mcs/generic.cs:1531 +#: mcs/mcs/linq.cs:132 #, csharp-format msgid "" -"The type `{0}' must be a reference type in order to use it as type parameter " -"`{1}' in the generic type or method `{2}'." +"An expression type is incorrect in a subsequent `from' clause in a query " +"expression with source type `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1540 +#: mcs/mcs/linq.cs:136 #, csharp-format msgid "" -"The type `{0}' must be a non-nullable value type in order to use it as type " -"parameter `{1}' in the generic type or method `{2}'." +"An expression type in `{0}' clause is incorrect. Type inference failed in " +"the call to `{1}'" +msgstr "" + +#: mcs/mcs/linq.cs:248 +#, csharp-format +msgid "A range variable `{0}' cannot be initialized with `{1}'" +msgstr "" + +#: mcs/mcs/linq.cs:750 +#, csharp-format +msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" msgstr "" -#: ../mcs/mcs/generic.cs:1583 +#: mcs/mcs/linq.cs:757 +#, csharp-format +msgid "A range variable `{0}' has already been declared in this scope" +msgstr "" + +#: mcs/mcs/linq.cs:764 +#, csharp-format +msgid "A range variable `{0}' conflicts with a method type parameter" +msgstr "" + +#: mcs/mcs/linq.cs:796 #, csharp-format msgid "" -"The type `{0}' must have a public parameterless constructor in order to use " -"it as parameter `{1}' in the generic type or method `{2}'" +"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " +"store the value" +msgstr "" + +#: mcs/mcs/literal.cs:49 +#, csharp-format +msgid "" +"Cannot convert null to the type parameter `{0}' because it could be a value " +"type. Consider using `default ({0})' instead" +msgstr "" + +#: mcs/mcs/literal.cs:55 +#, csharp-format +msgid "Cannot convert null to `{0}' because it is a value type" +msgstr "" + +#: mcs/mcs/literal.cs:204 +#, csharp-format +msgid "" +"Literal of type double cannot be implicitly converted to type `{0}'. Add " +"suffix `{1}' to create a literal of this type" +msgstr "" + +#: mcs/mcs/membercache.cs:1261 +msgid "" +"A partial method declaration and partial method implementation cannot differ " +"on use of `params' modifier" +msgstr "" + +#: mcs/mcs/membercache.cs:1264 +msgid "" +"A partial method declaration and partial method implementation must be both " +"an extension method or neither" +msgstr "" + +#: mcs/mcs/membercache.cs:1268 +#, csharp-format +msgid "" +"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only" +msgstr "" + +#: mcs/mcs/membercache.cs:1272 +#, csharp-format +msgid "" +"Overloaded method `{0}' cannot differ on use of parameter modifiers only" +msgstr "" + +#: mcs/mcs/membercache.cs:1304 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`static' or neither" +msgstr "" + +#: mcs/mcs/membercache.cs:1309 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`unsafe' or neither" +msgstr "" + +#: mcs/mcs/membercache.cs:1315 +#, csharp-format +msgid "A partial method `{0}' declaration is already defined" +msgstr "" + +#: mcs/mcs/membercache.cs:1319 +#, csharp-format +msgid "A partial method `{0}' implementation is already defined" +msgstr "" + +#: mcs/mcs/membercache.cs:1330 mcs/mcs/property.cs:81 +#, csharp-format +msgid "A member `{0}' is already reserved" +msgstr "" + +#: mcs/mcs/membercache.cs:1341 +#, csharp-format +msgid "Duplicate user-defined conversion in type `{0}'" +msgstr "" + +#: mcs/mcs/method.cs:484 +msgid "" +"The DllImport attribute must be specified on a method marked `static' and " +"`extern'" +msgstr "" + +#: mcs/mcs/method.cs:572 +#, csharp-format +msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgstr "" + +#: mcs/mcs/method.cs:631 +#, csharp-format +msgid "" +"Conditional not valid on `{0}' because it is a constructor, destructor, " +"operator or explicit interface implementation" +msgstr "" + +#: mcs/mcs/method.cs:844 +#, csharp-format +msgid "Program `{0}' has more than one entry point defined: `{1}'" +msgstr "" + +#: mcs/mcs/method.cs:888 +#, csharp-format +msgid "Conditional not valid on `{0}' because it is an override method" +msgstr "" + +#: mcs/mcs/method.cs:893 +#, csharp-format +msgid "Conditional not valid on `{0}' because its return type is not void" +msgstr "" + +#: mcs/mcs/method.cs:898 +msgid "Conditional not valid on interface members" +msgstr "" + +#: mcs/mcs/method.cs:904 +#, csharp-format +msgid "Conditional member `{0}' cannot implement interface member `{1}'" +msgstr "" + +#: mcs/mcs/method.cs:911 +#, csharp-format +msgid "Conditional method `{0}' cannot have an out parameter" +msgstr "" + +#: mcs/mcs/method.cs:1017 +#, csharp-format +msgid "" +"The constraints for type parameter `{0}' of method `{1}' must match the " +"constraints for type parameter `{2}' of interface method `{3}'. Consider " +"using an explicit interface implementation instead" +msgstr "" + +#: mcs/mcs/method.cs:1071 +#, csharp-format +msgid "`{0}': Extension methods cannot be defined in a nested class" +msgstr "" + +#: mcs/mcs/method.cs:1077 +#, csharp-format +msgid "" +"`{0}': Extension methods cannot be declared without a reference to System." +"Core.dll assembly. Add the assembly reference or remove `this' modifer from " +"the first parameter" +msgstr "" + +#: mcs/mcs/method.cs:1086 +#, csharp-format +msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgstr "" + +#: mcs/mcs/method.cs:1139 +#, csharp-format +msgid "" +"A partial method `{0}' implementation is missing a partial method declaration" +msgstr "" + +#: mcs/mcs/method.cs:1186 +#, csharp-format +msgid "Method or delegate cannot return type `{0}'" +msgstr "" + +#: mcs/mcs/method.cs:1261 +msgid "" +"The constructor call cannot be dynamically dispatched within constructor " +"initializer" +msgstr "" + +#: mcs/mcs/method.cs:1275 +#, csharp-format +msgid "`{0}': Struct constructors cannot call base constructors" msgstr "" -#: ../mcs/mcs/generic.cs:1628 +#: mcs/mcs/method.cs:1294 #, csharp-format -msgid "" -"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " -"method `{2}'. The nullable type `{0}' never satisfies interface constraint " -"of type `{3}'" +msgid "Constructor `{0}' cannot call itself" msgstr "" -#: ../mcs/mcs/generic.cs:1634 +#: mcs/mcs/method.cs:1413 #, csharp-format -msgid "" -"The type `{0}' must be convertible to `{1}' in order to use it as parameter `" -"{2}' in the generic type or method `{3}'" +msgid "`{0}': The static constructor must be parameterless" msgstr "" -#: ../mcs/mcs/generic.cs:1827 -#, csharp-format -msgid "The type parameter name `{0}' is the same as `{1}'" +#: mcs/mcs/method.cs:1431 +msgid "Structs cannot contain explicit parameterless constructors" msgstr "" -#: ../mcs/mcs/iterators.cs:42 ../mcs/mcs/iterators.cs:939 -msgid "Unsafe code may not appear in iterators" +#: mcs/mcs/method.cs:1487 +#, csharp-format +msgid "" +"`{0}': A class with the ComImport attribute cannot have a user-defined " +"constructor" msgstr "" -#: ../mcs/mcs/iterators.cs:52 -msgid "The yield statement cannot be used inside anonymous method blocks" +#: mcs/mcs/method.cs:1730 +#, csharp-format +msgid "`{0}' is an accessor not found in interface member `{1}{2}'" msgstr "" -#: ../mcs/mcs/iterators.cs:907 +#: mcs/mcs/method.cs:1736 #, csharp-format msgid "" -"The body of `{0}' cannot be an iterator block because `{1}' is not an " -"iterator interface type" +"`{0}.{1}' in explicit interface declaration is not a member of interface" msgstr "" -#: ../mcs/mcs/iterators.cs:920 -msgid "Iterators cannot have ref or out parameters" +#: mcs/mcs/method.cs:1743 +#, csharp-format +msgid "" +"`{0}' explicit method implementation cannot implement `{1}' because it is an " +"accessor" msgstr "" -#: ../mcs/mcs/iterators.cs:926 -msgid "__arglist is not allowed in parameter list of iterators" +#: mcs/mcs/method.cs:1753 +#, csharp-format +msgid "Method `{0}' cannot implement interface accessor `{1}'" msgstr "" -#: ../mcs/mcs/iterators.cs:932 -msgid "Iterators cannot have unsafe parameters or yield types" +#: mcs/mcs/method.cs:1759 +#, csharp-format +msgid "" +"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " +"an explicit interface implementation" msgstr "" -#: ../mcs/mcs/linq.cs:79 +#: mcs/mcs/method.cs:1765 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern could not be found. Are " -"you missing `System.Linq' using directive or `System.Core.dll' assembly " -"reference?" +"Accessor `{0}' must be declared public to implement interface member `{1}'" msgstr "" -#: ../mcs/mcs/linq.cs:117 +#: mcs/mcs/method.cs:1789 #, csharp-format msgid "" -"An implementation of `{0}' query expression pattern for source type `{1}' " -"could not be found" +"`{0}': the explicit interface implementation cannot introduce the params " +"modifier" msgstr "" -#: ../mcs/mcs/linq.cs:126 +#: mcs/mcs/method.cs:2107 #, csharp-format msgid "" -"Type inference failed to infer type argument for `{0}' clause. Try " -"specifying the type argument explicitly" +"Attribute `{0}' is not valid on property or event accessors. It is valid on `" +"{1}' declarations only" msgstr "" -#: ../mcs/mcs/linq.cs:525 +#: mcs/mcs/method.cs:2318 #, csharp-format -msgid "A range variable `{0}' cannot be initialized with `{1}'" +msgid "User-defined operator `{0}' must be declared static and public" msgstr "" -#: ../mcs/mcs/linq.cs:825 -#, csharp-format -msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" +#: mcs/mcs/method.cs:2357 +msgid "" +"User-defined operator cannot take an object of the enclosing type and " +"convert to an object of the enclosing type" msgstr "" -#: ../mcs/mcs/linq.cs:831 -#, csharp-format -msgid "A range variable `{0}' has already been declared in this scope" +#: mcs/mcs/method.cs:2368 +msgid "User-defined conversion must convert to or from the enclosing type" msgstr "" -#: ../mcs/mcs/linq.cs:837 +#: mcs/mcs/method.cs:2374 #, csharp-format -msgid "A range variable `{0}' conflicts with a method type parameter" +msgid "" +"User-defined conversion `{0}' cannot convert to or from the dynamic type" msgstr "" -#: ../mcs/mcs/literal.cs:76 +#: mcs/mcs/method.cs:2381 #, csharp-format msgid "" -"Cannot convert null to the type parameter `{0}' because it could be a value " -"type. Consider using `default ({0})' instead" +"User-defined conversion `{0}' cannot convert to or from an interface type" msgstr "" -#: ../mcs/mcs/literal.cs:79 +#: mcs/mcs/method.cs:2388 #, csharp-format -msgid "Cannot convert null to `{0}' because it is a value type" +msgid "User-defined conversion `{0}' cannot convert to or from a base class" msgstr "" -#: ../mcs/mcs/literal.cs:323 +#: mcs/mcs/method.cs:2394 #, csharp-format +msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgstr "" + +#: mcs/mcs/method.cs:2401 msgid "" -"Literal of type double cannot be implicitly converted to type `{0}'. Add " -"suffix `{1}' to create a literal of this type" +"Overloaded shift operator must have the type of the first operand be the " +"containing type, and the type of the second operand must be int" msgstr "" -#: ../mcs/mcs/location.cs:224 -#, csharp-format -msgid "Source file `{0}' specified multiple times" +#: mcs/mcs/method.cs:2410 +msgid "" +"The return type for ++ or -- operator must be the containing type or derived " +"from the containing type" msgstr "" -#: ../mcs/mcs/location.cs:226 -#, csharp-format -msgid "Source filenames `{0}' and `{1}' both refer to the same file: {2}" +#: mcs/mcs/method.cs:2415 +msgid "The parameter type for ++ or -- operator must be the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:241 -msgid "More than one protection modifier specified" +#: mcs/mcs/method.cs:2422 +msgid "The parameter type of a unary operator must be the containing type" msgstr "" -#: ../mcs/mcs/modifiers.cs:258 -msgid "The modifier `" +#: mcs/mcs/method.cs:2430 +msgid "The return type of operator True or False must be bool" msgstr "" -#: ../mcs/mcs/namespace.cs:113 -#, csharp-format -msgid "An assembly `{0}' is used without being referenced" +#: mcs/mcs/method.cs:2445 +msgid "One of the parameters of a binary operator must be the containing type" msgstr "" -#: ../mcs/mcs/namespace.cs:136 +#: mcs/mcs/modifiers.cs:275 #, csharp-format -msgid "The imported type `{0}' is defined multiple times" +msgid "The modifier `{0}' is not valid for this item" msgstr "" -#: ../mcs/mcs/namespace.cs:259 +#: mcs/mcs/namespace.cs:70 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found in the global namespace " "(are you missing an assembly reference?)" msgstr "" -#: ../mcs/mcs/namespace.cs:380 +#: mcs/mcs/namespace.cs:177 #, csharp-format msgid "" "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are " "you missing an assembly reference?" msgstr "" -#: ../mcs/mcs/namespace.cs:387 +#: mcs/mcs/namespace.cs:256 #, csharp-format -msgid "Using the generic type `{0}' requires `{1}' type argument(s)" -msgstr "" - -#: ../mcs/mcs/namespace.cs:405 -#, csharp-format -msgid "The non-generic {0} `{1}' cannot be used with the type arguments" +msgid "The imported type `{0}' is defined multiple times" msgstr "" -#: ../mcs/mcs/namespace.cs:642 +#: mcs/mcs/namespace.cs:583 #, csharp-format msgid "" "`{0}' is a type not a namespace. A using namespace directive can only be " "applied to namespaces" msgstr "" -#: ../mcs/mcs/namespace.cs:669 +#: mcs/mcs/namespace.cs:610 #, csharp-format msgid "The extern alias `{0}' was not specified in -reference option" msgstr "" -#: ../mcs/mcs/namespace.cs:880 ../mcs/mcs/namespace.cs:902 +#: mcs/mcs/namespace.cs:820 mcs/mcs/namespace.cs:842 msgid "" "A using clause must precede all other namespace elements except extern alias " "declarations" msgstr "" -#: ../mcs/mcs/namespace.cs:926 +#: mcs/mcs/namespace.cs:866 msgid "An extern alias declaration must precede all other elements" msgstr "" -#: ../mcs/mcs/namespace.cs:944 +#: mcs/mcs/namespace.cs:884 #, csharp-format msgid "The using alias `{0}' appeared previously in this namespace" msgstr "" -#: ../mcs/mcs/namespace.cs:1017 +#: mcs/mcs/namespace.cs:1005 #, csharp-format -msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" +msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1056 +#: mcs/mcs/namespace.cs:1059 #, csharp-format -msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" +msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" msgstr "" -#: ../mcs/mcs/namespace.cs:1149 -msgid "You cannot redefine the global extern alias" +#: mcs/mcs/namespace.cs:1127 +msgid "The global extern alias cannot be redefined" msgstr "" -#: ../mcs/mcs/namespace.cs:1159 +#: mcs/mcs/namespace.cs:1132 #, csharp-format msgid "" "The type or namespace name `{0}' could not be found. Are you missing a using " "directive or an assembly reference?" msgstr "" -#: ../mcs/mcs/nullable.cs:985 +#: mcs/mcs/nullable.cs:1036 msgid "" "An expression tree cannot contain a coalescing operator with null left side" msgstr "" -#: ../mcs/mcs/parameter.cs:176 +#: mcs/mcs/parameter.cs:156 msgid "The params parameter must be a single dimensional array" msgstr "" -#: ../mcs/mcs/parameter.cs:277 -msgid "Invalid parameter type `void'" -msgstr "" - -#: ../mcs/mcs/parameter.cs:288 +#: mcs/mcs/parameter.cs:288 msgid "An out parameter cannot have the `In' attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:293 +#: mcs/mcs/parameter.cs:293 msgid "" "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead" msgstr "" -#: ../mcs/mcs/parameter.cs:300 +#: mcs/mcs/parameter.cs:300 msgid "" "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and " "`Out' attributes or neither" msgstr "" -#: ../mcs/mcs/parameter.cs:318 +#: mcs/mcs/parameter.cs:310 +#, csharp-format +msgid "Cannot specify `{0}' attribute on optional parameter `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:320 #, csharp-format -msgid "Argument of type `{0}' is not applicable for the DefaultValue attribute" +msgid "" +"Argument of type `{0}' is not applicable for the DefaultParameterValue " +"attribute" msgstr "" -#: ../mcs/mcs/parameter.cs:321 +#: mcs/mcs/parameter.cs:323 #, csharp-format msgid "" -"The DefaultValue attribute is not applicable on parameters of type `{0}'" +"The DefaultParameterValue attribute is not applicable on parameters of type `" +"{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:333 +#: mcs/mcs/parameter.cs:334 msgid "The type of the default value should match the type of the parameter" msgstr "" -#: ../mcs/mcs/parameter.cs:373 +#: mcs/mcs/parameter.cs:376 #, csharp-format msgid "Method or delegate parameter cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:386 +#: mcs/mcs/parameter.cs:386 #, csharp-format msgid "`{0}': static types cannot be used as parameters" msgstr "" -#: ../mcs/mcs/parameter.cs:392 +#: mcs/mcs/parameter.cs:392 #, csharp-format -msgid "The type of extension method cannot be `{0}'" +msgid "The extension method cannot be of type `{0}'" msgstr "" -#: ../mcs/mcs/parameter.cs:497 -msgid "An expression tree parameter cannot use `ref' or `out' modifier" +#: mcs/mcs/parameter.cs:448 +#, csharp-format +msgid "" +"The expression being assigned to optional parameter `{0}' must be a constant " +"or default value" msgstr "" -#: ../mcs/mcs/parameter.cs:884 +#: mcs/mcs/parameter.cs:464 #, csharp-format -msgid "The parameter name `{0}' is a duplicate" +msgid "" +"The expression being assigned to nullable optional parameter `{0}' must be " +"default value" +msgstr "" + +#: mcs/mcs/parameter.cs:472 +#, csharp-format +msgid "" +"Optional parameter `{0}' of type `{1}' can only be initialized with `null'" +msgstr "" + +#: mcs/mcs/parameter.cs:482 +#, csharp-format +msgid "" +"Optional parameter expression of type `{0}' cannot be converted to parameter " +"type `{1}'" +msgstr "" + +#: mcs/mcs/parameter.cs:624 +msgid "An expression tree parameter cannot use `ref' or `out' modifier" msgstr "" -#: ../mcs/mcs/parameter.cs:936 +#: mcs/mcs/parameter.cs:1096 #, csharp-format msgid "The parameter name `{0}' conflicts with a compiler generated name" msgstr "" -#: ../mcs/mcs/pending.cs:598 +#: mcs/mcs/pending.cs:443 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' is static" msgstr "" -#: ../mcs/mcs/pending.cs:602 +#: mcs/mcs/pending.cs:447 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " "candidate `{2}' in not public" msgstr "" -#: ../mcs/mcs/pending.cs:606 +#: mcs/mcs/pending.cs:451 #, csharp-format msgid "" "`{0}' does not implement interface member `{1}' and the best implementing " @@ -2900,88 +3325,165 @@ msgid "" "type `{4}'" msgstr "" -#: ../mcs/mcs/pending.cs:611 +#: mcs/mcs/pending.cs:456 #, csharp-format msgid "`{0}' does not implement interface member `{1}'" msgstr "" -#: ../mcs/mcs/pending.cs:615 +#: mcs/mcs/pending.cs:461 #, csharp-format msgid "`{0}' does not implement inherited abstract member `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:574 +#: mcs/mcs/property.cs:352 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers may not be used on accessors in an interface" +msgstr "" + +#: mcs/mcs/property.cs:356 +#, csharp-format +msgid "`{0}': abstract properties cannot have private accessors" +msgstr "" + +#: mcs/mcs/property.cs:401 #, csharp-format msgid "" -"Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " -"`gmcs' compiler instead" +"The accessibility modifier of the `{0}' accessor must be more restrictive " +"than the modifier of the property or indexer `{1}'" +msgstr "" + +#: mcs/mcs/property.cs:502 +#, csharp-format +msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" msgstr "" -#: ../mcs/mcs/report.cs:582 +#: mcs/mcs/property.cs:521 #, csharp-format msgid "" -"Feature `{0}' cannot be used because it is not part of the C# {1} language " -"specification" +"`{0}': cannot override because `{1}' does not have an overridable get " +"accessor" msgstr "" -#: ../mcs/mcs/report.cs:639 +#: mcs/mcs/property.cs:538 #, csharp-format msgid "" -"Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime " -"instead." +"`{0}': cannot override because `{1}' does not have an overridable set " +"accessor" msgstr "" -#: ../mcs/mcs/rootcontext.cs:410 -msgid "Unsafe code requires the `unsafe' command line option to be specified" +#: mcs/mcs/property.cs:579 +#, csharp-format +msgid "" +"`{0}': Cannot specify accessibility modifiers for both accessors of the " +"property or indexer" +msgstr "" + +#: mcs/mcs/property.cs:586 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers on accessors may only be used if the property " +"or indexer has both a get and a set accessor" +msgstr "" + +#: mcs/mcs/property.cs:783 +#, csharp-format +msgid "" +"Automatically implemented property `{0}' cannot be used inside a type with " +"an explicit StructLayout attribute" +msgstr "" + +#: mcs/mcs/property.cs:1274 +#, csharp-format +msgid "`{0}': event must be of a delegate type" +msgstr "" + +#: mcs/mcs/property.cs:1482 +#, csharp-format +msgid "" +"The `{0}' attribute is valid only on an indexer that is not an explicit " +"interface member declaration" +msgstr "" + +#: mcs/mcs/property.cs:1516 +msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +msgstr "" + +#: mcs/mcs/reflection.cs:217 +msgid "Could not access the key inside the container `" +msgstr "" + +#: mcs/mcs/roottypes.cs:363 +msgid "" +"The compilation may fail due to missing `System.Reflection.Emit." +"AssemblyBuilder.SetCorlibTypeBuilders(...)' method" +msgstr "" + +#: mcs/mcs/roottypes.cs:470 +#, csharp-format +msgid "Value specified for the argument to `{0}' is not valid" msgstr "" -#: ../mcs/mcs/statement.cs:105 +#: mcs/mcs/statement.cs:87 msgid "" "A lambda expression with statement body cannot be converted to an expresion " "tree" msgstr "" -#: ../mcs/mcs/statement.cs:818 +#: mcs/mcs/statement.cs:740 +#, csharp-format msgid "" -"Cannot return a value from iterators. Use the yield return statement to " -"return a value, or yield break to end the iteration" +"An object of a type convertible to `{0}' is required for the return statement" msgstr "" -#: ../mcs/mcs/statement.cs:825 +#: mcs/mcs/statement.cs:753 #, csharp-format msgid "" "`{0}': A return keyword must not be followed by any expression when method " "returns void" msgstr "" -#: ../mcs/mcs/statement.cs:849 +#: mcs/mcs/statement.cs:778 #, csharp-format msgid "" "Cannot convert `{0}' to delegate type `{1}' because some of the return types " "in the block are not implicitly convertible to the delegate return type" msgstr "" -#: ../mcs/mcs/statement.cs:1041 ../mcs/mcs/statement.cs:1073 +#: mcs/mcs/statement.cs:806 +msgid "" +"Cannot return a value from iterators. Use the yield return statement to " +"return a value, or yield break to end the iteration" +msgstr "" + +#: mcs/mcs/statement.cs:963 mcs/mcs/statement.cs:997 msgid "A goto case is only valid inside a switch statement" msgstr "" -#: ../mcs/mcs/statement.cs:1656 -#, csharp-format -msgid "" -"The label `{0}' shadows another label by the same name in a contained scope" +#: mcs/mcs/statement.cs:1076 mcs/mcs/statement.cs:4726 +msgid "The type caught or thrown must be derived from System.Exception" msgstr "" -#: ../mcs/mcs/statement.cs:1681 -#, csharp-format -msgid "The label `{0}' is a duplicate" +#: mcs/mcs/statement.cs:1298 +msgid "A fixed statement cannot use an implicitly typed local variable" msgstr "" -#: ../mcs/mcs/statement.cs:1776 -#, csharp-format -msgid "`{0}' conflicts with a declaration in a child block" +#: mcs/mcs/statement.cs:1303 +msgid "An implicitly typed local variable cannot be a constant" +msgstr "" + +#: mcs/mcs/statement.cs:1308 +msgid "" +"An implicitly typed local variable declarator must include an initializer" +msgstr "" + +#: mcs/mcs/statement.cs:1313 +msgid "" +"An implicitly typed local variable declaration cannot include multiple " +"declarators" msgstr "" -#: ../mcs/mcs/statement.cs:1877 +#: mcs/mcs/statement.cs:1883 #, csharp-format msgid "" "A local variable named `{0}' cannot be declared in this scope because it " @@ -2989,102 +3491,111 @@ msgid "" "scope to denote something else" msgstr "" -#: ../mcs/mcs/statement.cs:1886 +#: mcs/mcs/statement.cs:1894 +#, csharp-format +msgid "" +"`{0}': An anonymous type cannot have multiple properties with the same name" +msgstr "" + +#: mcs/mcs/statement.cs:1897 +#, csharp-format +msgid "The parameter name `{0}' is a duplicate" +msgstr "" + +#: mcs/mcs/statement.cs:1904 #, csharp-format msgid "A local variable named `{0}' is already defined in this scope" msgstr "" -#: ../mcs/mcs/statement.cs:2041 -msgid "An implicitly typed local variable cannot be a constant" +#: mcs/mcs/statement.cs:1910 +#, csharp-format +msgid "" +"The type parameter name `{0}' is the same as local variable or parameter name" msgstr "" -#: ../mcs/mcs/statement.cs:2891 +#: mcs/mcs/statement.cs:2482 #, csharp-format msgid "" "The out parameter `{0}' must be assigned to before control leaves the " "current method" msgstr "" -#: ../mcs/mcs/statement.cs:3024 +#: mcs/mcs/statement.cs:2573 #, csharp-format -msgid "The label `case {0}:' already occurs in this switch statement" +msgid "`{0}': not all code paths return a value" msgstr "" -#: ../mcs/mcs/statement.cs:3570 -msgid "A value of an integral type or string expected for switch" +#: mcs/mcs/statement.cs:2577 +#, csharp-format +msgid "Not all code paths return a value in anonymous method of type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4029 +#: mcs/mcs/statement.cs:2748 #, csharp-format -msgid "`{0}' is not a reference type as required by the lock statement" +msgid "The label `{0}' is a duplicate" msgstr "" -#: ../mcs/mcs/statement.cs:4346 -msgid "A fixed statement cannot use an implicitly typed local variable" +#: mcs/mcs/statement.cs:2757 mcs/mcs/statement.cs:2768 +#, csharp-format +msgid "" +"The label `{0}' shadows another label by the same name in a contained scope" +msgstr "" + +#: mcs/mcs/statement.cs:3088 +#, csharp-format +msgid "The label `case {0}:' already occurs in this switch statement" +msgstr "" + +#: mcs/mcs/statement.cs:3629 +#, csharp-format +msgid "" +"A switch expression of type `{0}' cannot be converted to an integral type, " +"bool, char, string, enum or nullable type" +msgstr "" + +#: mcs/mcs/statement.cs:4114 +#, csharp-format +msgid "`{0}' is not a reference type as required by the lock statement" msgstr "" -#: ../mcs/mcs/statement.cs:4356 +#: mcs/mcs/statement.cs:4455 msgid "The type of locals declared in a fixed statement must be a pointer type" msgstr "" -#: ../mcs/mcs/statement.cs:4380 +#: mcs/mcs/statement.cs:4471 msgid "" "The right hand side of a fixed statement assignment may not be a cast " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4457 +#: mcs/mcs/statement.cs:4542 msgid "" "You cannot use the fixed statement to take the address of an already fixed " "expression" msgstr "" -#: ../mcs/mcs/statement.cs:4707 -msgid "Try statement already has an empty catch block" -msgstr "" - -#: ../mcs/mcs/statement.cs:4745 +#: mcs/mcs/statement.cs:4856 #, csharp-format msgid "" "A previous catch clause already catches all exceptions of this or a super " "type `{0}'" msgstr "" -#: ../mcs/mcs/statement.cs:4920 ../mcs/mcs/statement.cs:5035 -msgid "Internal error: No Dispose method which takes 0 parameters." -msgstr "" - -#: ../mcs/mcs/statement.cs:4992 +#: mcs/mcs/statement.cs:5029 #, csharp-format msgid "" "`{0}': type used in a using statement must be implicitly convertible to " "`System.IDisposable'" msgstr "" -#: ../mcs/mcs/statement.cs:5115 -msgid "Use of null is not valid in this context" -msgstr "" - -#: ../mcs/mcs/statement.cs:5120 -#, csharp-format -msgid "Foreach statement cannot operate on a `{0}'" -msgstr "" - -#: ../mcs/mcs/statement.cs:5433 +#: mcs/mcs/statement.cs:5451 #, csharp-format msgid "" "foreach statement requires that the return type `{0}' of `{1}' must have a " "suitable public MoveNext method and public Current property" msgstr "" -#: ../mcs/mcs/statement.cs:5518 -#, csharp-format -msgid "" -"foreach statement cannot operate on variables of type `{0}' because it does " -"not contain a definition for `GetEnumerator' or is not accessible" -msgstr "" - -#: ../mcs/mcs/statement.cs:5570 +#: mcs/mcs/statement.cs:5490 #, csharp-format msgid "" "foreach statement cannot operate on variables of type `{0}' because it " @@ -3092,45 +3603,40 @@ msgid "" "implementation" msgstr "" -#: ../mcs/mcs/typemanager.cs:878 +#: mcs/mcs/statement.cs:5509 #, csharp-format -msgid "The predefined type `{0}.{1}' is not defined or imported" +msgid "" +"foreach statement cannot operate on variables of type `{0}' because it does " +"not contain a definition for `{1}' or is inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:902 -#, csharp-format -msgid "The predefined type `{0}.{1}' is not declared correctly" +#: mcs/mcs/statement.cs:5715 +msgid "Use of null is not valid in this context" msgstr "" -#: ../mcs/mcs/typemanager.cs:952 +#: mcs/mcs/statement.cs:5725 #, csharp-format -msgid "" -"The compiler required member `{0}.{1}{2}' could not be found or is " -"inaccessible" +msgid "Foreach statement cannot operate on a `{0}'" msgstr "" -#: ../mcs/mcs/typemanager.cs:1161 +#: mcs/mcs/typemanager.cs:389 #, csharp-format -msgid "" -"The compilation may fail due to missing `{0}.SetCorlibTypeBuilders({1})' " -"method" +msgid "The predefined type `{0}.{1}' is not defined or imported" msgstr "" -#: ../mcs/mcs/typemanager.cs:1706 +#: mcs/mcs/typemanager.cs:395 #, csharp-format -msgid "" -"Friend access was granted to `{0}', but the output assembly is named `{1}'. " -"Try adding a reference to `{0}' or change the output assembly name to match " -"it" +msgid "The predefined type `{0}.{1}' is not declared correctly" msgstr "" -#: ../mcs/mcs/typemanager.cs:1961 +#: mcs/mcs/typemanager.cs:574 #, csharp-format msgid "" -"Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" +"The compiler required member `{0}.{1}{2}' could not be found or is " +"inaccessible" msgstr "" -#: ../mcs/mcs/typemanager.cs:2308 +#: mcs/mcs/typemanager.cs:885 #, csharp-format msgid "" "Cannot take the address of, get the size of, or declare a pointer to a " diff --git a/po/mcs/pt_BR.po b/po/mcs/pt_BR.po new file mode 100644 index 000000000000..fdf170f521c9 --- /dev/null +++ b/po/mcs/pt_BR.po @@ -0,0 +1,4614 @@ +# Mono C# compiler translation file for Brazilian Portuguese. +# Copyright (C) 2008 Novell, Inc. +# This file is distributed under the same license as the Mono package. +# Rodrigo Luiz Marques Flores , 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: mono 2.1\n" +"Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" +"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"PO-Revision-Date: 2009-03-01 07:52-0300\n" +"Last-Translator: Rodrigo Luiz Marques Flores \n" +"Language-Team: pt-BR \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: mcs/mcs/anonymous.cs:880 +#, csharp-format +msgid "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'" +msgstr "" +"Não foi possível converter \"{0}\" para uma árvore de expressão de um tipo " +"não-delegate \"{1}\"" + +#: mcs/mcs/anonymous.cs:885 +#, csharp-format +msgid "Cannot convert `{0}' to non-delegate type `{1}'" +msgstr "Não foi possível converter \"{0}\" para um tipo não-delegate \"{1}\"" + +#: mcs/mcs/anonymous.cs:897 +#, csharp-format +msgid "" +"Cannot convert `{0}' to delegate type `{1}' since there is a parameter " +"mismatch" +msgstr "" +"Não foi possível converter \"{0}\" para um tipo delegate \"{1}\"pois os " +"parâmetros não conferem" + +#: mcs/mcs/anonymous.cs:909 mcs/mcs/ecore.cs:4469 +#, csharp-format +msgid "Delegate `{0}' does not take `{1}' arguments" +msgstr "Delegate \"{0}\" não recebe \"{1}\" argumentos" + +#: mcs/mcs/anonymous.cs:924 +#, csharp-format +msgid "Parameter `{0}' should not be declared with the `{1}' keyword" +msgstr "O parâmetro \"{0}\" não deve ser declarado com a palavra chave \"{1}\"" + +#: mcs/mcs/anonymous.cs:927 +#, csharp-format +msgid "Parameter `{0}' must be declared with the `{1}' keyword" +msgstr "O parâmetro \"{0}\" deve ser declarado com a palavra chave \"{1}\"" + +#: mcs/mcs/anonymous.cs:948 +#, csharp-format +msgid "Parameter `{0}' is declared as type `{1}' but should be `{2}'" +msgstr "" +"O parâmetro \"{0}\" é declarado como tipo \"{1}\" mas deveria ser \"{2}\"" + +#: mcs/mcs/anonymous.cs:1103 +msgid "An anonymous method cannot be converted to an expression tree" +msgstr "Um método anônimo não pode ser convertido para uma árvore de expressão" + +#: mcs/mcs/anonymous.cs:1122 +#, fuzzy, csharp-format +msgid "" +"Cannot convert anonymous method block without a parameter list to delegate " +"type `{0}' because it has one or more `out' parameters" +msgstr "" +"Não foi possível converter um bloco anônimo de um método sem uma lista de " +"parâmetros para representar o tipo \"{0}\" por que este possui um ou mais " +"parâmetros \"externos\"." + +#: mcs/mcs/anonymous.cs:1146 +msgid "" +"Anonymous methods and lambda expressions cannot be used in the current " +"context" +msgstr "" +"Métodos anônimos ou expressões lambdas não podem ser utilizados no contexto " +"atual" + +#: mcs/mcs/anonymous.cs:1188 +#, csharp-format +msgid "" +"Local variable or parameter `{0}' cannot have their address taken and be " +"used inside an anonymous method or lambda expression" +msgstr "" +"A variável local ou parâmetro \"{0}\" não pode ter seu endereço obtido e ser " +"utilizado dentro de um método anônimo ou expressão lambda" + +#: mcs/mcs/anonymous.cs:1438 +msgid "An expression tree cannot contain an anonymous method expression" +msgstr "" +"Uma árvore de expressão não pode conter uma expressão que seja um método " +"anônimo" + +#: mcs/mcs/argument.cs:101 +#, fuzzy +msgid "" +"An expression tree cannot contain an invocation which uses optional parameter" +msgstr "" +"Uma árvore de expressão não pode conter um método com argumentos variáveis" + +#: mcs/mcs/argument.cs:184 +#, fuzzy +msgid "An expression tree cannot contain named argument" +msgstr "" +"Uma árvore de expressão não pode conter um método com argumentos variáveis" + +#: mcs/mcs/argument.cs:303 +#, fuzzy, csharp-format +msgid "" +"The method group `{0}' cannot be used as an argument of dynamic operation. " +"Consider using parentheses to invoke the method" +msgstr "" +"Não foi possível converter o grupo de método \"{0}\" para o tipo não-" +"delegate \"{1}\". Consider a utilização de parênteses quando chamar o método" + +#: mcs/mcs/argument.cs:307 +#, fuzzy +msgid "" +"An anonymous method or lambda expression cannot be used as an argument of " +"dynamic operation. Consider using a cast" +msgstr "" +"Métodos anônimos ou expressões lambdas não podem ser utilizados no contexto " +"atual" + +#: mcs/mcs/argument.cs:310 +#, fuzzy, csharp-format +msgid "" +"An expression of type `{0}' cannot be used as an argument of dynamic " +"operation" +msgstr "Uma árvore de expressão não pode conter um operador de atribuição" + +#: mcs/mcs/assign.cs:299 +msgid "An expression tree cannot contain an assignment operator" +msgstr "Uma árvore de expressão não pode conter um operador de atribuição" + +#: mcs/mcs/assign.cs:627 +#, csharp-format +msgid "Cannot assign to `{0}' because it is a `{1}'" +msgstr "Não foi possível atribuir a \"{0}\" por que este é um \"{1}\"" + +#: mcs/mcs/attribute.cs:196 +#, csharp-format +msgid "" +"`{0}' is not a valid named attribute argument. Named attribute arguments " +"must be fields which are not readonly, static, const or read-write " +"properties which are public and not static" +msgstr "" +"\"{0}\" não é um argumento de atributo nomeado válido. Argumentos de " +"atributo nomeado devem ser campos que não são somente leitura, estáticos, " +"constantes ou possuir propriedades de leitura-escrita que são públicas e não " +"estáticas" + +#: mcs/mcs/attribute.cs:205 +#, csharp-format +msgid "" +"`{0}' is not a valid named attribute argument because it is not a valid " +"attribute parameter type" +msgstr "" +"\"{0}\" não é um atributo nomeado válida para um argumento de atributo por " +"quê não é um tipo de parâmetro de atributo válido" + +#: mcs/mcs/attribute.cs:211 +#, fuzzy +msgid "An attribute argument cannot be dynamic expression" +msgstr "\"{0}\": um argumento de atributo não pode usar parâmetros de tipo" + +#: mcs/mcs/attribute.cs:216 +msgid "The Guid attribute must be specified with the ComImport attribute" +msgstr "O atributo Guid deve ser especificado com o atributo ComImport" + +#: mcs/mcs/attribute.cs:221 +#, csharp-format +msgid "Do not use `{0}' directly. Use parameter modifier `this' instead" +msgstr "" +"Não use \"{0}\" diretamente. Ao invés disso, use o modificador de parâmetro " +"\"this\"" + +#: mcs/mcs/attribute.cs:226 +#, fuzzy, csharp-format +msgid "Do not use `{0}' directly. Use `dynamic' keyword instead" +msgstr "" +"Não use \"{0}\" diretamente. Ao invés disso, use o modificador de parâmetro " +"\"this\"" + +#: mcs/mcs/attribute.cs:235 +#, csharp-format +msgid "Error during emitting `{0}' attribute. The reason is `{1}'" +msgstr "Erro enquanto emitia o atributo \"{0}\". O motivo é \"{1}\"" + +#: mcs/mcs/attribute.cs:266 +#, csharp-format +msgid "`{0}': is not an attribute class" +msgstr "\"{0}\" não é uma classe de atributos" + +#: mcs/mcs/attribute.cs:302 +#, fuzzy, csharp-format +msgid "" +"`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}" +"Attribute'" +msgstr "" +"\"{0}\" está ambíguo entre \"{0}\" e \"{0}Atributo\". Utilize \"@{0}\" ou " +"\"{0}Atributo\"" + +#: mcs/mcs/attribute.cs:385 +#, csharp-format +msgid "Cannot apply attribute class `{0}' because it is abstract" +msgstr "" +"Não foi possível aplicar a classe de atributo \"{0}\" por que esta é abstrata" + +#: mcs/mcs/attribute.cs:453 +#, fuzzy, csharp-format +msgid "Duplicate named attribute `{0}' argument" +msgstr "argumento de atributo nomeado \"{0}\" duplicado" + +#: mcs/mcs/attribute.cs:730 +#, csharp-format +msgid "" +"`{0}' is not a valid attribute location for this declaration. Valid " +"attribute locations for this declaration are `{1}'" +msgstr "" +"\"{0}\" não é uma localização de atributo válido para esta declaração. " +"Localizações de atributos válidos para esta declaração são \"{1}\"" + +#: mcs/mcs/attribute.cs:1004 +#, csharp-format +msgid "" +"The attribute `{0}' is not valid on this declaration type. It is valid on `" +"{1}' declarations only" +msgstr "" +"O atributo \"{0}\" não é válido neste tipo de declaração. Isso é válido " +"somente nas declarações \"{1}\"" + +#: mcs/mcs/attribute.cs:1022 +#, csharp-format +msgid "The argument to the `{0}' attribute must be a valid identifier" +msgstr "O argumento para o atributo \"{0}\" deve ser um identificador válido" + +#: mcs/mcs/attribute.cs:1035 +#, fuzzy, csharp-format +msgid "Invalid value for argument to `{0}' attribute" +msgstr "" +"Valor inválido para o argumento para o atributo \"System.AttributeUsage\"" + +#: mcs/mcs/attribute.cs:1341 +#, csharp-format +msgid "The attribute `{0}' cannot be applied multiple times" +msgstr "O atributo \"{0}\" não pode ser aplicado múltiplas vezes" + +#: mcs/mcs/attribute.cs:1603 +#, csharp-format +msgid "`{0}' is obsolete: `{1}'" +msgstr "\"{0}\" é obsoleto: \"{1}\"" + +#: mcs/mcs/cs-parser.cs:1646 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 +#, fuzzy +msgid "Interfaces cannot contain fields or constants" +msgstr "Structs não podem conter construtores explícitos sem parâmetros" + +#: mcs/mcs/cs-parser.cs:1952 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "" +"\"{0}\": Classes estáticas não podem conter operadores definidos pelo usuário" + +#: mcs/mcs/cs-parser.cs:1958 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" + +#: mcs/mcs/cs-parser.cs:1964 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3602 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3884 +#, fuzzy +msgid "A namespace declaration cannot have modifiers or attributes" +msgstr "Um parâmetro externo não pode ter o atributo \"In\"" + +#: mcs/mcs/cs-parser.cs:3948 +msgid "" +"Namespace elements cannot be explicitly declared as private, protected or " +"protected internal" +msgstr "" + +#: mcs/mcs/cs-parser.cs:3963 +#, fuzzy +msgid "" +"Assembly and module attributes must precede all other elements except using " +"clauses and extern alias declarations" +msgstr "" +"Uma cláusula em uso deve preceder todos os outros elementos do namespace, " +"exceto declarações de alias externos" + +#: mcs/mcs/cs-parser.cs:4080 +msgid "'<' unexpected: attributes cannot be generic" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4117 +msgid "Named attribute arguments must appear after the positional arguments" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4163 +#, csharp-format +msgid "" +"Unexpected symbol `{0}' in class, struct, or interface member declaration" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4220 +#, fuzzy, csharp-format +msgid "The constant `{0}' cannot be marked static" +msgstr "O método abstrato \"{0}\" não pode ser marcado como virtual" + +#: mcs/mcs/cs-parser.cs:4268 +#, fuzzy +msgid "Fields cannot have void type" +msgstr "Campo ou propriedade não podem ser do tipo \"{0}\"" + +#: mcs/mcs/cs-parser.cs:4369 +#, fuzzy +msgid "Value or constant expected" +msgstr "Um valor constante é esperado" + +#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 +#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 +#: mcs/mcs/cs-parser.cs:5427 +#, fuzzy, csharp-format +msgid "`{0}': interface members cannot have a definition" +msgstr "\"{0}\": evento abstrato não pode ter um inicializador" + +#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +msgid "Constraints are not allowed on non-generic declarations" +msgstr "Restrições não são permitidas em declarações não genéricas" + +#: mcs/mcs/cs-parser.cs:4429 +#, fuzzy, csharp-format +msgid "" +"`{0}': Cannot specify constraints for overrides and explicit interface " +"implementation methods" +msgstr "" +"\"{0}\": Não foi possível especificar restrições para sobrescritos ou " +"métodos de implementação explícitos de interface" + +#: mcs/mcs/cs-parser.cs:4470 +msgid "" +"A partial method cannot define access modifier or any of abstract, extern, " +"new, override, sealed, or virtual modifiers" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4476 +msgid "" +"A partial method must be declared within a partial class or partial struct" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4499 +#, csharp-format +msgid "Member modifier `{0}' must precede the member type and name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#, fuzzy +msgid "" +"A params parameter must be the last parameter in a formal parameter list" +msgstr "O parâmetro params deve ser um array de uma dimensão" + +#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +msgid "" +"An __arglist parameter must be the last parameter in a formal parameter list" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4601 +msgid "The parameter modifier `this' can only be used on the first parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4603 +#, fuzzy +msgid "Optional parameter cannot precede required parameters" +msgstr "Iteradores não podem ter parâmetros ref ou out" + +#: mcs/mcs/cs-parser.cs:4625 +msgid "Array type specifier, [], must appear before parameter name" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#, fuzzy, csharp-format +msgid "Cannot specify a default value for the `{0}' parameter" +msgstr "" +"Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " +"um indexador" + +#: mcs/mcs/cs-parser.cs:4666 +#, fuzzy +msgid "Optional parameter is not valid in this context" +msgstr "Uso do null é inválido neste contexto" + +#: mcs/mcs/cs-parser.cs:4686 +msgid "The parameter modifiers `this' and `ref' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4689 +msgid "The parameter modifiers `this' and `out' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4692 +#, fuzzy +msgid "A parameter cannot have specified more than one modifier" +msgstr "" +"Um parâmetro de árvore de expressão não pode usar modificadores \"ref\" ou " +"\"out\"" + +#: mcs/mcs/cs-parser.cs:4739 +#, fuzzy +msgid "Cannot specify a default value for a parameter array" +msgstr "" +"Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " +"um indexador" + +#: mcs/mcs/cs-parser.cs:4756 +#, fuzzy +msgid "The `params' modifier is not allowed in current context" +msgstr "O nome \"{0}\" não existe no contexto atual" + +#: mcs/mcs/cs-parser.cs:4764 +msgid "The parameter modifiers `this' and `params' cannot be used altogether" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4766 +#, fuzzy +msgid "The params parameter cannot be declared as ref or out" +msgstr "O tipo \"{0}\" não pode ser declarado const" + +#: mcs/mcs/cs-parser.cs:4774 +#, fuzzy +msgid "__arglist is not valid in this context" +msgstr "Uso do null é inválido neste contexto" + +#: mcs/mcs/cs-parser.cs:4791 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer cannot have void type" +msgstr "" +"A propriedade ou o indexador somente leitura \"{0}\" não pôde ser atribuído" + +#: mcs/mcs/cs-parser.cs:4829 +#, csharp-format +msgid "`{0}': indexer return type cannot be `void'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4832 +msgid "Indexers must have at least one parameter" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4857 +#, fuzzy, csharp-format +msgid "`{0}': property or indexer must have at least one accessor" +msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" + +#: mcs/mcs/cs-parser.cs:4860 +msgid "Semicolon after method or accessor block is not valid" +msgstr "" + +#: mcs/mcs/cs-parser.cs:4862 +#, fuzzy +msgid "A get or set accessor expected" +msgstr "Um valor constante é esperado" + +#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +msgid "Property accessor already defined" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5036 +#, fuzzy +msgid "User-defined operators cannot return void" +msgstr "" +"Operador definido pelo usuário \"{0}\" deve ser declarado estático e público" + +#: mcs/mcs/cs-parser.cs:5059 +msgid "Overloadable binary operator expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5061 +#, fuzzy, csharp-format +msgid "Overloaded unary operator `{0}' takes one parameter" +msgstr "Sem sobrecarga para o método \"{0}\" aceitar os argumentos \"{1}\"" + +#: mcs/mcs/cs-parser.cs:5066 +#, fuzzy, csharp-format +msgid "Overloaded binary operator `{0}' takes two parameters" +msgstr "Sem sobrecarga para o método \"{0}\" aceitar os argumentos \"{1}\"" + +#: mcs/mcs/cs-parser.cs:5069 +msgid "Overloadable unary operator expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5183 +msgid "Class, struct, or interface method must have a return type" +msgstr "Classes, structs ou métodos de interface devem ter um tipo de retorno" + +#: mcs/mcs/cs-parser.cs:5187 +#, fuzzy, csharp-format +msgid "`{0}': static constructor cannot have an access modifier" +msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" + +#: mcs/mcs/cs-parser.cs:5192 +#, fuzzy, csharp-format +msgid "" +"`{0}': static constructor cannot have an explicit `this' or `base' " +"constructor call" +msgstr "\"{0}\": Construtores de structs não podem chamar construtores da base" + +#: mcs/mcs/cs-parser.cs:5241 +msgid "Name of destructor must match name of class" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5243 +#, fuzzy +msgid "Only class types can contain destructor" +msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" + +#: mcs/mcs/cs-parser.cs:5265 +#, fuzzy, csharp-format +msgid "" +"`{0}': An explicit interface implementation of an event must use property " +"syntax" +msgstr "" +"\"{0}\": a implementação explicita da interface não pode fornecer o " +"modificador de parâmetros" + +#: mcs/mcs/cs-parser.cs:5298 +msgid "Event in interface cannot have add or remove accessors" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5344 +#, fuzzy, csharp-format +msgid "`{0}': event in interface cannot have an initializer" +msgstr "\"{0}\": evento abstrato não pode ter um inicializador" + +#: mcs/mcs/cs-parser.cs:5349 +#, csharp-format +msgid "`{0}': abstract event cannot have an initializer" +msgstr "\"{0}\": evento abstrato não pode ter um inicializador" + +#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#, fuzzy, csharp-format +msgid "`{0}': event property must have both add and remove accessors" +msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" + +#: mcs/mcs/cs-parser.cs:5371 +msgid "An add or remove accessor expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +msgid "Modifiers cannot be placed on event accessor declarations" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5436 +msgid "An add or remove accessor must have a body" +msgstr "" + +#: mcs/mcs/cs-parser.cs:5455 +#, fuzzy +msgid "Enums cannot have type parameters" +msgstr "Iteradores não podem ter parâmetros ref ou out" + +#: mcs/mcs/cs-parser.cs:5755 +msgid "Type parameter declaration must be an identifier not a type" +msgstr "" +"A declaração de um tipo parâmetro deve ser um identificador e não um tipo" + +#: mcs/mcs/cs-parser.cs:5779 +msgid "Invalid parameter type `void'" +msgstr "Tipo de parâmetro inválido \"void\"" + +#: mcs/mcs/cs-parser.cs:5825 +#, fuzzy, csharp-format +msgid "Invalid base type `{0}'" +msgstr "Tipo de parâmetro inválido \"void\"" + +#: mcs/mcs/cs-parser.cs:5984 +msgid "An element initializer cannot be empty" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6015 +#, fuzzy, csharp-format +msgid "Named argument `{0}' specified multiple times" +msgstr "Arquivo de código fonte \"{0}\" especificado múltiplas vezes" + +#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#, fuzzy +msgid "An argument is missing" +msgstr "Argumento \"#{0}\" não encontrou o modificador \"{1}\"" + +#: mcs/mcs/cs-parser.cs:6166 +msgid "Array creation must have array size or array initializer" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6183 +msgid "Invalid rank specifier, expecting `,' or `]'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6256 +msgid "" +"Invalid anonymous type member declarator. Anonymous type members must be a " +"member assignment, simple name or member access expression" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6658 +msgid "All lambda parameters must be typed either explicitly or implicitly" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6799 +#, csharp-format +msgid "Duplicate `{0}' modifier" +msgstr "" + +#: mcs/mcs/cs-parser.cs:6803 +msgid "More than one protection modifier specified" +msgstr "Mais de um modificador de proteção especificado" + +#: mcs/mcs/cs-parser.cs:6816 +#, fuzzy +msgid "Keyword `new' is not allowed on namespace elements" +msgstr "Palavra chave \"new\" não é permitida em elementos do namespace" + +#: mcs/mcs/cs-parser.cs:6936 +#, fuzzy, csharp-format +msgid "A constraint clause has already been specified for type parameter `{0}'" +msgstr "" +"Um tipo aninhado não pode ser especificado através de um tipo parâmetro " +"\"{0}\"" + +#: mcs/mcs/cs-parser.cs:6966 +#, fuzzy +msgid "The `new()' constraint must be the last constraint specified" +msgstr "A restrição new() deve ser a última restrição especificada" + +#: mcs/mcs/cs-parser.cs:6972 +msgid "" +"The `class' or `struct' constraint must be the first constraint specified" +msgstr "" +"As restrições \"class\" ou \"struct\" devem ser as primeiras restrições " +"especificadas" + +#: mcs/mcs/cs-parser.cs:6976 +msgid "The `new()' constraint cannot be used with the `struct' constraint" +msgstr "" +"A restrição \"new()\" não pode ser utilizada com a restrição \"struct\"" + +#: mcs/mcs/cs-parser.cs:6989 +#, fuzzy, csharp-format +msgid "Invalid constraint type `{0}'" +msgstr "Símbolo de definição condicional \"{0}\" inválido" + +#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +msgid "An embedded statement may not be a declaration or labeled statement" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7213 +msgid "" +"Syntax error, bad array declarator. To declare a managed array the rank " +"specifier precedes the variable's identifier. To declare a fixed size buffer " +"field, use the fixed keyword before the field type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7262 +msgid "A stackalloc expression requires [] after type" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7468 +msgid "Type and identifier are both required in a foreach statement" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#, fuzzy +msgid "; expected" +msgstr "Nome do método esperado" + +#: mcs/mcs/cs-parser.cs:7555 +msgid "Expression expected after yield return" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7598 +msgid "Expected catch or finally" +msgstr "" + +#: mcs/mcs/cs-parser.cs:7618 +msgid "Try statement already has an empty catch block" +msgstr "A declaração do try já tem um bloco catch vazio" + +#: mcs/mcs/cs-parser.cs:7651 +msgid "" +"A type that derives from `System.Exception', `object', or `string' expected" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11367 +msgid "Expecting `;'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11375 +#, fuzzy, csharp-format +msgid "The parameter modifier `{0}' is not valid in this context" +msgstr "Código de página \"{0}\" é inválido ou não está instalado" + +#: mcs/mcs/cs-parser.cs:11381 +#, fuzzy, csharp-format +msgid "Duplicate parameter modifier `{0}'" +msgstr "Tipo de parâmetro duplicado \"{0}\"" + +#: mcs/mcs/cs-parser.cs:11387 +#, fuzzy +msgid "Type expected" +msgstr "Nome do método esperado" + +#: mcs/mcs/cs-parser.cs:11392 +msgid "Unsafe code requires the `unsafe' command line option to be specified" +msgstr "" +"Código inseguro requer a opção de linha de comando \"unsafe\" para ser " +"especificada" + +#: mcs/mcs/cs-parser.cs:11402 +msgid "Named arguments must appear after the positional arguments" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11493 +msgid "Syntax error, " +msgstr "" + +#: mcs/mcs/cs-parser.cs:11547 +#, fuzzy +msgid "Parsing error" +msgstr "Erro na Análise de Detecção" + +#: mcs/mcs/cs-parser.cs:11553 +msgid "Internal compiler error during parsing" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11564 +#, csharp-format +msgid "{0}: `{1}' is a keyword" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11690 +#, fuzzy, csharp-format +msgid "Identifier expected, `{0}' is a keyword" +msgstr "Identificador esperado: {0}" + +#: mcs/mcs/cs-parser.cs:11704 +#, csharp-format +msgid "{1} `{0}'" +msgstr "" + +#: mcs/mcs/cs-parser.cs:11706 +#, csharp-format +msgid "{2} `{0}', expecting {1}" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:760 +msgid "" +"The `partial' modifier can be used only immediately before `class', " +"`struct', `interface', or `void' keyword" +msgstr "" +"O modificador \"parcial\" pode ser utilizado somente imediatamente antesdas " +"palavras chave \"class\", \"struct\", \"interface\" ou \"void\"" + +#: mcs/mcs/cs-tokenizer.cs:1395 mcs/mcs/cs-tokenizer.cs:1462 +msgid "Invalid number" +msgstr "Número inválido" + +#: mcs/mcs/cs-tokenizer.cs:1647 +#, csharp-format +msgid "Unrecognized escape sequence `\\{0}'" +msgstr "Sequência de escape não reconhecida \"\\{0}\"" + +#: mcs/mcs/cs-tokenizer.cs:1666 +msgid "Unrecognized escape sequence" +msgstr "Sequência de escape não reconhecida" + +#: mcs/mcs/cs-tokenizer.cs:1887 +msgid "Missing identifier to pre-processor directive" +msgstr "Identificador faltando para a diretiva do pré-processador" + +#: mcs/mcs/cs-tokenizer.cs:1897 mcs/mcs/cs-tokenizer.cs:1901 +#, csharp-format +msgid "Identifier expected: {0}" +msgstr "Identificador esperado: {0}" + +#: mcs/mcs/cs-tokenizer.cs:2373 +#, fuzzy +msgid "Integral constant is too large" +msgstr "Constante numérica muito longa" + +#: mcs/mcs/cs-tokenizer.cs:2378 +msgid "Invalid preprocessor directive" +msgstr "Diretiva de pré-processador inválida" + +#: mcs/mcs/cs-tokenizer.cs:2385 +#, csharp-format +msgid "Unexpected processor directive ({0})" +msgstr "Diretiva de processador inesperada ({0})" + +#: mcs/mcs/cs-tokenizer.cs:2391 +msgid "" +"Cannot define or undefine preprocessor symbols after first token in file" +msgstr "" +"Não foi possível definir ou indefinir símbolos depois do primeiro token no " +"arquivo" + +#: mcs/mcs/cs-tokenizer.cs:2397 +msgid "" +"Preprocessor directives must appear as the first non-whitespace character on " +"a line" +msgstr "" +"Diretivas de pré-processador devem aparecer como o primeiro caractere não-" +"branco na linha" + +#: mcs/mcs/cs-tokenizer.cs:2402 +msgid "Single-line comment or end-of-line expected" +msgstr "Comentário de linha única ou fim-de-linha esperado" + +#: mcs/mcs/cs-tokenizer.cs:2435 mcs/mcs/cs-tokenizer.cs:3431 +msgid "Expected `#endif' directive" +msgstr "Esperada diretiva \"#endif\"" + +#: mcs/mcs/cs-tokenizer.cs:2468 mcs/mcs/cs-tokenizer.cs:2489 +#: mcs/mcs/cs-tokenizer.cs:2520 mcs/mcs/cs-tokenizer.cs:3429 +msgid "#endregion directive expected" +msgstr "diretiva #endregion esperada" + +#: mcs/mcs/cs-tokenizer.cs:2567 +msgid "Wrong preprocessor directive" +msgstr "Diretiva do pré-processador incorreta" + +#: mcs/mcs/cs-tokenizer.cs:2579 +#, csharp-format +msgid "#error: '{0}'" +msgstr "#erro: \"{0}\"" + +#: mcs/mcs/cs-tokenizer.cs:2598 +msgid "The line number specified for #line directive is missing or invalid" +msgstr "" +"O número da linha especificada para a diretiva #line está faltando ou está " +"inválida" + +#: mcs/mcs/cs-tokenizer.cs:2625 mcs/mcs/cs-tokenizer.cs:3243 +msgid "Newline in constant" +msgstr "Quebra de linha em constante" + +#: mcs/mcs/cs-tokenizer.cs:2636 +msgid "Unterminated string literal" +msgstr "Literal de string não terminada" + +#: mcs/mcs/cs-tokenizer.cs:2705 +msgid "Identifier too long (limit is 512 chars)" +msgstr "Identificador muito longo (o limite é 512 caracteres)" + +#: mcs/mcs/cs-tokenizer.cs:3092 +msgid "End-of-file found, '*/' expected" +msgstr "Fim de arquivo encontrado, \"*/\" esperado" + +#: mcs/mcs/cs-tokenizer.cs:3201 +msgid "Keyword, identifier, or string expected after verbatim specifier: @" +msgstr "" +"Palavra-chave, identificador ou string esperado depois do especificador " +"verbatim: @" + +#: mcs/mcs/cs-tokenizer.cs:3217 +#, fuzzy, csharp-format +msgid "Unexpected character `{0}'" +msgstr "Experado \"{0}\"" + +#: mcs/mcs/cs-tokenizer.cs:3238 +msgid "Empty character literal" +msgstr "" + +#: mcs/mcs/cs-tokenizer.cs:3258 +msgid "Too many characters in character literal" +msgstr "" + +#: mcs/mcs/cfold.cs:84 +msgid "The operation overflows at compile time in checked mode" +msgstr "A operação estoura em tempo de compilação no modo marcado" + +#: mcs/mcs/cfold.cs:764 mcs/mcs/cfold.cs:849 +msgid "Division by constant zero" +msgstr "Divisão pela constante zero" + +#: mcs/mcs/class.cs:371 +#, csharp-format +msgid "" +"Partial declarations of `{0}' must be all classes, all structs or all " +"interfaces" +msgstr "" +"Declarações parciais de \"{0}\" devem ser todas as classes, todas structs ou " +"todas as interfaces" + +#: mcs/mcs/class.cs:380 +#, csharp-format +msgid "Partial declarations of `{0}' have conflicting accessibility modifiers" +msgstr "" +"Declarações parciais de \"{0}\" possuim modificadores de acessibilidade " +"conflitantes" + +#: mcs/mcs/class.cs:433 +#, csharp-format +msgid "" +"`{0}': explicit interface declaration can only be declared in a class or " +"struct" +msgstr "" +"\"{0}\": declaração explícita de interface pode apenas ser declarada em uma " +"classe ou struct" + +#: mcs/mcs/class.cs:470 mcs/mcs/membercache.cs:1347 +#, csharp-format +msgid "" +"A member `{0}' is already defined. Rename this member or use different " +"parameter types" +msgstr "" +"Um membro \"{0}\" já está definido. Renomeie esse membro ou use tipos de " +"parâmetros distintos" + +#: mcs/mcs/class.cs:578 +msgid "" +"Cannot specify the `DefaultMember' attribute on type containing an indexer" +msgstr "" +"Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " +"um indexador" + +#: mcs/mcs/class.cs:584 +msgid "The RequiredAttribute attribute is not permitted on C# types" +msgstr "O atributo RequiredAttribute não é permitido em tipos de C#" + +#: mcs/mcs/class.cs:855 +#, fuzzy, csharp-format +msgid "Class `{0}' cannot derive from the dynamic type" +msgstr "\"{0}\": não foi possível declarar variáveis de tipo estático" + +#: mcs/mcs/class.cs:872 +#, csharp-format +msgid "`{0}' is already listed in interface list" +msgstr "\"{0}\" já está listado na lista de interfaces" + +#: mcs/mcs/class.cs:880 +#, csharp-format +msgid "" +"Inconsistent accessibility: base interface `{0}' is less accessible than " +"interface `{1}'" +msgstr "" +"Acessibilidade inconsistente: interface base \"{0}\" é menos acessível que a " +"interface \"{1}\"" + +#: mcs/mcs/class.cs:886 +#, csharp-format +msgid "Type `{0}' in interface list is not an interface" +msgstr "Tipo \"{0}\" na lista de interfaces não é uma interface" + +#: mcs/mcs/class.cs:888 +#, csharp-format +msgid "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')" +msgstr "" +"\"{0}\": Classes não podem ter múltiplas classes base (\"{1}\" e \"{2}\")" + +#: mcs/mcs/class.cs:891 +#, csharp-format +msgid "`{0}': Base class `{1}' must be specified as first" +msgstr "\"{0}\": Classe base \"{1}\" deve ser especificada como primeira" + +#: mcs/mcs/class.cs:915 +#, csharp-format +msgid "Partial declarations of `{0}' must not specify different base classes" +msgstr "" +"Declarações parciais de \"{0}\" não devem especificar diferentes classes base" + +#: mcs/mcs/class.cs:996 +#, csharp-format +msgid "" +"The operator `{0}' requires a matching operator `{1}' to also be defined" +msgstr "" +"O operador `{0}' necessita um operador correspondente \"{1}\" para também " +"ser definido" + +#: mcs/mcs/class.cs:1021 +#, csharp-format +msgid "`{0}' clashes with a predefined namespace" +msgstr "" + +#: mcs/mcs/class.cs:1150 +#, csharp-format +msgid "" +"Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'" +msgstr "" +"Interface herdada \"{0}\" causa um ciclo na hierarquia de interfaces de " +"\"{1}\"" + +#: mcs/mcs/class.cs:1156 +#, csharp-format +msgid "Circular base class dependency involving `{0}' and `{1}'" +msgstr "Dependência circular na classe base envolvendo \"{0}\" e \"{1}\"" + +#: mcs/mcs/class.cs:1183 +#, csharp-format +msgid "" +"`{0}' cannot implement both `{1}' and `{2}' because they may unify for some " +"type parameter substitutions" +msgstr "" +"\"{0}\" não pode implementar ambos \"{1}\" e \"{2}\" por que estes devem " +"unificar para alguma substituição de tipo de parâmetro" + +#: mcs/mcs/class.cs:1223 +#, csharp-format +msgid "" +"The type `{0}' is defined in an assembly that is not referenced. Consider " +"adding a reference to assembly `{1}'" +msgstr "" + +#: mcs/mcs/class.cs:1339 +#, csharp-format +msgid "" +"Partial declarations of `{0}' must have the same type parameter names in the " +"same order" +msgstr "" +"Declarações parciais de \"{0}\" devem ter o mesmo nome de tipos de " +"parâmetros na mesma ordem" + +#: mcs/mcs/class.cs:1346 +#, fuzzy, csharp-format +msgid "" +"Partial declarations of `{0}' must have the same type parameter variance " +"modifiers" +msgstr "" +"Declarações parciais de \"{0}\" devem ter o mesmo nome de tipos de " +"parâmetros na mesma ordem" + +#: mcs/mcs/class.cs:1371 +#, csharp-format +msgid "" +"Partial declarations of `{0}' have inconsistent constraints for type " +"parameter `{1}'" +msgstr "" +"Declarações parciais \"{0}\" possuem restrições inconsistentes para o tipo " +"de parâmetro \"{1}\"" + +#: mcs/mcs/class.cs:1510 +#, fuzzy, csharp-format +msgid "`{0}': cannot implement a dynamic interface `{1}'" +msgstr "\"{0}\": tipo contendo não implementa interface \"{1}\"" + +#: mcs/mcs/class.cs:1623 +msgid "" +"Two indexers have different names; the IndexerName attribute must be used " +"with the same name on every indexer within a type" +msgstr "" +"Dois indexadores tem nomes diferentes; o atributo IndexerName deve ser " +"utilizado com o mesmo nome em todo indexador de um tipo" + +#: mcs/mcs/class.cs:1957 +#, csharp-format +msgid "A static member `{0}' cannot be marked as override, virtual or abstract" +msgstr "" +"Um membro estático \"{0}\" não pode ser marcado como sobrescrito, virtual ou " +"abstrato" + +#: mcs/mcs/class.cs:1964 +#, csharp-format +msgid "A member `{0}' marked as override cannot be marked as new or virtual" +msgstr "" +"Um membro \"{0}\" marcado como sobrescrito não pode ser marcado como novo ou " +"virtual" + +#: mcs/mcs/class.cs:1976 +#, csharp-format +msgid "`{0}' cannot be both extern and abstract" +msgstr "\"{0}\" não pode ser externo e abstrato ao mesmo tempo" + +#: mcs/mcs/class.cs:1981 +#, csharp-format +msgid "`{0}' cannot be both abstract and sealed" +msgstr "\"{0}\" não pode ser abstrato e selado" + +#: mcs/mcs/class.cs:1986 +#, csharp-format +msgid "The abstract method `{0}' cannot be marked virtual" +msgstr "O método abstrato \"{0}\" não pode ser marcado como virtual" + +#: mcs/mcs/class.cs:1992 +#, csharp-format +msgid "`{0}' is abstract but it is declared in the non-abstract class `{1}'" +msgstr "\"{0}\" é abstrato mas está declarado na classe não-abstrata \"{1}\"" + +#: mcs/mcs/class.cs:2000 +#, csharp-format +msgid "`{0}': virtual or abstract members cannot be private" +msgstr "\"{0}\": membros virtuais ou abstratos não podem ser privados" + +#: mcs/mcs/class.cs:2007 +#, csharp-format +msgid "`{0}' cannot be sealed because it is not an override" +msgstr "\"{0}\" não pode ser selado por que não é um sobrescrito" + +#: mcs/mcs/class.cs:2054 +#, csharp-format +msgid "`{0}': containing type does not implement interface `{1}'" +msgstr "\"{0}\": tipo contendo não implementa interface \"{1}\"" + +#: mcs/mcs/class.cs:2230 +#, csharp-format +msgid "Type parameter `{0}' has same name as containing type, or method" +msgstr "" +"Parâmetro de tipo \"{0}\" tem o mesmo nome que o tipo contendo, ou método" + +#: mcs/mcs/class.cs:2238 +#, csharp-format +msgid "`{0}': member names cannot be the same as their enclosing type" +msgstr "" +"\"{0}\": nomes de membros não podem ser os mesmos que seus tipos de " +"fechamento" + +#: mcs/mcs/class.cs:2404 +msgid "" +"The class System.Object cannot have a base class or implement an interface." +msgstr "" +"A classe System.Object não pode ter uma classe base ou implementar uma " +"interface." + +#: mcs/mcs/class.cs:2412 +#, csharp-format +msgid "Attribute `{0}' is only valid on classes derived from System.Attribute" +msgstr "" +"Atributo \"{0}\" é válido somente em classes derivadas de System.Attribute" + +#: mcs/mcs/class.cs:2417 +msgid "" +"Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods " +"or attribute classes" +msgstr "" +"Atributo \"System.Diagnostics.ConditionalAttribute\" é somente válido em " +"métodos ou classes de atributos" + +#: mcs/mcs/class.cs:2455 +#, csharp-format +msgid "`{0}': Static classes cannot contain user-defined operators" +msgstr "" +"\"{0}\": Classes estáticas não podem conter operadores definidos pelo usuário" + +#: mcs/mcs/class.cs:2460 +#, csharp-format +msgid "`{0}': Static classes cannot contain destructor" +msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" + +#: mcs/mcs/class.cs:2465 +#, csharp-format +msgid "`{0}': cannot declare indexers in a static class" +msgstr "\"{0}\": não é possível declarar indexadores como uma classe estática" + +#: mcs/mcs/class.cs:2473 +#, csharp-format +msgid "`{0}': Static classes cannot have instance constructors" +msgstr "\"{0}\": Classes estáticas não podem ter construtores de instâncias" + +#: mcs/mcs/class.cs:2479 +#, csharp-format +msgid "`{0}': Extension methods must be declared static" +msgstr "\"{0}\": Métodos de extensão devem ser declarados como estáticos" + +#: mcs/mcs/class.cs:2483 +#, csharp-format +msgid "`{0}': cannot declare instance members in a static class" +msgstr "" +"\"{0}\": não foi possível declarar membros de instâncias em uma classe " +"estática" + +#: mcs/mcs/class.cs:2492 +#, csharp-format +msgid "`{0}': an abstract class cannot be sealed or static" +msgstr "\"{0}\": uma classe abstrata não pode ser selada ou estática" + +#: mcs/mcs/class.cs:2496 +#, csharp-format +msgid "`{0}': a class cannot be both static and sealed" +msgstr "\"{0}\": uma classe não pode ser estática e selada ao mesmo tempo" + +#: mcs/mcs/class.cs:2526 +#, fuzzy, csharp-format +msgid "`{0}': Cannot derive from type parameter `{1}'" +msgstr "\"{0}\": Não foi possível derivar da classe estática \"{1}\"" + +#: mcs/mcs/class.cs:2530 +#, csharp-format +msgid "" +"A generic type cannot derive from `{0}' because it is an attribute class" +msgstr "" +"Um tipo genérico não pode derivar de \"{0}\" por que é uma classe de atributo" + +#: mcs/mcs/class.cs:2534 +#, csharp-format +msgid "`{0}': Cannot derive from static class `{1}'" +msgstr "\"{0}\": Não foi possível derivar da classe estática \"{1}\"" + +#: mcs/mcs/class.cs:2538 +#, fuzzy, csharp-format +msgid "`{0}': cannot derive from sealed type `{1}'" +msgstr "\"{0}\": não foi possível derivar da classe selada \"{1}\"" + +#: mcs/mcs/class.cs:2541 +#, csharp-format +msgid "" +"Static class `{0}' cannot derive from type `{1}'. Static classes must derive " +"from object" +msgstr "" +"Classe estática \"{0}\" não pode derivar do tipo \"{1}\". Classes estáticas " +"devem derivar de objetos" + +#: mcs/mcs/class.cs:2548 +#, csharp-format +msgid "`{0}' cannot derive from special class `{1}'" +msgstr "\"{0}\" não foi possível derivar da classe especial \"{1}\"" + +#: mcs/mcs/class.cs:2556 +#, csharp-format +msgid "" +"Inconsistent accessibility: base class `{0}' is less accessible than class `" +"{1}'" +msgstr "" +"Acessibilidade inconsistente: classe base \"{0}\" é menos acessível que a " +"classe \"{1}\"" + +#: mcs/mcs/class.cs:2564 +#, csharp-format +msgid "Static class `{0}' cannot implement interfaces" +msgstr "Classe estática \"{0}\" não pode implementar interfaces" + +#: mcs/mcs/class.cs:2683 mcs/mcs/class.cs:2694 +#, csharp-format +msgid "Struct member `{0}' of type `{1}' causes a cycle in the struct layout" +msgstr "" +"Membro da estrutura \"{0}\" do tipo \"{1}\" causou um ciclo na disposição de " +"structs" + +#: mcs/mcs/class.cs:2784 +#, csharp-format +msgid "`{0}': Structs cannot have instance field initializers" +msgstr "\"{0}\": Structs não podem ter inicializadores de campos de instância" + +#: mcs/mcs/class.cs:2965 +#, fuzzy, csharp-format +msgid "Do not override `{0}'. Use destructor syntax instead" +msgstr "" +"Não use \"{0}\" diretamente. Ao invés disso, use o modificador de parâmetro " +"\"this\"" + +#: mcs/mcs/class.cs:2968 +#, csharp-format +msgid "`{0}' is marked as an override but no suitable {1} found to override" +msgstr "" +"\"{0}\" está marcado como uma sobrescrita mas nenhuma {1} foi encontrada " +"para substituir" + +#: mcs/mcs/class.cs:2974 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not an event" +msgstr "\"{0}\": não foi possível sobrescrever pois \"{1}\" não é um evento" + +#: mcs/mcs/class.cs:2977 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not a property" +msgstr "" +"\"{0}\": não foi possível sobrescrever pois \"{1}\" não é uma propriedade" + +#: mcs/mcs/class.cs:2980 +#, csharp-format +msgid "`{0}': cannot override because `{1}' is not a method" +msgstr "\"{0}\": não foi possível sobrescrever pois \"{1}\" não é um método" + +#: mcs/mcs/class.cs:3036 mcs/mcs/field.cs:187 +#, csharp-format +msgid "`{0}' hides inherited abstract member `{1}'" +msgstr "\"{0}\" esconde membro abstrato herdado \"{1}\"" + +#: mcs/mcs/class.cs:3060 +#, csharp-format +msgid "" +"`{0}': cannot override inherited member `{1}' because it is not marked " +"virtual, abstract or override" +msgstr "" +"\"{0}\": não foi possível sobrescrever membro herdado \"{1}\" porque este " +"não está marcado como virtual, abstrato ou substituto" + +#: mcs/mcs/class.cs:3068 +#, csharp-format +msgid "`{0}': cannot override inherited member `{1}' because it is sealed" +msgstr "" +"\"{0}\": não foi possível sobrescrever membro herdado \"{1}\" por que está " +"selado" + +#: mcs/mcs/class.cs:3077 +#, csharp-format +msgid "`{0}': type must be `{1}' to match overridden member `{2}'" +msgstr "" +"\"{0}\": o tipo deve ser \"{1}\" para corresponder com o membro da " +"substituição \"{2}\"" + +#: mcs/mcs/class.cs:3080 +#, csharp-format +msgid "`{0}': return type must be `{1}' to match overridden member `{2}'" +msgstr "" +"\"{0}\": tipo de retorno deve ser \"{1}\" para corresponder com o membro da " +"substituição \"{2}\"" + +#: mcs/mcs/class.cs:3152 +#, csharp-format +msgid "A partial method `{0}' cannot explicitly implement an interface" +msgstr "" +"Um método parcial \"{0}\" não pode implementar uma interface explicitamente" + +#: mcs/mcs/class.cs:3160 +#, fuzzy, csharp-format +msgid "The type `{0}' in explicit interface declaration is not an interface" +msgstr "\"{0}\" na declaração explícita da interface não é uma interface" + +#: mcs/mcs/class.cs:3191 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"indexer `{1}'" +msgstr "" +"Acessibilidade inconsistente: tipo de parâmetro \"{0}\" é menos acessível " +"que o indexador \"{1}\"" + +#: mcs/mcs/class.cs:3195 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"operator `{1}'" +msgstr "" +"Acessibilidade inconsistente: tipo de parâmetro \"{0}\" é menos acessível " +"que o operador \"{1}\"" + +#: mcs/mcs/class.cs:3199 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"method `{1}'" +msgstr "" +"Acessibilidade inconsistente: tipo de parâmetro \"{0}\" é menos acessível " +"que o método \"{1}\"" + +#: mcs/mcs/class.cs:3213 +#, csharp-format +msgid "" +"Constructor `{0}' is marked `external' but has no external implementation " +"specified" +msgstr "" + +#: mcs/mcs/class.cs:3216 +#, csharp-format +msgid "" +"`{0}' is marked as an external but has no DllImport attribute. Consider " +"adding a DllImport attribute to specify the external implementation" +msgstr "" +"\"{0}\" está marcado com externo mas não possui atributo DllImport. " +"Considere adicionar um atributo DllImport para especificar a implementação " +"externa" + +#: mcs/mcs/class.cs:3245 +#, csharp-format +msgid "" +"`{0}': cannot change access modifiers when overriding `{1}' inherited member " +"`{2}'" +msgstr "" +"\"{0}\": não foi possível alterar modificadores de acesso ao substituir " +"\"{1}\" membro herdado \"{2}\"" + +#: mcs/mcs/class.cs:3254 +#, fuzzy, csharp-format +msgid "`{0}': static types cannot be used as return types" +msgstr "\"{0}\": tipos estáticos não podem ser utilizados como parâmetros" + +#: mcs/mcs/class.cs:3379 +#, csharp-format +msgid "New virtual member `{0}' is declared in a sealed class `{1}'" +msgstr "Novo membro virtual \"{0}\" é declarado em uma classe selada \"{1}\"" + +#: mcs/mcs/class.cs:3394 +msgid "Inconsistent accessibility: property type `" +msgstr "Acessibilidade inconsistente: tipo da propriedade \"" + +#: mcs/mcs/class.cs:3399 +msgid "Inconsistent accessibility: indexer return type `" +msgstr "Acessibilidade inconsistente: tipo de retorno do indexador \"" + +#: mcs/mcs/class.cs:3405 mcs/mcs/class.cs:3410 mcs/mcs/delegate.cs:159 +msgid "Inconsistent accessibility: return type `" +msgstr "Acessibilidade inconsistente: tipo de retorno \"" + +#: mcs/mcs/class.cs:3415 +msgid "Inconsistent accessibility: field type `" +msgstr "Acessibilidade inconsistente: tipo de campo \"" + +#: mcs/mcs/class.cs:3428 +#, csharp-format +msgid "Field or property cannot be of type `{0}'" +msgstr "Campo ou propriedade não podem ser do tipo \"{0}\"" + +#: mcs/mcs/const.cs:103 +#, fuzzy, csharp-format +msgid "Type parameter `{0}' cannot be declared const" +msgstr "O tipo \"{0}\" não pode ser declarado const" + +#: mcs/mcs/const.cs:106 +#, csharp-format +msgid "The type `{0}' cannot be declared const" +msgstr "O tipo \"{0}\" não pode ser declarado const" + +#: mcs/mcs/const.cs:181 +#, csharp-format +msgid "" +"The evaluation of the constant value for `{0}' involves a circular definition" +msgstr "" +"O cálculo do valor constante para \"{0}\" involve uma definição circular" + +#: mcs/mcs/constant.cs:68 mcs/mcs/constant.cs:319 +#, csharp-format +msgid "Constant value `{0}' cannot be converted to a `{1}'" +msgstr "Valor constante \"{0}\" não pode ser convertido para um \"{1}\"" + +#: mcs/mcs/constant.cs:187 +#, csharp-format +msgid "" +"Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax " +"to override)" +msgstr "" +"Valor constante \"{0}\" não pode ser convertido para um \"{1}\" (use a " +"sintaxe \"unchecked\" para sobrescrever)" + +#: mcs/mcs/convert.cs:1158 +#, csharp-format +msgid "" +"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' " +"to `{3}'" +msgstr "" + +#: mcs/mcs/decl.cs:376 +#, csharp-format +msgid "`{0}' cannot declare a body because it is marked extern" +msgstr "\"{0}\" não pode declarar um corpo porque está marcada como externa" + +#: mcs/mcs/decl.cs:382 +#, csharp-format +msgid "`{0}' cannot declare a body because it is marked abstract" +msgstr "\"{0}\" nao pode declarar um corpo porque está marcada como abstrato" + +#: mcs/mcs/decl.cs:395 +#, csharp-format +msgid "" +"`{0}' must have a body because it is not marked abstract or extern. The " +"property can be automatically implemented when you define both accessors" +msgstr "" +"\"{0}\" deve ter um corpo porque não está marcado como abstrato ou externo. " +"A propriedade pode ser automaticamente implementada quando você define ambos " +"os acessores" + +#: mcs/mcs/decl.cs:401 +#, csharp-format +msgid "" +"`{0}' must have a body because it is not marked abstract, extern, or partial" +msgstr "" +"\"{0}\" deve ter um corpo porquê não está marcada como abstrato, externo ou " +"parcial" + +#: mcs/mcs/decl.cs:416 +#, csharp-format +msgid "`{0}': Structs cannot contain protected members" +msgstr "\"{0}\": Structs não podem conter membros protegidos" + +#: mcs/mcs/decl.cs:422 +#, csharp-format +msgid "`{0}': Static classes cannot contain protected members" +msgstr "\"{0}\": Classes estáticas não podem conter membros protegidos" + +#: mcs/mcs/decl.cs:1264 +#, csharp-format +msgid "The namespace `{0}' already contains a definition for `{1}'" +msgstr "O namespace \"{0}\" já contém uma definição para \"{1}\"" + +#: mcs/mcs/decl.cs:1268 +#, csharp-format +msgid "Duplicate type parameter `{0}'" +msgstr "Tipo de parâmetro duplicado \"{0}\"" + +#: mcs/mcs/decl.cs:1271 +#, csharp-format +msgid "The type `{0}' already contains a definition for `{1}'" +msgstr "O tipo \"{0}\" já contém uma definição para \"{1}\"" + +#: mcs/mcs/decl.cs:1321 +#, csharp-format +msgid "" +"Missing partial modifier on declaration of type `{0}'. Another partial " +"declaration of this type exists" +msgstr "" +"Está faltando o modificador parcial na declaração do tipo \"{0}\". Outra " +"declaração parcial deste tipo existe" + +#: mcs/mcs/decl.cs:1410 +msgid "Variant type parameters can only be used with interfaces and delegates" +msgstr "" + +#: mcs/mcs/decl.cs:1422 +#, csharp-format +msgid "`{0}': A constraint references nonexistent type parameter `{1}'" +msgstr "\"{0}\": Uma referência restritiva não existente no parâmetro \"{1}\"" + +#: mcs/mcs/delegate.cs:141 +#, csharp-format +msgid "" +"Inconsistent accessibility: parameter type `{0}' is less accessible than " +"delegate `{1}'" +msgstr "" +"Acessibilidade inconsiste: tipo de parâmetro \"{0}\" é menos acessível que o " +"delegate \"{1}\"" + +#: mcs/mcs/delegate.cs:487 +#, csharp-format +msgid "" +"Cannot create delegate from method `{0}' because it is a member of System." +"Nullable type" +msgstr "" +"Não foi possível criar delegate do método \"{0}\" porque este é um membro do " +"tipo do System.Nullable" + +#: mcs/mcs/delegate.cs:499 +#, csharp-format +msgid "" +"Extension method `{0}' of value type `{1}' cannot be used to create delegates" +msgstr "" +"Método de extensão \"{0}\" de tipo de valor \"{1}\" não pode ser utilizado " +"para criar delegates" + +#: mcs/mcs/delegate.cs:514 +#, csharp-format +msgid "Cannot create delegate from partial method declaration `{0}'" +msgstr "" +"Não foi possível criar delegate da declaração de método parcial \"{0}\"" + +#: mcs/mcs/delegate.cs:517 +#, csharp-format +msgid "" +"Cannot create delegate with `{0}' because it has a Conditional attribute" +msgstr "" +"Não foi possível criar delegate com \"{0}\" porque este contém um atributo " +"Conditional" + +#: mcs/mcs/delegate.cs:560 +#, csharp-format +msgid "" +"A method or delegate `{0} {1}' parameters and return type must be same as " +"delegate `{2} {3}' parameters and return type" +msgstr "" +"Os parâmetros do método ou do delegate \"{0} {1}\" e os tipos de retorno " +"devem ser os mesmos dos parâmetros do delegate \"{2} {3}\" e dos tipos de " +"retorno" + +#: mcs/mcs/delegate.cs:567 +#, csharp-format +msgid "" +"A method or delegate `{0}' parameters do not match delegate `{1}' parameters" +msgstr "" +"Os parâmetros do método ou do delegate \"{0}\" não coincidem com os " +"parâmetros do delegate \"{1}\"" + +#: mcs/mcs/delegate.cs:572 +#, csharp-format +msgid "" +"A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' " +"return type" +msgstr "" +"Os tipos de retorno do método o do delegate \"{0} {1}\" não coincidem com o " +"tipo de retorno do delegate \"{2} {3}\"" + +#: mcs/mcs/delegate.cs:655 +msgid "Method name expected" +msgstr "Nome do método esperado" + +#: mcs/mcs/doc.cs:914 +#, csharp-format +msgid "Error generating XML documentation file `{0}' (`{1}')" +msgstr "Erro ao gerar arquivo de documentação XML \"{0}\" (\"{1}\")" + +#: mcs/mcs/driver.cs:96 mcs/mcs/driver.cs:465 mcs/mcs/driver.cs:468 +msgid "Source file `" +msgstr "Arquivo fonte \"" + +#: mcs/mcs/driver.cs:123 +#, csharp-format +msgid "Source file `{0}' could not be found" +msgstr "Arquivo fonte \"{0}\" não pôde ser encontrado" + +#: mcs/mcs/driver.cs:129 +#, csharp-format +msgid "Source file `{0}' is a binary file and not a text file" +msgstr "Arquivo fonte \"{0}\" é um arquivo binário e não um arquivo texto" + +#: mcs/mcs/driver.cs:214 +msgid "" +"Invalid target type for -target. Valid options are `exe', `winexe', " +"`library' or `module'" +msgstr "" +"Tipo alvo inválido para -target. Opções válidas são \"exe\", \"winexe\", " +"\"library\" ou \"module\"" + +#: mcs/mcs/driver.cs:361 +msgid "Response file `" +msgstr "Arquivo de resposta \"" + +#: mcs/mcs/driver.cs:370 +msgid "Unable to open response file: " +msgstr "Não foi possível abrir arquivo de resposta: " + +#: mcs/mcs/driver.cs:420 mcs/mcs/driver.cs:430 +msgid "No files to compile were specified" +msgstr "Nenhum arquivo para compilar foi especificado" + +#: mcs/mcs/driver.cs:502 +msgid "Warning level must be in the range 0-4" +msgstr "Nível de avisis deve estar no intervalo 0-4" + +#: mcs/mcs/driver.cs:536 +msgid "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS" +msgstr "" +"Compatibilidade: Utilize -main:CLASSE ao invés de --main CLASSE ou -m CLASSE" + +#: mcs/mcs/driver.cs:545 +msgid "Compatibility: Use -unsafe instead of --unsafe" +msgstr "Compatibilidade: Utilize -unsafe ao invés de --unsafe" + +#: mcs/mcs/driver.cs:556 +msgid "Compatibility: Use -d:SYMBOL instead of --define SYMBOL" +msgstr "Compatibilidade: Utilize -d:SÍMBOLO ao invés de --define SÍMBOLO" + +#: mcs/mcs/driver.cs:570 +msgid "Compatibility: Use -out:FILE instead of --output FILE or -o FILE" +msgstr "" +"Compatibilidade: Utilize -out ARQUIVO ao invés de --output ARQUIVO ou -o " +"ARQUIVO" + +#: mcs/mcs/driver.cs:579 +msgid "Compatibility: Use -checked instead of --checked" +msgstr "Compatibilidade: Utilize -checked ao invés de --checked" + +#: mcs/mcs/driver.cs:589 +msgid "Compatibility: Use -linkres:VALUE instead of --linkres VALUE" +msgstr "Compatibilidade: Utilize -linkres:VALOR ao invés de --linkres VALOR" + +#: mcs/mcs/driver.cs:592 +msgid "Missing argument to --linkres" +msgstr "Argumento faltando para --linkres" + +#: mcs/mcs/driver.cs:601 +msgid "Compatibility: Use -res:VALUE instead of --res VALUE" +msgstr "Compatibilidade: Utilize -res:VALOR ao invés de --res VALOR" + +#: mcs/mcs/driver.cs:604 +msgid "Missing argument to --resource" +msgstr "Argumento faltando para --resource" + +#: mcs/mcs/driver.cs:612 +msgid "Compatibility: Use -target:KIND instead of --target KIND" +msgstr "Compatibilidade: Utilize -target:KIND ao invés de --target KIND" + +#: mcs/mcs/driver.cs:644 +msgid "Compatibility: Use -r:LIBRARY instead of -r library" +msgstr "Compatibilidade: Utilize -r:BIBLIOTECA ao invés de -r biblioteca" + +#: mcs/mcs/driver.cs:663 +msgid "Compatibility: Use -lib:ARG instead of --L arg" +msgstr "Compatibilidade: Utilize -lib:ARG ao invés de --L arg" + +#: mcs/mcs/driver.cs:676 +msgid "Compatibility: Use -nostdlib instead of --nostdlib" +msgstr "Compatibilidade: Utilize -nostdlib ao invés de --nostdlib" + +#: mcs/mcs/driver.cs:681 +msgid "Compatibility: Use -nowarn instead of --nowarn" +msgstr "Compatibilidade: Utilize -nowarn ao invés de --nowarn" + +#: mcs/mcs/driver.cs:698 +msgid "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL" +msgstr "Compatibilidade: Utilize -warn:NÍVEL ao invés de --wlevel NÍVEL" + +#: mcs/mcs/driver.cs:702 +msgid "--wlevel requires a value from 0 to 4" +msgstr "--wlevel requer um valor de 0 a 4" + +#: mcs/mcs/driver.cs:711 +msgid "--mcs-debug requires an argument" +msgstr "--mcs-debug requer um argumento" + +#: mcs/mcs/driver.cs:718 +msgid "Invalid argument to --mcs-debug" +msgstr "Argumento inválido para --mcs-debug" + +#: mcs/mcs/driver.cs:728 +msgid "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN" +msgstr "" +"Compatibilidade: Utilize a opção -recurse:PADRÂO ao invés de --recurse PADRÃO" + +#: mcs/mcs/driver.cs:730 +msgid "--recurse requires an argument" +msgstr "--recurse requer um argumento" + +#: mcs/mcs/driver.cs:741 +msgid "Compatibility: Use -debug option instead of -g or --debug" +msgstr "Compatibilidade: Utilize a opção -debug ao invés de -g ou --debug" + +#: mcs/mcs/driver.cs:746 +msgid "Compatibility: Use -noconfig option instead of --noconfig" +msgstr "Compatibilidade: Utilize a opção -noconfig ao invés de --noconfig" + +#: mcs/mcs/driver.cs:910 +#, csharp-format +msgid "Invalid conditional define symbol `{0}'" +msgstr "Símbolo de definição condicional \"{0}\" inválido" + +#: mcs/mcs/driver.cs:961 +#, csharp-format +msgid "" +"Invalid resource visibility option `{0}'. Use either `public' or `private' " +"instead" +msgstr "" +"Opção de visibilidade de recurso \"{0}\" inválida. Utilize, ao invés disto, " +"\"public\" ou \"private\"" + +#: mcs/mcs/driver.cs:967 +#, csharp-format +msgid "Wrong number of arguments for option `{0}'" +msgstr "Número de argumentos incorreto para a opção \"{0}\"" + +#: mcs/mcs/driver.cs:1005 +msgid "Cannot specify multiple aliases using single /reference option" +msgstr "" + +#: mcs/mcs/driver.cs:1033 mcs/mcs/driver.cs:1045 +msgid "" +"Cannot specify the `win32res' and the `win32ico' compiler option at the same " +"time" +msgstr "" +"Não se pode especificar as opções de compilador \"win32res\" e o \"win32ico" +"\" ao mesmo tempo" + +#: mcs/mcs/driver.cs:1160 +#, csharp-format +msgid "`{0}' is not a valid warning number" +msgstr "" + +#: mcs/mcs/driver.cs:1190 +#, fuzzy +msgid "" +"Invalid platform type for -platform. Valid options are `anycpu', `x86', " +"`x64' or `itanium'" +msgstr "" +"Tipo alvo inválido para -target. Opções válidas são \"exe\", \"winexe\", " +"\"library\" ou \"module\"" + +#: mcs/mcs/driver.cs:1288 +#, fuzzy, csharp-format +msgid "" +"Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or " +"`Default'" +msgstr "" +"Opção \"{0}\" inválida para /langversion. Este deve ser \"ISO-1\" ou " +"\"ISO-2\" ou \"Default\"" + +#: mcs/mcs/driver.cs:1308 +#, csharp-format +msgid "Code page `{0}' is invalid or not installed" +msgstr "Código de página \"{0}\" é inválido ou não está instalado" + +#: mcs/mcs/driver.cs:1323 +#, csharp-format +msgid "Unrecognized command-line option: `{0}'" +msgstr "Opção de linha de comando não reconhecida: \"{0}\"" + +#: mcs/mcs/driver.cs:1328 +#, csharp-format +msgid "Missing file specification for `{0}' option" +msgstr "" + +#: mcs/mcs/driver.cs:1333 +#, fuzzy, csharp-format +msgid "Missing argument for `{0}' option" +msgstr "Argumento faltando para --linkres" + +#: mcs/mcs/driver.cs:1368 +#, fuzzy, csharp-format +msgid "Invalid reference alias `{0}='. Missing filename" +msgstr "Apelido de referência inválido" + +#: mcs/mcs/driver.cs:1373 +#, fuzzy, csharp-format +msgid "" +"Invalid extern alias for -reference. Alias `{0}' is not a valid identifier" +msgstr "Apelido externo inválido para /reference. Apelido \"'" + +#: mcs/mcs/driver.cs:1389 +#, csharp-format +msgid "The resource identifier `{0}' has already been used in this assembly" +msgstr "O identificador do recurso \"{0}\" já foi utilizado neste assembly" + +#: mcs/mcs/driver.cs:1450 +msgid "" +"If no source files are specified you must specify the output file with -out:" +msgstr "" +"Se nenhum código fonte for especificado você deve especificar o arquivo de " +"saída com -out:" + +#: mcs/mcs/dynamic.cs:272 +#, fuzzy +msgid "An expression tree cannot contain a dynamic operation" +msgstr "" +"Uma árvore de expressão não pode conter uma operação de ponteiro insegura" + +#: mcs/mcs/dynamic.cs:302 +msgid "" +"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly " +"reference" +msgstr "" + +#: mcs/mcs/ecore.cs:242 +#, csharp-format +msgid "`{0}' is inaccessible due to its protection level" +msgstr "\"{0}\" está inacessível devido ao nível de proteção" + +#: mcs/mcs/ecore.cs:247 +#, csharp-format +msgid "The expression being assigned to `{0}' must be constant" +msgstr "A expressão sendo atribuída a \"{0}\" deve ser constante" + +#: mcs/mcs/ecore.cs:252 +#, csharp-format +msgid "" +"A constant `{0}' of reference type `{1}' can only be initialized with null" +msgstr "" +"A constante \"{0}\" do tipo de referência \"{1}\" só pode ser inicializada " +"com null" + +#: mcs/mcs/ecore.cs:258 +msgid "" +"Only assignment, call, increment, decrement, and new object expressions can " +"be used as a statement" +msgstr "" +"Apenas expressões de atribuição, chamada, incremento, decretomento e novos " +"elementos podem ser usadas como uma declaração" + +#: mcs/mcs/ecore.cs:269 +msgid "Keyword `void' cannot be used in this context" +msgstr "Palavra chave \"void\" não pode ser utilizada neste contexto" + +#: mcs/mcs/ecore.cs:303 +#, csharp-format +msgid "Cannot convert type `{0}' to `{1}'" +msgstr "Não foi possível converter o tipo \"{0}\" para \"{1}\"" + +#: mcs/mcs/ecore.cs:313 +#, csharp-format +msgid "" +"Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists " +"(are you missing a cast?)" +msgstr "" +"Não foi possível converter implicitamente o tipo \"{0}\" para \"{1}\". Uma " +"conversão explícita já existe (você não está esquecendo de um cast?)" + +#: mcs/mcs/ecore.cs:319 +#, csharp-format +msgid "Cannot implicitly convert type `{0}' to `{1}'" +msgstr "Não foi possível converter implicitamente o tipo \"{0}\" para \"{1}\"" + +#: mcs/mcs/ecore.cs:360 +#, csharp-format +msgid "`{0}' does not contain a definition for `{1}'" +msgstr "\"{0}\" não contém uma definição para \"{1}\"" + +#: mcs/mcs/ecore.cs:366 +msgid "" +"The left-hand side of an assignment must be a variable, a property or an " +"indexer" +msgstr "" +"O lado esquerdo de uma atribuição deve ser uma variável, uma propriedade ou " +"um indexador" + +#: mcs/mcs/ecore.cs:371 +msgid "The operation in question is undefined on void pointers" +msgstr "" + +#: mcs/mcs/ecore.cs:433 mcs/mcs/statement.cs:2558 mcs/mcs/statement.cs:2560 +#, csharp-format +msgid "Internal compiler error: {0}" +msgstr "" + +#: mcs/mcs/ecore.cs:473 +msgid "A ref or out argument must be an assignable variable" +msgstr "Um argumento ref ou out deve ser uma variável atribuível" + +#: mcs/mcs/ecore.cs:492 +msgid "" +"An attribute argument must be a constant expression, typeof expression or " +"array creation expression" +msgstr "" +"Um argumento de atributo deve ser uma expressão constante, typeof ou " +"expressão de criação de array" + +#: mcs/mcs/ecore.cs:563 +#, csharp-format +msgid "The class `{0}' has no constructors defined" +msgstr "" + +#: mcs/mcs/ecore.cs:648 +#, csharp-format +msgid "Ambiguity between `{0}' and `{1}'" +msgstr "Ambiguidade entre \"{0}\" e \"{1}\"" + +#: mcs/mcs/ecore.cs:675 +msgid "An expression tree cannot contain an unsafe pointer operation" +msgstr "" +"Uma árvore de expressão não pode conter uma operação de ponteiro insegura" + +#: mcs/mcs/ecore.cs:796 +#, csharp-format +msgid "Expression denotes a `{0}', where a `{1}' was expected" +msgstr "A expressão denota um \"{0}\", onde um \"{1}\" era esperado" + +#: mcs/mcs/ecore.cs:806 +msgid "Pointers and fixed size buffers may only be used in an unsafe context" +msgstr "" +"Ponteiros e buffers de tamanho fixo devem apenas ser utilizados num contexto " +"inseguro" + +#: mcs/mcs/ecore.cs:841 +#, csharp-format +msgid "" +"Members of value type `{0}' cannot be assigned using a property `{1}' object " +"initializer" +msgstr "" +"Membros do tipo de valor \"{0}\" não podem ser atribuidos usando uma " +"propriedade \"{1}\" inicializadora de objeto" + +#: mcs/mcs/ecore.cs:844 +#, csharp-format +msgid "" +"Cannot modify a value type return value of `{0}'. Consider storing the value " +"in a temporary variable" +msgstr "" +"Não foi possível modificar o valor do retorno do tipo de valor de \"{0}\". " +"Considere guardar o valor em uma variável temporária" + +#: mcs/mcs/ecore.cs:2270 +#, fuzzy, csharp-format +msgid "" +"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core." +"dll assembly reference?" +msgstr "" +"O tipo ou nome de namespace \"{0}\" não pôde ser encontrado. Você está " +"esquecendo de uma diretiva em uso ou uma referência do assembly?" + +#: mcs/mcs/ecore.cs:2344 +#, fuzzy, csharp-format +msgid "" +"A local variable `{0}' cannot be used before it is declared. Consider " +"renaming the local variable when it hides the member `{1}'" +msgstr "" +"A variável local \"{0}\" não pode ser utilizada antes de ser declarada. " +"Considere renomear a variável local quando esta esconder o campo \"{1}\"" + +#: mcs/mcs/ecore.cs:2359 mcs/mcs/ecore.cs:2403 +#, csharp-format +msgid "`{0}' conflicts with a declaration in a child block" +msgstr "\"{0}\" conflita com uma declaração em um bloco filho" + +#: mcs/mcs/ecore.cs:2412 +#, csharp-format +msgid "A local variable `{0}' cannot be used before it is declared" +msgstr "" +"Uma variável local \"{0}\" não pode ser utilizada antes de ser declarada" + +#: mcs/mcs/ecore.cs:2414 +#, csharp-format +msgid "The name `{0}' does not exist in the current context" +msgstr "O nome \"{0}\" não existe no contexto atual" + +#: mcs/mcs/ecore.cs:2664 +#, csharp-format +msgid "" +"Cannot access protected member `{0}' via a qualifier of type `{1}'. The " +"qualifier must be of type `{2}' or derived from it" +msgstr "" +"Não foi possível acessar membro protegido \"{0}\" a partir de um " +"qualificador do tipo \"{1}\". O qualificador deve ser do tipo \"{2}\" ou " +"derivado deste" + +#: mcs/mcs/ecore.cs:2708 +#, csharp-format +msgid "Cannot call an abstract base member `{0}'" +msgstr "Não foi possível chamar um membro abstrato da base \"{0}\"" + +#: mcs/mcs/ecore.cs:2747 +#, csharp-format +msgid "" +"Static member `{0}' cannot be accessed with an instance reference, qualify " +"it with a type name instead" +msgstr "" +"O membro estático \"{0}\" não pode ser acessado com uma referência de " +"instância, ao invés disso, qualifique com um nome de tipo" + +#: mcs/mcs/ecore.cs:2762 +#, csharp-format +msgid "" +"A field initializer cannot reference the nonstatic field, method, or " +"property `{0}'" +msgstr "" +"Um inicializador de campo não pode referenciar um campo não estático, método " +"ou propriedade \"{0}\"" + +#: mcs/mcs/ecore.cs:2766 +#, csharp-format +msgid "An object reference is required to access non-static member `{0}'" +msgstr "" +"Uma referência de objeto é necessária para acessar o membro não estático " +"\"{0}\"" + +#: mcs/mcs/ecore.cs:2774 +#, csharp-format +msgid "" +"Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'" +msgstr "" +"Não foi possível acessar um membro não estático de um tipo externo \"{0}\" " +"de um tipo aninhado \"{1}\"" + +#: mcs/mcs/ecore.cs:2822 +msgid "Cannot modify the result of an unboxing conversion" +msgstr "Não foi possível modificar o resultado de uma conversão unboxing" + +#: mcs/mcs/ecore.cs:2943 +#, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' has some invalid arguments" +msgstr "" +"Tipo \"{0}\" não contém um membro \"{1}\" e o melhor método de extensão " +"sobrecarregado \"{2}\" tem alguns argumentos inválidos" + +#: mcs/mcs/ecore.cs:2948 +#, csharp-format +msgid "Extension method instance type `{0}' cannot be converted to `{1}'" +msgstr "" +"Tipo de instância do método de extensão \"{0}\" não pode ser convertido para " +"\"{1}\"" + +#: mcs/mcs/ecore.cs:3072 +msgid "An expression tree cannot contain an expression with method group" +msgstr "" +"Uma árvore de expressão não pode conter uma expressão com um grupo de método" + +#: mcs/mcs/ecore.cs:3078 +msgid "" +"Partial methods with only a defining declaration or removed conditional " +"methods cannot be used in an expression tree" +msgstr "" +"Métodos parciais com somente uma declaração de definição ou métodos com " +"condicionais removidos não podem ser utilizados em uma árvore de expressão" + +#: mcs/mcs/ecore.cs:3108 +#, csharp-format +msgid "" +"Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using " +"parentheses to invoke the method" +msgstr "" +"Não foi possível converter o grupo de método \"{0}\" para o tipo não-" +"delegate \"{1}\". Consider a utilização de parênteses quando chamar o método" + +#: mcs/mcs/ecore.cs:3676 +#, csharp-format +msgid "" +"The type `{0}' does not contain a constructor that takes `{1}' arguments" +msgstr "" +"O tipo \"{0}\" não contém um construtor que aceite os argumentos \"{1}\"" + +#: mcs/mcs/ecore.cs:4284 +#, fuzzy, csharp-format +msgid "" +"Type `{0}' does not contain a member `{1}' and the best extension method " +"overload `{2}' cannot be dynamically dispatched. Consider calling the method " +"without the extension method syntax" +msgstr "" +"Tipo \"{0}\" não contém um membro \"{1}\" e o melhor método de extensão " +"sobrecarregado \"{2}\" tem alguns argumentos inválidos" + +#: mcs/mcs/ecore.cs:4305 +#, csharp-format +msgid "" +"The call is ambiguous between the following methods or properties: `{0}' and " +"`{1}'" +msgstr "" +"Essa chamada é ambígua entre os seguintes métodos ou propriedades: \"{0}\" e " +"\"{1}\"" + +#: mcs/mcs/ecore.cs:4360 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' cannot have 'ref', or " +"`out' modifier" +msgstr "" +"O melhor método sobrecarregado de coleção \"{0}\" não pode ter o modificador " +"\"ref\" ou \"out\"" + +#: mcs/mcs/ecore.cs:4364 +#, csharp-format +msgid "" +"The best overloaded collection initalizer method `{0}' has some invalid " +"arguments" +msgstr "" +"O melhor método sobrecarregado inicializador de coleção \"{0}\" tem alguns " +"argumentos inválidos" + +#: mcs/mcs/ecore.cs:4367 +#, csharp-format +msgid "Delegate `{0}' has some invalid arguments" +msgstr "Delegate \"{0}\" tem alguns argumentos inválidos" + +#: mcs/mcs/ecore.cs:4371 +#, csharp-format +msgid "The best overloaded method match for `{0}' has some invalid arguments" +msgstr "" +"O melhor método sobrecarregado para \"{0}\" tem alguns argumentos inválidos" + +#: mcs/mcs/ecore.cs:4381 +#, csharp-format +msgid "" +"Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' " +"modifier" +msgstr "" +"Argumento \"#{0}\" não requer o modificador \"{1}\". Considere remover o " +"modificador \"{1}\"" + +#: mcs/mcs/ecore.cs:4384 +#, csharp-format +msgid "Argument `#{0}' is missing `{1}' modifier" +msgstr "Argumento \"#{0}\" não encontrou o modificador \"{1}\"" + +#: mcs/mcs/ecore.cs:4397 +#, csharp-format +msgid "Argument `#{0}' cannot convert `{1}' expression to type `{2}'" +msgstr "" +"Argumento \"#{0}\" não pôde converter a expressão \"{1}\" para o tipo \"{2}\"" + +#: mcs/mcs/ecore.cs:4445 +#, csharp-format +msgid "" +"The type arguments for method `{0}' cannot be inferred from the usage. Try " +"specifying the type arguments explicitly" +msgstr "" +"O argumentos de tipo para o método \"{0}\" não pôde ser inferido do uso. " +"Tente especificar os tipos dos argumentos explicitamente" + +#: mcs/mcs/ecore.cs:4474 +#, csharp-format +msgid "No overload for method `{0}' takes `{1}' arguments" +msgstr "Sem sobrecarga para o método \"{0}\" aceitar os argumentos \"{1}\"" + +#: mcs/mcs/ecore.cs:4527 +#, fuzzy, csharp-format +msgid "The delegate `{0}' does not contain a parameter named `{1}'" +msgstr "O tipo aninhado \"{0}\" não existe no tipo \"{1}\"" + +#: mcs/mcs/ecore.cs:4532 +#, fuzzy, csharp-format +msgid "" +"The best overloaded method match for `{0}' does not contain a parameter " +"named `{1}'" +msgstr "" +"O melhor método sobrecarregado para \"{0}\" tem alguns argumentos inválidos" + +#: mcs/mcs/ecore.cs:4542 +#, csharp-format +msgid "" +"Named argument `{0}' cannot be used for a parameter which has positional " +"argument specified" +msgstr "" + +#: mcs/mcs/ecore.cs:4855 +msgid "" +"You cannot use fixed size buffers contained in unfixed expressions. Try " +"using the fixed statement" +msgstr "" +"Você não pode usar buffers de tamanho fixo contidos em expressões não " +"fixadas. Tente utilizar a declaração fixa" + +#: mcs/mcs/ecore.cs:4860 +#, csharp-format +msgid "`{0}': Fixed size buffers can only be accessed through locals or fields" +msgstr "" +"\"{0}\": Buffers de tamanho fixo podem apenas ser acessados atravéis de " +"locais ou campos" + +#: mcs/mcs/ecore.cs:5255 +#, fuzzy, csharp-format +msgid "Property or event `{0}' is not supported by the C# language" +msgstr "" +"A propriedade \"{0}\" não tem suporte na linguagem C#. Tente chamar o método " +"acessor \"{1}\" diretamente" + +#: mcs/mcs/ecore.cs:5416 +#, csharp-format +msgid "A range variable `{0}' may not be passes as `ref' or `out' parameter" +msgstr "" +"Uma variável de intervalo \"{0}\" não deve ser passada como parâmetros \"ref" +"\" ou \"out\"" + +#: mcs/mcs/ecore.cs:5464 +#, csharp-format +msgid "" +"The property or indexer `{0}' cannot be used in this context because it " +"lacks the `get' accessor" +msgstr "" +"A propriedade ou indexador \"{0}\" não pôde ser utilizada nesse contexto " +"porque falta o acessor \"get\"" + +#: mcs/mcs/ecore.cs:5471 +#, csharp-format +msgid "" +"The property or indexer `{0}' cannot be used in this context because the get " +"accessor is inaccessible" +msgstr "" +"A propriedade ou indexador \"{0}\" não pôde ser utilizada nesse contexto " +"porque o acessor get está inacessível" + +#: mcs/mcs/ecore.cs:5490 +#, fuzzy, csharp-format +msgid "Property or indexer `{0}' cannot be assigned to (it is read-only)" +msgstr "" +"Propriedade ou indexador \"{0}\" não pôde ser atribuida (ela é somente " +"leitura)" + +#: mcs/mcs/ecore.cs:5498 +#, csharp-format +msgid "" +"The property or indexer `{0}' cannot be used in this context because the set " +"accessor is inaccessible" +msgstr "" +"A propriedade ou indexador \"{0}\" não pôde ser utilizada neste contexto por " +"que o acessor do conjunto está inacessível" + +#: mcs/mcs/ecore.cs:5659 +#, csharp-format +msgid "" +"The event `{0}' can only appear on the left hand side of `+=' or `-=' " +"operator" +msgstr "" +"O evento \"{0}\" pode apenas aparecer no lado esquerdo do operador \"+=\" ou " +"\"-=\"" + +#: mcs/mcs/ecore.cs:5663 +#, csharp-format +msgid "" +"The event `{0}' can only appear on the left hand side of += or -= when used " +"outside of the type `{1}'" +msgstr "" +"O evento \"{0}\" pode apenas aparecer no lado esquerdo do operador += ou -= " +"quando utilizado fora do tipo \"{1}\"" + +#: mcs/mcs/ecore.cs:5827 +#, csharp-format +msgid "" +"An implicitly typed local variable declaration cannot be initialized with `" +"{0}'" +msgstr "" +"Uma declaração de variável local tipada implicitamente não pode ser " +"inicializada com \"{0}\"" + +#: mcs/mcs/ecore.cs:5841 +msgid "" +"The contextual keyword `var' may only appear within a local variable " +"declaration" +msgstr "" +"A palavra chave contextual \"var\" deve apenas aparecer dentro de uma " +"declaração de variável local" + +#: mcs/mcs/enum.cs:125 +#, fuzzy, csharp-format +msgid "" +"The enumerator value `{0}' is outside the range of enumerator underlying " +"type `{1}'" +msgstr "" +"O valor enumerador \"{0}\" é muito grande para caber no seu tipo \"{1}\"" + +#: mcs/mcs/enum.cs:189 +#, csharp-format +msgid "An item in an enumeration cannot have an identifier `{0}'" +msgstr "Um ítem em uma enumeração não pode ter um identificador \"{0}\"" + +#: mcs/mcs/enum.cs:200 +msgid "Type byte, sbyte, short, ushort, int, uint, long or ulong expected" +msgstr "Tipo byte, sbyte, short, ushort, int, uint, long ou ulong esperado" + +#: mcs/mcs/eval.cs:625 +msgid "Detection Parsing Error" +msgstr "Erro na Análise de Detecção" + +#: mcs/mcs/expression.cs:542 +#, csharp-format +msgid "The `{0}' operator cannot be applied to operand of type `{1}'" +msgstr "O operador \"{0}\" não pode ser aplicado ao operando de tipo \"{1}\"" + +#: mcs/mcs/expression.cs:622 +#, fuzzy +msgid "Cannot take the address of the given expression" +msgstr "" +"Não foi possível encontrar o endereço de \"this\" por que este é somente " +"leitura" + +#: mcs/mcs/expression.cs:656 +msgid "" +"You can only take the address of unfixed expression inside of a fixed " +"statement initializer" +msgstr "" + +#: mcs/mcs/expression.cs:745 +#, csharp-format +msgid "Operator `{0}' is ambiguous on an operand of type `{1}'" +msgstr "Operador \"{0}\" é ambíguo em um operando de tipo \"{1}\"" + +#: mcs/mcs/expression.cs:868 +#, fuzzy +msgid "The * or -> operator must be applied to a pointer" +msgstr "" +"O operador \"{0}\" não pode ser aplicado em um operando de tipo ponteiro" + +#: mcs/mcs/expression.cs:1070 +msgid "" +"The operand of an increment or decrement operator must be a variable, " +"property or indexer" +msgstr "" +"O operando de um operador de incremento ou decremento deve ser uma variável, " +"propriedade ou indexador" + +#: mcs/mcs/expression.cs:1260 +#, csharp-format +msgid "The `{0}' operator cannot be applied to an operand of a static type" +msgstr "" +"O operador \"{0}\" não pode ser aplicado a um operando de tipo estático" + +#: mcs/mcs/expression.cs:1265 +#, csharp-format +msgid "The `{0}' operator cannot be applied to an operand of pointer type" +msgstr "" +"O operador \"{0}\" não pode ser aplicado em um operando de tipo ponteiro" + +#: mcs/mcs/expression.cs:1271 +#, csharp-format +msgid "" +"The `{0}' operator cannot be applied to a lambda expression or anonymous " +"method" +msgstr "" +"O operador \"{0}\" não pode ser aplicado a uma expressão lambda ou método " +"anônimo" + +#: mcs/mcs/expression.cs:1507 +#, fuzzy, csharp-format +msgid "" +"The `as' operator cannot be used with a non-reference type parameter `{0}'. " +"Consider adding `class' or a reference type constraint" +msgstr "" +"O operador \"as\" não pode ser utilizada com um parâmetro de tipo não " +"referência \"{0}\"" + +#: mcs/mcs/expression.cs:1511 +#, csharp-format +msgid "The `as' operator cannot be used with a non-nullable value type `{0}'" +msgstr "" +"O operador \"as\" não pode ser utilizado com um valor não de tipo não NULL " +"\"{0}\"" + +#: mcs/mcs/expression.cs:1548 +#, csharp-format +msgid "Cannot convert type `{0}' to `{1}' via a built-in conversion" +msgstr "" +"Não foi possível converter o tipo \"{0}\" para \"{1}\" através de uma " +"conversão inclusa" + +#: mcs/mcs/expression.cs:1589 +#, csharp-format +msgid "Cannot convert to static type `{0}'" +msgstr "Não foi possível converter para o tipo estático \"{0}\"" + +#: mcs/mcs/expression.cs:1679 +msgid "" +"The `default value' operator cannot be applied to an operand of a static type" +msgstr "" +"O operador \"valor padrão\" não pode ser aplicado a um operando de um tipo " +"estático" + +#: mcs/mcs/expression.cs:2184 +#, csharp-format +msgid "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'" +msgstr "" +"O operador \"{0}\" não pode ser aplicado aos operados do tipo \"{1}\" e " +"\"{2}\"" + +#: mcs/mcs/expression.cs:2747 +msgid "To cast a negative value, you must enclose the value in parentheses" +msgstr "" +"Para fazer o cast do valor negativo, você deve colocar o valor em parênteses" + +#: mcs/mcs/expression.cs:3400 +#, csharp-format +msgid "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'" +msgstr "O operador \"{0}\" é ambíguo em operandos do tipo \"{1}\" e \"{2}\"" + +#: mcs/mcs/expression.cs:4152 +#, csharp-format +msgid "" +"A user-defined operator `{0}' must have parameters and return values of the " +"same type in order to be applicable as a short circuit operator" +msgstr "" +"O operador definido pelo usuário \"{0}\" deve ter parâmetros e valores de " +"retorno do mesmo tipo, para que seja aplicável como um operador de curto " +"circuito" + +#: mcs/mcs/expression.cs:4162 +#, csharp-format +msgid "" +"The type `{0}' must have operator `true' and operator `false' defined when `" +"{1}' is used as a short circuit operator" +msgstr "" +"O tipo \"{0}\" deve ter operadores \"true\" e \"false\" definidos quando " +"\"{1}\" é utilizado como um operador curto circuito" + +#: mcs/mcs/expression.cs:4472 +#, fuzzy, csharp-format +msgid "" +"Type of conditional expression cannot be determined as `{0}' and `{1}' " +"convert implicitly to each other" +msgstr "" +"Tipo da expressão condicional não pôde ser determinada por que não há uma " +"conversão implícita entre \"{0}\" e \"{1}\"" + +#: mcs/mcs/expression.cs:4482 +#, csharp-format +msgid "" +"Type of conditional expression cannot be determined because there is no " +"implicit conversion between `{0}' and `{1}'" +msgstr "" +"Tipo da expressão condicional não pôde ser determinada por que não há uma " +"conversão implícita entre \"{0}\" e \"{1}\"" + +#: mcs/mcs/expression.cs:4934 +#, csharp-format +msgid "Use of unassigned out parameter `{0}'" +msgstr "Uso do parâmetro removido \"{0}\"" + +#: mcs/mcs/expression.cs:4964 +#, csharp-format +msgid "" +"Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' " +"modifier" +msgstr "" +"Parâmetro \"{0}\" não pôde ser utilizado dentro de \"{1}\" quando estiver " +"usando modificadores \"ref\" ou \"out\"" + +#: mcs/mcs/expression.cs:5165 +#, fuzzy, csharp-format +msgid "Cannot invoke a non-delegate type `{0}'" +msgstr "Não foi possível converter \"{0}\" para um tipo não-delegate \"{1}\"" + +#: mcs/mcs/expression.cs:5176 +#, csharp-format +msgid "The member `{0}' cannot be used as method or delegate" +msgstr "O membro \"{0}\" não pode ser utilizado como método ou delegate" + +#: mcs/mcs/expression.cs:5196 +msgid "" +"Do not directly call your base class Finalize method. It is called " +"automatically from your destructor" +msgstr "" +"Não chame diretamente seu método Finalize da classe base. Este é chamado " +"automaticamente de seu destrutor" + +#: mcs/mcs/expression.cs:5198 +msgid "" +"Destructors and object.Finalize cannot be called directly. Consider calling " +"IDisposable.Dispose if available" +msgstr "" +"Destrutores e o object.Finalize não podem ser chamados diretamente. " +"Considere chamar IDisposable.Dispose se disponível" + +#: mcs/mcs/expression.cs:5227 +#, csharp-format +msgid "" +"The base call to method `{0}' cannot be dynamically dispatched. Consider " +"casting the dynamic arguments or eliminating the base access" +msgstr "" + +#: mcs/mcs/expression.cs:5304 +#, csharp-format +msgid "`{0}': cannot explicitly call operator or accessor" +msgstr "\"{0}\": não foi possível chamar explicitamente operador ou acessor" + +#: mcs/mcs/expression.cs:5631 +#, csharp-format +msgid "Unsafe type `{0}' cannot be used in an object creation expression" +msgstr "" +"Tipo inseguro \"{0}\" não pode ser utilizado em uma expressão criadora de " +"objetos" + +#: mcs/mcs/expression.cs:5654 +#, csharp-format +msgid "" +"Cannot create an instance of the variable type `{0}' because it does not " +"have the new() constraint" +msgstr "" + +#: mcs/mcs/expression.cs:5660 +#, csharp-format +msgid "" +"`{0}': cannot provide arguments when creating an instance of a variable type" +msgstr "" + +#: mcs/mcs/expression.cs:5669 +#, csharp-format +msgid "Cannot create an instance of the static class `{0}'" +msgstr "Não foi possível criar uma instância da classe estática \"{0}\"" + +#: mcs/mcs/expression.cs:5681 +#, csharp-format +msgid "Cannot create an instance of the abstract class or interface `{0}'" +msgstr "" +"Não foi possível criar uma instância da classe abstrata ou interface \"{0}\"" + +#: mcs/mcs/expression.cs:5977 +msgid "" +"An implicitly typed local variable declarator cannot use an array initializer" +msgstr "" +"Um declarador de variável local tipada implícitamente não pode usar um " +"inicializador de array" + +#: mcs/mcs/expression.cs:6070 +msgid "Cannot create an array with a negative size" +msgstr "Não foi possível criar um array com um tamanho negativo" + +#: mcs/mcs/expression.cs:6102 mcs/mcs/expression.cs:6110 +#: mcs/mcs/statement.cs:1009 mcs/mcs/statement.cs:3055 +msgid "A constant value is expected" +msgstr "Um valor constante é esperado" + +#: mcs/mcs/expression.cs:6116 +#, csharp-format +msgid "An array initializer of length `{0}' was expected" +msgstr "" + +#: mcs/mcs/expression.cs:6132 +#, fuzzy +msgid "" +"Array initializers can only be used in a variable or field initializer. Try " +"using a new expression instead" +msgstr "" +"É possivel apenas utilizar uma expressão de inicialização de array para " +"atríbui-la a tipos de array. Tente, ao invés disso, utilizar uma nova " +"expressão" + +#: mcs/mcs/expression.cs:6140 +#, fuzzy +msgid "A nested array initializer was expected" +msgstr "Um valor constante é esperado" + +#: mcs/mcs/expression.cs:6177 +msgid "An expression tree cannot contain a multidimensional array initializer" +msgstr "" +"Uma árvore de expressão não pode contar um inicializador de array " +"multidimensional" + +#: mcs/mcs/expression.cs:6279 +msgid "" +"Can only use array initializer expressions to assign to array types. Try " +"using a new expression instead" +msgstr "" +"É possivel apenas utilizar uma expressão de inicialização de array para " +"atríbui-la a tipos de array. Tente, ao invés disso, utilizar uma nova " +"expressão" + +#: mcs/mcs/expression.cs:6718 +msgid "" +"The type of an implicitly typed array cannot be inferred from the " +"initializer. Try specifying array type explicitly" +msgstr "" +"O tipo de um array tipado implicitamente não pode ser inferido do " +"inicializador. Tente especificar o tipo de array explicitamente" + +#: mcs/mcs/expression.cs:6855 +msgid "" +"The `this' object cannot be used before all of its fields are assigned to" +msgstr "" + +#: mcs/mcs/expression.cs:6862 +msgid "" +"Keyword `this' is not valid in a static property, static method, or static " +"field initializer" +msgstr "" + +#: mcs/mcs/expression.cs:6865 +msgid "" +"Anonymous methods inside structs cannot access instance members of `this'. " +"Consider copying `this' to a local variable outside the anonymous method and " +"using the local instead" +msgstr "" +"Métodos anônimos dentro de structs não podem acessar instâncias de \"this\". " +"Considere copiar \"this\" para um variável local fora do método anônimo e " +"utilizar, ao invés disso, o local" + +#: mcs/mcs/expression.cs:6868 +#, fuzzy +msgid "Keyword `this' is not available in the current context" +msgstr "O nome \"{0}\" não existe no contexto atual" + +#: mcs/mcs/expression.cs:6955 +msgid "Cannot take the address of `this' because it is read-only" +msgstr "" +"Não foi possível encontrar o endereço de \"this\" por que este é somente " +"leitura" + +#: mcs/mcs/expression.cs:6957 +msgid "Cannot pass `this' as a ref or out argument because it is read-only" +msgstr "" +"Não foi possível passar \"thus\" com uma ref ou argumento out por que este é " +"somente leitura" + +#: mcs/mcs/expression.cs:6959 +msgid "Cannot assign to `this' because it is read-only" +msgstr "Não foi possível atribuir para \"this\" por que este é somente leitura" + +#: mcs/mcs/expression.cs:7012 +msgid "The __arglist construct is valid only within a variable argument method" +msgstr "" + +#: mcs/mcs/expression.cs:7062 +msgid "An expression tree cannot contain a method with variable arguments" +msgstr "" +"Uma árvore de expressão não pode conter um método com argumentos variáveis" + +#: mcs/mcs/expression.cs:7146 +msgid "" +"System.Void cannot be used from C#. Use typeof (void) to get the void type " +"object" +msgstr "" + +#: mcs/mcs/expression.cs:7149 +#, fuzzy +msgid "The typeof operator cannot be used on the dynamic type" +msgstr "" +"O operador \"{0}\" não pode ser aplicado a um operando de tipo estático" + +#: mcs/mcs/expression.cs:7218 +#, csharp-format +msgid "`{0}': an attribute argument cannot use type parameters" +msgstr "\"{0}\": um argumento de atributo não pode usar parâmetros de tipo" + +#: mcs/mcs/expression.cs:7472 +#, csharp-format +msgid "" +"`{0}' does not have a predefined size, therefore sizeof can only be used in " +"an unsafe context (consider using System.Runtime.InteropServices.Marshal." +"SizeOf)" +msgstr "" +"\"{0}\" não tem um tamanho predefinido, portanto sizeof pode apenas ser " +"utilizado em um contexto inseguro (consider utilizar System.Runtime." +"InteropServices.Marshal.SizeOf)" + +#: mcs/mcs/expression.cs:7528 +#, csharp-format +msgid "Alias `{0}' not found" +msgstr "Apelido \"{0}\" não encontrado" + +#: mcs/mcs/expression.cs:7539 +#, csharp-format +msgid "" +"Alias `{0}' cannot be used with '::' since it denotes a type. Consider " +"replacing '::' with '.'" +msgstr "" +"Apelido \"{0}\" não pôde ser utilizado com \"::\" pois denota um tipo. " +"Considere substituir \"::\" com \".\"" + +#: mcs/mcs/expression.cs:7555 +#, csharp-format +msgid "" +"A namespace alias qualifier `{0}' did not resolve to a namespace or a type" +msgstr "" +"O qualificador de apelidos do namespace \"{0}\" não resolveu para um " +"namespace ou um tipo" + +#: mcs/mcs/expression.cs:7712 +msgid "Cannot perform member binding on `null' value" +msgstr "" + +#: mcs/mcs/expression.cs:7779 +#, csharp-format +msgid "`{0}': cannot reference a type through an expression; try `{1}' instead" +msgstr "" +"\"{0}\" não pôde referenciar um tipo através de uma expressão; tente, ao " +"invés, \"{1}\"" + +#: mcs/mcs/expression.cs:7855 +#, csharp-format +msgid "A nested type cannot be specified through a type parameter `{0}'" +msgstr "" +"Um tipo aninhado não pode ser especificado através de um tipo parâmetro " +"\"{0}\"" + +#: mcs/mcs/expression.cs:7914 +#, csharp-format +msgid "The nested type `{0}' does not exist in the type `{1}'" +msgstr "O tipo aninhado \"{0}\" não existe no tipo \"{1}\"" + +#: mcs/mcs/expression.cs:7923 +#, csharp-format +msgid "" +"Type `{0}' does not contain a definition for `{1}' and no extension method `" +"{1}' of type `{0}' could be found (are you missing a using directive or an " +"assembly reference?)" +msgstr "" +"O tipo \"{0}\" não contém uma definição para \"{1}\" e nenhuma extensão de " +"método \"{1}\" do tipo \"{0}\" pôde ser encontrada (você está esquecendo uma " +"diretiva em uso ou uma referência do assembly?)" + +#: mcs/mcs/expression.cs:8103 +#, csharp-format +msgid "Cannot apply indexing with [] to an expression of type `{0}'" +msgstr "" +"Não foi possível aplicar uma indexação com [] para uma expressão do tipo " +"\"{0}\"" + +#: mcs/mcs/expression.cs:8119 +msgid "A pointer must be indexed by only one value" +msgstr "" + +#: mcs/mcs/expression.cs:8168 +msgid "An element access expression cannot use named argument" +msgstr "" + +#: mcs/mcs/expression.cs:8224 +#, csharp-format +msgid "Wrong number of indexes `{0}' inside [], expected `{1}'" +msgstr "Número incorreto de índices \"{0}\" dentro de [], esperados \"{1}\"" + +#: mcs/mcs/expression.cs:8560 +msgid "" +"The indexer base access cannot be dynamically dispatched. Consider casting " +"the dynamic arguments or eliminating the base access" +msgstr "" + +#: mcs/mcs/expression.cs:8641 +msgid "An expression tree may not contain a base access" +msgstr "Uma árvore de expressão não deve conter uma acesso de base" + +#: mcs/mcs/expression.cs:8658 +#, fuzzy +msgid "Keyword `base' is not available in a static method" +msgstr "Palavra chave \"new\" não é permitida em elementos do namespace" + +#: mcs/mcs/expression.cs:8660 +#, fuzzy +msgid "Keyword `base' is not available in the current context" +msgstr "O nome \"{0}\" não existe no contexto atual" + +#: mcs/mcs/expression.cs:8691 +#, fuzzy +msgid "" +"A property, indexer or dynamic member access may not be passed as `ref' or " +"`out' parameter" +msgstr "" +"Uma propriedade ou indexador \"{0}\" não deve ser passada como parâmetos " +"\"ref\" ou \"out\"" + +#: mcs/mcs/expression.cs:8968 +#, csharp-format +msgid "Array elements cannot be of type `{0}'" +msgstr "Elementos de array não podem ser do tipo \"{0}\"" + +#: mcs/mcs/expression.cs:8971 +#, csharp-format +msgid "Array elements cannot be of static type `{0}'" +msgstr "Elementos de array não podem ser do tipo estático \"{0}\"" + +#: mcs/mcs/expression.cs:9121 +msgid "Cannot use a negative size with stackalloc" +msgstr "Não é possível utilizar um tamanho negativo com stackalloc" + +#: mcs/mcs/expression.cs:9125 +msgid "Cannot use stackalloc in finally or catch" +msgstr "" + +#: mcs/mcs/expression.cs:9230 +#, csharp-format +msgid "" +"Member `{0}' cannot be initialized. An object initializer may only be used " +"for fields, or properties" +msgstr "" +"Membro \"{0}\" não pode ser inicializado. Um inicializador de objetos pode " +"apenas ser utilizado para campos, ou propriedades" + +#: mcs/mcs/expression.cs:9239 +#, fuzzy, csharp-format +msgid "" +"Static field or property `{0}' cannot be assigned in an object initializer" +msgstr "" +" Campo estático ou propriedade \"{0}\" não podem ser atribuídas a um " +"inicializador de objeto" + +#: mcs/mcs/expression.cs:9414 +#, csharp-format +msgid "" +"A field or property `{0}' cannot be initialized with a collection object " +"initializer because type `{1}' does not implement `{2}' interface" +msgstr "" +"Um campo ou propriedade \"{0}\" não podem ser inicializados com uma " +"inicializador de coleção de objetos porque o tipo \"{1}\" não implementa a " +"interface \"{2}\"" + +#: mcs/mcs/expression.cs:9425 +#, csharp-format +msgid "Inconsistent `{0}' member declaration" +msgstr "Declaração do membro \"{0}\" inconsistente" + +#: mcs/mcs/expression.cs:9433 +#, csharp-format +msgid "" +"An object initializer includes more than one member `{0}' initialization" +msgstr "" +"Um inicializador de objeto inclui mais que um membro \"{0}\" de inicialização" + +#: mcs/mcs/expression.cs:9451 +#, csharp-format +msgid "Cannot initialize object of type `{0}' with a collection initializer" +msgstr "" +"Não foi possível inicializar objetos do tipo \"{0}\" com um inicializador de " +"coleções" + +#: mcs/mcs/expression.cs:9688 +msgid "Anonymous types cannot be used in this expression" +msgstr "Tipos anônimos não podem ser utilizados nesta expressão" + +#: mcs/mcs/expression.cs:9776 +#, csharp-format +msgid "An anonymous type property `{0}' cannot be initialized with `{1}'" +msgstr "" +"Uma propriedade anônima de tipo \"{0}\" não pode ser inicializada com \"{1}\"" + +#: mcs/mcs/field.cs:70 +msgid "" +"The modifier 'abstract' is not valid on fields. Try using a property instead" +msgstr "" +"O modificador \"abstract\" não é válido em campos. Tente, ao invés disso, " +"utilizar uma propriedade" + +#: mcs/mcs/field.cs:121 +msgid "" +"The FieldOffset attribute can only be placed on members of types marked with " +"the StructLayout(LayoutKind.Explicit)" +msgstr "" +"O atributo FieldOffset pode apenas ser colocado em membros de tipos marcados " +"com o StructLayout(LayoutKind.Explicit)" + +#: mcs/mcs/field.cs:126 +msgid "The FieldOffset attribute is not allowed on static or const fields" +msgstr "" +"O atributo FieldOffset não é permitido em campos estáticos ou constantes" + +#: mcs/mcs/field.cs:132 +msgid "" +"Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the " +"'fixed' field modifier instead" +msgstr "" +"Não utilize o atributo \"System.Runtime.CompilerServices.FixedBuffer\". " +"Utilize, ao invés desse, o campo modificador \"fixed\"" + +#: mcs/mcs/field.cs:237 +#, csharp-format +msgid "" +"`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) " +"must have a FieldOffset attribute" +msgstr "" +"\"{0}\": Tipo de campo de instância marcado com StructLayout(LayoutKind." +"Explicit) deve ter um atributo FieldOffset" + +#: mcs/mcs/field.cs:246 +#, csharp-format +msgid "`{0}': cannot declare variables of static types" +msgstr "\"{0}\": não foi possível declarar variáveis de tipo estático" + +#: mcs/mcs/field.cs:388 +#, csharp-format +msgid "" +"`{0}': Fixed size buffers type must be one of the following: bool, byte, " +"short, int, long, char, sbyte, ushort, uint, ulong, float or double" +msgstr "" +"\"{0}\": Buffers de tamanho fixo deve ser algum desses: bool, byte, short, " +"int, long, char, sbyte, ushort, uint, ulong, float or double" + +#: mcs/mcs/field.cs:424 +#, csharp-format +msgid "`{0}': Fixed size buffer fields may only be members of structs" +msgstr "" +"\"{0}\": Campos de buffer de tamanho fixo devem ser somente membros de " +"structs" + +#: mcs/mcs/field.cs:439 +#, csharp-format +msgid "`{0}': Fixed size buffers must have a length greater than zero" +msgstr "" +"\"{0}\": Buffers de tamanho fixo devem ter um comprimento maior que zero" + +#: mcs/mcs/field.cs:446 +#, csharp-format +msgid "" +"Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit" +msgstr "" +"Buffer de tamanho fixo \"{0}\" de comprimento \"{1}\" e tipo \"{2}\" excedeu " +"o limite de 2^31" + +#: mcs/mcs/field.cs:628 +#, csharp-format +msgid "`{0}': A volatile field cannot be of the type `{1}'" +msgstr "\"{0}\": Um campo volátil não pode ser do tipo \"{1}\"" + +#: mcs/mcs/field.cs:633 +#, csharp-format +msgid "`{0}': A field cannot be both volatile and readonly" +msgstr "" +"\"{0}\": Um campo não pode ser volátil e somente leitura ao mesmo tempo" + +#: mcs/mcs/flowanalysis.cs:307 +msgid "Control cannot fall through from one case label to another" +msgstr "Controle não pode passar de um rótulo de caso para outro" + +#: mcs/mcs/flowanalysis.cs:536 +#, csharp-format +msgid "" +"The label `{0}:' could not be found within the scope of the goto statement" +msgstr "" +"O rótulo \"{0}:\" não pôde ser encontrado no escopo do declaração do goto" + +#: mcs/mcs/flowanalysis.cs:664 +msgid "" +"A throw statement with no arguments is not allowed outside of a catch clause" +msgstr "" +"Uma declaração throw sem argumentos não é permitida fora de uma cláusula " +"catch" + +#: mcs/mcs/flowanalysis.cs:675 mcs/mcs/flowanalysis.cs:681 +msgid "No enclosing loop out of which to break or continue" +msgstr "Sem fechamento de loop para break ou continue" + +#: mcs/mcs/flowanalysis.cs:709 +msgid "Control cannot leave the body of an anonymous method" +msgstr "Controle não pode deixar o corpo de um método anônimo" + +#: mcs/mcs/flowanalysis.cs:750 +msgid "Cannot yield a value in the body of a try block with a catch clause" +msgstr "" +"Não foi possível deixar um valor no corpo de um bloco try com uma cláusula " +"catch" + +#: mcs/mcs/flowanalysis.cs:752 +msgid "Cannot yield a value in the body of a catch clause" +msgstr "Não foi possível deixar um valor no corpo de um cláusula catch" + +#: mcs/mcs/flowanalysis.cs:904 +msgid "" +"A throw statement with no arguments is not allowed inside of a finally " +"clause nested inside of the innermost catch clause" +msgstr "" +"Uma declaração throw sem argumentos não é permitida dentro de uma clálculsa " +"finalmente aninhada dentro da cláusula de catch mais interna" + +#: mcs/mcs/flowanalysis.cs:916 mcs/mcs/iterators.cs:102 +msgid "Cannot yield in the body of a finally clause" +msgstr "Não foi possível deixar no corpo uma cláusula final" + +#: mcs/mcs/flowanalysis.cs:927 mcs/mcs/flowanalysis.cs:943 +#: mcs/mcs/flowanalysis.cs:979 mcs/mcs/statement.cs:694 +msgid "Control cannot leave the body of a finally clause" +msgstr "O controle não pode deixar o corpo de uma cláusula final" + +#: mcs/mcs/flowanalysis.cs:1130 +#, fuzzy, csharp-format +msgid "" +"An automatically implemented property `{0}' must be fully assigned before " +"control leaves the constructor. Consider calling the default struct " +"contructor from a constructor initializer" +msgstr "" +"Uma propriedade implementada automaticamente \"{0}\" deve ser inteiramente " +"atríbuida antes que o controle deixe o construtor. Considere chamar o " +"construtor padrão" + +#: mcs/mcs/flowanalysis.cs:1134 +#, csharp-format +msgid "" +"Field `{0}' must be fully assigned before control leaves the constructor" +msgstr "" +"Campo \"{0}\" deve ser inteiramente atríbuido antes que o controle deixe o " +"construtor" + +#: mcs/mcs/flowanalysis.cs:1376 +msgid "Use of unassigned local variable `" +msgstr "Uso de variável não atríbuida \"" + +#: mcs/mcs/flowanalysis.cs:1446 +msgid "Use of possibly unassigned field `" +msgstr "Uso de campo possivelmente não atribuído \"" + +#: mcs/mcs/generic.cs:102 mcs/mcs/generic.cs:120 +#, csharp-format +msgid "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'" +msgstr "" +"O tipo de parâmetro \"{0}\" herda as restrições conflitantes \"{1}\" e " +"\"{2}\"" + +#: mcs/mcs/generic.cs:173 +#, fuzzy, csharp-format +msgid "A constraint cannot be the dynamic type `{0}'" +msgstr "Uma restrição não pode ser a classe especial \"{0}\"" + +#: mcs/mcs/generic.cs:182 +#, csharp-format +msgid "" +"Inconsistent accessibility: constraint type `{0}' is less accessible than `" +"{1}'" +msgstr "" +"Accessibilidade inconsistente: tipo de restrição \"{0}\" é menos acessível " +"que \"{1}\"" + +#: mcs/mcs/generic.cs:189 mcs/mcs/generic.cs:203 +#, fuzzy, csharp-format +msgid "Duplicate constraint `{0}' for type parameter `{1}'" +msgstr "Restrição duplicada \"{0}\" para o tipo de parâmetro \"{1}\"." + +#: mcs/mcs/generic.cs:218 +#, csharp-format +msgid "Circular constraint dependency involving `{0}' and `{1}'" +msgstr "Dependência circular de restrições envolvendo \"{0}\" e \"{1}\"" + +#: mcs/mcs/generic.cs:249 +#, csharp-format +msgid "" +"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a " +"constraint for `{1}'" +msgstr "" +"O tipo de parâmetro \"{0}\" tem a \"struct\" constraint, então não pode ser " +"utilizada como restrição para \"{1}\"" + +#: mcs/mcs/generic.cs:260 +#, csharp-format +msgid "" +"The class type constraint `{0}' must be listed before any other constraints. " +"Consider moving type constraint to the beginning of the constraint list" +msgstr "" +"A restrição \"{0}\" do tipo da classe deve ser lista antes de quaisquer " +"outras restrições. Considere mover a restrição de tipo para o início da " +"lista de restrições" + +#: mcs/mcs/generic.cs:266 +#, csharp-format +msgid "" +"`{0}': cannot specify both a constraint class and the `class' or `struct' " +"constraint" +msgstr "" +"\"{0}\": não foi possível especificar uma classe de restrição e a \"classe\" " +"ou \"struct\" restrita" + +#: mcs/mcs/generic.cs:271 +#, fuzzy +msgid "A constraint cannot be the dynamic type" +msgstr "Uma restrição não pode ser a classe especial \"{0}\"" + +#: mcs/mcs/generic.cs:277 +#, csharp-format +msgid "" +"`{0}' is not a valid constraint. A constraint must be an interface, a non-" +"sealed class or a type parameter" +msgstr "" +"\"{0}\" não é uma restrição válida. Uma restrição deve ser uma interface, " +"uma classe não selada ou um tipo parâmetro" + +#: mcs/mcs/generic.cs:284 +#, csharp-format +msgid "" +"`{0}' is not a valid constraint. Static classes cannot be used as constraints" +msgstr "" +"\"{0}\" não é uma restrição válida. Classes estáticas não pode ser " +"utilizadas como restrições" + +#: mcs/mcs/generic.cs:290 +#, csharp-format +msgid "A constraint cannot be special class `{0}'" +msgstr "Uma restrição não pode ser a classe especial \"{0}\"" + +#: mcs/mcs/generic.cs:538 +#, fuzzy, csharp-format +msgid "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'" +msgstr "O nome do tipo parâmetro \"{0}\" é o mesmo que \"{1}\"" + +#: mcs/mcs/generic.cs:1720 +#, csharp-format +msgid "`{0}': static classes cannot be used as generic arguments" +msgstr "" +"\"{0}\": classes estáticas não podem ser utilizadas como argumentos genéricos" + +#: mcs/mcs/generic.cs:1727 +#, csharp-format +msgid "The type `{0}' may not be used as a type argument" +msgstr "O tipo \"{0}\" não deve ser utilizado como um tipo argumento" + +#: mcs/mcs/generic.cs:1982 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' must be a reference type in order to use it as type parameter " +"`{1}' in the generic type or method `{2}'" +msgstr "" +"O tipo \"{0}\" deve ser uma refêrencia de tipo para poder utilizá-lo como o " +"tipo parâmetro \"{1}\" no tipo genérico ou método \"{2}\"." + +#: mcs/mcs/generic.cs:1992 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' must be a non-nullable value type in order to use it as type " +"parameter `{1}' in the generic type or method `{2}'" +msgstr "" +"O tipo \"{0}\" deve ser um tipo de valor não NULL para poder utilizá-lo como " +"tipo parâmetro \"{1}\" no tipo genérico ou método \"{2}\"." + +#: mcs/mcs/generic.cs:2022 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. The nullable type `{0}' never satisfies interface constraint" +msgstr "" +"O tipo \"{0}\" não pode ser utilizado como tipo parâmetro \"{1}\" no tipo " +"genérico ou método \"{2}\". O tipo anulável \"{0}\" nunca satisfaz a " +"restrição de interface do tipo \"{3}\"" + +#: mcs/mcs/generic.cs:2061 +#, csharp-format +msgid "" +"The type `{0}' must have a public parameterless constructor in order to use " +"it as parameter `{1}' in the generic type or method `{2}'" +msgstr "" +"O tipo \"{0}\" deve ter um construtor público sem parâmetros para poder " +"utilizá-lo como parâmetro \"{1}\" no tipo genérico ou método \"{2}\"" + +#: mcs/mcs/generic.cs:2113 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing conversion from `{0}' to `{3}'" +msgstr "" +"O tipo \"{0}\" não pode ser utilizado como tipo parâmetro \"{1}\" no tipo " +"genérico ou método \"{2}\". O tipo anulável \"{0}\" nunca satisfaz a " +"restrição de interface do tipo \"{3}\"" + +#: mcs/mcs/generic.cs:2117 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no boxing or type parameter conversion from `{0}' to `" +"{3}'" +msgstr "" +"O tipo \"{0}\" não pode ser utilizado como tipo parâmetro \"{1}\" no tipo " +"genérico ou método \"{2}\". O tipo anulável \"{0}\" nunca satisfaz a " +"restrição de interface do tipo \"{3}\"" + +#: mcs/mcs/generic.cs:2121 +#, fuzzy, csharp-format +msgid "" +"The type `{0}' cannot be used as type parameter `{1}' in the generic type or " +"method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'" +msgstr "" +"O tipo \"{0}\" não pode ser utilizado como tipo parâmetro \"{1}\" no tipo " +"genérico ou método \"{2}\". O tipo anulável \"{0}\" nunca satisfaz a " +"restrição de interface do tipo \"{3}\"" + +#: mcs/mcs/iterators.cs:44 +msgid "The yield statement cannot be used inside anonymous method blocks" +msgstr "" +"Declaração yield não pode ser utilizada dentro de blocos de método anônimo" + +#: mcs/mcs/iterators.cs:856 +#, csharp-format +msgid "" +"The body of `{0}' cannot be an iterator block because `{1}' is not an " +"iterator interface type" +msgstr "" +"O corpo de \"{0}\" não pode ser um bloco iterador porque \"{1}\" não é um " +"tipo de interface iteradora" + +#: mcs/mcs/iterators.cs:869 +msgid "Iterators cannot have ref or out parameters" +msgstr "Iteradores não podem ter parâmetros ref ou out" + +#: mcs/mcs/iterators.cs:875 +msgid "__arglist is not allowed in parameter list of iterators" +msgstr "__arglist não é permitida em parâmetros de listas de iteradores" + +#: mcs/mcs/iterators.cs:881 +msgid "Iterators cannot have unsafe parameters or yield types" +msgstr "Iteradores não podem ter parâmetros inseguros ou tipos yield" + +#: mcs/mcs/iterators.cs:888 mcs/mcs/statement.cs:4324 +msgid "Unsafe code may not appear in iterators" +msgstr "Código inseguro não pode aparecer em iteradores" + +#: mcs/mcs/linq.cs:68 +#, csharp-format +msgid "" +"An implementation of `{0}' query expression pattern could not be found. Are " +"you missing `System.Linq' using directive or `System.Core.dll' assembly " +"reference?" +msgstr "" +"Uma implementação da consulta de padrão de expressão \"{0}\" não pode ser " +"encontrada. Você está esquecendo da diretiva de uso \"System.Linq\" ou da " +"referência do assembly \"System.Core.dll\" ?" + +#: mcs/mcs/linq.cs:93 +#, fuzzy, csharp-format +msgid "" +"Ambiguous implementation of the query pattern `{0}' for source type `{1}'" +msgstr "" +"Uma implementação da consulta de padrão de expressão \"{0}\" para um código " +"fonte do tipo \"{1}\" não pôde ser encontrada" + +#: mcs/mcs/linq.cs:124 +#, csharp-format +msgid "" +"An implementation of `{0}' query expression pattern for source type `{1}' " +"could not be found" +msgstr "" +"Uma implementação da consulta de padrão de expressão \"{0}\" para um código " +"fonte do tipo \"{1}\" não pôde ser encontrada" + +#: mcs/mcs/linq.cs:132 +#, csharp-format +msgid "" +"An expression type is incorrect in a subsequent `from' clause in a query " +"expression with source type `{0}'" +msgstr "" + +#: mcs/mcs/linq.cs:136 +#, csharp-format +msgid "" +"An expression type in `{0}' clause is incorrect. Type inference failed in " +"the call to `{1}'" +msgstr "" + +#: mcs/mcs/linq.cs:248 +#, csharp-format +msgid "A range variable `{0}' cannot be initialized with `{1}'" +msgstr "" +"Uma variável de intervalo \"{0}\" nâo pode ser inicializada com \"{1}\"" + +#: mcs/mcs/linq.cs:750 +#, csharp-format +msgid "A range variable `{0}' conflicts with a previous declaration of `{0}'" +msgstr "" +"Uma variável de intervalo \"{0}\" conflita com um declaração anterior de " +"\"{0}\"" + +#: mcs/mcs/linq.cs:757 +#, csharp-format +msgid "A range variable `{0}' has already been declared in this scope" +msgstr "Uma variável de intervalor \"{0}\" já foi declarada neste escopo" + +#: mcs/mcs/linq.cs:764 +#, csharp-format +msgid "A range variable `{0}' conflicts with a method type parameter" +msgstr "" +"Uma variável de intervalor \"{0}\" conflita com um método de tipo parâmetro" + +#: mcs/mcs/linq.cs:796 +#, csharp-format +msgid "" +"A range variable `{0}' cannot be assigned to. Consider using `let' clause to " +"store the value" +msgstr "" +"Uma variável de intervalo \"{0}\" não pôde ser atribuida. Considere a " +"utilização da claúsula \"let\" para armazenar o valor" + +#: mcs/mcs/literal.cs:49 +#, csharp-format +msgid "" +"Cannot convert null to the type parameter `{0}' because it could be a value " +"type. Consider using `default ({0})' instead" +msgstr "" +"Não foi possível converter null para o tipo parâmetro \"{0}\" porque este " +"pode ser um tipo de valor. Considere utilizar, ao invés disso, \"default " +"({0})\"" + +#: mcs/mcs/literal.cs:55 +#, csharp-format +msgid "Cannot convert null to `{0}' because it is a value type" +msgstr "" +"Não foi possível converter null para \"{0}\" porque este é um tipo de valor" + +#: mcs/mcs/literal.cs:204 +#, csharp-format +msgid "" +"Literal of type double cannot be implicitly converted to type `{0}'. Add " +"suffix `{1}' to create a literal of this type" +msgstr "" +"Literal do tipo double não pode ser implicitamente convertido para o tipo " +"\"{0}\". Adicione o sufixo \"{1}\" para criar um literal desse tipo" + +#: mcs/mcs/membercache.cs:1261 +msgid "" +"A partial method declaration and partial method implementation cannot differ " +"on use of `params' modifier" +msgstr "" +"Uma declaração de método parcial e uma implementação de método parcial não " +"podem diferir no uso do modificador \"params\"" + +#: mcs/mcs/membercache.cs:1264 +msgid "" +"A partial method declaration and partial method implementation must be both " +"an extension method or neither" +msgstr "" +"Uma declaração de método parcial e uma implementação de método parcial ou " +"devem ser ambas um método de extenção ou ambas não serem" + +#: mcs/mcs/membercache.cs:1268 +#, fuzzy, csharp-format +msgid "" +"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only" +msgstr "" +"Um método sobrecarregado \"{0}\" não pode diferir no uso de modificadores de " +"parâmetros somente" + +#: mcs/mcs/membercache.cs:1272 +#, fuzzy, csharp-format +msgid "" +"Overloaded method `{0}' cannot differ on use of parameter modifiers only" +msgstr "" +"Um método sobrecarregado \"{0}\" não pode diferir no uso de modificadores de " +"parâmetros somente" + +#: mcs/mcs/membercache.cs:1304 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`static' or neither" +msgstr "" +"Uma declaração de método parcial e uma implementação de método parcial ou " +"devem ser ambas estáticas ou ambas não serem" + +#: mcs/mcs/membercache.cs:1309 +msgid "" +"A partial method declaration and partial method implementation must be both " +"`unsafe' or neither" +msgstr "" +"Uma declaração de método parcial e uma implementação de método parcial ou " +"devem ser ambas inseguras ou ambas não serem" + +#: mcs/mcs/membercache.cs:1315 +#, csharp-format +msgid "A partial method `{0}' declaration is already defined" +msgstr "Uma declaração do método parcial \"{0}\" já está definida" + +#: mcs/mcs/membercache.cs:1319 +#, csharp-format +msgid "A partial method `{0}' implementation is already defined" +msgstr "Uma implementação do método parcial \"{0}\" já esa definido" + +#: mcs/mcs/membercache.cs:1330 mcs/mcs/property.cs:81 +#, csharp-format +msgid "A member `{0}' is already reserved" +msgstr "Um membro \"{0}\" já está reservado" + +#: mcs/mcs/membercache.cs:1341 +#, csharp-format +msgid "Duplicate user-defined conversion in type `{0}'" +msgstr "Conversão definida pelo usuário duplicada no topo \"{0}\"" + +#: mcs/mcs/method.cs:484 +msgid "" +"The DllImport attribute must be specified on a method marked `static' and " +"`extern'" +msgstr "" +"O atributo DllImport deve ser especificado em um método marcado \"estático\" " +"e \"externo\"" + +#: mcs/mcs/method.cs:572 +#, csharp-format +msgid "`{0}': A partial method parameters cannot use `out' modifier" +msgstr "" +"\"{0}\": Os parâmetros parciais de um método não podem utilizar o " +"modificador \"out\"" + +#: mcs/mcs/method.cs:631 +#, csharp-format +msgid "" +"Conditional not valid on `{0}' because it is a constructor, destructor, " +"operator or explicit interface implementation" +msgstr "" +"Condicional inválido em \"{0}\" por que é um construtor, destrutor, operador " +"ou interface explícita de implementação" + +#: mcs/mcs/method.cs:844 +#, csharp-format +msgid "Program `{0}' has more than one entry point defined: `{1}'" +msgstr "Programa \"{0}\" possue mais que um ponto de entrada definido \"{1}\"" + +#: mcs/mcs/method.cs:888 +#, csharp-format +msgid "Conditional not valid on `{0}' because it is an override method" +msgstr "Condicional inválido em \"{0}\" por que este é um método sobrescrito" + +#: mcs/mcs/method.cs:893 +#, csharp-format +msgid "Conditional not valid on `{0}' because its return type is not void" +msgstr "Condicional inválido em \"{0}\" porque seu tipo de retorno não é void" + +#: mcs/mcs/method.cs:898 +msgid "Conditional not valid on interface members" +msgstr "Condicional inválido em membros de interface" + +#: mcs/mcs/method.cs:904 +#, csharp-format +msgid "Conditional member `{0}' cannot implement interface member `{1}'" +msgstr "" +"Membro condicional \"{0}\" não podem implementar membros de interface \"{1}\"" + +#: mcs/mcs/method.cs:911 +#, csharp-format +msgid "Conditional method `{0}' cannot have an out parameter" +msgstr "Método condicional \"{0}\" não pode ter um parâmetro externo" + +#: mcs/mcs/method.cs:1017 +#, csharp-format +msgid "" +"The constraints for type parameter `{0}' of method `{1}' must match the " +"constraints for type parameter `{2}' of interface method `{3}'. Consider " +"using an explicit interface implementation instead" +msgstr "" +"As restrições para o tipo parâmetro \"{0}\" do método \"{1}\" devem possuir " +"as mesmas restrições para o tipo parâmetro \"{2}\" do método de interface " +"\"{3}\". Considere, ao invés disso, utilizar uma implementação de interface " +"explícita" + +#: mcs/mcs/method.cs:1071 +#, csharp-format +msgid "`{0}': Extension methods cannot be defined in a nested class" +msgstr "" +"\"{0}\": Métodos de extensão não podem ser definidos em uma classe aninhada" + +#: mcs/mcs/method.cs:1077 +#, csharp-format +msgid "" +"`{0}': Extension methods cannot be declared without a reference to System." +"Core.dll assembly. Add the assembly reference or remove `this' modifer from " +"the first parameter" +msgstr "" +"\"{0}\": Métodos de extensão não podem ser declarados sem uma referência ao " +"assembly System.Core.dll. Adicione a referência do assembly ou remova o " +"modificador \"this\" do primeiro parâmetro" + +#: mcs/mcs/method.cs:1086 +#, csharp-format +msgid "`{0}': Extension methods must be defined in a non-generic static class" +msgstr "" +"\"{0}\": Métodos de estensão devem ser definidos em uma classe estática não-" +"genérica" + +#: mcs/mcs/method.cs:1139 +#, csharp-format +msgid "" +"A partial method `{0}' implementation is missing a partial method declaration" +msgstr "" +"Na implementação do método parcial \"{0}\" está faltando a declaração do " +"método parcial" + +#: mcs/mcs/method.cs:1186 +#, csharp-format +msgid "Method or delegate cannot return type `{0}'" +msgstr "Método ou delegate não podem ter um tipo de retorno \"{0}\"" + +#: mcs/mcs/method.cs:1261 +msgid "" +"The constructor call cannot be dynamically dispatched within constructor " +"initializer" +msgstr "" + +#: mcs/mcs/method.cs:1275 +#, csharp-format +msgid "`{0}': Struct constructors cannot call base constructors" +msgstr "\"{0}\": Construtores de structs não podem chamar construtores da base" + +#: mcs/mcs/method.cs:1294 +#, csharp-format +msgid "Constructor `{0}' cannot call itself" +msgstr "Construtor \"{0}\" não pode chamar a si mesmo" + +#: mcs/mcs/method.cs:1413 +#, csharp-format +msgid "`{0}': The static constructor must be parameterless" +msgstr "\"{0}\": O construtor estático não deve ter parâmetros" + +#: mcs/mcs/method.cs:1431 +msgid "Structs cannot contain explicit parameterless constructors" +msgstr "Structs não podem conter construtores explícitos sem parâmetros" + +#: mcs/mcs/method.cs:1487 +#, csharp-format +msgid "" +"`{0}': A class with the ComImport attribute cannot have a user-defined " +"constructor" +msgstr "" +"\"{0}\": Uma classe com o atributo ComImport não pode ter um construtor " +"definido pelo usuário" + +#: mcs/mcs/method.cs:1730 +#, csharp-format +msgid "`{0}' is an accessor not found in interface member `{1}{2}'" +msgstr "\"{0}\" é um acessor não encontrado no membro da interface \"{1}{2}\"" + +#: mcs/mcs/method.cs:1736 +#, csharp-format +msgid "" +"`{0}.{1}' in explicit interface declaration is not a member of interface" +msgstr "" +"\"{0}.{1}\" na declaração da interface explícita não é um membro da interface" + +#: mcs/mcs/method.cs:1743 +#, csharp-format +msgid "" +"`{0}' explicit method implementation cannot implement `{1}' because it is an " +"accessor" +msgstr "" +"\"{0}\" implementação de método explícito não pode implementar \"{1}\" " +"porque é um acessor" + +#: mcs/mcs/method.cs:1753 +#, fuzzy, csharp-format +msgid "Method `{0}' cannot implement interface accessor `{1}'" +msgstr "Método \"{0}\" não pode implementar acessor de interface \"{1}.{2}\"" + +#: mcs/mcs/method.cs:1759 +#, csharp-format +msgid "" +"Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use " +"an explicit interface implementation" +msgstr "" +"Acessor \"{0}\" não pode implementar o membro da interface \"{1}\" para o " +"tipo \"{2}\". Utilize uma implementação explícita da interface" + +#: mcs/mcs/method.cs:1765 +#, csharp-format +msgid "" +"Accessor `{0}' must be declared public to implement interface member `{1}'" +msgstr "" +"Acessor \"{0}\" deve ser declarado público para implementar o membro da " +"interface \"{1}\"" + +#: mcs/mcs/method.cs:1789 +#, csharp-format +msgid "" +"`{0}': the explicit interface implementation cannot introduce the params " +"modifier" +msgstr "" +"\"{0}\": a implementação explicita da interface não pode fornecer o " +"modificador de parâmetros" + +#: mcs/mcs/method.cs:2107 +#, csharp-format +msgid "" +"Attribute `{0}' is not valid on property or event accessors. It is valid on `" +"{1}' declarations only" +msgstr "" +"Atributo \"{0}\" não é válido em propriedade ou acessores de evento. É " +"válido nas declarações \"{1}\" somente" + +#: mcs/mcs/method.cs:2318 +#, csharp-format +msgid "User-defined operator `{0}' must be declared static and public" +msgstr "" +"Operador definido pelo usuário \"{0}\" deve ser declarado estático e público" + +#: mcs/mcs/method.cs:2357 +msgid "" +"User-defined operator cannot take an object of the enclosing type and " +"convert to an object of the enclosing type" +msgstr "" +"Operador definido pelo usuário não pode pegar um objeto de um tipo no qual " +"está definido e converter para um objeto deste tipo" + +#: mcs/mcs/method.cs:2368 +msgid "User-defined conversion must convert to or from the enclosing type" +msgstr "" +"Converção definida pela usuário deve conver para ou a partir de um tipo no " +"qual está definido" + +#: mcs/mcs/method.cs:2374 +#, fuzzy, csharp-format +msgid "" +"User-defined conversion `{0}' cannot convert to or from the dynamic type" +msgstr "" +"Conversão definida pelo usuário \"{0}\" não pode converter para ou a partir " +"de um tipo de interface" + +#: mcs/mcs/method.cs:2381 +#, csharp-format +msgid "" +"User-defined conversion `{0}' cannot convert to or from an interface type" +msgstr "" +"Conversão definida pelo usuário \"{0}\" não pode converter para ou a partir " +"de um tipo de interface" + +#: mcs/mcs/method.cs:2388 +#, csharp-format +msgid "User-defined conversion `{0}' cannot convert to or from a base class" +msgstr "" +"Conversão definida pelo usuário \"{0}\" não pode converter para ou a partir " +"de uma classe base" + +#: mcs/mcs/method.cs:2394 +#, csharp-format +msgid "User-defined conversion `{0}' cannot convert to or from a derived class" +msgstr "" +"Conversão definida pelo usuário \"{0}\" não pode converter para ou a partir " +"de uma classe derivada" + +#: mcs/mcs/method.cs:2401 +msgid "" +"Overloaded shift operator must have the type of the first operand be the " +"containing type, and the type of the second operand must be int" +msgstr "" +"Operador de shift sobrecarregado deve ter o tipo do primeiro operando como " +"sendo o próprio tipo, e o tipo do segundo operando deve ser int" + +#: mcs/mcs/method.cs:2410 +msgid "" +"The return type for ++ or -- operator must be the containing type or derived " +"from the containing type" +msgstr "" +"O tipo de retorno para o operador ++ ou -- deve ser do próprio tipo ou " +"derivadodo próprio tipo" + +#: mcs/mcs/method.cs:2415 +msgid "The parameter type for ++ or -- operator must be the containing type" +msgstr "O tipo de parâmetro para o operador ++ ou -- deve ser do próprio tipo" + +#: mcs/mcs/method.cs:2422 +msgid "The parameter type of a unary operator must be the containing type" +msgstr "O tipo de parâmetro de um operador unário deve ser do próprio tipo" + +#: mcs/mcs/method.cs:2430 +msgid "The return type of operator True or False must be bool" +msgstr "O tipo de retorno do operador True ou False deve ser bool" + +#: mcs/mcs/method.cs:2445 +msgid "One of the parameters of a binary operator must be the containing type" +msgstr "Um dos parâmetros de um operador binário deve ser do próprio tipo" + +#: mcs/mcs/modifiers.cs:275 +#, fuzzy, csharp-format +msgid "The modifier `{0}' is not valid for this item" +msgstr "Código de página \"{0}\" é inválido ou não está instalado" + +#: mcs/mcs/namespace.cs:70 +#, csharp-format +msgid "" +"The type or namespace name `{0}' could not be found in the global namespace " +"(are you missing an assembly reference?)" +msgstr "" +"O tipo ou nome de namespace \"{0}\" não pôde ser encontrado no namespace " +"global (você não está esquecendo de uma referência do assembly?)" + +#: mcs/mcs/namespace.cs:177 +#, csharp-format +msgid "" +"The type or namespace name `{0}' does not exist in the namespace `{1}'. Are " +"you missing an assembly reference?" +msgstr "" +"O tipo ou nome do namespace \"{0}\" não existe no namespace \"{1}\". Você " +"não está esquecendo de uma referência do assembly?" + +#: mcs/mcs/namespace.cs:256 +#, csharp-format +msgid "The imported type `{0}' is defined multiple times" +msgstr "O tipo importado \"{0}\" é definido múltiplas vezes" + +#: mcs/mcs/namespace.cs:583 +#, csharp-format +msgid "" +"`{0}' is a type not a namespace. A using namespace directive can only be " +"applied to namespaces" +msgstr "" +"\"{0}\" é um tipo e não um namespace. Uma diretiva de namespace em uso pode " +"apenas ser aplicado a namespaces" + +#: mcs/mcs/namespace.cs:610 +#, csharp-format +msgid "The extern alias `{0}' was not specified in -reference option" +msgstr "O alias externo \"{0}\" não foi especificado na opção -reference" + +#: mcs/mcs/namespace.cs:820 mcs/mcs/namespace.cs:842 +msgid "" +"A using clause must precede all other namespace elements except extern alias " +"declarations" +msgstr "" +"Uma cláusula em uso deve preceder todos os outros elementos do namespace, " +"exceto declarações de alias externos" + +#: mcs/mcs/namespace.cs:866 +msgid "An extern alias declaration must precede all other elements" +msgstr "Um alias externo deve preceder todos os outros elementos" + +#: mcs/mcs/namespace.cs:884 +#, csharp-format +msgid "The using alias `{0}' appeared previously in this namespace" +msgstr "O alias em uso \"{0}\" apareceu antes neste namespace" + +#: mcs/mcs/namespace.cs:1005 +#, csharp-format +msgid "Namespace `{0}' contains a definition with same name as alias `{1}'" +msgstr "" +"O namespace \"{0}\" contém uma definição com o mesmo nome do alias \"{1}\"" + +#: mcs/mcs/namespace.cs:1059 +#, csharp-format +msgid "`{0}' is an ambiguous reference between `{1}' and `{2}'" +msgstr "\"{0}\" é uma referência ambígua entre \"{1}\" e \"{2}\"" + +#: mcs/mcs/namespace.cs:1127 +msgid "The global extern alias cannot be redefined" +msgstr "" + +#: mcs/mcs/namespace.cs:1132 +#, csharp-format +msgid "" +"The type or namespace name `{0}' could not be found. Are you missing a using " +"directive or an assembly reference?" +msgstr "" +"O tipo ou nome de namespace \"{0}\" não pôde ser encontrado. Você está " +"esquecendo de uma diretiva em uso ou uma referência do assembly?" + +#: mcs/mcs/nullable.cs:1036 +msgid "" +"An expression tree cannot contain a coalescing operator with null left side" +msgstr "" +"Uma árvore de expressão não pode conter um operador crescente com null no " +"lado esquerdo" + +#: mcs/mcs/parameter.cs:156 +msgid "The params parameter must be a single dimensional array" +msgstr "O parâmetro params deve ser um array de uma dimensão" + +#: mcs/mcs/parameter.cs:288 +msgid "An out parameter cannot have the `In' attribute" +msgstr "Um parâmetro externo não pode ter o atributo \"In\"" + +#: mcs/mcs/parameter.cs:293 +msgid "" +"Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead" +msgstr "" +"Não use \"System.ParamArrayAttribute\". Ao invés disso, use a palavra chave " +"\"params\"" + +#: mcs/mcs/parameter.cs:300 +msgid "" +"Cannot specify only `Out' attribute on a ref parameter. Use both `In' and " +"`Out' attributes or neither" +msgstr "" +"Não foi possível especificar somente o atributo \"Out\" em um parâmetro ref. " +"Utilize ambos os atributos \"In\" e \"Out\" ou nenhum" + +#: mcs/mcs/parameter.cs:310 +#, fuzzy, csharp-format +msgid "Cannot specify `{0}' attribute on optional parameter `{1}'" +msgstr "" +"Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " +"um indexador" + +#: mcs/mcs/parameter.cs:320 +#, fuzzy, csharp-format +msgid "" +"Argument of type `{0}' is not applicable for the DefaultParameterValue " +"attribute" +msgstr "Argumento do tipo \"{0}\" não é aplicável para o atributo DefaultValue" + +#: mcs/mcs/parameter.cs:323 +#, fuzzy, csharp-format +msgid "" +"The DefaultParameterValue attribute is not applicable on parameters of type `" +"{0}'" +msgstr "O atributo DefaultValue não é aplicável em parâmetros do tipo \"{0}\"" + +#: mcs/mcs/parameter.cs:334 +msgid "The type of the default value should match the type of the parameter" +msgstr "O tipo de valor padrão deve ter o mesmo tipo do parâmetro" + +#: mcs/mcs/parameter.cs:376 +#, csharp-format +msgid "Method or delegate parameter cannot be of type `{0}'" +msgstr "Método ou parâmetro delegate não pode ser do tipo \"{0}\"" + +#: mcs/mcs/parameter.cs:386 +#, csharp-format +msgid "`{0}': static types cannot be used as parameters" +msgstr "\"{0}\": tipos estáticos não podem ser utilizados como parâmetros" + +#: mcs/mcs/parameter.cs:392 +#, fuzzy, csharp-format +msgid "The extension method cannot be of type `{0}'" +msgstr "O tipo do método de extenção não pode ser \"{0}\"" + +#: mcs/mcs/parameter.cs:448 +#, fuzzy, csharp-format +msgid "" +"The expression being assigned to optional parameter `{0}' must be a constant " +"or default value" +msgstr "A expressão sendo atribuída a \"{0}\" deve ser constante" + +#: mcs/mcs/parameter.cs:464 +#, fuzzy, csharp-format +msgid "" +"The expression being assigned to nullable optional parameter `{0}' must be " +"default value" +msgstr "A expressão sendo atribuída a \"{0}\" deve ser constante" + +#: mcs/mcs/parameter.cs:472 +#, fuzzy, csharp-format +msgid "" +"Optional parameter `{0}' of type `{1}' can only be initialized with `null'" +msgstr "" +"A constante \"{0}\" do tipo de referência \"{1}\" só pode ser inicializada " +"com null" + +#: mcs/mcs/parameter.cs:482 +#, fuzzy, csharp-format +msgid "" +"Optional parameter expression of type `{0}' cannot be converted to parameter " +"type `{1}'" +msgstr "" +"Tipo de instância do método de extensão \"{0}\" não pode ser convertido para " +"\"{1}\"" + +#: mcs/mcs/parameter.cs:624 +msgid "An expression tree parameter cannot use `ref' or `out' modifier" +msgstr "" +"Um parâmetro de árvore de expressão não pode usar modificadores \"ref\" ou " +"\"out\"" + +#: mcs/mcs/parameter.cs:1096 +#, csharp-format +msgid "The parameter name `{0}' conflicts with a compiler generated name" +msgstr "" +"O nome do parâmetro \"{0}\" conflita com um nome gerado pelo compilador" + +#: mcs/mcs/pending.cs:443 +#, csharp-format +msgid "" +"`{0}' does not implement interface member `{1}' and the best implementing " +"candidate `{2}' is static" +msgstr "" +"O \"{0}\" não implementa o membro da interface \"{1}\" e o melhor candidato " +"a implementação \"{2}\" é estático" + +#: mcs/mcs/pending.cs:447 +#, csharp-format +msgid "" +"`{0}' does not implement interface member `{1}' and the best implementing " +"candidate `{2}' in not public" +msgstr "" +"O \"{0}\" não implementa o membro da interface \"{1}\" e o melhor candidato " +"a implementação \"{2}\" não é público" + +#: mcs/mcs/pending.cs:451 +#, csharp-format +msgid "" +"`{0}' does not implement interface member `{1}' and the best implementing " +"candidate `{2}' return type `{3}' does not match interface member return " +"type `{4}'" +msgstr "" +"O \"{0}\" não implementa o membro da interface \"{1}\" e o melhor candidato " +"a implementação \"{2}\" devolve o tipo \"{3}\" o que não é o mesmo tipo de " +"retorno \"{4}\" do membro da interface" + +#: mcs/mcs/pending.cs:456 +#, csharp-format +msgid "`{0}' does not implement interface member `{1}'" +msgstr "\"{0}\" não implementa o membro da interface \"{1}\"" + +#: mcs/mcs/pending.cs:461 +#, csharp-format +msgid "`{0}' does not implement inherited abstract member `{1}'" +msgstr "\"{0}\" não implementa o membro abstrato herdado \"{1}\"" + +#: mcs/mcs/property.cs:352 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers may not be used on accessors in an interface" +msgstr "" +"\"{0}\": modificadores de acessibilidade não devem ser utilizados em " +"acessores dentro de uma interface" + +#: mcs/mcs/property.cs:356 +#, csharp-format +msgid "`{0}': abstract properties cannot have private accessors" +msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" + +#: mcs/mcs/property.cs:401 +#, csharp-format +msgid "" +"The accessibility modifier of the `{0}' accessor must be more restrictive " +"than the modifier of the property or indexer `{1}'" +msgstr "" +"O modificador de acessibilidade do acessor \"{0}\" deve ser mais restritivo " +"que o modificador da propriedade ou indexador \"{1}\"" + +#: mcs/mcs/property.cs:502 +#, csharp-format +msgid "Explicit interface implementation `{0}' is missing accessor `{1}'" +msgstr "" +"Implementação explícita de interface \"{0}\" está faltando acessor \"{1}\"" + +#: mcs/mcs/property.cs:521 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable get " +"accessor" +msgstr "" +"\"{0}.get\": não foi possível sobrescrever porque \"{1}\" não possui um " +"acessor get que pode ser sobrescrito" + +#: mcs/mcs/property.cs:538 +#, fuzzy, csharp-format +msgid "" +"`{0}': cannot override because `{1}' does not have an overridable set " +"accessor" +msgstr "" +"\"{0}.set\": não foi possível substituir porque \"{1}\" não possui um " +"acessor set que pode ser sobrescrito" + +#: mcs/mcs/property.cs:579 +#, csharp-format +msgid "" +"`{0}': Cannot specify accessibility modifiers for both accessors of the " +"property or indexer" +msgstr "" +"\"{0}\": Não foi possível especificar modificadores de acessibilidade para " +"ambos os acessores de propriedade ou indexadores" + +#: mcs/mcs/property.cs:586 +#, csharp-format +msgid "" +"`{0}': accessibility modifiers on accessors may only be used if the property " +"or indexer has both a get and a set accessor" +msgstr "" +"\"{0}\": modificadores de acessibilidade em acessores devem apenas ser " +"utilizados se a propriedade ou indexador tiverem, ambas, um acessor get e set" + +#: mcs/mcs/property.cs:783 +#, csharp-format +msgid "" +"Automatically implemented property `{0}' cannot be used inside a type with " +"an explicit StructLayout attribute" +msgstr "" +"Propriedade implementada automaticamente \"{0}\" não pode ser utilizada " +"dentro de um tipo com um atributo StructLayout explícito" + +#: mcs/mcs/property.cs:1274 +#, csharp-format +msgid "`{0}': event must be of a delegate type" +msgstr "\"{0}\": evento deve ser de um tipo delegate" + +#: mcs/mcs/property.cs:1482 +#, fuzzy, csharp-format +msgid "" +"The `{0}' attribute is valid only on an indexer that is not an explicit " +"interface member declaration" +msgstr "" +"O atributo \"IndexerName\" é válido somente em um indexador que não seja uma " +"declaração explícita de um membro da interface" + +#: mcs/mcs/property.cs:1516 +msgid "Cannot set the `IndexerName' attribute on an indexer marked override" +msgstr "" +"Não foi possível definir o atributo \"IndexerName\" em um indexador marcado " +"como sobrescrito" + +#: mcs/mcs/reflection.cs:217 +msgid "Could not access the key inside the container `" +msgstr "Não foi possível acessar a chave dentro do tipo no qual está definido" + +#: mcs/mcs/roottypes.cs:363 +#, fuzzy +msgid "" +"The compilation may fail due to missing `System.Reflection.Emit." +"AssemblyBuilder.SetCorlibTypeBuilders(...)' method" +msgstr "" +"A compilação deve falhar devedo a um método \"{0}.SetCorlibTypeBuilders" +"({1})\"faltando" + +#: mcs/mcs/roottypes.cs:470 +#, fuzzy, csharp-format +msgid "Value specified for the argument to `{0}' is not valid" +msgstr "" +"Valor especificado para o argumento ao \"System.Runtime.InteropServices." +"DefaultCharSetAttribute\" não é válido" + +#: mcs/mcs/statement.cs:87 +msgid "" +"A lambda expression with statement body cannot be converted to an expresion " +"tree" +msgstr "" +"Uma expressão lambda com um corpo de declarações não pode ser convertida " +"para uma árvore de expressão" + +#: mcs/mcs/statement.cs:740 +#, csharp-format +msgid "" +"An object of a type convertible to `{0}' is required for the return statement" +msgstr "" + +#: mcs/mcs/statement.cs:753 +#, csharp-format +msgid "" +"`{0}': A return keyword must not be followed by any expression when method " +"returns void" +msgstr "" +"\"{0}\": Uma palavra chave return não deve ser seguida por nenhuma expressão " +"quando o método retornar void" + +#: mcs/mcs/statement.cs:778 +#, csharp-format +msgid "" +"Cannot convert `{0}' to delegate type `{1}' because some of the return types " +"in the block are not implicitly convertible to the delegate return type" +msgstr "" +"Não foi possível converter \"{0}\" para o tipo delegate \"{1}\" porque " +"alguns dos tipos de retorno no bloco não são implicitamente conversíveis no " +"tipo de retorno delegate" + +#: mcs/mcs/statement.cs:806 +msgid "" +"Cannot return a value from iterators. Use the yield return statement to " +"return a value, or yield break to end the iteration" +msgstr "" +"Não foi possível devolver um valor de iteradores. Use a declaração yield do " +"return para devolver um valor, ou yield break para terminar a iteração" + +#: mcs/mcs/statement.cs:963 mcs/mcs/statement.cs:997 +msgid "A goto case is only valid inside a switch statement" +msgstr "Um case do goto é válido somente dentro de uma declaração switch" + +#: mcs/mcs/statement.cs:1076 mcs/mcs/statement.cs:4726 +msgid "The type caught or thrown must be derived from System.Exception" +msgstr "" + +#: mcs/mcs/statement.cs:1298 +msgid "A fixed statement cannot use an implicitly typed local variable" +msgstr "" +"Uma declaração fixa não pode utilizar uma variável local tipada " +"implicitamente" + +#: mcs/mcs/statement.cs:1303 +msgid "An implicitly typed local variable cannot be a constant" +msgstr "Uma variável local implicitamente tipada não pode ser uma constante" + +#: mcs/mcs/statement.cs:1308 +msgid "" +"An implicitly typed local variable declarator must include an initializer" +msgstr "" +"Uma declaração de variável local tipada implicitamente deve incluir um " +"inicializador" + +#: mcs/mcs/statement.cs:1313 +msgid "" +"An implicitly typed local variable declaration cannot include multiple " +"declarators" +msgstr "" +"Uma declaração de variável local tipada implicitamente não pode incluir " +"múltiplos declaradores" + +#: mcs/mcs/statement.cs:1883 +#, csharp-format +msgid "" +"A local variable named `{0}' cannot be declared in this scope because it " +"would give a different meaning to `{0}', which is already used in a `{1}' " +"scope to denote something else" +msgstr "" +"Uma variável local nomeada \"{0}\" não pode ser declarada neste escopo pois " +"esta daria um significado distinto para \"{0}\", que já é usada em um escopo " +"\"{1}\" para denotar outra coisa" + +#: mcs/mcs/statement.cs:1894 +#, csharp-format +msgid "" +"`{0}': An anonymous type cannot have multiple properties with the same name" +msgstr "" +"\"{0}\": Um tipo anônimo não pode ter múltiplas propriedades com o mesmo nome" + +#: mcs/mcs/statement.cs:1897 +#, csharp-format +msgid "The parameter name `{0}' is a duplicate" +msgstr "O nome do parâmetro \"{0}\" é uma duplicata" + +#: mcs/mcs/statement.cs:1904 +#, csharp-format +msgid "A local variable named `{0}' is already defined in this scope" +msgstr "Uma variável local nomeada \"{0}\" já foi definida neste escopo" + +#: mcs/mcs/statement.cs:1910 +#, fuzzy, csharp-format +msgid "" +"The type parameter name `{0}' is the same as local variable or parameter name" +msgstr "O nome do tipo parâmetro \"{0}\" é o mesmo que \"{1}\"" + +#: mcs/mcs/statement.cs:2482 +#, csharp-format +msgid "" +"The out parameter `{0}' must be assigned to before control leaves the " +"current method" +msgstr "" +"O parâmetro externo \"{0}\" deve estar atribuída para antes que o controle " +"deixe o método atual" + +#: mcs/mcs/statement.cs:2573 +#, csharp-format +msgid "`{0}': not all code paths return a value" +msgstr "\"{0}\": nem todos caminhos de códigos devolvem um valor" + +#: mcs/mcs/statement.cs:2577 +#, csharp-format +msgid "Not all code paths return a value in anonymous method of type `{0}'" +msgstr "" +"Nem todos os caminhos de código devolvem um valor num método anônimo do tipo " +"\"{0}\"" + +#: mcs/mcs/statement.cs:2748 +#, csharp-format +msgid "The label `{0}' is a duplicate" +msgstr "O rótulo \"{0}\" é uma duplicata" + +#: mcs/mcs/statement.cs:2757 mcs/mcs/statement.cs:2768 +#, csharp-format +msgid "" +"The label `{0}' shadows another label by the same name in a contained scope" +msgstr "" +"O rótulo \"{0}\" esconde outro rótulo pelo mesmo nome em um escopo contido" + +#: mcs/mcs/statement.cs:3088 +#, csharp-format +msgid "The label `case {0}:' already occurs in this switch statement" +msgstr "O rótulo \"case {0}:\" já ocorre nesta declaração de switch" + +#: mcs/mcs/statement.cs:3629 +#, csharp-format +msgid "" +"A switch expression of type `{0}' cannot be converted to an integral type, " +"bool, char, string, enum or nullable type" +msgstr "" + +#: mcs/mcs/statement.cs:4114 +#, csharp-format +msgid "`{0}' is not a reference type as required by the lock statement" +msgstr "" +"\"{0}\" não é um tipo de referência como necessário para a declaração lock" + +#: mcs/mcs/statement.cs:4455 +msgid "The type of locals declared in a fixed statement must be a pointer type" +msgstr "" +"O tipo de locais declarados em uma declaração fixa devem ser tipos ponteiros" + +#: mcs/mcs/statement.cs:4471 +msgid "" +"The right hand side of a fixed statement assignment may not be a cast " +"expression" +msgstr "O lado direito de uma declaração fixa não deve ser uma expressão cast" + +#: mcs/mcs/statement.cs:4542 +msgid "" +"You cannot use the fixed statement to take the address of an already fixed " +"expression" +msgstr "" +"Você não pode usar a declaração fixa para pegar o endereço de uma expressão " +"já fixa" + +#: mcs/mcs/statement.cs:4856 +#, csharp-format +msgid "" +"A previous catch clause already catches all exceptions of this or a super " +"type `{0}'" +msgstr "" +"Uma cláusula catch anterior já pega todas as exceções do this ou um tipo " +"super \"{0}\"" + +#: mcs/mcs/statement.cs:5029 +#, csharp-format +msgid "" +"`{0}': type used in a using statement must be implicitly convertible to " +"`System.IDisposable'" +msgstr "" +"\"{0}\": tipo utilizado em uma declaração em uso deve ser implicitamente " +"conversível para \"System.IDisposable\"" + +#: mcs/mcs/statement.cs:5451 +#, csharp-format +msgid "" +"foreach statement requires that the return type `{0}' of `{1}' must have a " +"suitable public MoveNext method and public Current property" +msgstr "" +"declaração do foreach requer que o tipo de retorno \"{0}\" de \"{1}\" deve " +"ter um método apropriado público MoveNext e a propriedade pública Current" + +#: mcs/mcs/statement.cs:5490 +#, csharp-format +msgid "" +"foreach statement cannot operate on variables of type `{0}' because it " +"contains multiple implementation of `{1}'. Try casting to a specific " +"implementation" +msgstr "" +"declaração do foreach não pode operar em variáveis do tipo \"{0}\" pois " +"estas contém múltiplas implementações de \"{1}\". Tente um casting para uma " +"implementação específica" + +#: mcs/mcs/statement.cs:5509 +#, fuzzy, csharp-format +msgid "" +"foreach statement cannot operate on variables of type `{0}' because it does " +"not contain a definition for `{1}' or is inaccessible" +msgstr "" +"declaração do foreach não pode operar em variáveis do tipo \"{0}\" pois " +"estas não contém uma definição para \"GetEnumerator\" ou não estão acessíveis" + +#: mcs/mcs/statement.cs:5715 +msgid "Use of null is not valid in this context" +msgstr "Uso do null é inválido neste contexto" + +#: mcs/mcs/statement.cs:5725 +#, csharp-format +msgid "Foreach statement cannot operate on a `{0}'" +msgstr "Declaração do foreach não pode operar em um \"{0}\"" + +#: mcs/mcs/typemanager.cs:389 +#, csharp-format +msgid "The predefined type `{0}.{1}' is not defined or imported" +msgstr "O tipo predefinido \"{0}.{1}\" não está definido ou importado" + +#: mcs/mcs/typemanager.cs:395 +#, csharp-format +msgid "The predefined type `{0}.{1}' is not declared correctly" +msgstr "O tipo predefinido \"{0}.{1}\" não está declarado corretamente" + +#: mcs/mcs/typemanager.cs:574 +#, csharp-format +msgid "" +"The compiler required member `{0}.{1}{2}' could not be found or is " +"inaccessible" +msgstr "" +"O membro necessário para o compilador \"{0}.{1}{2}\" não pode ser encontrado " +"ou é inacessível" + +#: mcs/mcs/typemanager.cs:885 +#, csharp-format +msgid "" +"Cannot take the address of, get the size of, or declare a pointer to a " +"managed type `{0}'" +msgstr "" +"Não foi possível obter o acesso de, conseguir o tamanho de, ou declarar um " +"ponteiro para um tipo gerenciado \"{0}\"" + +#~ msgid "Can not use a type parameter in an attribute" +#~ msgstr "Não é possível usar um parâmetro de tipo em um atributo" + +#~ msgid "" +#~ "Added modules must be marked with the CLSCompliant attribute to match the " +#~ "assembly" +#~ msgstr "" +#~ "Módulos adicionados devem ser marcados com o atributo CLSCompliant para " +#~ "coincidir com o assembly" + +#~ msgid "" +#~ "`{0}': Any identifier with double underscores cannot be used when ISO " +#~ "language version mode is specified" +#~ msgstr "" +#~ "\"{0}\": Qualquer identificador com underline duplo não pode ser " +#~ "utilizado quando o modo de versão da linguagem ISO é especificado" + +#~ msgid "Cannot derive from `{0}' because it is a type parameter" +#~ msgstr "Não foi possível derivar de \"{0}\" por que é um parâmetro de tipo" + +#~ msgid "'{0}' in explicit interface declaration is not an interface" +#~ msgstr "\"{0}\" na declaração explicita da interface não é uma interface" + +#~ msgid "Do not override object.Finalize. Instead, provide a destructor" +#~ msgstr "" +#~ "Não sobrescreva objetos. Destrua-os. Ao invés disso, proporcione um " +#~ "destrutor" + +#~ msgid "Assembly generation failed -- Referenced assembly '" +#~ msgstr "Geração do assembly falhou -- assembly referenciado" + +#~ msgid "Could not use the specified key to strongname the assembly." +#~ msgstr "" +#~ "Não foi possível utilizar a chave especificada para dar o strongname ao " +#~ "assembly." + +#~ msgid "" +#~ "Could not find the symbol writer assembly (Mono.CompilerServices." +#~ "SymbolWriter.dll)" +#~ msgstr "" +#~ "Não foi possível encontrar o assembly do symbol writer (Mono." +#~ "CompilerServices.SymbolWriter.dll)" + +#~ msgid "Unexpected debug information initialization error `{0}'" +#~ msgstr "Erro de inicialização de informação de depuração inesperada \"{0}\"" + +#~ msgid "Couldn't delay-sign the assembly with the '" +#~ msgstr "Não foi possível fazer o delay-sign do assembly com o \"" + +#~ msgid "Could not write to file `" +#~ msgstr "Não foi possível escrever para o arquivo \"" + +#~ msgid "" +#~ "Option `{0}' overrides attribute `{1}' given in a source file or added " +#~ "module" +#~ msgstr "" +#~ "Opção \"{0}\" sobrescreve atributo \"{1}\" dado num código-fonte ou " +#~ "módulo adicionado" + +#~ msgid "" +#~ "Could not sign the assembly. ECMA key can only be used to delay-sign " +#~ "assemblies" +#~ msgstr "" +#~ "Não foi possível assinar o assembly. Chave ECMA pode apenas ser utilizada " +#~ "para assinar o adiamento do assembly" + +#~ msgid "Error during assembly signing. " +#~ msgstr "Erro durante a assinatura do assembly. " + +#~ msgid "Friend assembly reference `" +#~ msgstr "Referência amiga do assembly \"" + +#~ msgid "Invalid type specified as an argument for TypeForwardedTo attribute" +#~ msgstr "" +#~ "Tipo inválido especificado com um argumento para um atributo " +#~ "TypeForwardedTo" + +#~ msgid "A duplicate type forward of type `{0}'" +#~ msgstr "Um encaminhamento de tipo duplicado do tipo \"{0}\"" + +#~ msgid "Cannot forward type `{0}' because it is defined in this assembly" +#~ msgstr "" +#~ "Não foi possível encaminhar o tipo \"{0}\" porque este está definido " +#~ "neste assembly" + +#~ msgid "Cannot forward type `{0}' because it is a nested type" +#~ msgstr "Não foi possível encaminhar tipo \"{0}\" por que é um tipo aninhado" + +#~ msgid "Cannot forward generic type `{0}'" +#~ msgstr "Não foi possível encaminhar tipo genérico \"{0}\"" + +#~ msgid "Internal error: could not find delegate constructor!" +#~ msgstr "Erro interno: não foi possível encontrar o construtor do delegate!" + +#~ msgid "Internal error: could not find Invoke method!" +#~ msgstr "Erro interno: não foi possível encontrar o método Invoke!" + +#~ msgid "Compilation aborted in file `{0}', {1}" +#~ msgstr "Compilação abortada no arquivo \"{0}\", {1}" + +#~ msgid "cannot find metadata file `{0}'" +#~ msgstr "não foi possível encontrar arquivo de metadados \"{0}\"" + +#~ msgid "file `{0}' has invalid `{1}' metadata" +#~ msgstr "arquivo \"{0}\" possui metadados inválidos \"{1}\"" + +#~ msgid "" +#~ "Referenced file `{0}' is not an assembly. Consider using `-addmodule' " +#~ "option instead" +#~ msgstr "" +#~ "Arquivo referenciado \"{0}\" não é um assembly. Considere, ao invés " +#~ "disso, utilizar a opção \"-addmodule\"" + +#~ msgid "Compatibility: Use -warnaserror: option instead of --werror" +#~ msgstr "Compatibilidade: Utilize a opção -warnaserror: ao invés de --werror" + +#~ msgid "Couldn't run pkg-config: " +#~ msgstr "Não foi possível executar o pkg-config: " + +#~ msgid "Specified package did not return any information" +#~ msgstr "Pacote especificado não devolveu qualquer informação" + +#~ msgid "Error running pkg-config. Check the above output." +#~ msgstr "Erro executando pkg-config. Verifique a saída abaixo." + +#~ msgid "-recurse requires an argument" +#~ msgstr "-recurse requer um argumento" + +#~ msgid "-reference requires an argument" +#~ msgstr "-reference requer um argumento" + +#~ msgid " requires an argument" +#~ msgstr " requer um argumento" + +#~ msgid "/lib requires an argument" +#~ msgstr "/lib requer um argumento" + +#~ msgid "/nowarn requires an argument" +#~ msgstr "/nowarn requer um argumento" + +#~ msgid "Could not find `{0}' specified for Main method" +#~ msgstr "" +#~ "Não foi possível encontrar o \"{0}\" especificado para o método Main" + +#~ msgid "`{0}' specified for Main method must be a valid class or struct" +#~ msgstr "" +#~ "\"{0}\" especificado para o método Main deve ser uma classe válida ou " +#~ "struct" + +#~ msgid "`{0}' does not have a suitable static Main method" +#~ msgstr "\"{0}\" não possue um método Main estático apropriado" + +#~ msgid "" +#~ "Program `{0}' does not contain a static `Main' method suitable for an " +#~ "entry point" +#~ msgstr "" +#~ "Programa \"{0}\" não contém um método estático \"Main\" apropriado para " +#~ "um ponto de entrada" + +#~ msgid "Cannot specify -main if building a module or library" +#~ msgstr "" +#~ "Não é possível especificar -main se estiver compilando um módulo ou " +#~ "biblioteca" + +#~ msgid "Cannot link resource file when building a module" +#~ msgstr "" +#~ "Não é possível apontar arquivo de recursos quando estiver compilando um " +#~ "módulo" + +#~ msgid "Error reading resource file `{0}'" +#~ msgstr "Erro ao ler arquivo de recurso \"{0}\"" + +#~ msgid "Using the generic type `{0}' requires {1} type arguments" +#~ msgstr "Usar o tipo genérico \"{0}\" requer {1} argumentos de tipo" + +#~ msgid "`{0}' is a `{1}' but a `{2}' was expected" +#~ msgstr "\"{0}\" é um \"{1}\" mas um \"{2}\" era esperado" + +#~ msgid "The variable `{0}' cannot be used with type arguments" +#~ msgstr "A variável \"{0}\" não pode ser utilizada com argumentos de tipo" + +#~ msgid "The property `{0}' cannot be used with type arguments" +#~ msgstr "A propriedade \"{0}\" não pode ser utilizada com argumentos de tipo" + +#~ msgid "Method `" +#~ msgstr "Método \"" + +#~ msgid "Invoke cannot be called directly on a delegate" +#~ msgstr "Chamada não pode ser chamada diretamente em um delegate" + +#~ msgid "Using the generic method `{0}' requires `{1}' type argument(s)" +#~ msgstr "" +#~ "Utilizar o método genérico \"{0}\" requer o(s) argumento(s) de tipo " +#~ "\"{1}\"" + +#~ msgid "New invocation: Can not find a constructor for this argument list" +#~ msgstr "" +#~ "Nova chamada: Não foi possível achar um construtor para esta lista de " +#~ "argumentos" + +#~ msgid "" +#~ "Cannot apply indexing with [] to an expression of type `System.Array'" +#~ msgstr "" +#~ "Não foi possível aplicar a indexação com [] a uma expressão do tipo " +#~ "\"System.Array\"" + +#~ msgid "" +#~ "A property or indexer `{0}' may not be passed as an out or ref parameter" +#~ msgstr "" +#~ "Uma propriedade ou indexador \"{0}\" não devem ser passados como um " +#~ "parâmetro out ou ref" + +#~ msgid "" +#~ "The property or indexer `{0}' cannot be used in this context because it " +#~ "lacks a `{1}' accessor" +#~ msgstr "" +#~ "A propriedade ou o indexador \"{0}\" não pôde ser utilizado neste " +#~ "contexto porque faltam um acessor \"{1}\"" + +#~ msgid "" +#~ "The property or indexer `{0}' cannot be used in this context because a `" +#~ "{1}' accessor is inaccessible" +#~ msgstr "" +#~ "A propriedade ou o indexador \"{0}\" não podem ser utilizadas neste " +#~ "contexto porque um acessor \"{1}\" está inacessível" + +#~ msgid "Cannot find type `{0}'<...>" +#~ msgstr "Não foi possível encontrar o tipo \"{0}\"<...>" + +#~ msgid "The non-generic type `{0}' cannot be used with type arguments." +#~ msgstr "" +#~ "O tipo não genérico \"{0}\" não pode ser utilizado como tipo argumento." + +#~ msgid "" +#~ "The type `{0}' must be convertible to `{1}' in order to use it as " +#~ "parameter `{2}' in the generic type or method `{3}'" +#~ msgstr "" +#~ "O tipo \"{0}\" deve poder ser conversível para \"{1}\" para poder utilizá-" +#~ "lo como o parâmetro \"{2}\" no tipo genérico ou método \"{3}\"" + +#~ msgid "" +#~ "Type inference failed to infer type argument for `{0}' clause. Try " +#~ "specifying the type argument explicitly" +#~ msgstr "" +#~ "Inferência de tipo falhou para inferir o tipo do argumento da cláusula " +#~ "\"{0}\". Tente especificar o tipo de argumento explicitamente" + +#~ msgid "Source filenames `{0}' and `{1}' both refer to the same file: {2}" +#~ msgstr "" +#~ "Nomes de arquivos de código fonte \"{0}\" e \"{1}\" se referem ambos ao " +#~ "mesmo arquivo: {2}" + +#~ msgid "The modifier `" +#~ msgstr "O modificador \"" + +#~ msgid "An assembly `{0}' is used without being referenced" +#~ msgstr "Um assembly \"{0}\" é utilizado sem ser referenciado" + +#~ msgid "Using the generic type `{0}' requires `{1}' type argument(s)" +#~ msgstr "" +#~ "Utilizar o tipo genérico \"{0}\" requer o(s) argumento(s) de tipo \"{1}\"" + +#~ msgid "The non-generic {0} `{1}' cannot be used with the type arguments" +#~ msgstr "" +#~ "O não-genérico {0} \"{1}\" não pode ser utilizado com os argumentos de " +#~ "tipo" + +#~ msgid "You cannot redefine the global extern alias" +#~ msgstr "Você não pode redefinir o alias externo global" + +#~ msgid "" +#~ "Feature `{0}' is not available in Mono mcs1 compiler. Consider using the " +#~ "`gmcs' compiler instead" +#~ msgstr "" +#~ "O recurso \"{0}\" não está disponível no compilador Mono mcs1. Considere " +#~ "utilizar, ao invés deste, o compilador \"gmcs\"" + +#~ msgid "" +#~ "Feature `{0}' cannot be used because it is not part of the C# {1} " +#~ "language specification" +#~ msgstr "" +#~ "O recurso \"{0}\" não pode ser utilizado por que não faz parte da " +#~ "especificação da linguagem C# {1}" + +#~ msgid "" +#~ "Your .NET Runtime does not support `{0}'. Please use the latest Mono " +#~ "runtime instead." +#~ msgstr "" +#~ "Seu runtime do .NET não tem suporte a(o) \"{0}\". Por favor, utilize o " +#~ "runtime do Mono mais recente." + +#~ msgid "A value of an integral type or string expected for switch" +#~ msgstr "Um valor de um tipo integral ou string esperados para o switch" + +#~ msgid "Internal error: No Dispose method which takes 0 parameters." +#~ msgstr "Erro interno: Nenhum método Dispose que pegue 0 parâmetros." + +#~ msgid "" +#~ "Friend access was granted to `{0}', but the output assembly is named `" +#~ "{1}'. Try adding a reference to `{0}' or change the output assembly name " +#~ "to match it" +#~ msgstr "" +#~ "Acesso amigável foi permitido para \"{0}\", mas a saída do assembly é " +#~ "nomeada \"{1}\". Tente adicionar uma referência para \"{0}\" ou alterar " +#~ "a saída do assembly para igualar isso" + +#~ msgid "" +#~ "Struct member `{0}.{1}' of type `{2}' causes a cycle in the struct layout" +#~ msgstr "" +#~ "Membro da estrutura \"{0}.{1}\" do tipo \"{2}\" causa um ciclo no layout " +#~ "de structs" + +#~ msgid "" +#~ "Could not find the symbol writer assembly (Mono.CompilerServices." +#~ "SymbolWriter.dll). This is normally an installation problem. Please make " +#~ "sure to compile and install the mcs/class/Mono.CompilerServices." +#~ "SymbolWriter directory." +#~ msgstr "" +#~ "Não foi possível encontrar o símbolo escritor do assembly (Mono." +#~ "CompilerServices.SymbolWriter.dll). Isso é normalmente um problema de " +#~ "instalação. Por favor tenha certeza de compilar e instalar o diretório " +#~ "mcs/class/Mono.CompilerServices.SymbolWriter." From 4657d0ac34f235fd394a8962f58abaad67233b46 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 13:33:49 +0000 Subject: [PATCH 48/93] Build po files from cs-parser.jay and not cs-parser.cs --- po/mcs/POTFILES.in | 2 +- po/mcs/de.po | 272 ++++++++++++++++++++++----------------------- po/mcs/es.po | 272 ++++++++++++++++++++++----------------------- po/mcs/ja.po | 268 ++++++++++++++++++++++---------------------- po/mcs/mcs.pot | 264 +++++++++++++++++++++---------------------- po/mcs/pt_BR.po | 272 ++++++++++++++++++++++----------------------- 6 files changed, 675 insertions(+), 675 deletions(-) diff --git a/po/mcs/POTFILES.in b/po/mcs/POTFILES.in index 2a4baddf0ef6..87e67c3df592 100644 --- a/po/mcs/POTFILES.in +++ b/po/mcs/POTFILES.in @@ -3,7 +3,7 @@ mcs/mcs/anonymous.cs mcs/mcs/argument.cs mcs/mcs/assign.cs mcs/mcs/attribute.cs -mcs/mcs/cs-parser.cs +mcs/mcs/cs-parser.jay mcs/mcs/cs-tokenizer.cs mcs/mcs/cfold.cs mcs/mcs/class.cs diff --git a/po/mcs/de.po b/po/mcs/de.po index 278bc7892e0b..e037836fb067 100644 --- a/po/mcs/de.po +++ b/po/mcs/de.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"POT-Creation-Date: 2010-12-16 13:32+0000\n" "PO-Revision-Date: 2008-09-26 15:14+0100\n" "Last-Translator: Daniel Nauck \n" "Language-Team: http://www.mono-project.de\n" @@ -210,489 +210,489 @@ msgstr "" msgid "`{0}' is obsolete: `{1}'" msgstr "`{0}' ist veraltet: `{1}'" -#: mcs/mcs/cs-parser.cs:1646 -msgid "" -"A fixed size buffer field must have the array size specifier after the field " -"name" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 -msgid "Interfaces cannot contain fields or constants" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1952 -#, fuzzy -msgid "Interfaces cannot contain operators" -msgstr "" -"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " -"beinhalten" - -#: mcs/mcs/cs-parser.cs:1958 -#, fuzzy -msgid "Interfaces cannot contain contructors" -msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" - -#: mcs/mcs/cs-parser.cs:1964 -msgid "" -"Interfaces cannot declare classes, structs, interfaces, delegates, or " -"enumerations" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 -msgid "A const field requires a value to be provided" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3602 -msgid "" -"You must provide an initializer in a fixed or using statement declaration" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3884 +#: mcs/mcs/cs-parser.jay:474 msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: mcs/mcs/cs-parser.cs:3948 +#: mcs/mcs/cs-parser.jay:570 msgid "" "Namespace elements cannot be explicitly declared as private, protected or " "protected internal" msgstr "" -#: mcs/mcs/cs-parser.cs:3963 +#: mcs/mcs/cs-parser.jay:613 msgid "" "Assembly and module attributes must precede all other elements except using " "clauses and extern alias declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4080 +#: mcs/mcs/cs-parser.jay:752 msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: mcs/mcs/cs-parser.cs:4117 +#: mcs/mcs/cs-parser.jay:800 msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:4163 +#: mcs/mcs/cs-parser.jay:892 #, csharp-format msgid "" "Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: mcs/mcs/cs-parser.cs:4220 +#: mcs/mcs/cs-parser.jay:992 #, fuzzy, csharp-format msgid "The constant `{0}' cannot be marked static" msgstr "`{0}': Eine abstrakte Klasse darf nicht versiegelt oder statisch sein" -#: mcs/mcs/cs-parser.cs:4268 +#: mcs/mcs/cs-parser.jay:1047 mcs/mcs/cs-parser.jay:4787 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1066 msgid "Fields cannot have void type" msgstr "" -#: mcs/mcs/cs-parser.cs:4369 +#: mcs/mcs/cs-parser.jay:1116 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1211 #, fuzzy msgid "Value or constant expected" msgstr "Methodennamen erwartet" -#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 -#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 -#: mcs/mcs/cs-parser.cs:5427 +#: mcs/mcs/cs-parser.jay:1239 mcs/mcs/cs-parser.jay:1800 +#: mcs/mcs/cs-parser.jay:1848 mcs/mcs/cs-parser.jay:2433 +#: mcs/mcs/cs-parser.jay:2461 #, fuzzy, csharp-format msgid "`{0}': interface members cannot have a definition" msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" -#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +#: mcs/mcs/cs-parser.jay:1276 mcs/mcs/cs-parser.jay:1316 mcs/mcs/decl.cs:1373 msgid "Constraints are not allowed on non-generic declarations" msgstr "Einschränkungen sind nicht erlaubt für nicht generische Deklarationen" -#: mcs/mcs/cs-parser.cs:4429 +#: mcs/mcs/cs-parser.jay:1284 #, csharp-format msgid "" "`{0}': Cannot specify constraints for overrides and explicit interface " "implementation methods" msgstr "" -#: mcs/mcs/cs-parser.cs:4470 +#: mcs/mcs/cs-parser.jay:1335 msgid "" "A partial method cannot define access modifier or any of abstract, extern, " "new, override, sealed, or virtual modifiers" msgstr "" -#: mcs/mcs/cs-parser.cs:4476 +#: mcs/mcs/cs-parser.jay:1341 msgid "" "A partial method must be declared within a partial class or partial struct" msgstr "" -#: mcs/mcs/cs-parser.cs:4499 +#: mcs/mcs/cs-parser.jay:1365 #, csharp-format msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#: mcs/mcs/cs-parser.jay:1411 mcs/mcs/cs-parser.jay:1418 msgid "" "A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +#: mcs/mcs/cs-parser.jay:1427 mcs/mcs/cs-parser.jay:1433 msgid "" "An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4601 +#: mcs/mcs/cs-parser.jay:1471 msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4603 +#: mcs/mcs/cs-parser.jay:1473 msgid "Optional parameter cannot precede required parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:4625 +#: mcs/mcs/cs-parser.jay:1500 msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#: mcs/mcs/cs-parser.jay:1532 mcs/mcs/cs-parser.jay:1537 #, csharp-format msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4666 +#: mcs/mcs/cs-parser.jay:1548 msgid "Optional parameter is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4686 +#: mcs/mcs/cs-parser.jay:1578 msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4689 +#: mcs/mcs/cs-parser.jay:1581 msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4692 +#: mcs/mcs/cs-parser.jay:1584 msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:4739 +#: mcs/mcs/cs-parser.jay:1627 msgid "Cannot specify a default value for a parameter array" msgstr "" -#: mcs/mcs/cs-parser.cs:4756 +#: mcs/mcs/cs-parser.jay:1643 msgid "The `params' modifier is not allowed in current context" msgstr "" -#: mcs/mcs/cs-parser.cs:4764 +#: mcs/mcs/cs-parser.jay:1649 msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4766 +#: mcs/mcs/cs-parser.jay:1651 msgid "The params parameter cannot be declared as ref or out" msgstr "" -#: mcs/mcs/cs-parser.cs:4774 +#: mcs/mcs/cs-parser.jay:1664 msgid "__arglist is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4791 +#: mcs/mcs/cs-parser.jay:1683 #, fuzzy, csharp-format msgid "`{0}': property or indexer cannot have void type" msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: mcs/mcs/cs-parser.cs:4829 +#: mcs/mcs/cs-parser.jay:1724 #, csharp-format msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:4832 +#: mcs/mcs/cs-parser.jay:1727 msgid "Indexers must have at least one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4857 +#: mcs/mcs/cs-parser.jay:1760 #, fuzzy, csharp-format msgid "`{0}': property or indexer must have at least one accessor" msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: mcs/mcs/cs-parser.cs:4860 +#: mcs/mcs/cs-parser.jay:1763 msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: mcs/mcs/cs-parser.cs:4862 +#: mcs/mcs/cs-parser.jay:1765 #, fuzzy msgid "A get or set accessor expected" msgstr "Methodennamen erwartet" -#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +#: mcs/mcs/cs-parser.jay:1778 mcs/mcs/cs-parser.jay:1821 msgid "Property accessor already defined" msgstr "" -#: mcs/mcs/cs-parser.cs:5036 +#: mcs/mcs/cs-parser.jay:1931 mcs/mcs/cs-parser.jay:1935 +msgid "Interfaces cannot contain fields or constants" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1943 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "" +"`{0}': Statische Klassen können keine benutzerdefinierten Operatoren " +"beinhalten" + +#: mcs/mcs/cs-parser.jay:1947 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" + +#: mcs/mcs/cs-parser.jay:1951 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1992 msgid "User-defined operators cannot return void" msgstr "" -#: mcs/mcs/cs-parser.cs:5059 +#: mcs/mcs/cs-parser.jay:2020 msgid "Overloadable binary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5061 +#: mcs/mcs/cs-parser.jay:2022 #, csharp-format msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:5066 +#: mcs/mcs/cs-parser.jay:2027 #, csharp-format msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:5069 +#: mcs/mcs/cs-parser.jay:2030 msgid "Overloadable unary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5183 +#: mcs/mcs/cs-parser.jay:2177 msgid "Class, struct, or interface method must have a return type" msgstr "" -#: mcs/mcs/cs-parser.cs:5187 +#: mcs/mcs/cs-parser.jay:2181 #, fuzzy, csharp-format msgid "`{0}': static constructor cannot have an access modifier" msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: mcs/mcs/cs-parser.cs:5192 +#: mcs/mcs/cs-parser.jay:2186 #, fuzzy, csharp-format msgid "" "`{0}': static constructor cannot have an explicit `this' or `base' " "constructor call" msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: mcs/mcs/cs-parser.cs:5241 +#: mcs/mcs/cs-parser.jay:2249 msgid "Name of destructor must match name of class" msgstr "" -#: mcs/mcs/cs-parser.cs:5243 +#: mcs/mcs/cs-parser.jay:2251 #, fuzzy msgid "Only class types can contain destructor" msgstr "`{0}': Statische Klassen können keinen Destruktor enthalten" -#: mcs/mcs/cs-parser.cs:5265 +#: mcs/mcs/cs-parser.jay:2276 #, csharp-format msgid "" "`{0}': An explicit interface implementation of an event must use property " "syntax" msgstr "" -#: mcs/mcs/cs-parser.cs:5298 +#: mcs/mcs/cs-parser.jay:2308 msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5344 +#: mcs/mcs/cs-parser.jay:2377 #, fuzzy, csharp-format msgid "`{0}': event in interface cannot have an initializer" msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" -#: mcs/mcs/cs-parser.cs:5349 +#: mcs/mcs/cs-parser.jay:2382 #, fuzzy, csharp-format msgid "`{0}': abstract event cannot have an initializer" msgstr "`{0}': Instanzfeldinitialisierungen können nicht in Strukturen sein" -#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#: mcs/mcs/cs-parser.jay:2397 mcs/mcs/cs-parser.jay:2402 #, fuzzy, csharp-format msgid "`{0}': event property must have both add and remove accessors" msgstr "`{0}': Abstrakte Eigenschaften können keine privaten-Accessoren haben" -#: mcs/mcs/cs-parser.cs:5371 +#: mcs/mcs/cs-parser.jay:2407 msgid "An add or remove accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +#: mcs/mcs/cs-parser.jay:2416 mcs/mcs/cs-parser.jay:2444 msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:5436 +#: mcs/mcs/cs-parser.jay:2471 msgid "An add or remove accessor must have a body" msgstr "" -#: mcs/mcs/cs-parser.cs:5455 +#: mcs/mcs/cs-parser.jay:2493 #, fuzzy msgid "Enums cannot have type parameters" msgstr "`{0}' implementiert den Schnittstellenmember `{1}' nicht" -#: mcs/mcs/cs-parser.cs:5755 +#: mcs/mcs/cs-parser.jay:2824 #, fuzzy msgid "Type parameter declaration must be an identifier not a type" msgstr "Der Parameter für den ++ oder -- Operator muss der enthaltene Typ sein" -#: mcs/mcs/cs-parser.cs:5779 +#: mcs/mcs/cs-parser.jay:2875 msgid "Invalid parameter type `void'" msgstr "Ungültiger Parametertyp `void'" -#: mcs/mcs/cs-parser.cs:5825 +#: mcs/mcs/cs-parser.jay:2940 #, fuzzy, csharp-format msgid "Invalid base type `{0}'" msgstr "Ungültiger Parametertyp `void'" -#: mcs/mcs/cs-parser.cs:5984 +#: mcs/mcs/cs-parser.jay:3189 msgid "An element initializer cannot be empty" msgstr "" -#: mcs/mcs/cs-parser.cs:6015 +#: mcs/mcs/cs-parser.jay:3227 #, csharp-format msgid "Named argument `{0}' specified multiple times" msgstr "" -#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#: mcs/mcs/cs-parser.jay:3236 mcs/mcs/cs-parser.jay:3241 msgid "An argument is missing" msgstr "" -#: mcs/mcs/cs-parser.cs:6166 +#: mcs/mcs/cs-parser.jay:3410 msgid "Array creation must have array size or array initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:6183 +#: mcs/mcs/cs-parser.jay:3423 msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: mcs/mcs/cs-parser.cs:6256 +#: mcs/mcs/cs-parser.jay:3503 msgid "" "Invalid anonymous type member declarator. Anonymous type members must be a " "member assignment, simple name or member access expression" msgstr "" -#: mcs/mcs/cs-parser.cs:6658 +#: mcs/mcs/cs-parser.jay:4027 msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: mcs/mcs/cs-parser.cs:6799 +#: mcs/mcs/cs-parser.jay:4213 #, csharp-format msgid "Duplicate `{0}' modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:6803 +#: mcs/mcs/cs-parser.jay:4217 msgid "More than one protection modifier specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6816 +#: mcs/mcs/cs-parser.jay:4231 msgid "Keyword `new' is not allowed on namespace elements" msgstr "" -#: mcs/mcs/cs-parser.cs:6936 +#: mcs/mcs/cs-parser.jay:4338 #, csharp-format msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:6966 +#: mcs/mcs/cs-parser.jay:4368 #, fuzzy msgid "The `new()' constraint must be the last constraint specified" msgstr "" "Die `new()'-Einschränkung muss als letzte Einschränkung definiert werden" -#: mcs/mcs/cs-parser.cs:6972 +#: mcs/mcs/cs-parser.jay:4374 msgid "" "The `class' or `struct' constraint must be the first constraint specified" msgstr "" "Die `class'- oder `struct'-Einschränkung muss als erste Einschränkung " "definiert werden" -#: mcs/mcs/cs-parser.cs:6976 +#: mcs/mcs/cs-parser.jay:4378 msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" "Die `new()'-Einschränkung kann nicht mit der `struct'-Einschränkung genutzt " "werden" -#: mcs/mcs/cs-parser.cs:6989 +#: mcs/mcs/cs-parser.jay:4392 #, fuzzy, csharp-format msgid "Invalid constraint type `{0}'" msgstr "Ungültiger Parametertyp `void'" -#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +#: mcs/mcs/cs-parser.jay:4574 mcs/mcs/cs-parser.jay:4579 msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7213 +#: mcs/mcs/cs-parser.jay:4746 msgid "" "Syntax error, bad array declarator. To declare a managed array the rank " "specifier precedes the variable's identifier. To declare a fixed size buffer " "field, use the fixed keyword before the field type" msgstr "" -#: mcs/mcs/cs-parser.cs:7262 +#: mcs/mcs/cs-parser.jay:4826 msgid "A stackalloc expression requires [] after type" msgstr "" -#: mcs/mcs/cs-parser.cs:7468 +#: mcs/mcs/cs-parser.jay:5108 msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#: mcs/mcs/cs-parser.jay:5200 mcs/mcs/cs-parser.jay:5216 #, fuzzy msgid "; expected" msgstr "Methodennamen erwartet" -#: mcs/mcs/cs-parser.cs:7555 +#: mcs/mcs/cs-parser.jay:5202 msgid "Expression expected after yield return" msgstr "" -#: mcs/mcs/cs-parser.cs:7598 +#: mcs/mcs/cs-parser.jay:5249 msgid "Expected catch or finally" msgstr "" -#: mcs/mcs/cs-parser.cs:7618 +#: mcs/mcs/cs-parser.jay:5268 msgid "Try statement already has an empty catch block" msgstr "" -#: mcs/mcs/cs-parser.cs:7651 +#: mcs/mcs/cs-parser.jay:5313 msgid "" "A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11367 +#: mcs/mcs/cs-parser.jay:5421 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.jay:6009 msgid "Expecting `;'" msgstr "" -#: mcs/mcs/cs-parser.cs:11375 +#: mcs/mcs/cs-parser.jay:6017 #, csharp-format msgid "The parameter modifier `{0}' is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:11381 +#: mcs/mcs/cs-parser.jay:6023 #, csharp-format msgid "Duplicate parameter modifier `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11387 +#: mcs/mcs/cs-parser.jay:6029 #, fuzzy msgid "Type expected" msgstr "Methodennamen erwartet" -#: mcs/mcs/cs-parser.cs:11392 +#: mcs/mcs/cs-parser.jay:6034 msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: mcs/mcs/cs-parser.cs:11402 +#: mcs/mcs/cs-parser.jay:6044 msgid "Named arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:11493 +#: mcs/mcs/cs-parser.jay:6135 msgid "Syntax error, " msgstr "" -#: mcs/mcs/cs-parser.cs:11547 +#: mcs/mcs/cs-parser.jay:6189 msgid "Parsing error" msgstr "" -#: mcs/mcs/cs-parser.cs:11553 +#: mcs/mcs/cs-parser.jay:6195 msgid "Internal compiler error during parsing" msgstr "" -#: mcs/mcs/cs-parser.cs:11564 +#: mcs/mcs/cs-parser.jay:6206 #, csharp-format msgid "{0}: `{1}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11690 +#: mcs/mcs/cs-parser.jay:6332 #, csharp-format msgid "Identifier expected, `{0}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11704 +#: mcs/mcs/cs-parser.jay:6346 #, csharp-format msgid "{1} `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11706 +#: mcs/mcs/cs-parser.jay:6348 #, csharp-format msgid "{2} `{0}', expecting {1}" msgstr "" diff --git a/po/mcs/es.po b/po/mcs/es.po index 061393c9ba69..cb4741078999 100644 --- a/po/mcs/es.po +++ b/po/mcs/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: mono 2.1\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"POT-Creation-Date: 2010-12-16 13:32+0000\n" "PO-Revision-Date: 2008-09-19 13:28-0400\n" "Last-Translator: Miguel de Icaza \n" "Language-Team: es \n" @@ -238,255 +238,250 @@ msgstr "" msgid "`{0}' is obsolete: `{1}'" msgstr "" -#: mcs/mcs/cs-parser.cs:1646 -msgid "" -"A fixed size buffer field must have the array size specifier after the field " -"name" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 -msgid "Interfaces cannot contain fields or constants" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1952 -#, fuzzy -msgid "Interfaces cannot contain operators" -msgstr "" -"`{0}': las clases estáticas no pueden contener operadores definidos por el " -"usuario" - -#: mcs/mcs/cs-parser.cs:1958 -#, fuzzy -msgid "Interfaces cannot contain contructors" -msgstr "`{0}': las clases estáticas no pueden contener un destructor" - -#: mcs/mcs/cs-parser.cs:1964 -msgid "" -"Interfaces cannot declare classes, structs, interfaces, delegates, or " -"enumerations" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 -msgid "A const field requires a value to be provided" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3602 -msgid "" -"You must provide an initializer in a fixed or using statement declaration" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3884 +#: mcs/mcs/cs-parser.jay:474 msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: mcs/mcs/cs-parser.cs:3948 +#: mcs/mcs/cs-parser.jay:570 msgid "" "Namespace elements cannot be explicitly declared as private, protected or " "protected internal" msgstr "" -#: mcs/mcs/cs-parser.cs:3963 +#: mcs/mcs/cs-parser.jay:613 msgid "" "Assembly and module attributes must precede all other elements except using " "clauses and extern alias declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4080 +#: mcs/mcs/cs-parser.jay:752 msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: mcs/mcs/cs-parser.cs:4117 +#: mcs/mcs/cs-parser.jay:800 msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:4163 +#: mcs/mcs/cs-parser.jay:892 #, csharp-format msgid "" "Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: mcs/mcs/cs-parser.cs:4220 +#: mcs/mcs/cs-parser.jay:992 #, fuzzy, csharp-format msgid "The constant `{0}' cannot be marked static" msgstr "El método abstracto `{0} no puede ser marcado como virtual" -#: mcs/mcs/cs-parser.cs:4268 +#: mcs/mcs/cs-parser.jay:1047 mcs/mcs/cs-parser.jay:4787 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1066 msgid "Fields cannot have void type" msgstr "" -#: mcs/mcs/cs-parser.cs:4369 +#: mcs/mcs/cs-parser.jay:1116 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1211 msgid "Value or constant expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 -#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 -#: mcs/mcs/cs-parser.cs:5427 +#: mcs/mcs/cs-parser.jay:1239 mcs/mcs/cs-parser.jay:1800 +#: mcs/mcs/cs-parser.jay:1848 mcs/mcs/cs-parser.jay:2433 +#: mcs/mcs/cs-parser.jay:2461 #, fuzzy, csharp-format msgid "`{0}': interface members cannot have a definition" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +#: mcs/mcs/cs-parser.jay:1276 mcs/mcs/cs-parser.jay:1316 mcs/mcs/decl.cs:1373 msgid "Constraints are not allowed on non-generic declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4429 +#: mcs/mcs/cs-parser.jay:1284 #, csharp-format msgid "" "`{0}': Cannot specify constraints for overrides and explicit interface " "implementation methods" msgstr "" -#: mcs/mcs/cs-parser.cs:4470 +#: mcs/mcs/cs-parser.jay:1335 msgid "" "A partial method cannot define access modifier or any of abstract, extern, " "new, override, sealed, or virtual modifiers" msgstr "" -#: mcs/mcs/cs-parser.cs:4476 +#: mcs/mcs/cs-parser.jay:1341 msgid "" "A partial method must be declared within a partial class or partial struct" msgstr "" -#: mcs/mcs/cs-parser.cs:4499 +#: mcs/mcs/cs-parser.jay:1365 #, csharp-format msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#: mcs/mcs/cs-parser.jay:1411 mcs/mcs/cs-parser.jay:1418 msgid "" "A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +#: mcs/mcs/cs-parser.jay:1427 mcs/mcs/cs-parser.jay:1433 msgid "" "An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4601 +#: mcs/mcs/cs-parser.jay:1471 msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4603 +#: mcs/mcs/cs-parser.jay:1473 msgid "Optional parameter cannot precede required parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:4625 +#: mcs/mcs/cs-parser.jay:1500 msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#: mcs/mcs/cs-parser.jay:1532 mcs/mcs/cs-parser.jay:1537 #, fuzzy, csharp-format msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" "No puede especificar el atributo `DefaultMember' en un tipo que contiene un " "indexador" -#: mcs/mcs/cs-parser.cs:4666 +#: mcs/mcs/cs-parser.jay:1548 msgid "Optional parameter is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4686 +#: mcs/mcs/cs-parser.jay:1578 msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4689 +#: mcs/mcs/cs-parser.jay:1581 msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4692 +#: mcs/mcs/cs-parser.jay:1584 msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:4739 +#: mcs/mcs/cs-parser.jay:1627 #, fuzzy msgid "Cannot specify a default value for a parameter array" msgstr "" "No puede especificar el atributo `DefaultMember' en un tipo que contiene un " "indexador" -#: mcs/mcs/cs-parser.cs:4756 +#: mcs/mcs/cs-parser.jay:1643 #, fuzzy msgid "The `params' modifier is not allowed in current context" msgstr "" "La palabra reservada `new' no está permitida en los elementos de un espacio " "de nombres" -#: mcs/mcs/cs-parser.cs:4764 +#: mcs/mcs/cs-parser.jay:1649 msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4766 +#: mcs/mcs/cs-parser.jay:1651 #, fuzzy msgid "The params parameter cannot be declared as ref or out" msgstr "El método abstracto `{0} no puede ser marcado como virtual" -#: mcs/mcs/cs-parser.cs:4774 +#: mcs/mcs/cs-parser.jay:1664 msgid "__arglist is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4791 +#: mcs/mcs/cs-parser.jay:1683 #, fuzzy, csharp-format msgid "`{0}': property or indexer cannot have void type" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: mcs/mcs/cs-parser.cs:4829 +#: mcs/mcs/cs-parser.jay:1724 #, csharp-format msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:4832 +#: mcs/mcs/cs-parser.jay:1727 msgid "Indexers must have at least one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4857 +#: mcs/mcs/cs-parser.jay:1760 #, fuzzy, csharp-format msgid "`{0}': property or indexer must have at least one accessor" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: mcs/mcs/cs-parser.cs:4860 +#: mcs/mcs/cs-parser.jay:1763 msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: mcs/mcs/cs-parser.cs:4862 +#: mcs/mcs/cs-parser.jay:1765 msgid "A get or set accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +#: mcs/mcs/cs-parser.jay:1778 mcs/mcs/cs-parser.jay:1821 msgid "Property accessor already defined" msgstr "" -#: mcs/mcs/cs-parser.cs:5036 +#: mcs/mcs/cs-parser.jay:1931 mcs/mcs/cs-parser.jay:1935 +msgid "Interfaces cannot contain fields or constants" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1943 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "" +"`{0}': las clases estáticas no pueden contener operadores definidos por el " +"usuario" + +#: mcs/mcs/cs-parser.jay:1947 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': las clases estáticas no pueden contener un destructor" + +#: mcs/mcs/cs-parser.jay:1951 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1992 msgid "User-defined operators cannot return void" msgstr "" -#: mcs/mcs/cs-parser.cs:5059 +#: mcs/mcs/cs-parser.jay:2020 msgid "Overloadable binary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5061 +#: mcs/mcs/cs-parser.jay:2022 #, csharp-format msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:5066 +#: mcs/mcs/cs-parser.jay:2027 #, csharp-format msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:5069 +#: mcs/mcs/cs-parser.jay:2030 msgid "Overloadable unary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5183 +#: mcs/mcs/cs-parser.jay:2177 msgid "Class, struct, or interface method must have a return type" msgstr "El método debe tener un tipo de retorno" -#: mcs/mcs/cs-parser.cs:5187 +#: mcs/mcs/cs-parser.jay:2181 #, fuzzy, csharp-format msgid "`{0}': static constructor cannot have an access modifier" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: mcs/mcs/cs-parser.cs:5192 +#: mcs/mcs/cs-parser.jay:2186 #, fuzzy, csharp-format msgid "" "`{0}': static constructor cannot have an explicit `this' or `base' " @@ -494,16 +489,16 @@ msgid "" msgstr "" "`{0}': las clases estáticas no pueden tener constructores de instancias" -#: mcs/mcs/cs-parser.cs:5241 +#: mcs/mcs/cs-parser.jay:2249 msgid "Name of destructor must match name of class" msgstr "" -#: mcs/mcs/cs-parser.cs:5243 +#: mcs/mcs/cs-parser.jay:2251 #, fuzzy msgid "Only class types can contain destructor" msgstr "`{0}': las clases estáticas no pueden contener un destructor" -#: mcs/mcs/cs-parser.cs:5265 +#: mcs/mcs/cs-parser.jay:2276 #, fuzzy, csharp-format msgid "" "`{0}': An explicit interface implementation of an event must use property " @@ -512,223 +507,228 @@ msgstr "" "`{0}': las declaraciones explícitas de interfaces solamente pueden ser " "declaradas en una clase o estructura" -#: mcs/mcs/cs-parser.cs:5298 +#: mcs/mcs/cs-parser.jay:2308 msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5344 +#: mcs/mcs/cs-parser.jay:2377 #, fuzzy, csharp-format msgid "`{0}': event in interface cannot have an initializer" msgstr "" "`{0}': las estructuras no pueden tener inicializadores de campos en " "instancias" -#: mcs/mcs/cs-parser.cs:5349 +#: mcs/mcs/cs-parser.jay:2382 #, fuzzy, csharp-format msgid "`{0}': abstract event cannot have an initializer" msgstr "" "`{0}': las estructuras no pueden tener inicializadores de campos en " "instancias" -#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#: mcs/mcs/cs-parser.jay:2397 mcs/mcs/cs-parser.jay:2402 #, fuzzy, csharp-format msgid "`{0}': event property must have both add and remove accessors" msgstr "`{0}': los miembros virtuales o abstractos no pueden ser privados" -#: mcs/mcs/cs-parser.cs:5371 +#: mcs/mcs/cs-parser.jay:2407 msgid "An add or remove accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +#: mcs/mcs/cs-parser.jay:2416 mcs/mcs/cs-parser.jay:2444 msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:5436 +#: mcs/mcs/cs-parser.jay:2471 msgid "An add or remove accessor must have a body" msgstr "" -#: mcs/mcs/cs-parser.cs:5455 +#: mcs/mcs/cs-parser.jay:2493 #, fuzzy msgid "Enums cannot have type parameters" msgstr "`{0}': no es posible derivar de una clase estática (`{1}')" -#: mcs/mcs/cs-parser.cs:5755 +#: mcs/mcs/cs-parser.jay:2824 msgid "Type parameter declaration must be an identifier not a type" msgstr "" -#: mcs/mcs/cs-parser.cs:5779 +#: mcs/mcs/cs-parser.jay:2875 msgid "Invalid parameter type `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:5825 +#: mcs/mcs/cs-parser.jay:2940 #, csharp-format msgid "Invalid base type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:5984 +#: mcs/mcs/cs-parser.jay:3189 msgid "An element initializer cannot be empty" msgstr "" -#: mcs/mcs/cs-parser.cs:6015 +#: mcs/mcs/cs-parser.jay:3227 #, csharp-format msgid "Named argument `{0}' specified multiple times" msgstr "" -#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#: mcs/mcs/cs-parser.jay:3236 mcs/mcs/cs-parser.jay:3241 msgid "An argument is missing" msgstr "" -#: mcs/mcs/cs-parser.cs:6166 +#: mcs/mcs/cs-parser.jay:3410 msgid "Array creation must have array size or array initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:6183 +#: mcs/mcs/cs-parser.jay:3423 msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: mcs/mcs/cs-parser.cs:6256 +#: mcs/mcs/cs-parser.jay:3503 msgid "" "Invalid anonymous type member declarator. Anonymous type members must be a " "member assignment, simple name or member access expression" msgstr "" -#: mcs/mcs/cs-parser.cs:6658 +#: mcs/mcs/cs-parser.jay:4027 msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: mcs/mcs/cs-parser.cs:6799 +#: mcs/mcs/cs-parser.jay:4213 #, csharp-format msgid "Duplicate `{0}' modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:6803 +#: mcs/mcs/cs-parser.jay:4217 msgid "More than one protection modifier specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6816 +#: mcs/mcs/cs-parser.jay:4231 #, fuzzy msgid "Keyword `new' is not allowed on namespace elements" msgstr "" "La palabra reservada `new' no está permitida en los elementos de un espacio " "de nombres" -#: mcs/mcs/cs-parser.cs:6936 +#: mcs/mcs/cs-parser.jay:4338 #, csharp-format msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:6966 +#: mcs/mcs/cs-parser.jay:4368 msgid "The `new()' constraint must be the last constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6972 +#: mcs/mcs/cs-parser.jay:4374 msgid "" "The `class' or `struct' constraint must be the first constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6976 +#: mcs/mcs/cs-parser.jay:4378 msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" -#: mcs/mcs/cs-parser.cs:6989 +#: mcs/mcs/cs-parser.jay:4392 #, csharp-format msgid "Invalid constraint type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +#: mcs/mcs/cs-parser.jay:4574 mcs/mcs/cs-parser.jay:4579 msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7213 +#: mcs/mcs/cs-parser.jay:4746 msgid "" "Syntax error, bad array declarator. To declare a managed array the rank " "specifier precedes the variable's identifier. To declare a fixed size buffer " "field, use the fixed keyword before the field type" msgstr "" -#: mcs/mcs/cs-parser.cs:7262 +#: mcs/mcs/cs-parser.jay:4826 msgid "A stackalloc expression requires [] after type" msgstr "" -#: mcs/mcs/cs-parser.cs:7468 +#: mcs/mcs/cs-parser.jay:5108 msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#: mcs/mcs/cs-parser.jay:5200 mcs/mcs/cs-parser.jay:5216 msgid "; expected" msgstr "" -#: mcs/mcs/cs-parser.cs:7555 +#: mcs/mcs/cs-parser.jay:5202 msgid "Expression expected after yield return" msgstr "" -#: mcs/mcs/cs-parser.cs:7598 +#: mcs/mcs/cs-parser.jay:5249 msgid "Expected catch or finally" msgstr "" -#: mcs/mcs/cs-parser.cs:7618 +#: mcs/mcs/cs-parser.jay:5268 msgid "Try statement already has an empty catch block" msgstr "" -#: mcs/mcs/cs-parser.cs:7651 +#: mcs/mcs/cs-parser.jay:5313 msgid "" "A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11367 +#: mcs/mcs/cs-parser.jay:5421 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.jay:6009 msgid "Expecting `;'" msgstr "" -#: mcs/mcs/cs-parser.cs:11375 +#: mcs/mcs/cs-parser.jay:6017 #, fuzzy, csharp-format msgid "The parameter modifier `{0}' is not valid in this context" msgstr "El tipo predefinido `{0}.{1}' no está definido o no ha sido importado" -#: mcs/mcs/cs-parser.cs:11381 +#: mcs/mcs/cs-parser.jay:6023 #, csharp-format msgid "Duplicate parameter modifier `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11387 +#: mcs/mcs/cs-parser.jay:6029 msgid "Type expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11392 +#: mcs/mcs/cs-parser.jay:6034 msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: mcs/mcs/cs-parser.cs:11402 +#: mcs/mcs/cs-parser.jay:6044 msgid "Named arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:11493 +#: mcs/mcs/cs-parser.jay:6135 msgid "Syntax error, " msgstr "" -#: mcs/mcs/cs-parser.cs:11547 +#: mcs/mcs/cs-parser.jay:6189 msgid "Parsing error" msgstr "" -#: mcs/mcs/cs-parser.cs:11553 +#: mcs/mcs/cs-parser.jay:6195 msgid "Internal compiler error during parsing" msgstr "" -#: mcs/mcs/cs-parser.cs:11564 +#: mcs/mcs/cs-parser.jay:6206 #, csharp-format msgid "{0}: `{1}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11690 +#: mcs/mcs/cs-parser.jay:6332 #, fuzzy, csharp-format msgid "Identifier expected, `{0}' is a keyword" msgstr "Esperaba un identificador: {0}." -#: mcs/mcs/cs-parser.cs:11704 +#: mcs/mcs/cs-parser.jay:6346 #, csharp-format msgid "{1} `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11706 +#: mcs/mcs/cs-parser.jay:6348 #, csharp-format msgid "{2} `{0}', expecting {1}" msgstr "" diff --git a/po/mcs/ja.po b/po/mcs/ja.po index 1aff9dcb0d14..5ce6d97feef3 100644 --- a/po/mcs/ja.po +++ b/po/mcs/ja.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"POT-Creation-Date: 2010-12-16 13:32+0000\n" "PO-Revision-Date: \n" "Last-Translator: Atsushi Eno \n" "Language-Team: \n" @@ -229,263 +229,258 @@ msgstr "属性 `{0}' は複数回指定することができません" msgid "`{0}' is obsolete: `{1}'" msgstr "`{0}'は廃止されています: `{1}'" -#: mcs/mcs/cs-parser.cs:1646 -msgid "" -"A fixed size buffer field must have the array size specifier after the field " -"name" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 -msgid "Interfaces cannot contain fields or constants" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1952 -#, fuzzy -msgid "Interfaces cannot contain operators" -msgstr "`{0}': staticクラスにはユーザー定義の演算子を含むことはできません" - -#: mcs/mcs/cs-parser.cs:1958 -#, fuzzy -msgid "Interfaces cannot contain contructors" -msgstr "`{0}': staticクラスではデストラクタを定義できません" - -#: mcs/mcs/cs-parser.cs:1964 -msgid "" -"Interfaces cannot declare classes, structs, interfaces, delegates, or " -"enumerations" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 -msgid "A const field requires a value to be provided" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3602 -msgid "" -"You must provide an initializer in a fixed or using statement declaration" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3884 +#: mcs/mcs/cs-parser.jay:474 msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: mcs/mcs/cs-parser.cs:3948 +#: mcs/mcs/cs-parser.jay:570 msgid "" "Namespace elements cannot be explicitly declared as private, protected or " "protected internal" msgstr "" -#: mcs/mcs/cs-parser.cs:3963 +#: mcs/mcs/cs-parser.jay:613 msgid "" "Assembly and module attributes must precede all other elements except using " "clauses and extern alias declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4080 +#: mcs/mcs/cs-parser.jay:752 msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: mcs/mcs/cs-parser.cs:4117 +#: mcs/mcs/cs-parser.jay:800 msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:4163 +#: mcs/mcs/cs-parser.jay:892 #, csharp-format msgid "" "Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: mcs/mcs/cs-parser.cs:4220 +#: mcs/mcs/cs-parser.jay:992 #, fuzzy, csharp-format msgid "The constant `{0}' cannot be marked static" msgstr "abstractメソッド `{0}' はvirtualとすることはできません" -#: mcs/mcs/cs-parser.cs:4268 +#: mcs/mcs/cs-parser.jay:1047 mcs/mcs/cs-parser.jay:4787 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1066 msgid "Fields cannot have void type" msgstr "" -#: mcs/mcs/cs-parser.cs:4369 +#: mcs/mcs/cs-parser.jay:1116 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1211 msgid "Value or constant expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 -#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 -#: mcs/mcs/cs-parser.cs:5427 +#: mcs/mcs/cs-parser.jay:1239 mcs/mcs/cs-parser.jay:1800 +#: mcs/mcs/cs-parser.jay:1848 mcs/mcs/cs-parser.jay:2433 +#: mcs/mcs/cs-parser.jay:2461 #, fuzzy, csharp-format msgid "`{0}': interface members cannot have a definition" msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +#: mcs/mcs/cs-parser.jay:1276 mcs/mcs/cs-parser.jay:1316 mcs/mcs/decl.cs:1373 msgid "Constraints are not allowed on non-generic declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4429 +#: mcs/mcs/cs-parser.jay:1284 #, csharp-format msgid "" "`{0}': Cannot specify constraints for overrides and explicit interface " "implementation methods" msgstr "" -#: mcs/mcs/cs-parser.cs:4470 +#: mcs/mcs/cs-parser.jay:1335 msgid "" "A partial method cannot define access modifier or any of abstract, extern, " "new, override, sealed, or virtual modifiers" msgstr "" -#: mcs/mcs/cs-parser.cs:4476 +#: mcs/mcs/cs-parser.jay:1341 msgid "" "A partial method must be declared within a partial class or partial struct" msgstr "" -#: mcs/mcs/cs-parser.cs:4499 +#: mcs/mcs/cs-parser.jay:1365 #, csharp-format msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#: mcs/mcs/cs-parser.jay:1411 mcs/mcs/cs-parser.jay:1418 msgid "" "A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +#: mcs/mcs/cs-parser.jay:1427 mcs/mcs/cs-parser.jay:1433 msgid "" "An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4601 +#: mcs/mcs/cs-parser.jay:1471 msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4603 +#: mcs/mcs/cs-parser.jay:1473 msgid "Optional parameter cannot precede required parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:4625 +#: mcs/mcs/cs-parser.jay:1500 msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#: mcs/mcs/cs-parser.jay:1532 mcs/mcs/cs-parser.jay:1537 #, fuzzy, csharp-format msgid "Cannot specify a default value for the `{0}' parameter" msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" -#: mcs/mcs/cs-parser.cs:4666 +#: mcs/mcs/cs-parser.jay:1548 msgid "Optional parameter is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4686 +#: mcs/mcs/cs-parser.jay:1578 msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4689 +#: mcs/mcs/cs-parser.jay:1581 msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4692 +#: mcs/mcs/cs-parser.jay:1584 msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:4739 +#: mcs/mcs/cs-parser.jay:1627 #, fuzzy msgid "Cannot specify a default value for a parameter array" msgstr "インデクサを含む型には`DefaultMember'属性を指定できません" -#: mcs/mcs/cs-parser.cs:4756 +#: mcs/mcs/cs-parser.jay:1643 #, fuzzy msgid "The `params' modifier is not allowed in current context" msgstr "キーワード `new' は名前空間要素で認められていません" -#: mcs/mcs/cs-parser.cs:4764 +#: mcs/mcs/cs-parser.jay:1649 msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4766 +#: mcs/mcs/cs-parser.jay:1651 #, fuzzy msgid "The params parameter cannot be declared as ref or out" msgstr "abstractメソッド `{0}' はvirtualとすることはできません" -#: mcs/mcs/cs-parser.cs:4774 +#: mcs/mcs/cs-parser.jay:1664 msgid "__arglist is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4791 +#: mcs/mcs/cs-parser.jay:1683 #, fuzzy, csharp-format msgid "`{0}': property or indexer cannot have void type" msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: mcs/mcs/cs-parser.cs:4829 +#: mcs/mcs/cs-parser.jay:1724 #, csharp-format msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:4832 +#: mcs/mcs/cs-parser.jay:1727 msgid "Indexers must have at least one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4857 +#: mcs/mcs/cs-parser.jay:1760 #, fuzzy, csharp-format msgid "`{0}': property or indexer must have at least one accessor" msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: mcs/mcs/cs-parser.cs:4860 +#: mcs/mcs/cs-parser.jay:1763 msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: mcs/mcs/cs-parser.cs:4862 +#: mcs/mcs/cs-parser.jay:1765 msgid "A get or set accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +#: mcs/mcs/cs-parser.jay:1778 mcs/mcs/cs-parser.jay:1821 msgid "Property accessor already defined" msgstr "" -#: mcs/mcs/cs-parser.cs:5036 +#: mcs/mcs/cs-parser.jay:1931 mcs/mcs/cs-parser.jay:1935 +msgid "Interfaces cannot contain fields or constants" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1943 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "`{0}': staticクラスにはユーザー定義の演算子を含むことはできません" + +#: mcs/mcs/cs-parser.jay:1947 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "`{0}': staticクラスではデストラクタを定義できません" + +#: mcs/mcs/cs-parser.jay:1951 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1992 msgid "User-defined operators cannot return void" msgstr "" -#: mcs/mcs/cs-parser.cs:5059 +#: mcs/mcs/cs-parser.jay:2020 msgid "Overloadable binary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5061 +#: mcs/mcs/cs-parser.jay:2022 #, fuzzy, csharp-format msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "Conditionalメソッド `{0}' ではoutパラメータを指定できません" -#: mcs/mcs/cs-parser.cs:5066 +#: mcs/mcs/cs-parser.jay:2027 #, csharp-format msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:5069 +#: mcs/mcs/cs-parser.jay:2030 msgid "Overloadable unary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5183 +#: mcs/mcs/cs-parser.jay:2177 msgid "Class, struct, or interface method must have a return type" msgstr "クラス、構造体、インターフェースのメソッドには戻り値型が必要です" -#: mcs/mcs/cs-parser.cs:5187 +#: mcs/mcs/cs-parser.jay:2181 #, fuzzy, csharp-format msgid "`{0}': static constructor cannot have an access modifier" msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: mcs/mcs/cs-parser.cs:5192 +#: mcs/mcs/cs-parser.jay:2186 #, fuzzy, csharp-format msgid "" "`{0}': static constructor cannot have an explicit `this' or `base' " "constructor call" msgstr "`{0}': staticクラスではインスタンス コンストラクタを定義できません" -#: mcs/mcs/cs-parser.cs:5241 +#: mcs/mcs/cs-parser.jay:2249 msgid "Name of destructor must match name of class" msgstr "" -#: mcs/mcs/cs-parser.cs:5243 +#: mcs/mcs/cs-parser.jay:2251 #, fuzzy msgid "Only class types can contain destructor" msgstr "`{0}': staticクラスではデストラクタを定義できません" -#: mcs/mcs/cs-parser.cs:5265 +#: mcs/mcs/cs-parser.jay:2276 #, fuzzy, csharp-format msgid "" "`{0}': An explicit interface implementation of an event must use property " @@ -494,217 +489,222 @@ msgstr "" "明示的なインターフェースの宣言で記述された `{0}' は、インターフェースではあり" "ません" -#: mcs/mcs/cs-parser.cs:5298 +#: mcs/mcs/cs-parser.jay:2308 msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5344 +#: mcs/mcs/cs-parser.jay:2377 #, fuzzy, csharp-format msgid "`{0}': event in interface cannot have an initializer" msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" -#: mcs/mcs/cs-parser.cs:5349 +#: mcs/mcs/cs-parser.jay:2382 #, fuzzy, csharp-format msgid "`{0}': abstract event cannot have an initializer" msgstr "`{0}': 構造体ではインスタンス フィールドを初期化できません" -#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#: mcs/mcs/cs-parser.jay:2397 mcs/mcs/cs-parser.jay:2402 #, fuzzy, csharp-format msgid "`{0}': event property must have both add and remove accessors" msgstr "`{0}': virtualまたはabstractのメンバはprivateにはできません" -#: mcs/mcs/cs-parser.cs:5371 +#: mcs/mcs/cs-parser.jay:2407 msgid "An add or remove accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +#: mcs/mcs/cs-parser.jay:2416 mcs/mcs/cs-parser.jay:2444 msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:5436 +#: mcs/mcs/cs-parser.jay:2471 msgid "An add or remove accessor must have a body" msgstr "" -#: mcs/mcs/cs-parser.cs:5455 +#: mcs/mcs/cs-parser.jay:2493 #, fuzzy msgid "Enums cannot have type parameters" msgstr "`{0}': staticクラス '{1}' から派生することはできません" -#: mcs/mcs/cs-parser.cs:5755 +#: mcs/mcs/cs-parser.jay:2824 msgid "Type parameter declaration must be an identifier not a type" msgstr "" -#: mcs/mcs/cs-parser.cs:5779 +#: mcs/mcs/cs-parser.jay:2875 msgid "Invalid parameter type `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:5825 +#: mcs/mcs/cs-parser.jay:2940 #, csharp-format msgid "Invalid base type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:5984 +#: mcs/mcs/cs-parser.jay:3189 msgid "An element initializer cannot be empty" msgstr "" -#: mcs/mcs/cs-parser.cs:6015 +#: mcs/mcs/cs-parser.jay:3227 #, fuzzy, csharp-format msgid "Named argument `{0}' specified multiple times" msgstr "属性 `{0}' は複数回指定することができません" -#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#: mcs/mcs/cs-parser.jay:3236 mcs/mcs/cs-parser.jay:3241 msgid "An argument is missing" msgstr "" -#: mcs/mcs/cs-parser.cs:6166 +#: mcs/mcs/cs-parser.jay:3410 msgid "Array creation must have array size or array initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:6183 +#: mcs/mcs/cs-parser.jay:3423 msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: mcs/mcs/cs-parser.cs:6256 +#: mcs/mcs/cs-parser.jay:3503 msgid "" "Invalid anonymous type member declarator. Anonymous type members must be a " "member assignment, simple name or member access expression" msgstr "" -#: mcs/mcs/cs-parser.cs:6658 +#: mcs/mcs/cs-parser.jay:4027 msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: mcs/mcs/cs-parser.cs:6799 +#: mcs/mcs/cs-parser.jay:4213 #, csharp-format msgid "Duplicate `{0}' modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:6803 +#: mcs/mcs/cs-parser.jay:4217 msgid "More than one protection modifier specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6816 +#: mcs/mcs/cs-parser.jay:4231 #, fuzzy msgid "Keyword `new' is not allowed on namespace elements" msgstr "キーワード `new' は名前空間要素で認められていません" -#: mcs/mcs/cs-parser.cs:6936 +#: mcs/mcs/cs-parser.jay:4338 #, csharp-format msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:6966 +#: mcs/mcs/cs-parser.jay:4368 msgid "The `new()' constraint must be the last constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6972 +#: mcs/mcs/cs-parser.jay:4374 msgid "" "The `class' or `struct' constraint must be the first constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6976 +#: mcs/mcs/cs-parser.jay:4378 msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" -#: mcs/mcs/cs-parser.cs:6989 +#: mcs/mcs/cs-parser.jay:4392 #, csharp-format msgid "Invalid constraint type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +#: mcs/mcs/cs-parser.jay:4574 mcs/mcs/cs-parser.jay:4579 msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7213 +#: mcs/mcs/cs-parser.jay:4746 msgid "" "Syntax error, bad array declarator. To declare a managed array the rank " "specifier precedes the variable's identifier. To declare a fixed size buffer " "field, use the fixed keyword before the field type" msgstr "" -#: mcs/mcs/cs-parser.cs:7262 +#: mcs/mcs/cs-parser.jay:4826 msgid "A stackalloc expression requires [] after type" msgstr "" -#: mcs/mcs/cs-parser.cs:7468 +#: mcs/mcs/cs-parser.jay:5108 msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#: mcs/mcs/cs-parser.jay:5200 mcs/mcs/cs-parser.jay:5216 msgid "; expected" msgstr "" -#: mcs/mcs/cs-parser.cs:7555 +#: mcs/mcs/cs-parser.jay:5202 msgid "Expression expected after yield return" msgstr "" -#: mcs/mcs/cs-parser.cs:7598 +#: mcs/mcs/cs-parser.jay:5249 msgid "Expected catch or finally" msgstr "" -#: mcs/mcs/cs-parser.cs:7618 +#: mcs/mcs/cs-parser.jay:5268 msgid "Try statement already has an empty catch block" msgstr "" -#: mcs/mcs/cs-parser.cs:7651 +#: mcs/mcs/cs-parser.jay:5313 msgid "" "A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11367 +#: mcs/mcs/cs-parser.jay:5421 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.jay:6009 msgid "Expecting `;'" msgstr "" -#: mcs/mcs/cs-parser.cs:11375 +#: mcs/mcs/cs-parser.jay:6017 #, csharp-format msgid "The parameter modifier `{0}' is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:11381 +#: mcs/mcs/cs-parser.jay:6023 #, fuzzy, csharp-format msgid "Duplicate parameter modifier `{0}'" msgstr "属性の引数名 '{0}' が重複しています" -#: mcs/mcs/cs-parser.cs:11387 +#: mcs/mcs/cs-parser.jay:6029 msgid "Type expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11392 +#: mcs/mcs/cs-parser.jay:6034 msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: mcs/mcs/cs-parser.cs:11402 +#: mcs/mcs/cs-parser.jay:6044 msgid "Named arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:11493 +#: mcs/mcs/cs-parser.jay:6135 msgid "Syntax error, " msgstr "" -#: mcs/mcs/cs-parser.cs:11547 +#: mcs/mcs/cs-parser.jay:6189 msgid "Parsing error" msgstr "" -#: mcs/mcs/cs-parser.cs:11553 +#: mcs/mcs/cs-parser.jay:6195 msgid "Internal compiler error during parsing" msgstr "" -#: mcs/mcs/cs-parser.cs:11564 +#: mcs/mcs/cs-parser.jay:6206 #, csharp-format msgid "{0}: `{1}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11690 +#: mcs/mcs/cs-parser.jay:6332 #, fuzzy, csharp-format msgid "Identifier expected, `{0}' is a keyword" msgstr "識別子が必要です: {0}" -#: mcs/mcs/cs-parser.cs:11704 +#: mcs/mcs/cs-parser.jay:6346 #, csharp-format msgid "{1} `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11706 +#: mcs/mcs/cs-parser.jay:6348 #, csharp-format msgid "{2} `{0}', expecting {1}" msgstr "" diff --git a/po/mcs/mcs.pot b/po/mcs/mcs.pot index edf46e95c92a..3ca34d019596 100644 --- a/po/mcs/mcs.pot +++ b/po/mcs/mcs.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: mono 2.9\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"POT-Creation-Date: 2010-12-16 13:32+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -214,472 +214,472 @@ msgstr "" msgid "`{0}' is obsolete: `{1}'" msgstr "" -#: mcs/mcs/cs-parser.cs:1646 -msgid "" -"A fixed size buffer field must have the array size specifier after the field " -"name" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 -msgid "Interfaces cannot contain fields or constants" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1952 -msgid "Interfaces cannot contain operators" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1958 -msgid "Interfaces cannot contain contructors" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1964 -msgid "" -"Interfaces cannot declare classes, structs, interfaces, delegates, or " -"enumerations" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 -msgid "A const field requires a value to be provided" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3602 -msgid "" -"You must provide an initializer in a fixed or using statement declaration" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3884 +#: mcs/mcs/cs-parser.jay:474 msgid "A namespace declaration cannot have modifiers or attributes" msgstr "" -#: mcs/mcs/cs-parser.cs:3948 +#: mcs/mcs/cs-parser.jay:570 msgid "" "Namespace elements cannot be explicitly declared as private, protected or " "protected internal" msgstr "" -#: mcs/mcs/cs-parser.cs:3963 +#: mcs/mcs/cs-parser.jay:613 msgid "" "Assembly and module attributes must precede all other elements except using " "clauses and extern alias declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4080 +#: mcs/mcs/cs-parser.jay:752 msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: mcs/mcs/cs-parser.cs:4117 +#: mcs/mcs/cs-parser.jay:800 msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:4163 +#: mcs/mcs/cs-parser.jay:892 #, csharp-format msgid "" "Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: mcs/mcs/cs-parser.cs:4220 +#: mcs/mcs/cs-parser.jay:992 #, csharp-format msgid "The constant `{0}' cannot be marked static" msgstr "" -#: mcs/mcs/cs-parser.cs:4268 +#: mcs/mcs/cs-parser.jay:1047 mcs/mcs/cs-parser.jay:4787 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1066 msgid "Fields cannot have void type" msgstr "" -#: mcs/mcs/cs-parser.cs:4369 +#: mcs/mcs/cs-parser.jay:1116 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1211 msgid "Value or constant expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 -#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 -#: mcs/mcs/cs-parser.cs:5427 +#: mcs/mcs/cs-parser.jay:1239 mcs/mcs/cs-parser.jay:1800 +#: mcs/mcs/cs-parser.jay:1848 mcs/mcs/cs-parser.jay:2433 +#: mcs/mcs/cs-parser.jay:2461 #, csharp-format msgid "`{0}': interface members cannot have a definition" msgstr "" -#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +#: mcs/mcs/cs-parser.jay:1276 mcs/mcs/cs-parser.jay:1316 mcs/mcs/decl.cs:1373 msgid "Constraints are not allowed on non-generic declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:4429 +#: mcs/mcs/cs-parser.jay:1284 #, csharp-format msgid "" "`{0}': Cannot specify constraints for overrides and explicit interface " "implementation methods" msgstr "" -#: mcs/mcs/cs-parser.cs:4470 +#: mcs/mcs/cs-parser.jay:1335 msgid "" "A partial method cannot define access modifier or any of abstract, extern, " "new, override, sealed, or virtual modifiers" msgstr "" -#: mcs/mcs/cs-parser.cs:4476 +#: mcs/mcs/cs-parser.jay:1341 msgid "" "A partial method must be declared within a partial class or partial struct" msgstr "" -#: mcs/mcs/cs-parser.cs:4499 +#: mcs/mcs/cs-parser.jay:1365 #, csharp-format msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#: mcs/mcs/cs-parser.jay:1411 mcs/mcs/cs-parser.jay:1418 msgid "" "A params parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +#: mcs/mcs/cs-parser.jay:1427 mcs/mcs/cs-parser.jay:1433 msgid "" "An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4601 +#: mcs/mcs/cs-parser.jay:1471 msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4603 +#: mcs/mcs/cs-parser.jay:1473 msgid "Optional parameter cannot precede required parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:4625 +#: mcs/mcs/cs-parser.jay:1500 msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#: mcs/mcs/cs-parser.jay:1532 mcs/mcs/cs-parser.jay:1537 #, csharp-format msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4666 +#: mcs/mcs/cs-parser.jay:1548 msgid "Optional parameter is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4686 +#: mcs/mcs/cs-parser.jay:1578 msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4689 +#: mcs/mcs/cs-parser.jay:1581 msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4692 +#: mcs/mcs/cs-parser.jay:1584 msgid "A parameter cannot have specified more than one modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:4739 +#: mcs/mcs/cs-parser.jay:1627 msgid "Cannot specify a default value for a parameter array" msgstr "" -#: mcs/mcs/cs-parser.cs:4756 +#: mcs/mcs/cs-parser.jay:1643 msgid "The `params' modifier is not allowed in current context" msgstr "" -#: mcs/mcs/cs-parser.cs:4764 +#: mcs/mcs/cs-parser.jay:1649 msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4766 +#: mcs/mcs/cs-parser.jay:1651 msgid "The params parameter cannot be declared as ref or out" msgstr "" -#: mcs/mcs/cs-parser.cs:4774 +#: mcs/mcs/cs-parser.jay:1664 msgid "__arglist is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:4791 +#: mcs/mcs/cs-parser.jay:1683 #, csharp-format msgid "`{0}': property or indexer cannot have void type" msgstr "" -#: mcs/mcs/cs-parser.cs:4829 +#: mcs/mcs/cs-parser.jay:1724 #, csharp-format msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:4832 +#: mcs/mcs/cs-parser.jay:1727 msgid "Indexers must have at least one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4857 +#: mcs/mcs/cs-parser.jay:1760 #, csharp-format msgid "`{0}': property or indexer must have at least one accessor" msgstr "" -#: mcs/mcs/cs-parser.cs:4860 +#: mcs/mcs/cs-parser.jay:1763 msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: mcs/mcs/cs-parser.cs:4862 +#: mcs/mcs/cs-parser.jay:1765 msgid "A get or set accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +#: mcs/mcs/cs-parser.jay:1778 mcs/mcs/cs-parser.jay:1821 msgid "Property accessor already defined" msgstr "" -#: mcs/mcs/cs-parser.cs:5036 +#: mcs/mcs/cs-parser.jay:1931 mcs/mcs/cs-parser.jay:1935 +msgid "Interfaces cannot contain fields or constants" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1943 +msgid "Interfaces cannot contain operators" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1947 +msgid "Interfaces cannot contain contructors" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1951 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1992 msgid "User-defined operators cannot return void" msgstr "" -#: mcs/mcs/cs-parser.cs:5059 +#: mcs/mcs/cs-parser.jay:2020 msgid "Overloadable binary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5061 +#: mcs/mcs/cs-parser.jay:2022 #, csharp-format msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:5066 +#: mcs/mcs/cs-parser.jay:2027 #, csharp-format msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:5069 +#: mcs/mcs/cs-parser.jay:2030 msgid "Overloadable unary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5183 +#: mcs/mcs/cs-parser.jay:2177 msgid "Class, struct, or interface method must have a return type" msgstr "" -#: mcs/mcs/cs-parser.cs:5187 +#: mcs/mcs/cs-parser.jay:2181 #, csharp-format msgid "`{0}': static constructor cannot have an access modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:5192 +#: mcs/mcs/cs-parser.jay:2186 #, csharp-format msgid "" "`{0}': static constructor cannot have an explicit `this' or `base' " "constructor call" msgstr "" -#: mcs/mcs/cs-parser.cs:5241 +#: mcs/mcs/cs-parser.jay:2249 msgid "Name of destructor must match name of class" msgstr "" -#: mcs/mcs/cs-parser.cs:5243 +#: mcs/mcs/cs-parser.jay:2251 msgid "Only class types can contain destructor" msgstr "" -#: mcs/mcs/cs-parser.cs:5265 +#: mcs/mcs/cs-parser.jay:2276 #, csharp-format msgid "" "`{0}': An explicit interface implementation of an event must use property " "syntax" msgstr "" -#: mcs/mcs/cs-parser.cs:5298 +#: mcs/mcs/cs-parser.jay:2308 msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5344 +#: mcs/mcs/cs-parser.jay:2377 #, csharp-format msgid "`{0}': event in interface cannot have an initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:5349 +#: mcs/mcs/cs-parser.jay:2382 #, csharp-format msgid "`{0}': abstract event cannot have an initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#: mcs/mcs/cs-parser.jay:2397 mcs/mcs/cs-parser.jay:2402 #, csharp-format msgid "`{0}': event property must have both add and remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5371 +#: mcs/mcs/cs-parser.jay:2407 msgid "An add or remove accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +#: mcs/mcs/cs-parser.jay:2416 mcs/mcs/cs-parser.jay:2444 msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:5436 +#: mcs/mcs/cs-parser.jay:2471 msgid "An add or remove accessor must have a body" msgstr "" -#: mcs/mcs/cs-parser.cs:5455 +#: mcs/mcs/cs-parser.jay:2493 msgid "Enums cannot have type parameters" msgstr "" -#: mcs/mcs/cs-parser.cs:5755 +#: mcs/mcs/cs-parser.jay:2824 msgid "Type parameter declaration must be an identifier not a type" msgstr "" -#: mcs/mcs/cs-parser.cs:5779 +#: mcs/mcs/cs-parser.jay:2875 msgid "Invalid parameter type `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:5825 +#: mcs/mcs/cs-parser.jay:2940 #, csharp-format msgid "Invalid base type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:5984 +#: mcs/mcs/cs-parser.jay:3189 msgid "An element initializer cannot be empty" msgstr "" -#: mcs/mcs/cs-parser.cs:6015 +#: mcs/mcs/cs-parser.jay:3227 #, csharp-format msgid "Named argument `{0}' specified multiple times" msgstr "" -#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#: mcs/mcs/cs-parser.jay:3236 mcs/mcs/cs-parser.jay:3241 msgid "An argument is missing" msgstr "" -#: mcs/mcs/cs-parser.cs:6166 +#: mcs/mcs/cs-parser.jay:3410 msgid "Array creation must have array size or array initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:6183 +#: mcs/mcs/cs-parser.jay:3423 msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: mcs/mcs/cs-parser.cs:6256 +#: mcs/mcs/cs-parser.jay:3503 msgid "" "Invalid anonymous type member declarator. Anonymous type members must be a " "member assignment, simple name or member access expression" msgstr "" -#: mcs/mcs/cs-parser.cs:6658 +#: mcs/mcs/cs-parser.jay:4027 msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: mcs/mcs/cs-parser.cs:6799 +#: mcs/mcs/cs-parser.jay:4213 #, csharp-format msgid "Duplicate `{0}' modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:6803 +#: mcs/mcs/cs-parser.jay:4217 msgid "More than one protection modifier specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6816 +#: mcs/mcs/cs-parser.jay:4231 msgid "Keyword `new' is not allowed on namespace elements" msgstr "" -#: mcs/mcs/cs-parser.cs:6936 +#: mcs/mcs/cs-parser.jay:4338 #, csharp-format msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:6966 +#: mcs/mcs/cs-parser.jay:4368 msgid "The `new()' constraint must be the last constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6972 +#: mcs/mcs/cs-parser.jay:4374 msgid "" "The `class' or `struct' constraint must be the first constraint specified" msgstr "" -#: mcs/mcs/cs-parser.cs:6976 +#: mcs/mcs/cs-parser.jay:4378 msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" -#: mcs/mcs/cs-parser.cs:6989 +#: mcs/mcs/cs-parser.jay:4392 #, csharp-format msgid "Invalid constraint type `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +#: mcs/mcs/cs-parser.jay:4574 mcs/mcs/cs-parser.jay:4579 msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7213 +#: mcs/mcs/cs-parser.jay:4746 msgid "" "Syntax error, bad array declarator. To declare a managed array the rank " "specifier precedes the variable's identifier. To declare a fixed size buffer " "field, use the fixed keyword before the field type" msgstr "" -#: mcs/mcs/cs-parser.cs:7262 +#: mcs/mcs/cs-parser.jay:4826 msgid "A stackalloc expression requires [] after type" msgstr "" -#: mcs/mcs/cs-parser.cs:7468 +#: mcs/mcs/cs-parser.jay:5108 msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#: mcs/mcs/cs-parser.jay:5200 mcs/mcs/cs-parser.jay:5216 msgid "; expected" msgstr "" -#: mcs/mcs/cs-parser.cs:7555 +#: mcs/mcs/cs-parser.jay:5202 msgid "Expression expected after yield return" msgstr "" -#: mcs/mcs/cs-parser.cs:7598 +#: mcs/mcs/cs-parser.jay:5249 msgid "Expected catch or finally" msgstr "" -#: mcs/mcs/cs-parser.cs:7618 +#: mcs/mcs/cs-parser.jay:5268 msgid "Try statement already has an empty catch block" msgstr "" -#: mcs/mcs/cs-parser.cs:7651 +#: mcs/mcs/cs-parser.jay:5313 msgid "" "A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11367 +#: mcs/mcs/cs-parser.jay:5421 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.jay:6009 msgid "Expecting `;'" msgstr "" -#: mcs/mcs/cs-parser.cs:11375 +#: mcs/mcs/cs-parser.jay:6017 #, csharp-format msgid "The parameter modifier `{0}' is not valid in this context" msgstr "" -#: mcs/mcs/cs-parser.cs:11381 +#: mcs/mcs/cs-parser.jay:6023 #, csharp-format msgid "Duplicate parameter modifier `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11387 +#: mcs/mcs/cs-parser.jay:6029 msgid "Type expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11392 +#: mcs/mcs/cs-parser.jay:6034 msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" -#: mcs/mcs/cs-parser.cs:11402 +#: mcs/mcs/cs-parser.jay:6044 msgid "Named arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:11493 +#: mcs/mcs/cs-parser.jay:6135 msgid "Syntax error, " msgstr "" -#: mcs/mcs/cs-parser.cs:11547 +#: mcs/mcs/cs-parser.jay:6189 msgid "Parsing error" msgstr "" -#: mcs/mcs/cs-parser.cs:11553 +#: mcs/mcs/cs-parser.jay:6195 msgid "Internal compiler error during parsing" msgstr "" -#: mcs/mcs/cs-parser.cs:11564 +#: mcs/mcs/cs-parser.jay:6206 #, csharp-format msgid "{0}: `{1}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11690 +#: mcs/mcs/cs-parser.jay:6332 #, csharp-format msgid "Identifier expected, `{0}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11704 +#: mcs/mcs/cs-parser.jay:6346 #, csharp-format msgid "{1} `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11706 +#: mcs/mcs/cs-parser.jay:6348 #, csharp-format msgid "{2} `{0}', expecting {1}" msgstr "" diff --git a/po/mcs/pt_BR.po b/po/mcs/pt_BR.po index fdf170f521c9..c56316ff9d8f 100644 --- a/po/mcs/pt_BR.po +++ b/po/mcs/pt_BR.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: mono 2.1\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2010-12-16 13:01+0000\n" +"POT-Creation-Date: 2010-12-16 13:32+0000\n" "PO-Revision-Date: 2009-03-01 07:52-0300\n" "Last-Translator: Rodrigo Luiz Marques Flores \n" "Language-Team: pt-BR \n" @@ -255,55 +255,18 @@ msgstr "O atributo \"{0}\" não pode ser aplicado múltiplas vezes" msgid "`{0}' is obsolete: `{1}'" msgstr "\"{0}\" é obsoleto: \"{1}\"" -#: mcs/mcs/cs-parser.cs:1646 -msgid "" -"A fixed size buffer field must have the array size specifier after the field " -"name" -msgstr "" - -#: mcs/mcs/cs-parser.cs:1940 mcs/mcs/cs-parser.cs:1946 -#, fuzzy -msgid "Interfaces cannot contain fields or constants" -msgstr "Structs não podem conter construtores explícitos sem parâmetros" - -#: mcs/mcs/cs-parser.cs:1952 -#, fuzzy -msgid "Interfaces cannot contain operators" -msgstr "" -"\"{0}\": Classes estáticas não podem conter operadores definidos pelo usuário" - -#: mcs/mcs/cs-parser.cs:1958 -#, fuzzy -msgid "Interfaces cannot contain contructors" -msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" - -#: mcs/mcs/cs-parser.cs:1964 -msgid "" -"Interfaces cannot declare classes, structs, interfaces, delegates, or " -"enumerations" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3341 mcs/mcs/cs-parser.cs:4257 -msgid "A const field requires a value to be provided" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3602 -msgid "" -"You must provide an initializer in a fixed or using statement declaration" -msgstr "" - -#: mcs/mcs/cs-parser.cs:3884 +#: mcs/mcs/cs-parser.jay:474 #, fuzzy msgid "A namespace declaration cannot have modifiers or attributes" msgstr "Um parâmetro externo não pode ter o atributo \"In\"" -#: mcs/mcs/cs-parser.cs:3948 +#: mcs/mcs/cs-parser.jay:570 msgid "" "Namespace elements cannot be explicitly declared as private, protected or " "protected internal" msgstr "" -#: mcs/mcs/cs-parser.cs:3963 +#: mcs/mcs/cs-parser.jay:613 #, fuzzy msgid "" "Assembly and module attributes must precede all other elements except using " @@ -312,47 +275,57 @@ msgstr "" "Uma cláusula em uso deve preceder todos os outros elementos do namespace, " "exceto declarações de alias externos" -#: mcs/mcs/cs-parser.cs:4080 +#: mcs/mcs/cs-parser.jay:752 msgid "'<' unexpected: attributes cannot be generic" msgstr "" -#: mcs/mcs/cs-parser.cs:4117 +#: mcs/mcs/cs-parser.jay:800 msgid "Named attribute arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:4163 +#: mcs/mcs/cs-parser.jay:892 #, csharp-format msgid "" "Unexpected symbol `{0}' in class, struct, or interface member declaration" msgstr "" -#: mcs/mcs/cs-parser.cs:4220 +#: mcs/mcs/cs-parser.jay:992 #, fuzzy, csharp-format msgid "The constant `{0}' cannot be marked static" msgstr "O método abstrato \"{0}\" não pode ser marcado como virtual" -#: mcs/mcs/cs-parser.cs:4268 +#: mcs/mcs/cs-parser.jay:1047 mcs/mcs/cs-parser.jay:4787 +msgid "A const field requires a value to be provided" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1066 #, fuzzy msgid "Fields cannot have void type" msgstr "Campo ou propriedade não podem ser do tipo \"{0}\"" -#: mcs/mcs/cs-parser.cs:4369 +#: mcs/mcs/cs-parser.jay:1116 +msgid "" +"A fixed size buffer field must have the array size specifier after the field " +"name" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1211 #, fuzzy msgid "Value or constant expected" msgstr "Um valor constante é esperado" -#: mcs/mcs/cs-parser.cs:4396 mcs/mcs/cs-parser.cs:4898 -#: mcs/mcs/cs-parser.cs:4947 mcs/mcs/cs-parser.cs:5398 -#: mcs/mcs/cs-parser.cs:5427 +#: mcs/mcs/cs-parser.jay:1239 mcs/mcs/cs-parser.jay:1800 +#: mcs/mcs/cs-parser.jay:1848 mcs/mcs/cs-parser.jay:2433 +#: mcs/mcs/cs-parser.jay:2461 #, fuzzy, csharp-format msgid "`{0}': interface members cannot have a definition" msgstr "\"{0}\": evento abstrato não pode ter um inicializador" -#: mcs/mcs/cs-parser.cs:4421 mcs/mcs/cs-parser.cs:4451 mcs/mcs/decl.cs:1373 +#: mcs/mcs/cs-parser.jay:1276 mcs/mcs/cs-parser.jay:1316 mcs/mcs/decl.cs:1373 msgid "Constraints are not allowed on non-generic declarations" msgstr "Restrições não são permitidas em declarações não genéricas" -#: mcs/mcs/cs-parser.cs:4429 +#: mcs/mcs/cs-parser.jay:1284 #, fuzzy, csharp-format msgid "" "`{0}': Cannot specify constraints for overrides and explicit interface " @@ -361,182 +334,204 @@ msgstr "" "\"{0}\": Não foi possível especificar restrições para sobrescritos ou " "métodos de implementação explícitos de interface" -#: mcs/mcs/cs-parser.cs:4470 +#: mcs/mcs/cs-parser.jay:1335 msgid "" "A partial method cannot define access modifier or any of abstract, extern, " "new, override, sealed, or virtual modifiers" msgstr "" -#: mcs/mcs/cs-parser.cs:4476 +#: mcs/mcs/cs-parser.jay:1341 msgid "" "A partial method must be declared within a partial class or partial struct" msgstr "" -#: mcs/mcs/cs-parser.cs:4499 +#: mcs/mcs/cs-parser.jay:1365 #, csharp-format msgid "Member modifier `{0}' must precede the member type and name" msgstr "" -#: mcs/mcs/cs-parser.cs:4540 mcs/mcs/cs-parser.cs:4549 +#: mcs/mcs/cs-parser.jay:1411 mcs/mcs/cs-parser.jay:1418 #, fuzzy msgid "" "A params parameter must be the last parameter in a formal parameter list" msgstr "O parâmetro params deve ser um array de uma dimensão" -#: mcs/mcs/cs-parser.cs:4560 mcs/mcs/cs-parser.cs:4568 +#: mcs/mcs/cs-parser.jay:1427 mcs/mcs/cs-parser.jay:1433 msgid "" "An __arglist parameter must be the last parameter in a formal parameter list" msgstr "" -#: mcs/mcs/cs-parser.cs:4601 +#: mcs/mcs/cs-parser.jay:1471 msgid "The parameter modifier `this' can only be used on the first parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4603 +#: mcs/mcs/cs-parser.jay:1473 #, fuzzy msgid "Optional parameter cannot precede required parameters" msgstr "Iteradores não podem ter parâmetros ref ou out" -#: mcs/mcs/cs-parser.cs:4625 +#: mcs/mcs/cs-parser.jay:1500 msgid "Array type specifier, [], must appear before parameter name" msgstr "" -#: mcs/mcs/cs-parser.cs:4650 mcs/mcs/cs-parser.cs:4655 +#: mcs/mcs/cs-parser.jay:1532 mcs/mcs/cs-parser.jay:1537 #, fuzzy, csharp-format msgid "Cannot specify a default value for the `{0}' parameter" msgstr "" "Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " "um indexador" -#: mcs/mcs/cs-parser.cs:4666 +#: mcs/mcs/cs-parser.jay:1548 #, fuzzy msgid "Optional parameter is not valid in this context" msgstr "Uso do null é inválido neste contexto" -#: mcs/mcs/cs-parser.cs:4686 +#: mcs/mcs/cs-parser.jay:1578 msgid "The parameter modifiers `this' and `ref' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4689 +#: mcs/mcs/cs-parser.jay:1581 msgid "The parameter modifiers `this' and `out' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4692 +#: mcs/mcs/cs-parser.jay:1584 #, fuzzy msgid "A parameter cannot have specified more than one modifier" msgstr "" "Um parâmetro de árvore de expressão não pode usar modificadores \"ref\" ou " "\"out\"" -#: mcs/mcs/cs-parser.cs:4739 +#: mcs/mcs/cs-parser.jay:1627 #, fuzzy msgid "Cannot specify a default value for a parameter array" msgstr "" "Não foi possível especificar o atributo \"DefaultMember\" no tipo contendo " "um indexador" -#: mcs/mcs/cs-parser.cs:4756 +#: mcs/mcs/cs-parser.jay:1643 #, fuzzy msgid "The `params' modifier is not allowed in current context" msgstr "O nome \"{0}\" não existe no contexto atual" -#: mcs/mcs/cs-parser.cs:4764 +#: mcs/mcs/cs-parser.jay:1649 msgid "The parameter modifiers `this' and `params' cannot be used altogether" msgstr "" -#: mcs/mcs/cs-parser.cs:4766 +#: mcs/mcs/cs-parser.jay:1651 #, fuzzy msgid "The params parameter cannot be declared as ref or out" msgstr "O tipo \"{0}\" não pode ser declarado const" -#: mcs/mcs/cs-parser.cs:4774 +#: mcs/mcs/cs-parser.jay:1664 #, fuzzy msgid "__arglist is not valid in this context" msgstr "Uso do null é inválido neste contexto" -#: mcs/mcs/cs-parser.cs:4791 +#: mcs/mcs/cs-parser.jay:1683 #, fuzzy, csharp-format msgid "`{0}': property or indexer cannot have void type" msgstr "" "A propriedade ou o indexador somente leitura \"{0}\" não pôde ser atribuído" -#: mcs/mcs/cs-parser.cs:4829 +#: mcs/mcs/cs-parser.jay:1724 #, csharp-format msgid "`{0}': indexer return type cannot be `void'" msgstr "" -#: mcs/mcs/cs-parser.cs:4832 +#: mcs/mcs/cs-parser.jay:1727 msgid "Indexers must have at least one parameter" msgstr "" -#: mcs/mcs/cs-parser.cs:4857 +#: mcs/mcs/cs-parser.jay:1760 #, fuzzy, csharp-format msgid "`{0}': property or indexer must have at least one accessor" msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" -#: mcs/mcs/cs-parser.cs:4860 +#: mcs/mcs/cs-parser.jay:1763 msgid "Semicolon after method or accessor block is not valid" msgstr "" -#: mcs/mcs/cs-parser.cs:4862 +#: mcs/mcs/cs-parser.jay:1765 #, fuzzy msgid "A get or set accessor expected" msgstr "Um valor constante é esperado" -#: mcs/mcs/cs-parser.cs:4874 mcs/mcs/cs-parser.cs:4918 +#: mcs/mcs/cs-parser.jay:1778 mcs/mcs/cs-parser.jay:1821 msgid "Property accessor already defined" msgstr "" -#: mcs/mcs/cs-parser.cs:5036 +#: mcs/mcs/cs-parser.jay:1931 mcs/mcs/cs-parser.jay:1935 +#, fuzzy +msgid "Interfaces cannot contain fields or constants" +msgstr "Structs não podem conter construtores explícitos sem parâmetros" + +#: mcs/mcs/cs-parser.jay:1943 +#, fuzzy +msgid "Interfaces cannot contain operators" +msgstr "" +"\"{0}\": Classes estáticas não podem conter operadores definidos pelo usuário" + +#: mcs/mcs/cs-parser.jay:1947 +#, fuzzy +msgid "Interfaces cannot contain contructors" +msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" + +#: mcs/mcs/cs-parser.jay:1951 +msgid "" +"Interfaces cannot declare classes, structs, interfaces, delegates, or " +"enumerations" +msgstr "" + +#: mcs/mcs/cs-parser.jay:1992 #, fuzzy msgid "User-defined operators cannot return void" msgstr "" "Operador definido pelo usuário \"{0}\" deve ser declarado estático e público" -#: mcs/mcs/cs-parser.cs:5059 +#: mcs/mcs/cs-parser.jay:2020 msgid "Overloadable binary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5061 +#: mcs/mcs/cs-parser.jay:2022 #, fuzzy, csharp-format msgid "Overloaded unary operator `{0}' takes one parameter" msgstr "Sem sobrecarga para o método \"{0}\" aceitar os argumentos \"{1}\"" -#: mcs/mcs/cs-parser.cs:5066 +#: mcs/mcs/cs-parser.jay:2027 #, fuzzy, csharp-format msgid "Overloaded binary operator `{0}' takes two parameters" msgstr "Sem sobrecarga para o método \"{0}\" aceitar os argumentos \"{1}\"" -#: mcs/mcs/cs-parser.cs:5069 +#: mcs/mcs/cs-parser.jay:2030 msgid "Overloadable unary operator expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5183 +#: mcs/mcs/cs-parser.jay:2177 msgid "Class, struct, or interface method must have a return type" msgstr "Classes, structs ou métodos de interface devem ter um tipo de retorno" -#: mcs/mcs/cs-parser.cs:5187 +#: mcs/mcs/cs-parser.jay:2181 #, fuzzy, csharp-format msgid "`{0}': static constructor cannot have an access modifier" msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" -#: mcs/mcs/cs-parser.cs:5192 +#: mcs/mcs/cs-parser.jay:2186 #, fuzzy, csharp-format msgid "" "`{0}': static constructor cannot have an explicit `this' or `base' " "constructor call" msgstr "\"{0}\": Construtores de structs não podem chamar construtores da base" -#: mcs/mcs/cs-parser.cs:5241 +#: mcs/mcs/cs-parser.jay:2249 msgid "Name of destructor must match name of class" msgstr "" -#: mcs/mcs/cs-parser.cs:5243 +#: mcs/mcs/cs-parser.jay:2251 #, fuzzy msgid "Only class types can contain destructor" msgstr "\"{0}\": Classes estáticas não podem conter um destrutor" -#: mcs/mcs/cs-parser.cs:5265 +#: mcs/mcs/cs-parser.jay:2276 #, fuzzy, csharp-format msgid "" "`{0}': An explicit interface implementation of an event must use property " @@ -545,230 +540,235 @@ msgstr "" "\"{0}\": a implementação explicita da interface não pode fornecer o " "modificador de parâmetros" -#: mcs/mcs/cs-parser.cs:5298 +#: mcs/mcs/cs-parser.jay:2308 msgid "Event in interface cannot have add or remove accessors" msgstr "" -#: mcs/mcs/cs-parser.cs:5344 +#: mcs/mcs/cs-parser.jay:2377 #, fuzzy, csharp-format msgid "`{0}': event in interface cannot have an initializer" msgstr "\"{0}\": evento abstrato não pode ter um inicializador" -#: mcs/mcs/cs-parser.cs:5349 +#: mcs/mcs/cs-parser.jay:2382 #, csharp-format msgid "`{0}': abstract event cannot have an initializer" msgstr "\"{0}\": evento abstrato não pode ter um inicializador" -#: mcs/mcs/cs-parser.cs:5357 mcs/mcs/cs-parser.cs:5364 +#: mcs/mcs/cs-parser.jay:2397 mcs/mcs/cs-parser.jay:2402 #, fuzzy, csharp-format msgid "`{0}': event property must have both add and remove accessors" msgstr "\"{0}\": propriedades abstratas não podem ter acessores privados" -#: mcs/mcs/cs-parser.cs:5371 +#: mcs/mcs/cs-parser.jay:2407 msgid "An add or remove accessor expected" msgstr "" -#: mcs/mcs/cs-parser.cs:5379 mcs/mcs/cs-parser.cs:5408 +#: mcs/mcs/cs-parser.jay:2416 mcs/mcs/cs-parser.jay:2444 msgid "Modifiers cannot be placed on event accessor declarations" msgstr "" -#: mcs/mcs/cs-parser.cs:5436 +#: mcs/mcs/cs-parser.jay:2471 msgid "An add or remove accessor must have a body" msgstr "" -#: mcs/mcs/cs-parser.cs:5455 +#: mcs/mcs/cs-parser.jay:2493 #, fuzzy msgid "Enums cannot have type parameters" msgstr "Iteradores não podem ter parâmetros ref ou out" -#: mcs/mcs/cs-parser.cs:5755 +#: mcs/mcs/cs-parser.jay:2824 msgid "Type parameter declaration must be an identifier not a type" msgstr "" "A declaração de um tipo parâmetro deve ser um identificador e não um tipo" -#: mcs/mcs/cs-parser.cs:5779 +#: mcs/mcs/cs-parser.jay:2875 msgid "Invalid parameter type `void'" msgstr "Tipo de parâmetro inválido \"void\"" -#: mcs/mcs/cs-parser.cs:5825 +#: mcs/mcs/cs-parser.jay:2940 #, fuzzy, csharp-format msgid "Invalid base type `{0}'" msgstr "Tipo de parâmetro inválido \"void\"" -#: mcs/mcs/cs-parser.cs:5984 +#: mcs/mcs/cs-parser.jay:3189 msgid "An element initializer cannot be empty" msgstr "" -#: mcs/mcs/cs-parser.cs:6015 +#: mcs/mcs/cs-parser.jay:3227 #, fuzzy, csharp-format msgid "Named argument `{0}' specified multiple times" msgstr "Arquivo de código fonte \"{0}\" especificado múltiplas vezes" -#: mcs/mcs/cs-parser.cs:6026 mcs/mcs/cs-parser.cs:6033 +#: mcs/mcs/cs-parser.jay:3236 mcs/mcs/cs-parser.jay:3241 #, fuzzy msgid "An argument is missing" msgstr "Argumento \"#{0}\" não encontrou o modificador \"{1}\"" -#: mcs/mcs/cs-parser.cs:6166 +#: mcs/mcs/cs-parser.jay:3410 msgid "Array creation must have array size or array initializer" msgstr "" -#: mcs/mcs/cs-parser.cs:6183 +#: mcs/mcs/cs-parser.jay:3423 msgid "Invalid rank specifier, expecting `,' or `]'" msgstr "" -#: mcs/mcs/cs-parser.cs:6256 +#: mcs/mcs/cs-parser.jay:3503 msgid "" "Invalid anonymous type member declarator. Anonymous type members must be a " "member assignment, simple name or member access expression" msgstr "" -#: mcs/mcs/cs-parser.cs:6658 +#: mcs/mcs/cs-parser.jay:4027 msgid "All lambda parameters must be typed either explicitly or implicitly" msgstr "" -#: mcs/mcs/cs-parser.cs:6799 +#: mcs/mcs/cs-parser.jay:4213 #, csharp-format msgid "Duplicate `{0}' modifier" msgstr "" -#: mcs/mcs/cs-parser.cs:6803 +#: mcs/mcs/cs-parser.jay:4217 msgid "More than one protection modifier specified" msgstr "Mais de um modificador de proteção especificado" -#: mcs/mcs/cs-parser.cs:6816 +#: mcs/mcs/cs-parser.jay:4231 #, fuzzy msgid "Keyword `new' is not allowed on namespace elements" msgstr "Palavra chave \"new\" não é permitida em elementos do namespace" -#: mcs/mcs/cs-parser.cs:6936 +#: mcs/mcs/cs-parser.jay:4338 #, fuzzy, csharp-format msgid "A constraint clause has already been specified for type parameter `{0}'" msgstr "" "Um tipo aninhado não pode ser especificado através de um tipo parâmetro " "\"{0}\"" -#: mcs/mcs/cs-parser.cs:6966 +#: mcs/mcs/cs-parser.jay:4368 #, fuzzy msgid "The `new()' constraint must be the last constraint specified" msgstr "A restrição new() deve ser a última restrição especificada" -#: mcs/mcs/cs-parser.cs:6972 +#: mcs/mcs/cs-parser.jay:4374 msgid "" "The `class' or `struct' constraint must be the first constraint specified" msgstr "" "As restrições \"class\" ou \"struct\" devem ser as primeiras restrições " "especificadas" -#: mcs/mcs/cs-parser.cs:6976 +#: mcs/mcs/cs-parser.jay:4378 msgid "The `new()' constraint cannot be used with the `struct' constraint" msgstr "" "A restrição \"new()\" não pode ser utilizada com a restrição \"struct\"" -#: mcs/mcs/cs-parser.cs:6989 +#: mcs/mcs/cs-parser.jay:4392 #, fuzzy, csharp-format msgid "Invalid constraint type `{0}'" msgstr "Símbolo de definição condicional \"{0}\" inválido" -#: mcs/mcs/cs-parser.cs:7055 mcs/mcs/cs-parser.cs:7062 +#: mcs/mcs/cs-parser.jay:4574 mcs/mcs/cs-parser.jay:4579 msgid "An embedded statement may not be a declaration or labeled statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7213 +#: mcs/mcs/cs-parser.jay:4746 msgid "" "Syntax error, bad array declarator. To declare a managed array the rank " "specifier precedes the variable's identifier. To declare a fixed size buffer " "field, use the fixed keyword before the field type" msgstr "" -#: mcs/mcs/cs-parser.cs:7262 +#: mcs/mcs/cs-parser.jay:4826 msgid "A stackalloc expression requires [] after type" msgstr "" -#: mcs/mcs/cs-parser.cs:7468 +#: mcs/mcs/cs-parser.jay:5108 msgid "Type and identifier are both required in a foreach statement" msgstr "" -#: mcs/mcs/cs-parser.cs:7553 mcs/mcs/cs-parser.cs:7571 +#: mcs/mcs/cs-parser.jay:5200 mcs/mcs/cs-parser.jay:5216 #, fuzzy msgid "; expected" msgstr "Nome do método esperado" -#: mcs/mcs/cs-parser.cs:7555 +#: mcs/mcs/cs-parser.jay:5202 msgid "Expression expected after yield return" msgstr "" -#: mcs/mcs/cs-parser.cs:7598 +#: mcs/mcs/cs-parser.jay:5249 msgid "Expected catch or finally" msgstr "" -#: mcs/mcs/cs-parser.cs:7618 +#: mcs/mcs/cs-parser.jay:5268 msgid "Try statement already has an empty catch block" msgstr "A declaração do try já tem um bloco catch vazio" -#: mcs/mcs/cs-parser.cs:7651 +#: mcs/mcs/cs-parser.jay:5313 msgid "" "A type that derives from `System.Exception', `object', or `string' expected" msgstr "" -#: mcs/mcs/cs-parser.cs:11367 +#: mcs/mcs/cs-parser.jay:5421 +msgid "" +"You must provide an initializer in a fixed or using statement declaration" +msgstr "" + +#: mcs/mcs/cs-parser.jay:6009 msgid "Expecting `;'" msgstr "" -#: mcs/mcs/cs-parser.cs:11375 +#: mcs/mcs/cs-parser.jay:6017 #, fuzzy, csharp-format msgid "The parameter modifier `{0}' is not valid in this context" msgstr "Código de página \"{0}\" é inválido ou não está instalado" -#: mcs/mcs/cs-parser.cs:11381 +#: mcs/mcs/cs-parser.jay:6023 #, fuzzy, csharp-format msgid "Duplicate parameter modifier `{0}'" msgstr "Tipo de parâmetro duplicado \"{0}\"" -#: mcs/mcs/cs-parser.cs:11387 +#: mcs/mcs/cs-parser.jay:6029 #, fuzzy msgid "Type expected" msgstr "Nome do método esperado" -#: mcs/mcs/cs-parser.cs:11392 +#: mcs/mcs/cs-parser.jay:6034 msgid "Unsafe code requires the `unsafe' command line option to be specified" msgstr "" "Código inseguro requer a opção de linha de comando \"unsafe\" para ser " "especificada" -#: mcs/mcs/cs-parser.cs:11402 +#: mcs/mcs/cs-parser.jay:6044 msgid "Named arguments must appear after the positional arguments" msgstr "" -#: mcs/mcs/cs-parser.cs:11493 +#: mcs/mcs/cs-parser.jay:6135 msgid "Syntax error, " msgstr "" -#: mcs/mcs/cs-parser.cs:11547 +#: mcs/mcs/cs-parser.jay:6189 #, fuzzy msgid "Parsing error" msgstr "Erro na Análise de Detecção" -#: mcs/mcs/cs-parser.cs:11553 +#: mcs/mcs/cs-parser.jay:6195 msgid "Internal compiler error during parsing" msgstr "" -#: mcs/mcs/cs-parser.cs:11564 +#: mcs/mcs/cs-parser.jay:6206 #, csharp-format msgid "{0}: `{1}' is a keyword" msgstr "" -#: mcs/mcs/cs-parser.cs:11690 +#: mcs/mcs/cs-parser.jay:6332 #, fuzzy, csharp-format msgid "Identifier expected, `{0}' is a keyword" msgstr "Identificador esperado: {0}" -#: mcs/mcs/cs-parser.cs:11704 +#: mcs/mcs/cs-parser.jay:6346 #, csharp-format msgid "{1} `{0}'" msgstr "" -#: mcs/mcs/cs-parser.cs:11706 +#: mcs/mcs/cs-parser.jay:6348 #, csharp-format msgid "{2} `{0}', expecting {1}" msgstr "" From 09185b9e811dfe702809cfd5960e523ca8f4e7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Thu, 16 Dec 2010 13:38:40 +0000 Subject: [PATCH 49/93] Add support for storing elements with the same hashcode in ConcurrentDictionary. Add corresponding unit test. --- .../System.Web.UI/TemplateControl.cs | 5 +- .../ConcurrentDictionary.cs | 21 ++-- .../SplitOrderedList.cs | 107 +++++++++--------- .../ConcurrentDictionaryTests.cs | 48 ++++++++ 4 files changed, 114 insertions(+), 67 deletions(-) diff --git a/mcs/class/System.Web/System.Web.UI/TemplateControl.cs b/mcs/class/System.Web/System.Web.UI/TemplateControl.cs index ba86c11478ff..6480b008bd98 100644 --- a/mcs/class/System.Web/System.Web.UI/TemplateControl.cs +++ b/mcs/class/System.Web/System.Web.UI/TemplateControl.cs @@ -40,6 +40,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; +using System.Collections.Generic; using System.Collections.Concurrent; namespace System.Web.UI @@ -130,7 +131,7 @@ class EvtInfo { public bool noParams; } - static SplitOrderedList auto_event_info = new SplitOrderedList (); + static SplitOrderedList auto_event_info = new SplitOrderedList (EqualityComparer.Default); internal void WireupAutomaticEvents () { @@ -139,7 +140,7 @@ internal void WireupAutomaticEvents () /* Avoid expensive reflection operations by computing the event info only once */ Type type = GetType (); - ArrayList events = auto_event_info.InsertOrGet ((uint)type.GetHashCode (), null, CollectAutomaticEventInfo); + ArrayList events = auto_event_info.InsertOrGet ((uint)type.GetHashCode (), type, null, CollectAutomaticEventInfo); for (int i = 0; i < events.Count; ++i) { EvtInfo evinfo = (EvtInfo)events [i]; diff --git a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs index 957b7df739e0..6a2e3347ad9a 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs @@ -41,7 +41,7 @@ public class ConcurrentDictionary : IDictionary, { IEqualityComparer comparer; - SplitOrderedList> internalDictionary = new SplitOrderedList> (); + SplitOrderedList> internalDictionary; public ConcurrentDictionary () : this (EqualityComparer.Default) { @@ -57,6 +57,7 @@ public ConcurrentDictionary (IEnumerable> collection) public ConcurrentDictionary (IEqualityComparer comparer) { this.comparer = comparer; + this.internalDictionary = new SplitOrderedList> (comparer); } public ConcurrentDictionary (IEnumerable> collection, IEqualityComparer comparer) @@ -100,7 +101,7 @@ void IDictionary.Add (TKey key, TValue value) public bool TryAdd (TKey key, TValue value) { - return internalDictionary.Insert (Hash (key), Make (key, value)); + return internalDictionary.Insert (Hash (key), key, Make (key, value)); } void ICollection>.Add (KeyValuePair pair) @@ -111,6 +112,7 @@ void ICollection>.Add (KeyValuePair pair public TValue AddOrUpdate (TKey key, Func addValueFactory, Func updateValueFactory) { return internalDictionary.InsertOrUpdate (Hash (key), + key, () => Make (key, addValueFactory (key)), (e) => Make (key, updateValueFactory (key, e.Value))).Value; } @@ -123,6 +125,7 @@ public TValue AddOrUpdate (TKey key, TValue addValue, Func TValue AddOrUpdate (TKey key, TValue addValue, TValue updateValue) { return internalDictionary.InsertOrUpdate (Hash (key), + key, Make (key, addValue), Make (key, updateValue)).Value; } @@ -139,7 +142,7 @@ TValue GetValue (TKey key) public bool TryGetValue (TKey key, out TValue value) { KeyValuePair pair; - bool result = internalDictionary.Find (Hash (key), out pair); + bool result = internalDictionary.Find (Hash (key), key, out pair); value = pair.Value; return result; @@ -147,7 +150,7 @@ public bool TryGetValue (TKey key, out TValue value) public bool TryUpdate (TKey key, TValue newValue, TValue comparisonValue) { - return internalDictionary.CompareExchange (Hash (key), Make (key, newValue), (e) => e.Value.Equals (comparisonValue)); + return internalDictionary.CompareExchange (Hash (key), key, Make (key, newValue), (e) => e.Value.Equals (comparisonValue)); } public TValue this[TKey key] { @@ -161,18 +164,18 @@ public TValue this[TKey key] { public TValue GetOrAdd (TKey key, Func valueFactory) { - return internalDictionary.InsertOrGet (Hash (key), Make (key, default(TValue)), () => Make (key, valueFactory (key))).Value; + return internalDictionary.InsertOrGet (Hash (key), key, Make (key, default(TValue)), () => Make (key, valueFactory (key))).Value; } public TValue GetOrAdd (TKey key, TValue value) { - return internalDictionary.InsertOrGet (Hash (key), Make (key, value), null).Value; + return internalDictionary.InsertOrGet (Hash (key), key, Make (key, value), null).Value; } public bool TryRemove (TKey key, out TValue value) { KeyValuePair data; - bool result = internalDictionary.Delete (Hash (key), out data); + bool result = internalDictionary.Delete (Hash (key), key, out data); value = data.Value; return result; } @@ -197,7 +200,7 @@ bool ICollection>.Remove (KeyValuePair pa public bool ContainsKey (TKey key) { KeyValuePair dummy; - return internalDictionary.Find (Hash (key), out dummy); + return internalDictionary.Find (Hash (key), key, out dummy); } bool IDictionary.Contains (object key) @@ -256,7 +259,7 @@ public KeyValuePair[] ToArray () public void Clear() { // Pronk - internalDictionary = new SplitOrderedList> (); + internalDictionary = new SplitOrderedList> (comparer); } public int Count { diff --git a/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs b/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs index 4824d52621ef..2d2d04832a5a 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs @@ -32,22 +32,30 @@ namespace System.Collections.Concurrent { - internal class SplitOrderedList + internal class SplitOrderedList { class Node { public readonly bool Marked; public readonly ulong Key; + public readonly TKey SubKey; public T Data; - public Node Next; - public Node (ulong key, T data) + public Node (ulong key, TKey subKey, T data) { this.Key = key; + this.SubKey = subKey; this.Data = data; } + // Used to create dummy node + public Node (ulong key) + { + this.Key = key; + this.Data = default (T); + } + // Used to create marked node public Node (Node wrapped) { @@ -57,27 +65,24 @@ public Node (Node wrapped) } const int MaxLoad = 5; - /*const uint SegmentSize = 1u << SegmentShift; - const int SegmentShift = 5;*/ const uint BucketSize = 512; - /*[ThreadStatic] - Node[] segmentCache;*/ - Node head; Node tail; - //Node[][] buckets = new Node[BucketSize][]; Node[] buckets = new Node [BucketSize]; int count; int size = 2; SimpleRwLock slim = new SimpleRwLock (); - public SplitOrderedList () + readonly IEqualityComparer comparer; + + public SplitOrderedList (IEqualityComparer comparer) { - head = new Node (0, default (T)); - tail = new Node (ulong.MaxValue, default (T)); + this.comparer = comparer; + head = new Node (0); + tail = new Node (ulong.MaxValue); head.Next = tail; SetBucket (0, head); } @@ -88,10 +93,10 @@ public int Count { } } - public T InsertOrUpdate (uint key, Func addGetter, Func updateGetter) + public T InsertOrUpdate (uint key, TKey subKey, Func addGetter, Func updateGetter) { Node current; - bool result = InsertInternal (key, default (T), addGetter, out current); + bool result = InsertInternal (key, subKey, default (T), addGetter, out current); if (result) return current.Data; @@ -100,32 +105,32 @@ public T InsertOrUpdate (uint key, Func addGetter, Func updateGetter) return current.Data = updateGetter (current.Data); } - public T InsertOrUpdate (uint key, T addValue, T updateValue) + public T InsertOrUpdate (uint key, TKey subKey, T addValue, T updateValue) { Node current; - if (InsertInternal (key, addValue, null, out current)) + if (InsertInternal (key, subKey, addValue, null, out current)) return current.Data; // FIXME: this should have a CAS-like behavior return current.Data = updateValue; } - public bool Insert (uint key, T data) + public bool Insert (uint key, TKey subKey, T data) { Node current; - return InsertInternal (key, data, null, out current); + return InsertInternal (key, subKey, data, null, out current); } - public T InsertOrGet (uint key, T data, Func dataCreator) + public T InsertOrGet (uint key, TKey subKey, T data, Func dataCreator) { Node current; - InsertInternal (key, data, dataCreator, out current); + InsertInternal (key, subKey, data, dataCreator, out current); return current.Data; } - bool InsertInternal (uint key, T data, Func dataCreator, out Node current) + bool InsertInternal (uint key, TKey subKey, T data, Func dataCreator, out Node current) { - Node node = new Node (ComputeRegularKey (key), data); + Node node = new Node (ComputeRegularKey (key), subKey, data); uint b = key % (uint)size; Node bucket; @@ -145,7 +150,7 @@ bool InsertInternal (uint key, T data, Func dataCreator, out Node current) return true; } - public bool Find (uint key, out T data) + public bool Find (uint key, TKey subKey, out T data) { Node node; uint b = key % (uint)size; @@ -155,7 +160,7 @@ public bool Find (uint key, out T data) if ((bucket = GetBucket (b)) == null) bucket = InitializeBucket (b); - if (!ListFind (ComputeRegularKey (key), bucket, out node)) + if (!ListFind (ComputeRegularKey (key), subKey, bucket, out node)) return false; data = node.Data; @@ -163,7 +168,7 @@ public bool Find (uint key, out T data) return !node.Marked; } - public bool CompareExchange (uint key, T data, Func check) + public bool CompareExchange (uint key, TKey subKey, T data, Func check) { Node node; uint b = key % (uint)size; @@ -172,7 +177,7 @@ public bool CompareExchange (uint key, T data, Func check) if ((bucket = GetBucket (b)) == null) bucket = InitializeBucket (b); - if (!ListFind (ComputeRegularKey (key), bucket, out node)) + if (!ListFind (ComputeRegularKey (key), subKey, bucket, out node)) return false; if (!check (node.Data)) @@ -183,7 +188,7 @@ public bool CompareExchange (uint key, T data, Func check) return true; } - public bool Delete (uint key, out T data) + public bool Delete (uint key, TKey subKey, out T data) { uint b = key % (uint)size; Node bucket; @@ -191,7 +196,7 @@ public bool Delete (uint key, out T data) if ((bucket = GetBucket (b)) == null) bucket = InitializeBucket (b); - if (!ListDelete (bucket, ComputeRegularKey (key), out data)) + if (!ListDelete (bucket, ComputeRegularKey (key), subKey, out data)) return false; Interlocked.Decrement (ref count); @@ -222,7 +227,7 @@ Node InitializeBucket (uint b) if ((bucket = GetBucket (parent)) == null) bucket = InitializeBucket (parent); - Node dummy = new Node (ComputeDummyKey (b), default (T)); + Node dummy = new Node (ComputeDummyKey (b)); if (!ListInsert (dummy, bucket, out current, null)) return current; @@ -260,12 +265,6 @@ static ulong ComputeDummyKey (uint key) // Bucket storage is abstracted in a simple two-layer tree to avoid too much memory resize Node GetBucket (uint index) { - /*uint segment = index >> SegmentShift; - - if (buckets[segment] == null) - return null; - - return buckets[segment][index & (SegmentSize - 1)];*/ if (index >= buckets.Length) return null; return buckets[index]; @@ -273,18 +272,10 @@ Node GetBucket (uint index) Node SetBucket (uint index, Node node) { - //uint segment = index >> SegmentShift; try { slim.EnterReadLock (); CheckSegment (index, true); - /*if (buckets[segment] == null) { - // Cache segment creation in case CAS fails - Node[] newSegment = segmentCache == null ? new Node[SegmentSize] : segmentCache; - segmentCache = Interlocked.CompareExchange (ref buckets[segment], newSegment, null) == null ? null : newSegment; - } - return buckets[segment][index & (SegmentSize - 1)] = node;*/ - Interlocked.CompareExchange (ref buckets[index], node, null); return buckets[index]; } finally { @@ -311,7 +302,7 @@ void CheckSegment (uint segment, bool readLockTaken) slim.EnterReadLock (); } - Node ListSearch (ulong key, ref Node left, Node h) + Node ListSearch (ulong key, TKey subKey, ref Node left, Node h) { Node leftNodeNext = null, rightNode = null; @@ -328,7 +319,8 @@ Node ListSearch (ulong key, ref Node left, Node h) break; tNext = t.Next; - } while (tNext.Marked || t.Key < key); + Console.WriteLine ("Check: " + (tNext.Key == key && !comparer.Equals (subKey, t.SubKey))); + } while (tNext.Marked || t.Key < key || (tNext.Key == key && !comparer.Equals (subKey, t.SubKey))); rightNode = t; @@ -348,13 +340,13 @@ Node ListSearch (ulong key, ref Node left, Node h) } while (true); } - bool ListDelete (Node startPoint, ulong key, out T data) + bool ListDelete (Node startPoint, ulong key, TKey subKey, out T data) { Node rightNode = null, rightNodeNext = null, leftNode = null; data = default (T); do { - rightNode = ListSearch (key, ref leftNode, startPoint); + rightNode = ListSearch (key, subKey, ref leftNode, startPoint); if (rightNode == tail || rightNode.Key != key) return false; @@ -367,7 +359,7 @@ bool ListDelete (Node startPoint, ulong key, out T data) } while (true); if (Interlocked.CompareExchange (ref leftNode.Next, rightNodeNext, rightNode) != rightNodeNext) - ListSearch (rightNode.Key, ref leftNode, startPoint); + ListSearch (rightNode.Key, subKey, ref leftNode, startPoint); return true; } @@ -378,8 +370,8 @@ bool ListInsert (Node newNode, Node startPoint, out Node current, Func dataCr Node rightNode = null, leftNode = null; do { - rightNode = current = ListSearch (key, ref leftNode, startPoint); - if (rightNode != tail && rightNode.Key == key) + rightNode = current = ListSearch (key, newNode.SubKey, ref leftNode, startPoint); + if (rightNode != tail && rightNode.Key == key && comparer.Equals (newNode.SubKey, rightNode.SubKey)) return false; newNode.Next = rightNode; @@ -390,12 +382,12 @@ bool ListInsert (Node newNode, Node startPoint, out Node current, Func dataCr } while (true); } - bool ListFind (ulong key, Node startPoint, out Node data) + bool ListFind (ulong key, TKey subKey, Node startPoint, out Node data) { Node rightNode = null, leftNode = null; data = null; - rightNode = ListSearch (key, ref leftNode, startPoint); + rightNode = ListSearch (key, subKey, ref leftNode, startPoint); data = rightNode; return rightNode != tail && rightNode.Key == key; @@ -465,23 +457,26 @@ public void ExitWriteLock () #if INSIDE_SYSTEM_WEB && !NET_4_0 && !BOOTSTRAP_NET_4_0 internal struct SpinWait { - const int step = 5; - const int maxTime = 50; + // The number of step until SpinOnce yield on multicore machine + const int step = 10; + const int maxTime = 200; static readonly bool isSingleCpu = (Environment.ProcessorCount == 1); int ntime; public void SpinOnce () { + ntime += 1; + if (isSingleCpu) { // On a single-CPU system, spinning does no good Thread.Sleep (0); } else { - if ((ntime = ntime == maxTime ? maxTime : ntime + 1) % step == 0) + if (ntime % step == 0) Thread.Sleep (0); else // Multi-CPU system might be hyper-threaded, let other thread run - Thread.SpinWait (ntime << 1); + Thread.SpinWait (Math.Min (ntime, maxTime) << 1); } } } diff --git a/mcs/class/corlib/Test/System.Collections.Concurrent/ConcurrentDictionaryTests.cs b/mcs/class/corlib/Test/System.Collections.Concurrent/ConcurrentDictionaryTests.cs index 4be09ac4f9c8..fe0930fec672 100644 --- a/mcs/class/corlib/Test/System.Collections.Concurrent/ConcurrentDictionaryTests.cs +++ b/mcs/class/corlib/Test/System.Collections.Concurrent/ConcurrentDictionaryTests.cs @@ -211,6 +211,54 @@ public void ContainsTest () Assert.IsFalse (map.ContainsKey ("baz")); Assert.IsFalse (map.ContainsKey ("oof")); } + + class DumbClass : IEquatable + { + int foo; + + public DumbClass (int foo) + { + this.foo = foo; + } + + public int Foo { + get { + return foo; + } + } + + public override bool Equals (object rhs) + { + DumbClass temp = rhs as DumbClass; + return temp == null ? false : Equals (temp); + } + + public bool Equals (DumbClass rhs) + { + return this.foo == rhs.foo; + } + + public override int GetHashCode () + { + return 5; + } + } + + [Test] + public void SameHashCodeInsertTest () + { + var classMap = new ConcurrentDictionary (); + + var class1 = new DumbClass (1); + var class2 = new DumbClass (2); + + Assert.IsTrue (classMap.TryAdd (class1, "class1"), "class 1"); + Console.WriteLine (); + Assert.IsTrue (classMap.TryAdd (class2, "class2"), "class 2"); + + Assert.AreEqual ("class1", classMap[class1], "class 1 check"); + Assert.AreEqual ("class2", classMap[class2], "class 2 check"); + } } } #endif From 15e3272b1cd889262755cd5e834f1bc5a4ded350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Thu, 16 Dec 2010 14:45:44 +0000 Subject: [PATCH 50/93] Clean and finish TaskFactory --- .../corlib/System.Threading.Tasks/Task.cs | 2 +- .../System.Threading.Tasks/TaskFactory.cs | 113 +++++++++--------- 2 files changed, 55 insertions(+), 60 deletions(-) diff --git a/mcs/class/corlib/System.Threading.Tasks/Task.cs b/mcs/class/corlib/System.Threading.Tasks/Task.cs index abb7c64b99eb..cafcee217404 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Task.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Task.cs @@ -365,7 +365,7 @@ internal void Schedule () } void ThreadStart () - { + { current = this; TaskScheduler.Current = taskScheduler; diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs b/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs index eeefc6dc4d45..84aa3e36cf7f 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs @@ -184,15 +184,18 @@ public Task ContinueWhenAny (Task[] tasks, Action continuationAction, Task return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action continuationAction, CancellationToken cancellationToken, - TaskContinuationOptions continuationOptions, TaskScheduler scheduler) + public Task ContinueWhenAny (Task[] tasks, + Action continuationAction, + CancellationToken cancellationToken, + TaskContinuationOptions continuationOptions, + TaskScheduler scheduler) { var ourTasks = (Task[])tasks.Clone (); AtomicBoolean trigger = new AtomicBoolean (); Task commonContinuation = new Task (null); foreach (Task t in ourTasks) { - Task cont = new Task ((o) => { continuationAction ((Task)o); }, t, cancellationToken, creationOptions); + Task cont = new Task ((o) => continuationAction ((Task)o), t, cancellationToken, creationOptions); t.ContinueWithCore (cont, continuationOptions, scheduler, trigger.TrySet); cont.ContinueWithCore (commonContinuation, TaskContinuationOptions.None, scheduler); } @@ -200,76 +203,87 @@ public Task ContinueWhenAny (Task[] tasks, Action continuationAction, Canc return commonContinuation; } - public Task ContinueWhenAny (Task[] tasks, Action> continuationAction) + public Task ContinueWhenAny (Task[] tasks, + Action> continuationAction) { return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, + public Task ContinueWhenAny (Task[] tasks, + Action> continuationAction, CancellationToken cancellationToken) { return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, + public Task ContinueWhenAny (Task[] tasks, + Action> continuationAction, TaskContinuationOptions continuationOptions) { return ContinueWhenAny (tasks, continuationAction, cancellationToken, continuationOptions, scheduler); } - public Task ContinueWhenAny (Task[] tasks, Action> continuationAction, - CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, + public Task ContinueWhenAny (Task[] tasks, + Action> continuationAction, + CancellationToken cancellationToken, + TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - return ContinueWhenAny ((Task[]) tasks, (o) => continuationAction ((Task)o), + return ContinueWhenAny ((Task[]) tasks, + (o) => continuationAction ((Task)o), cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, + + public Task ContinueWhenAny (Task[] tasks, + Func continuationFunction, CancellationToken cancellationToken) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, + + public Task ContinueWhenAny (Task[] tasks, + Func continuationFunction, TaskContinuationOptions continuationOptions) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - [MonoTODO] - public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, + public Task ContinueWhenAny (Task[] tasks, + Func continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - throw new NotImplementedException (); + var ourTasks = (Task[])tasks.Clone (); + AtomicBoolean trigger = new AtomicBoolean (); + TaskCompletionSource source = new TaskCompletionSource (); + + foreach (Task t in ourTasks) { + Task cont = new Task ((o) => source.SetResult (continuationFunction ((Task)o)), t, cancellationToken, creationOptions); + t.ContinueWithCore (cont, continuationOptions, scheduler, trigger.TrySet); + } + + return source.Task; } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - [MonoTODO] public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, CancellationToken cancellationToken) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, TaskContinuationOptions continuationOptions) @@ -277,14 +291,17 @@ public Task ContinueWhenAny (Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - return ContinueWhenAny ((Task[])tasks, (t) => continuationFunction((Task)t), cancellationToken, continuationOptions, scheduler); + return ContinueWhenAny ((Task[])tasks, + (t) => continuationFunction((Task)t), + cancellationToken, + continuationOptions, + scheduler); } public Task ContinueWhenAll (Task[] tasks, Action continuationAction) @@ -696,23 +713,20 @@ public Task StartNew (Func function, object state, #endregion #region Continue - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, CancellationToken cancellationToken) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, TaskContinuationOptions continuationOptions) @@ -720,32 +734,28 @@ public Task ContinueWhenAny (Task[] tasks, return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - [MonoTODO] public Task ContinueWhenAny (Task[] tasks, Func continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - throw new NotImplementedException (); + return parent.ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, CancellationToken cancellationToken) { return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - - [MonoTODO] + public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, TaskContinuationOptions continuationOptions) @@ -753,14 +763,13 @@ public Task ContinueWhenAny (Task return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } - [MonoTODO] public Task ContinueWhenAny (Task[] tasks, Func, TResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - throw new NotImplementedException (); + return parent.ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, @@ -788,14 +797,7 @@ public Task ContinueWhenAll (Task[] tasks, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - var ourTasks = (Task[])tasks.Clone (); - CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, cancellationToken, creationOptions); - - foreach (Task t in ourTasks) - t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); - - return cont; + return parent.ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } public Task ContinueWhenAll (Task[] tasks, @@ -823,14 +825,7 @@ public Task ContinueWhenAll (Task CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { - var ourTasks = (Task[])tasks.Clone (); - CountdownEvent evt = new CountdownEvent (ourTasks.Length); - Task cont = new Task ((o) => continuationFunction (ourTasks), ourTasks, cancellationToken, creationOptions); - - foreach (Task t in ourTasks) - t.ContinueWithCore (cont, continuationOptions, scheduler, evt.Signal); - - return cont; + return parent.ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler); } #endregion From 36fbacfe85d278427501305ac63f6e416db9b164 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 14 Dec 2010 13:33:44 -0500 Subject: [PATCH 51/93] Add README2 --- README2 | 568 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 568 insertions(+) create mode 100644 README2 diff --git a/README2 b/README2 new file mode 100644 index 000000000000..6d1033ac3a5b --- /dev/null +++ b/README2 @@ -0,0 +1,568 @@ + +This is Mono. + + 1. Installation + 2. Using Mono + 3. Directory Roadmap + +1. Compilation and Installation +=============================== + + a. Build Requirements + --------------------- + + To build Mono, you will need the following components: + + * pkg-config + + Available from: http://www.freedesktop.org/Software/pkgconfig + + * glib 2.4 + + Available from: http://www.gtk.org/ + + On Itanium, you must obtain libunwind: + + http://www.hpl.hp.com/research/linux/libunwind/download.php4 + + On Solaris, make sure that you used GNU tar to unpack this package, as + Solaris tar will not unpack this correctly, and you will get strange errors. + + On Solaris, make sure that you use the GNU toolchain to build the software. + + Optional dependencies: + + * libgdiplus + + If you want to get support for System.Drawing, you will need to get + Libgdiplus. + + * libzlib + + This library and the development headers are required for compression + file support in the 2.0 profile. + + b. Building the Software + ------------------------ + + If you obtained this package as an officially released tarball, + this is very simple, use configure and make: + + ./configure --prefix=/usr/local + make + make install + + Mono supports a JIT engine on x86, SPARC, SPARCv9, S/390, + S/390x, AMD64, ARM and PowerPC systems. + + If you obtained this as a snapshot, you will need an existing + Mono installation. To upgrade your installation, unpack both + mono and mcs: + + tar xzf mcs-XXXX.tar.gz + tar xzf mono-XXXX.tar.gz + mv mono-XXX mono + mv mcs-XXX mcs + cd mono + ./autogen.sh --prefix=/usr/local + make + + The Mono build system is silent for most compilation commands. + To enable a more verbose compile (for example, to pinpoint + problems in your makefiles or your system) pass the V=1 flag to make, like this: + + make V=1 + + + + c. Building the software from SVN + --------------------------------- + + If you are building the software from SVN, make sure that you + have up-to-date mcs and mono sources: + + svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mono + svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mcs + + Then, go into the mono directory, and configure: + + cd mono + ./autogen.sh --prefix=/usr/local + make + + For people with non-standard installations of the auto* utils and of + pkg-config (common on misconfigured OSX and windows boxes), you could get + an error like this: + + ./configure: line 19176: syntax error near unexpected token `PKG_CHECK_MODULES(BASE_DEPENDENCIES,' ... + + This means that you need to set the ACLOCAL_FLAGS environment var + when invoking autogen.sh, like this: + + ACLOCAL_FLAGS="-I $acprefix/share/aclocal" ./autogen.sh --prefix=/usr/loca + + where $acprefix is the prefix where aclocal has been installed. + + This will automatically go into the mcs/ tree and build the + binaries there. + + This assumes that you have a working mono installation, and that + there's a C# compiler named 'mcs', and a corresponding IL + runtime called 'mono'. You can use two make variables + EXTERNAL_MCS and EXTERNAL_RUNTIME to override these. e.g., you + can say + + make EXTERNAL_MCS=/foo/bar/mcs EXTERNAL_RUNTIME=/somewhere/else/mono + + If you don't have a working Mono installation + --------------------------------------------- + + If you don't have a working Mono installation, an obvious choice + is to install the latest released packages of 'mono' for your + distribution and running autogen.sh; make; make install in the + mono module directory. + + You can also try a slightly more risky approach: this may not work, + so start from the released tarball as detailed above. + + This works by first getting the latest version of the 'monolite' + distribution, which contains just enough to run the 'mcs' + compiler. You do this with: + + # Run the following line after ./autogen.sh + make get-monolite-latest + + This will download and automatically gunzip and untar the + tarball, and place the files appropriately so that you can then + just run: + + make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe + + And that will use the files downloaded by 'make get-monolite-latest. + + Testing and Installation + ------------------------ + + You can run (part of) the mono and mcs testsuites with the command: + + make check + + All tests should pass. + + If you want more extensive tests, including those that test the + class libraries, you need to re-run 'configure' with the + '--enable-nunit-tests' flag, and try + + make -k check + + Expect to find a few testsuite failures. As a sanity check, you + can compare the failures you got with + + http://go-mono.com/tests/displayTestResults.php + + You can now install mono with: + + make install + + Failure to follow these steps may result in a broken installation. + + d. Common Configuration Options + ------------------------------- + + The following are the configuration options that someone + building Mono might want to use: + + --with-sgen=yes,no + + Generational GC support: Used to enable or disable the + compilation of a Mono runtime with the SGen garbage collector. + + On platforms that support it, after building Mono, you + will have both a mono binary and a mono-sgen binary. + Mono uses Boehm, while mono-sgen uses the Simple + Generational GC. + + --with-gc=[boehm, included, sgen, none] + + Selects the default Boehm garbage collector engine to + use, the default is the "included" value. + + included: + This is the default value, and its + the most feature complete, it will allow Mono + to use typed allocations and support the + debugger. + + It is essentially a slightly modified Boehm GC + + boehm: + This is used to use a system-install Boehm GC, + it is useful to test new features available in + Boehm GC, but we do not recommend that people + use this, as it disables a few features. + + none: + Disables the inclusion of a garbage + collector. + + --with-tls=__thread,pthread + + Controls how Mono should access thread local storage, + pthread forces Mono to use the pthread APIs, while + __thread uses compiler-optimized access to it. + + Although __thread is faster, it requires support from + the compiler, kernel and libc. Old Linux systems do + not support with __thread. + + This value is typically pre-configured and there is no + need to set it, unless you are trying to debug a + problem. + + --with-sigaltstack=yes,no + + Experimental: Use at your own risk, it is known to + cause problems with garbage collection and is hard to + reproduce those bugs. + + This controls whether Mono will install a special + signal handler to handle stack overflows. If set to + "yes", it will turn stack overflows into the + StackOverflowException. Otherwise when a stack + overflow happens, your program will receive a + segmentation fault. + + The configure script will try to detect if your + operating system supports this. Some older Linux + systems do not support this feature, or you might want + to override the auto-detection. + + --with-static_mono=yes,no + + This controls whether `mono' should link against a + static library (libmono.a) or a shared library + (libmono.so). + + This defaults to yes, and will improve the performance + of the `mono' program. + + This only affects the `mono' binary, the shared + library libmono.so will always be produced for + developers that want to embed the runtime in their + application. + + --with-xen-opt=yes,no + + The default value for this is `yes', and it makes Mono + generate code which might be slightly slower on + average systems, but the resulting executable will run + faster under the Xen virtualization system. + + --with-large-heap=yes,no + + Enable support for GC heaps larger than 3GB. + + This value is set to `no' by default. + + --enable-small-config=yes,no + + Enable some tweaks to reduce memory usage and disk footprint at + the expense of some capabilities. Typically this means that the + number of threads that can be created is limited (256), that the + maxmimum heap size is also reduced (256 MB) and other such limitations + that still make mono useful, but more suitable to embedded devices + (like mobile phones). + + This value is set to `no' by default. + + --with-ikvm-native=yes,no + + Controls whether the IKVM JNI interface library is + built or not. This is used if you are planning on + using the IKVM Java Virtual machine with Mono. + + This defaults to `yes'. + + --with-profile4=yes,no + + Whether you want to build the 4.x profile libraries + and runtime. + + It defaults to `yes'. + + --with-moonlight=yes,no + + Whether you want to generate the Silverlight/Moonlight + libraries and toolchain in addition to the default + (1.1 and 2.0 APIs). + + This will produce the `smcs' compiler which will reference + the Silverlight modified assemblies (mscorlib.dll, + System.dll, System.Code.dll and System.Xml.Core.dll) and turn + on the LINQ extensions for the compiler. + + --with-libgdiplus=installed,sibling, + + This is used to configure where should Mono look for + libgdiplus when running the System.Drawing tests. + + It defaults to `installed', which means that the + library is available to Mono through the regular + system setup. + + `sibling' can be used to specify that a libgdiplus + that resides as a sibling of this directory (mono) + should be used. + + Or you can specify a path to a libgdiplus. + + --disable-shared-memory + + Use this option to disable the use of shared memory in + Mono (this is equivalent to setting the MONO_DISABLE_SHM + environment variable, although this removes the feature + completely). + + Disabling the shared memory support will disable certain + features like cross-process named mutexes. + + --enable-minimal=LIST + + Use this feature to specify optional runtime + components that you might not want to include. This + is only useful for developers embedding Mono that + require a subset of Mono functionality. + + The list is a comma-separated list of components that + should be removed, these are: + + aot: + Disables support for the Ahead of Time + compilation. + + attach: + Support for the Mono.Management assembly and the + VMAttach API (allowing code to be injected into + a target VM) + + com: + Disables COM support. + + debug: + Drop debugging support. + + decimal: + Disables support for System.Decimal. + + full_messages: + By default Mono comes with a full table + of messages for error codes. This feature + turns off uncommon error messages and reduces + the runtime size. + + generics: + Generics support. Disabling this will not + allow Mono to run any 2.0 libraries or + code that contains generics. + + jit: + Removes the JIT engine from the build, this reduces + the executable size, and requires that all code + executed by the virtual machine be compiled with + Full AOT before execution. + + large_code: + Disables support for large assemblies. + + logging: + Disables support for debug logging. + + pinvoke: + Support for Platform Invocation services, + disabling this will drop support for any + libraries using DllImport. + + portability: + Removes support for MONO_IOMAP, the environment + variables for simplifying porting applications that + are case-insensitive and that mix the Unix and Windows path separators. + + profiler: + Disables support for the default profiler. + + reflection_emit: + Drop System.Reflection.Emit support + + reflection_emit_save: + Drop support for saving dynamically created + assemblies (AssemblyBuilderAccess.Save) in + System.Reflection.Emit. + + shadow_copy: + Disables support for AppDomain's shadow copies + (you can disable this if you do not plan on + using appdomains). + + simd: + Disables support for the Mono.SIMD intrinsics + library. + + ssa: + Disables compilation for the SSA optimization + framework, and the various SSA-based + optimizations. + + --enable-llvm + --enable-loadedllvm + + This enables the use of LLVM as a code generation engine + for Mono. The LLVM code generator and optimizer will be + used instead of Mono's built-in code generator for both + Just in Time and Ahead of Time compilations. + + See the http://www.mono-project.com/Mono_LLVM for the + full details and up-to-date information on this feature. + + You will need to have an LLVM built that Mono can link + against, + + The --enable-loadedllvm variant will make the llvm backend + into a runtime-loadable module instead of linking it directly + into the main mono binary. + + --enable-big-arrays + + This enables the use arrays whose indexes are larger + than Int32.MaxValue. + + By default Mono has the same limitation as .NET on + Win32 and Win64 and limits array indexes to 32-bit + values (even on 64-bit systems). + + In certain scenarios where large arrays are required, + you can pass this flag and Mono will be built to + support 64-bit arrays. + + This is not the default as it breaks the C embedding + ABI that we have exposed through the Mono development + cycle. + + --enable-parallel-mark + + Use this option to enable the garbage collector to use + multiple CPUs to do its work. This helps performance + on multi-CPU machines as the work is divided across CPUS. + + This option is not currently the default as we have + not done much testing with Mono. + + --enable-dtrace + + On Solaris and MacOS X builds a version of the Mono + runtime that contains DTrace probes and can + participate in the system profiling using DTrace. + + + --disable-dev-random + + Mono uses /dev/random to obtain good random data for + any source that requires random numbers. If your + system does not support this, you might want to + disable it. + + There are a number of runtime options to control this + also, see the man page. + + --enable-nacl + + This configures the Mono compiler to generate code + suitable to be used by Google's Native Client: + + http://code.google.com/p/nativeclient/ + + Currently this is used with Mono's AOT engine as + Native Client does not support JIT engines yet. + +2. Using Mono +============= + + Once you have installed the software, you can run a few programs: + + * runtime engine + + mono program.exe + + * C# compiler + + mcs program.cs + + * CIL Disassembler + + monodis program.exe + + See the man pages for mono(1), mint(1), monodis(1) and mcs(2) + for further details. + +3. Directory Roadmap +==================== + + docs/ + Technical documents about the Mono runtime. + + data/ + Configuration files installed as part of the Mono runtime. + + mono/ + The core of the Mono Runtime. + + metadata/ + The object system and metadata reader. + + mini/ + The Just in Time Compiler. + + dis/ + CIL executable Disassembler + + cli/ + Common code for the JIT and the interpreter. + + io-layer/ + The I/O layer and system abstraction for + emulating the .NET IO model. + + cil/ + Common Intermediate Representation, XML + definition of the CIL bytecodes. + + interp/ + Interpreter for CLI executables (obsolete). + + arch/ + Architecture specific portions. + + man/ + + Manual pages for the various Mono commands and programs. + + samples/ + + Some simple sample programs on uses of the Mono + runtime as an embedded library. + + scripts/ + + Scripts used to invoke Mono and the corresponding program. + + runtime/ + + A directory that contains the Makefiles that link the + mono/ and mcs/ build systems. + + ../olive/ + + If the directory ../olive is present (as an + independent checkout) from the Mono module, that + directory is automatically configured to share the + same prefix than this module gets. + From 5fc671180e3ddaf117cf6bb8d2b659cd0e554efe Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 16 Dec 2010 11:10:33 -0500 Subject: [PATCH 52/93] Update COPYING file with MS-PL and Apache2 texts --- COPYING.LIB | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/COPYING.LIB b/COPYING.LIB index 0247f818a698..2f3b220f877d 100644 --- a/COPYING.LIB +++ b/COPYING.LIB @@ -11,7 +11,13 @@ The Boehm licensing information is in the libgc directory The SGen Garbage Collector is under the terms of the MIT X11 license - +The class libraries under mono/mcs are unless otherwise stated +under the MIT X11 license. + +Open source Microsoft code is licensed under the original terms +which is either MS-PL for older components, or dual licensed +MS-PL/Apache2 licensed. + GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 From 7a49c5d397c33f63ee47ec028ac5791349783bad Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Fri, 17 Dec 2010 01:32:49 +0900 Subject: [PATCH 53/93] Add attachable event support in XamlType (not yet in readers and writers). --- mcs/class/System.Xaml/System.Xaml/XamlType.cs | 33 ++++++++++++++----- .../Test/System.Xaml/TestedTypes.cs | 31 +++++++++++++++++ .../Test/System.Xaml/XamlTypeTest.cs | 4 ++- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/mcs/class/System.Xaml/System.Xaml/XamlType.cs b/mcs/class/System.Xaml/System.Xaml/XamlType.cs index d98839371373..a4c33a560893 100755 --- a/mcs/class/System.Xaml/System.Xaml/XamlType.cs +++ b/mcs/class/System.Xaml/System.Xaml/XamlType.cs @@ -391,18 +391,19 @@ IEnumerable DoLookupAllAttachableMembers () var gl = new Dictionary (); var sl = new Dictionary (); + var al = new Dictionary (); + //var rl = new Dictionary (); var nl = new List (); foreach (var mi in UnderlyingType.GetMethods (bf)) { + string name = null; if (mi.Name.StartsWith ("Get", StringComparison.Ordinal)) { if (mi.ReturnType == typeof (void)) continue; var args = mi.GetParameters (); if (args.Length != 1) continue; - var name = mi.Name.Substring (3); + name = mi.Name.Substring (3); gl.Add (name, mi); - if (!nl.Contains (name)) - nl.Add (name); } else if (mi.Name.StartsWith ("Set", StringComparison.Ordinal)) { // looks like the return type is *ignored* //if (mi.ReturnType != typeof (void)) @@ -410,21 +411,35 @@ IEnumerable DoLookupAllAttachableMembers () var args = mi.GetParameters (); if (args.Length != 2) continue; - var name = mi.Name.Substring (3); + name = mi.Name.Substring (3); sl.Add (name, mi); - if (!nl.Contains (name)) - nl.Add (name); + } else if (mi.Name.EndsWith ("Handler", StringComparison.Ordinal)) { + var args = mi.GetParameters (); + if (args.Length != 2) + continue; + if (mi.Name.StartsWith ("Add", StringComparison.Ordinal)) { + name = mi.Name.Substring (3, mi.Name.Length - 3 - 7); + al.Add (name, mi); + }/* else if (mi.Name.StartsWith ("Remove", StringComparison.Ordinal)) { + name = mi.Name.Substring (6, mi.Name.Length - 6 - 7); + rl.Add (name, mi); + }*/ } + if (name != null && !nl.Contains (name)) + nl.Add (name); } foreach (var name in nl) { MethodInfo m; var g = gl.TryGetValue (name, out m) ? m : null; var s = sl.TryGetValue (name, out m) ? m : null; - yield return new XamlMember (name, g, s, SchemaContext); + if (g != null || s != null) + yield return new XamlMember (name, g, s, SchemaContext); + var a = al.TryGetValue (name, out m) ? m : null; + //var r = rl.TryGetValue (name, out m) ? m : null; + if (a != null) + yield return new XamlMember (name, a, SchemaContext); } - - // FIXME: attachable events? } static readonly XamlMember [] empty_array = new XamlMember [0]; diff --git a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs index a5412b614894..92766fcb8e14 100755 --- a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs @@ -637,6 +637,23 @@ protected static void SetProtected (object target, string value) { dic [target] = value; } + + static Dictionary> handlers = new Dictionary> (); + + public static void AddXHandler (object target, EventHandler handler) + { + List l; + if (!handlers.TryGetValue (target, out l)) { + l = new List (); + handlers [target] = l; + } + l.Add (handler); + } + + public static void RemoveXHandler (object target, EventHandler handler) + { + handlers [target].Remove (handler); + } } public class AttachedPropertyStore : IAttachedPropertyStore @@ -671,4 +688,18 @@ public bool TryGetProperty (AttachableMemberIdentifier attachableMemberIdentifie return props.TryGetValue (attachableMemberIdentifier, out value); } } + + public class AttachedWrapper : Attachable + { + public AttachedWrapper () + { + Value = new Attached (); + } + + public Attached Value { get; set; } + } + + public class Attached + { + } } diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs index 5d1906e8ca5b..0543400d6303 100755 --- a/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs @@ -769,8 +769,10 @@ public void AttachableProperty () Assert.IsTrue (apl.Any (ap => ap.Name == "Protected"), "#2"); // oh? SetBaz() has non-void return value, but it seems ignored. Assert.IsTrue (apl.Any (ap => ap.Name == "Baz"), "#3"); - Assert.AreEqual (3, apl.Count, "#4"); + Assert.AreEqual (4, apl.Count, "#4"); Assert.IsTrue (apl.All (ap => ap.IsAttachable), "#5"); + var x = apl.First (ap => ap.Name == "X"); + Assert.IsTrue (x.IsEvent, "#6"); } } From a791cfc1640bec442757f78fe71e428d643e90ed Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 16 Dec 2010 12:55:24 -0500 Subject: [PATCH 54/93] [winforms] revert patch, it regresses the test suite: https://github.com/mono/mono/commit/8334fe3a56c978ffe7f8cb199536f9b3234afdbe --- .../System.Windows.Forms/CurrencyManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs index 5ec445f363a1..277e71c9c6b9 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs @@ -390,7 +390,7 @@ private void ListChangedHandler (object sender, ListChangedEventArgs e) else if (e.NewIndex <= listposition) { /* the deleted row was either the current one, or one earlier in the list. Update the index and emit PositionChanged, CurrentChanged, and ItemChanged. */ - ChangeRecordState (e.NewIndex, + ChangeRecordState (listposition+1, false, false, e.NewIndex != listposition, false); } else { From 9aa23d8ebec0f5c60ae66fee3df8a3c6c39cf191 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 16 Dec 2010 12:58:44 -0500 Subject: [PATCH 55/93] [winforms] undo accidental removal of a line --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs index 4ee4ba1a7e63..fc63bd438082 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs @@ -357,6 +357,7 @@ internal override Color ChangeBackColor (Color backColor) if (!ReadOnly) backColor = SystemColors.Window; } + backcolor_set = false; return backColor; } From 77af6420b916cae490a962422412debf40fb21cf Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 16 Dec 2010 12:59:50 -0500 Subject: [PATCH 56/93] Undo adding of README2 test file --- README2 | 568 -------------------------------------------------------- 1 file changed, 568 deletions(-) delete mode 100644 README2 diff --git a/README2 b/README2 deleted file mode 100644 index 6d1033ac3a5b..000000000000 --- a/README2 +++ /dev/null @@ -1,568 +0,0 @@ - -This is Mono. - - 1. Installation - 2. Using Mono - 3. Directory Roadmap - -1. Compilation and Installation -=============================== - - a. Build Requirements - --------------------- - - To build Mono, you will need the following components: - - * pkg-config - - Available from: http://www.freedesktop.org/Software/pkgconfig - - * glib 2.4 - - Available from: http://www.gtk.org/ - - On Itanium, you must obtain libunwind: - - http://www.hpl.hp.com/research/linux/libunwind/download.php4 - - On Solaris, make sure that you used GNU tar to unpack this package, as - Solaris tar will not unpack this correctly, and you will get strange errors. - - On Solaris, make sure that you use the GNU toolchain to build the software. - - Optional dependencies: - - * libgdiplus - - If you want to get support for System.Drawing, you will need to get - Libgdiplus. - - * libzlib - - This library and the development headers are required for compression - file support in the 2.0 profile. - - b. Building the Software - ------------------------ - - If you obtained this package as an officially released tarball, - this is very simple, use configure and make: - - ./configure --prefix=/usr/local - make - make install - - Mono supports a JIT engine on x86, SPARC, SPARCv9, S/390, - S/390x, AMD64, ARM and PowerPC systems. - - If you obtained this as a snapshot, you will need an existing - Mono installation. To upgrade your installation, unpack both - mono and mcs: - - tar xzf mcs-XXXX.tar.gz - tar xzf mono-XXXX.tar.gz - mv mono-XXX mono - mv mcs-XXX mcs - cd mono - ./autogen.sh --prefix=/usr/local - make - - The Mono build system is silent for most compilation commands. - To enable a more verbose compile (for example, to pinpoint - problems in your makefiles or your system) pass the V=1 flag to make, like this: - - make V=1 - - - - c. Building the software from SVN - --------------------------------- - - If you are building the software from SVN, make sure that you - have up-to-date mcs and mono sources: - - svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mono - svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mcs - - Then, go into the mono directory, and configure: - - cd mono - ./autogen.sh --prefix=/usr/local - make - - For people with non-standard installations of the auto* utils and of - pkg-config (common on misconfigured OSX and windows boxes), you could get - an error like this: - - ./configure: line 19176: syntax error near unexpected token `PKG_CHECK_MODULES(BASE_DEPENDENCIES,' ... - - This means that you need to set the ACLOCAL_FLAGS environment var - when invoking autogen.sh, like this: - - ACLOCAL_FLAGS="-I $acprefix/share/aclocal" ./autogen.sh --prefix=/usr/loca - - where $acprefix is the prefix where aclocal has been installed. - - This will automatically go into the mcs/ tree and build the - binaries there. - - This assumes that you have a working mono installation, and that - there's a C# compiler named 'mcs', and a corresponding IL - runtime called 'mono'. You can use two make variables - EXTERNAL_MCS and EXTERNAL_RUNTIME to override these. e.g., you - can say - - make EXTERNAL_MCS=/foo/bar/mcs EXTERNAL_RUNTIME=/somewhere/else/mono - - If you don't have a working Mono installation - --------------------------------------------- - - If you don't have a working Mono installation, an obvious choice - is to install the latest released packages of 'mono' for your - distribution and running autogen.sh; make; make install in the - mono module directory. - - You can also try a slightly more risky approach: this may not work, - so start from the released tarball as detailed above. - - This works by first getting the latest version of the 'monolite' - distribution, which contains just enough to run the 'mcs' - compiler. You do this with: - - # Run the following line after ./autogen.sh - make get-monolite-latest - - This will download and automatically gunzip and untar the - tarball, and place the files appropriately so that you can then - just run: - - make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe - - And that will use the files downloaded by 'make get-monolite-latest. - - Testing and Installation - ------------------------ - - You can run (part of) the mono and mcs testsuites with the command: - - make check - - All tests should pass. - - If you want more extensive tests, including those that test the - class libraries, you need to re-run 'configure' with the - '--enable-nunit-tests' flag, and try - - make -k check - - Expect to find a few testsuite failures. As a sanity check, you - can compare the failures you got with - - http://go-mono.com/tests/displayTestResults.php - - You can now install mono with: - - make install - - Failure to follow these steps may result in a broken installation. - - d. Common Configuration Options - ------------------------------- - - The following are the configuration options that someone - building Mono might want to use: - - --with-sgen=yes,no - - Generational GC support: Used to enable or disable the - compilation of a Mono runtime with the SGen garbage collector. - - On platforms that support it, after building Mono, you - will have both a mono binary and a mono-sgen binary. - Mono uses Boehm, while mono-sgen uses the Simple - Generational GC. - - --with-gc=[boehm, included, sgen, none] - - Selects the default Boehm garbage collector engine to - use, the default is the "included" value. - - included: - This is the default value, and its - the most feature complete, it will allow Mono - to use typed allocations and support the - debugger. - - It is essentially a slightly modified Boehm GC - - boehm: - This is used to use a system-install Boehm GC, - it is useful to test new features available in - Boehm GC, but we do not recommend that people - use this, as it disables a few features. - - none: - Disables the inclusion of a garbage - collector. - - --with-tls=__thread,pthread - - Controls how Mono should access thread local storage, - pthread forces Mono to use the pthread APIs, while - __thread uses compiler-optimized access to it. - - Although __thread is faster, it requires support from - the compiler, kernel and libc. Old Linux systems do - not support with __thread. - - This value is typically pre-configured and there is no - need to set it, unless you are trying to debug a - problem. - - --with-sigaltstack=yes,no - - Experimental: Use at your own risk, it is known to - cause problems with garbage collection and is hard to - reproduce those bugs. - - This controls whether Mono will install a special - signal handler to handle stack overflows. If set to - "yes", it will turn stack overflows into the - StackOverflowException. Otherwise when a stack - overflow happens, your program will receive a - segmentation fault. - - The configure script will try to detect if your - operating system supports this. Some older Linux - systems do not support this feature, or you might want - to override the auto-detection. - - --with-static_mono=yes,no - - This controls whether `mono' should link against a - static library (libmono.a) or a shared library - (libmono.so). - - This defaults to yes, and will improve the performance - of the `mono' program. - - This only affects the `mono' binary, the shared - library libmono.so will always be produced for - developers that want to embed the runtime in their - application. - - --with-xen-opt=yes,no - - The default value for this is `yes', and it makes Mono - generate code which might be slightly slower on - average systems, but the resulting executable will run - faster under the Xen virtualization system. - - --with-large-heap=yes,no - - Enable support for GC heaps larger than 3GB. - - This value is set to `no' by default. - - --enable-small-config=yes,no - - Enable some tweaks to reduce memory usage and disk footprint at - the expense of some capabilities. Typically this means that the - number of threads that can be created is limited (256), that the - maxmimum heap size is also reduced (256 MB) and other such limitations - that still make mono useful, but more suitable to embedded devices - (like mobile phones). - - This value is set to `no' by default. - - --with-ikvm-native=yes,no - - Controls whether the IKVM JNI interface library is - built or not. This is used if you are planning on - using the IKVM Java Virtual machine with Mono. - - This defaults to `yes'. - - --with-profile4=yes,no - - Whether you want to build the 4.x profile libraries - and runtime. - - It defaults to `yes'. - - --with-moonlight=yes,no - - Whether you want to generate the Silverlight/Moonlight - libraries and toolchain in addition to the default - (1.1 and 2.0 APIs). - - This will produce the `smcs' compiler which will reference - the Silverlight modified assemblies (mscorlib.dll, - System.dll, System.Code.dll and System.Xml.Core.dll) and turn - on the LINQ extensions for the compiler. - - --with-libgdiplus=installed,sibling, - - This is used to configure where should Mono look for - libgdiplus when running the System.Drawing tests. - - It defaults to `installed', which means that the - library is available to Mono through the regular - system setup. - - `sibling' can be used to specify that a libgdiplus - that resides as a sibling of this directory (mono) - should be used. - - Or you can specify a path to a libgdiplus. - - --disable-shared-memory - - Use this option to disable the use of shared memory in - Mono (this is equivalent to setting the MONO_DISABLE_SHM - environment variable, although this removes the feature - completely). - - Disabling the shared memory support will disable certain - features like cross-process named mutexes. - - --enable-minimal=LIST - - Use this feature to specify optional runtime - components that you might not want to include. This - is only useful for developers embedding Mono that - require a subset of Mono functionality. - - The list is a comma-separated list of components that - should be removed, these are: - - aot: - Disables support for the Ahead of Time - compilation. - - attach: - Support for the Mono.Management assembly and the - VMAttach API (allowing code to be injected into - a target VM) - - com: - Disables COM support. - - debug: - Drop debugging support. - - decimal: - Disables support for System.Decimal. - - full_messages: - By default Mono comes with a full table - of messages for error codes. This feature - turns off uncommon error messages and reduces - the runtime size. - - generics: - Generics support. Disabling this will not - allow Mono to run any 2.0 libraries or - code that contains generics. - - jit: - Removes the JIT engine from the build, this reduces - the executable size, and requires that all code - executed by the virtual machine be compiled with - Full AOT before execution. - - large_code: - Disables support for large assemblies. - - logging: - Disables support for debug logging. - - pinvoke: - Support for Platform Invocation services, - disabling this will drop support for any - libraries using DllImport. - - portability: - Removes support for MONO_IOMAP, the environment - variables for simplifying porting applications that - are case-insensitive and that mix the Unix and Windows path separators. - - profiler: - Disables support for the default profiler. - - reflection_emit: - Drop System.Reflection.Emit support - - reflection_emit_save: - Drop support for saving dynamically created - assemblies (AssemblyBuilderAccess.Save) in - System.Reflection.Emit. - - shadow_copy: - Disables support for AppDomain's shadow copies - (you can disable this if you do not plan on - using appdomains). - - simd: - Disables support for the Mono.SIMD intrinsics - library. - - ssa: - Disables compilation for the SSA optimization - framework, and the various SSA-based - optimizations. - - --enable-llvm - --enable-loadedllvm - - This enables the use of LLVM as a code generation engine - for Mono. The LLVM code generator and optimizer will be - used instead of Mono's built-in code generator for both - Just in Time and Ahead of Time compilations. - - See the http://www.mono-project.com/Mono_LLVM for the - full details and up-to-date information on this feature. - - You will need to have an LLVM built that Mono can link - against, - - The --enable-loadedllvm variant will make the llvm backend - into a runtime-loadable module instead of linking it directly - into the main mono binary. - - --enable-big-arrays - - This enables the use arrays whose indexes are larger - than Int32.MaxValue. - - By default Mono has the same limitation as .NET on - Win32 and Win64 and limits array indexes to 32-bit - values (even on 64-bit systems). - - In certain scenarios where large arrays are required, - you can pass this flag and Mono will be built to - support 64-bit arrays. - - This is not the default as it breaks the C embedding - ABI that we have exposed through the Mono development - cycle. - - --enable-parallel-mark - - Use this option to enable the garbage collector to use - multiple CPUs to do its work. This helps performance - on multi-CPU machines as the work is divided across CPUS. - - This option is not currently the default as we have - not done much testing with Mono. - - --enable-dtrace - - On Solaris and MacOS X builds a version of the Mono - runtime that contains DTrace probes and can - participate in the system profiling using DTrace. - - - --disable-dev-random - - Mono uses /dev/random to obtain good random data for - any source that requires random numbers. If your - system does not support this, you might want to - disable it. - - There are a number of runtime options to control this - also, see the man page. - - --enable-nacl - - This configures the Mono compiler to generate code - suitable to be used by Google's Native Client: - - http://code.google.com/p/nativeclient/ - - Currently this is used with Mono's AOT engine as - Native Client does not support JIT engines yet. - -2. Using Mono -============= - - Once you have installed the software, you can run a few programs: - - * runtime engine - - mono program.exe - - * C# compiler - - mcs program.cs - - * CIL Disassembler - - monodis program.exe - - See the man pages for mono(1), mint(1), monodis(1) and mcs(2) - for further details. - -3. Directory Roadmap -==================== - - docs/ - Technical documents about the Mono runtime. - - data/ - Configuration files installed as part of the Mono runtime. - - mono/ - The core of the Mono Runtime. - - metadata/ - The object system and metadata reader. - - mini/ - The Just in Time Compiler. - - dis/ - CIL executable Disassembler - - cli/ - Common code for the JIT and the interpreter. - - io-layer/ - The I/O layer and system abstraction for - emulating the .NET IO model. - - cil/ - Common Intermediate Representation, XML - definition of the CIL bytecodes. - - interp/ - Interpreter for CLI executables (obsolete). - - arch/ - Architecture specific portions. - - man/ - - Manual pages for the various Mono commands and programs. - - samples/ - - Some simple sample programs on uses of the Mono - runtime as an embedded library. - - scripts/ - - Scripts used to invoke Mono and the corresponding program. - - runtime/ - - A directory that contains the Makefiles that link the - mono/ and mcs/ build systems. - - ../olive/ - - If the directory ../olive is present (as an - independent checkout) from the Mono module, that - directory is automatically configured to share the - same prefix than this module gets. - From 8c686c3e13a48988b298569586f60e33d170d93b Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 16 Dec 2010 13:01:37 -0500 Subject: [PATCH 57/93] Update instructions --- README | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README b/README index 6d1033ac3a5b..ccfd67d4cfd7 100644 --- a/README +++ b/README @@ -75,14 +75,18 @@ This is Mono. - c. Building the software from SVN + c. Building the software from GIT --------------------------------- - If you are building the software from SVN, make sure that you + If you are building the software from GIT, make sure that you have up-to-date mcs and mono sources: - svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mono - svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mcs + If you are an anonymous user: + git clone git://github.com/mono/mono.git + + If you are a Mono contributors with read/write privileges: + git clone git@github.com:mono/mono.git + Then, go into the mono directory, and configure: From 8a263984e95113e8cb753e8f8b05b2342cb8e2d1 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 16 Dec 2010 13:10:44 -0500 Subject: [PATCH 58/93] [monodroid] Add support for the Android TimeZone file format. Fixes #657609. Android uses "ye standard" timezone file format, but instead of using a directory + file structure as libc uses, they throw everything into two files, a "zoneinfo.dat" and a "zoneinfo.idx", where "zoneinfo.dat" is the concatenation of all the TZIF files and "zoneinfo.idx" contains the timezone names and offsets into "zoneinfo.dat". From the ZoneInfoDB documentation: However, to conserve disk space the data for all time zones are concatenated into a single file, and a second file is used to indicate the starting position of each time zone record. A third file indicates the version of the zoneinfo databse used to generate the data. TimeZoneInfo.Android.cs is a C# port of the corresponding Android ZoneInfoDB type so that Mono can use Android's timezone DB. --- LICENSE | 7 + .../System/TimeZoneInfo.Android.cs | 299 ++++++++++++++++++ mcs/class/System.Core/System/TimeZoneInfo.cs | 18 +- .../monodroid_System.Core.dll.sources | 1 + 4 files changed, 320 insertions(+), 5 deletions(-) create mode 100644 mcs/class/System.Core/System/TimeZoneInfo.Android.cs diff --git a/LICENSE b/LICENSE index d78a60a85253..0cb310e11268 100644 --- a/LICENSE +++ b/LICENSE @@ -98,6 +98,13 @@ For comments, corrections and updates, please contact mono@novell.com ICSharpCode.SharpZipLib, GPL with exceptions. See: mcs/class/ICSharpCode.SharpZipLib/README +** mcs/class/System.Core/System/TimeZoneInfo.Android.cs + + This is a port of Apache 2.0-licensed Android code, and thus is + licensed under the Apache 2.0 license: + + http://www.apache.org/licenses/LICENSE-2.0 + ** mcs/tools diff --git a/mcs/class/System.Core/System/TimeZoneInfo.Android.cs b/mcs/class/System.Core/System/TimeZoneInfo.Android.cs new file mode 100644 index 000000000000..c95bb1ef15c8 --- /dev/null +++ b/mcs/class/System.Core/System/TimeZoneInfo.Android.cs @@ -0,0 +1,299 @@ +/* + * System.TimeZoneInfo Android Support + * + * Author(s) + * Jonathan Pryor + * The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if MONODROID + +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + +namespace System { + + partial class TimeZoneInfo { + + /* + * Android Timezone support infrastructure. + * + * This is a C# port of org.apache.harmony.luni.internal.util.ZoneInfoDB: + * + * http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java;h=3e7bdc3a952b24da535806d434a3a27690feae26;hb=HEAD + * + * From the ZoneInfoDB source: + * + * However, to conserve disk space the data for all time zones are + * concatenated into a single file, and a second file is used to indicate + * the starting position of each time zone record. A third file indicates + * the version of the zoneinfo databse used to generate the data. + * + * which succinctly describes why we can't just use the LIBC implementation in + * TimeZoneInfo.cs -- the "standard Unixy" directory structure is NOT used. + */ + static class ZoneInfoDB { + const int TimeZoneNameLength = 40; + const int TimeZoneIntSize = 4; + + static readonly string ZoneDirectoryName = Environment.GetEnvironmentVariable ("ANDROID_ROOT") + "/usr/share/zoneinfo/"; + static readonly string ZoneFileName = ZoneDirectoryName + "zoneinfo.dat"; + static readonly string IndexFileName = ZoneDirectoryName + "zoneinfo.idx"; + const string DefaultVersion = "2007h"; + static readonly string VersionFileName = ZoneDirectoryName + "zoneinfo.version"; + + static readonly object _lock = new object (); + + static readonly string version; + static readonly string[] names; + static readonly int[] starts; + static readonly int[] lengths; + static readonly int[] offsets; + + static ZoneInfoDB () + { + try { + version = ReadVersion (); + } catch { + version = DefaultVersion; + } + + try { + ReadDatabase (out names, out starts, out lengths, out offsets); + } catch { + names = new string [0]; + starts = new int [0]; + lengths = new int [0]; + offsets = new int [0]; + } + } + + static string ReadVersion () + { + using (var file = new StreamReader (VersionFileName, Encoding.GetEncoding ("iso-8859-1"))) { + return file.ReadToEnd ().Trim (); + } + } + + static void ReadDatabase (out string[] names, out int[] starts, out int[] lengths, out int[] offsets) + { + using (var file = File.OpenRead (IndexFileName)) { + var nbuf = new byte [TimeZoneNameLength]; + + int numEntries = (int) (file.Length / (TimeZoneNameLength + 3*TimeZoneIntSize)); + + char[] namebuf = new char [TimeZoneNameLength]; + + names = new string [numEntries]; + starts = new int [numEntries]; + lengths = new int [numEntries]; + offsets = new int [numEntries]; + + for (int i = 0; i < numEntries; ++i) { + Fill (file, nbuf, nbuf.Length); + int namelen; + for (namelen = 0; namelen < nbuf.Length; ++namelen) { + if (nbuf [namelen] == '\0') + break; + namebuf [namelen] = (char) (nbuf [namelen] & 0xFF); + } + + names [i] = new string (namebuf, 0, namelen); + starts [i] = ReadInt32 (file, nbuf); + lengths [i] = ReadInt32 (file, nbuf); + offsets [i] = ReadInt32 (file, nbuf); + } + } + } + + static void Fill (Stream stream, byte[] nbuf, int required) + { + int read, offset = 0; + while (offset < required && (read = stream.Read (nbuf, offset, required - offset)) > 0) + offset += read; + if (read != required) + throw new EndOfStreamException ("Needed to read " + required + " bytes; read " + read + " bytes"); + } + + // From java.io.RandomAccessFioe.readInt(), as we need to use the same + // byte ordering as Java uses. + static int ReadInt32 (Stream stream, byte[] nbuf) + { + Fill (stream, nbuf, 4); + return ((nbuf [0] & 0xff) << 24) + ((nbuf [1] & 0xff) << 16) + + ((nbuf [2] & 0xff) << 8) + (nbuf [3] & 0xff); + } + + internal static string Version { + get {return version;} + } + + internal static IEnumerable GetAvailableIds () + { + return GetAvailableIds (0, false); + } + + internal static IEnumerable GetAvailableIds (int rawOffset) + { + return GetAvailableIds (rawOffset, true); + } + + static IEnumerable GetAvailableIds (int rawOffset, bool checkOffset) + { + for (int i = 0; i < offsets.Length; ++i) { + if (!checkOffset || offsets [i] == rawOffset) + yield return names [i]; + } + } + + static TimeZoneInfo _GetTimeZone (string name) + { + int start, length; + using (var stream = GetTimeZoneData (name, out start, out length)) { + if (stream == null) + return null; + byte[] buf = new byte [length]; + Fill (stream, buf, buf.Length); + return TimeZoneInfo.ParseTZBuffer (name, buf, length); + } + } + + static FileStream GetTimeZoneData (string name, out int start, out int length) + { + var f = new FileInfo (Path.Combine (ZoneDirectoryName, name)); + if (f.Exists) { + start = 0; + length = (int) f.Length; + return f.OpenRead (); + } + + start = length = 0; + + int i = Array.BinarySearch (names, name); + if (i < 0) + return null; + + start = starts [i]; + length = lengths [i]; + + var stream = File.OpenRead (ZoneFileName); + stream.Seek (start, SeekOrigin.Begin); + + return stream; + } + + internal static TimeZoneInfo GetTimeZone (string id) + { + if (id != null) { + if (id == "GMT" || id == "UTC") + return new TimeZoneInfo (id, TimeSpan.FromSeconds (0), id, id, id, null, true); + if (id.StartsWith ("GMT")) + return new TimeZoneInfo (id, + TimeSpan.FromSeconds (ParseNumericZone (id)), + id, id, id, null, true); + } + + try { + return _GetTimeZone (id); + } catch (Exception e) { + return null; + } + } + + static int ParseNumericZone (string name) + { + if (name == null || !name.StartsWith ("GMT") || name.Length <= 3) + return 0; + + int sign; + if (name [3] == '+') + sign = 1; + else if (name [3] == '-') + sign = -1; + else + return 0; + + int where; + int hour = 0; + bool colon = false; + for (where = 4; where < name.Length; where++) { + char c = name [where]; + + if (c == ':') { + where++; + colon = true; + break; + } + + if (c >= '0' && c <= '9') + hour = hour * 10 + c - '0'; + else + return 0; + } + + int min = 0; + for (; where < name.Length; where++) { + char c = name [where]; + + if (c >= '0' && c <= '9') + min = min * 10 + c - '0'; + else + return 0; + } + + if (colon) + return sign * (hour * 60 + min) * 60; + else if (hour >= 100) + return sign * ((hour / 100) * 60 + (hour % 100)) * 60; + else + return sign * (hour * 60) * 60; + } + + static TimeZoneInfo defaultZone; + internal static TimeZoneInfo Default { + get { + lock (_lock) { + if (defaultZone != null) + return defaultZone; + return defaultZone = GetTimeZone (GetDefaultTimeZoneName ()); + } + } + } + + // + [DllImport ("/system/lib/libc.so")] + static extern int __system_property_get (string name, StringBuilder value); + + const int MaxPropertyNameLength = 32; // + const int MaxPropertyValueLength = 92; // + + static string GetDefaultTimeZoneName () + { + var buf = new StringBuilder (MaxPropertyValueLength + 1); + int n = __system_property_get ("persist.sys.timezone", buf); + if (n > 0) + return buf.ToString (); + return null; + } + } + } +} + +#endif // MONODROID + diff --git a/mcs/class/System.Core/System/TimeZoneInfo.cs b/mcs/class/System.Core/System/TimeZoneInfo.cs index 67cafd775da8..cb464b54ad9c 100644 --- a/mcs/class/System.Core/System/TimeZoneInfo.cs +++ b/mcs/class/System.Core/System/TimeZoneInfo.cs @@ -35,10 +35,11 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Runtime.Serialization; using System.Text; -#if LIBC +#if LIBC || MONODROID using System.IO; using Mono; #endif @@ -83,7 +84,9 @@ public string Id { public static TimeZoneInfo Local { get { if (local == null) { -#if LIBC +#if MONODROID + local = ZoneInfoDB.Default; +#elif LIBC try { local = FindSystemTimeZoneByFileName ("Local", "/etc/localtime"); } catch { @@ -320,7 +323,9 @@ public static TimeZoneInfo FindSystemTimeZoneById (string id) return FromRegistryKey(id, key); } #endif -#if LIBC +#if MONODROID + return ZoneInfoDB.GetTimeZone (id); +#elif LIBC string filepath = Path.Combine (TimeZoneDirectory, id); return FindSystemTimeZoneByFileName (id, filepath); #else @@ -522,7 +527,10 @@ public static ReadOnlyCollection GetSystemTimeZones () return new ReadOnlyCollection (systemTimeZones); } #endif -#if LIBC +#if MONODROID + systemTimeZones.AddRange (ZoneInfoDB.GetAvailableIds () + .Select (id => ZoneInfoDB.GetTimeZone (id))); +#elif LIBC string[] continents = new string [] {"Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Brazil", "Canada", "Chile", "Europe", "Indian", "Mexico", "Mideast", "Pacific", "US"}; foreach (string continent in continents) { try { @@ -782,7 +790,7 @@ static List ValidateRules (List adjustmentRules) return adjustmentRules; } -#if LIBC +#if LIBC || MONODROID private static bool ValidTZFile (byte [] buffer, int length) { StringBuilder magic = new StringBuilder (); diff --git a/mcs/class/System.Core/monodroid_System.Core.dll.sources b/mcs/class/System.Core/monodroid_System.Core.dll.sources index 0129121538cd..a1b6e09476de 100644 --- a/mcs/class/System.Core/monodroid_System.Core.dll.sources +++ b/mcs/class/System.Core/monodroid_System.Core.dll.sources @@ -1 +1,2 @@ #include monodroid_bootstrap_System.Core.dll.sources +System/TimeZoneInfo.Android.cs From 1fe8f7eca55af81f2fe5e481bc9f703cb25d61dc Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 16 Dec 2010 19:22:42 +0100 Subject: [PATCH 59/93] Improve support for exception filters. * mini-exceptions.c (mono_handle_exception_internal_first_pass): Store the exception object in bp + ei->exvar_offset before invoking an exception filter. Use mono_debugger_agent_exception_filter(). * debugger-agent.c: Add mono_debugger_agent_exception_filter(); stores the original context in `tls->filter_ctx' while invoking the filter. * Mono.Debugger.Soft/Test: Add test cases. --- mcs/class/Mono.Debugger.Soft/Makefile | 7 +- .../Mono.Debugger.Soft/Test/dtest-app.cs | 73 +++++++++++++++++ .../Test/dtest-excfilter.il | 47 +++++++++++ mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 81 ++++++++++++++++++- mono/mini/debugger-agent.c | 53 ++++++++++++ mono/mini/debugger-agent.h | 6 ++ mono/mini/mini-exceptions.c | 32 +++++++- 7 files changed, 294 insertions(+), 5 deletions(-) create mode 100644 mcs/class/Mono.Debugger.Soft/Test/dtest-excfilter.il diff --git a/mcs/class/Mono.Debugger.Soft/Makefile b/mcs/class/Mono.Debugger.Soft/Makefile index ac4d61bad533..607d3523574f 100644 --- a/mcs/class/Mono.Debugger.Soft/Makefile +++ b/mcs/class/Mono.Debugger.Soft/Makefile @@ -8,12 +8,15 @@ LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:Mono.Cecil.dll /r:System.Core.dll TEST_MCS_FLAGS = /r:Mono.Cecil.dll -test: dtest-app.exe -check: dtest-app.exe +test: dtest-app.exe dtest-excfilter.exe +check: dtest-app.exe dtest-excfilter.exe dtest-app.exe: Test/dtest-app.cs $(CSCOMPILE) -out:$@ -unsafe -debug Test/dtest-app.cs +dtest-excfilter.exe: Test/dtest-excfilter.il + $(INTERNAL_ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il + CLEAN_FILES = dtest-app.exe dtest-app.exe.mdb #NO_TEST = yes diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 501157943f94..55b6092e84b6 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -171,6 +171,7 @@ public static int Main (String[] args) { assembly_load (); invoke (); exceptions (); + exception_filter (); threads (); dynamic_methods (); if (args.Length > 0 && args [0] == "domain-test") @@ -642,6 +643,78 @@ public static void exceptions () { } } + internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method) + { + if (dlg == null) + throw new ArgumentNullException (); + if (dlg.Target != null) + throw new ArgumentException (); + if (dlg.Method == null) + throw new ArgumentException (); + + var ret_type = dlg.Method.ReturnType; + var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray (); + + var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true); + var ig = dynamic.GetILGenerator (); + + LocalBuilder retval = null; + if (ret_type != typeof (void)) + retval = ig.DeclareLocal (ret_type); + + var label = ig.BeginExceptionBlock (); + + for (int i = 0; i < param_types.Length; i++) + ig.Emit (OpCodes.Ldarg, i); + ig.Emit (OpCodes.Call, dlg.Method); + + if (retval != null) + ig.Emit (OpCodes.Stloc, retval); + + ig.Emit (OpCodes.Leave, label); + + ig.BeginExceptFilterBlock (); + + ig.Emit (OpCodes.Call, filter_method); + + ig.BeginCatchBlock (null); + + ig.Emit (OpCodes.Pop); + + ig.EndExceptionBlock (); + + if (retval != null) + ig.Emit (OpCodes.Ldloc, retval); + + ig.Emit (OpCodes.Ret); + + return dynamic.CreateDelegate (dlg.GetType ()); + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + static void exception_filter_method () { + throw new InvalidOperationException (); + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + static int exception_filter_filter (Exception exc) { + return 1; + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static void exception_filter () { + var method = typeof (Tests).GetMethod ( + "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static); + var filter_method = typeof (Tests).GetMethod ( + "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static); + + var dlg = Delegate.CreateDelegate (typeof (Action), method); + + var wrapper = (Action) create_filter_delegate (dlg, filter_method); + + wrapper (); + } + [MethodImplAttribute (MethodImplOptions.NoInlining)] public static bool return_true () { return true; diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-excfilter.il b/mcs/class/Mono.Debugger.Soft/Test/dtest-excfilter.il new file mode 100644 index 000000000000..3d435fda1e11 --- /dev/null +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-excfilter.il @@ -0,0 +1,47 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'dtest-lib' { } + +.class public auto ansi ExceptionFilterTest + extends [mscorlib]System.Object +{ + .method public static void Main () cil managed + { + .entrypoint + call void class ExceptionFilterTest::Test () + ret + } + + .method public static int32 Filter ([mscorlib]System.Exception exc) cil managed noinlining + { + ldc.i4.1 + ret + } + + .method public static void Handler ([mscorlib]System.Exception exc) cil managed noinlining + { + ret + } + + .method public static void Test () cil managed noinlining + { + .try { + newobj instance void class [mscorlib]System.InvalidOperationException::.ctor () + throw + + leave end + } filter { + call int32 class ExceptionFilterTest::Filter([mscorlib]System.Exception) + endfilter + } { + call void class ExceptionFilterTest::Handler([mscorlib]System.Exception) + leave end + } + + end: + ret + } +} diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 297910bdc63b..fcf774d47057 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -2184,6 +2184,85 @@ public void Exceptions () { }); } + [Test] + public void ExceptionFilter () { + Event e = run_until ("exception_filter"); + + MethodMirror m = entry_point.DeclaringType.GetMethod ("exception_filter_filter"); + Assert.IsNotNull (m); + + vm.SetBreakpoint (m, 0); + + vm.Resume (); + + e = vm.GetNextEvent (); + Assert.AreEqual (EventType.Breakpoint, e.EventType); + Assert.IsTrue (e is BreakpointEvent); + Assert.AreEqual (m.Name, (e as BreakpointEvent).Method.Name); + + var frames = e.Thread.GetFrames (); + + Assert.IsTrue (frames [0].Location.SourceFile.IndexOf ("dtest-app.cs") != -1); + Assert.AreEqual ("exception_filter_filter", frames [0].Location.Method.Name); + + Assert.AreEqual (0, frames [1].Location.Method.MetadataToken); + Assert.AreEqual (0x0f, frames [1].Location.ILOffset); + + Assert.AreEqual ("exception_filter_method", frames [2].Location.Method.Name); + Assert.AreEqual (0x05, frames [2].Location.ILOffset); + + Assert.AreEqual (0, frames [3].Location.Method.MetadataToken, 0); + Assert.AreEqual (0, frames [3].Location.ILOffset); + + Assert.AreEqual ("exception_filter", frames [4].Location.Method.Name); + } + + [Test] + public void ExceptionFilter2 () { + vm.Dispose (); + + Start (new string [] { "dtest-excfilter.exe" }); + + MethodMirror filter_method = entry_point.DeclaringType.GetMethod ("Filter"); + Assert.IsNotNull (filter_method); + + MethodMirror test_method = entry_point.DeclaringType.GetMethod ("Test"); + Assert.IsNotNull (test_method); + + vm.SetBreakpoint (filter_method, 0); + + vm.Resume (); + + var e = vm.GetNextEvent (); + Assert.AreEqual (EventType.Breakpoint, e.EventType); + Assert.IsTrue (e is BreakpointEvent); + Assert.AreEqual (filter_method.Name, (e as BreakpointEvent).Method.Name); + + var frames = e.Thread.GetFrames (); + + Assert.AreEqual (4, frames.Count ()); + + Assert.AreEqual (filter_method.Name, frames [0].Location.Method.Name); + Assert.AreEqual (20, frames [0].Location.LineNumber); + Assert.AreEqual (0, frames [0].Location.ILOffset); + + Assert.AreEqual (test_method.Name, frames [1].Location.Method.Name); + Assert.AreEqual (37, frames [1].Location.LineNumber); + Assert.AreEqual (0x0b, frames [1].Location.ILOffset); + + Assert.AreEqual (test_method.Name, frames [2].Location.Method.Name); + Assert.AreEqual (33, frames [2].Location.LineNumber); + Assert.AreEqual (0x05, frames [2].Location.ILOffset); + + Assert.AreEqual (entry_point.Name, frames [3].Location.Method.Name); + Assert.AreEqual (14, frames [3].Location.LineNumber); + Assert.AreEqual (0x00, frames [3].Location.ILOffset); + + vm.Exit (0); + + vm = null; + } + [Test] public void EventSets () { // @@ -2485,4 +2564,4 @@ public void SingleStepRegress654694 () { Assert.IsTrue (e is StepEvent); } -} \ No newline at end of file +} diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index fce0cad6357e..e68bf81c98af 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -213,6 +213,10 @@ typedef struct { gboolean has_async_ctx; + gboolean has_filter_ctx; + MonoContext filter_ctx; + MonoLMF *filter_lmf; + /* * The lmf where the stack walk can be started for running threads. */ @@ -2595,6 +2599,17 @@ process_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data) return FALSE; } +static gboolean +process_filter_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data) +{ + ComputeFramesUserData *ud = user_data; + + if (MONO_CONTEXT_GET_SP (ctx) >= MONO_CONTEXT_GET_SP (&ud->tls->filter_ctx)) + return TRUE; + + return process_frame (info, ctx, user_data); +} + static void compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) { @@ -2618,6 +2633,10 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) /* Have to use the state saved by the signal handler */ process_frame (&tls->async_last_frame, NULL, &user_data); mono_walk_stack (process_frame, tls->domain, &tls->async_ctx, FALSE, thread, tls->async_lmf, &user_data); + } else if (tls->has_filter_ctx) { + if (tls->has_context) + mono_walk_stack (process_filter_frame, tls->domain, &tls->ctx, FALSE, thread, tls->lmf, &user_data); + mono_walk_stack (process_frame, tls->domain, &tls->filter_ctx, FALSE, thread, tls->filter_lmf, &user_data); } else if (tls->has_context) { mono_walk_stack (process_frame, tls->domain, &tls->ctx, FALSE, thread, tls->lmf, &user_data); } else { @@ -4326,6 +4345,40 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx tls->has_catch_ctx = FALSE; } +void +mono_debugger_agent_begin_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx) +{ + DebuggerTlsData *tls; + + if (!inited) + return; + + tls = TlsGetValue (debugger_tls_id); + if (!tls) + return; + + memcpy (&tls->filter_ctx, orig_ctx, sizeof (MonoContext)); + tls->has_filter_ctx = TRUE; + + tls->filter_lmf = mono_get_lmf (); + tls->domain = mono_domain_get (); +} + +void +mono_debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx) +{ + DebuggerTlsData *tls; + + if (!inited) + return; + + tls = TlsGetValue (debugger_tls_id); + if (!tls) + return; + + tls->has_filter_ctx = FALSE; +} + /* * buffer_add_value_full: * diff --git a/mono/mini/debugger-agent.h b/mono/mini/debugger-agent.h index 4d7bf8c3341e..09549270a490 100644 --- a/mono/mini/debugger-agent.h +++ b/mono/mini/debugger-agent.h @@ -27,4 +27,10 @@ gboolean mono_debugger_agent_thread_interrupt (void *sigctx, MonoJitInfo *ji) MO void mono_debugger_agent_handle_exception (MonoException *ext, MonoContext *throw_ctx, MonoContext *catch_ctx) MONO_INTERNAL; +void +mono_debugger_agent_begin_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx) MONO_INTERNAL; + +void +mono_debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx) MONO_INTERNAL; + #endif diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index 2a022ec30808..1709de8ee582 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -1268,16 +1268,44 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, gpointer obj, gpoin if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) { mono_perfcounters->exceptions_filters++; mono_debugger_call_exception_handler (ei->data.filter, MONO_CONTEXT_GET_SP (ctx), ex_obj); + if (mono_ex && !initial_trace_ips) { + trace_ips = g_list_reverse (trace_ips); + MONO_OBJECT_SETREF (mono_ex, trace_ips, glist_to_array (trace_ips, mono_defaults.int_class)); + + if (has_dynamic_methods) + /* These methods could go away anytime, so compute the stack trace now */ + MONO_OBJECT_SETREF (mono_ex, stack_trace, ves_icall_System_Exception_get_trace (mono_ex)); + } + g_list_free (trace_ips); + + if (ji->from_llvm) { +#ifdef MONO_CONTEXT_SET_LLVM_EXC_REG + MONO_CONTEXT_SET_LLVM_EXC_REG (ctx, ex_obj); +#else + g_assert_not_reached (); +#endif + } else { + /* store the exception object in bp + ei->exvar_offset */ + *((gpointer *)(gpointer)((char *)MONO_CONTEXT_GET_BP (ctx) + ei->exvar_offset)) = ex_obj; + } + + mono_debugger_agent_begin_exception_filter (mono_ex, ctx, &initial_ctx); filtered = call_filter (ctx, ei->data.filter); + mono_debugger_agent_end_exception_filter (mono_ex, ctx, &initial_ctx); if (filtered && out_filter_idx) *out_filter_idx = filter_idx; if (out_ji) *out_ji = ji; filter_idx ++; + + if (filtered) { + /* mono_debugger_agent_handle_exception () needs this */ + MONO_CONTEXT_SET_IP (ctx, ei->handler_start); + return TRUE; + } } - if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE && - mono_object_isinst (ex_obj, catch_class)) || filtered) { + if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst (ex_obj, catch_class)) { if (mono_ex && !initial_trace_ips) { trace_ips = g_list_reverse (trace_ips); MONO_OBJECT_SETREF (mono_ex, trace_ips, glist_to_array (trace_ips, mono_defaults.int_class)); From 89587c475a48b06225f5005674b77234954184da Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 18:22:30 +0000 Subject: [PATCH 60/93] [659970] Close anonymous method scope also for top-level blocks --- mcs/mcs/cs-parser.jay | 1 + mcs/tests/test-anon-83.cs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 mcs/tests/test-anon-83.cs diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 06f6ceccf07c..6a9e1929176e 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -6250,6 +6250,7 @@ void start_block (Location loc) { if (current_block == null) { current_block = new ToplevelBlock (compiler, current_local_parameters, loc); + parsing_anonymous_method = false; } else if (parsing_anonymous_method) { current_block = new ParametersBlock (current_block, current_local_parameters, loc); parsing_anonymous_method = false; diff --git a/mcs/tests/test-anon-83.cs b/mcs/tests/test-anon-83.cs new file mode 100644 index 000000000000..879c2c899cd4 --- /dev/null +++ b/mcs/tests/test-anon-83.cs @@ -0,0 +1,20 @@ +using System; + +public class C +{ + public event EventHandler MyDelegate = delegate { }; + + internal void DoSomething (bool bValue) + { + if (!bValue) { + // It has to be here to check we are closing correctly top-block + return; + } + } + + public static void Main () + { + } +} + + From bfb5bf16b80470c64c1d202b300e1d3a79fcd283 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 16 Dec 2010 19:46:07 +0100 Subject: [PATCH 61/93] Add documentation for my new exception filter code. --- mono/mini/debugger-agent.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index e68bf81c98af..59cb24f58a16 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -2604,6 +2604,14 @@ process_filter_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data { ComputeFramesUserData *ud = user_data; + /* + * 'tls->filter_ctx' is the location of the throw site. + * + * mono_walk_stack() will never actually hit the throw site, but unwind + * directly from the filter to the call site; we abort stack unwinding here + * once this happens and resume from the throw site. + */ + if (MONO_CONTEXT_GET_SP (ctx) >= MONO_CONTEXT_GET_SP (&ud->tls->filter_ctx)) return TRUE; @@ -2634,8 +2642,16 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) process_frame (&tls->async_last_frame, NULL, &user_data); mono_walk_stack (process_frame, tls->domain, &tls->async_ctx, FALSE, thread, tls->async_lmf, &user_data); } else if (tls->has_filter_ctx) { + /* + * We are inside an exception filter. + * + * First we add all the frames from inside the filter; 'tls->ctx' has the current context. + */ if (tls->has_context) mono_walk_stack (process_filter_frame, tls->domain, &tls->ctx, FALSE, thread, tls->lmf, &user_data); + /* + * After that, we resume unwinding from the location where the exception has been thrown. + */ mono_walk_stack (process_frame, tls->domain, &tls->filter_ctx, FALSE, thread, tls->filter_lmf, &user_data); } else if (tls->has_context) { mono_walk_stack (process_frame, tls->domain, &tls->ctx, FALSE, thread, tls->lmf, &user_data); @@ -4357,6 +4373,30 @@ mono_debugger_agent_begin_exception_filter (MonoException *exc, MonoContext *ctx if (!tls) return; + /* + * We're about to invoke an exception filter during the first pass of exception handling. + * + * 'ctx' is the context that'll get passed to the filter ('call_filter (ctx, ei->data.filter)'), + * 'orig_ctx' is the context where the exception has been thrown. + * + * + * See mcs/class/Mono.Debugger.Soft/Tests/dtest-excfilter.il for an example. + * + * If we're stopped in Filter(), normal stack unwinding would first unwind to + * the call site (line 37) and then continue to Main(), but it would never + * include the throw site (line 32). + * + * Since exception filters are invoked during the first pass of exception handling, + * the stack frames of the throw site are still intact, so we should include them + * in a stack trace. + * + * We do this here by saving the context of the throw site in 'tls->filter_ctx'. + * + * Exception filters are used by MonoDroid, where we want to stop inside a call filter, + * but report the location of the 'throw' to the user. + * + */ + memcpy (&tls->filter_ctx, orig_ctx, sizeof (MonoContext)); tls->has_filter_ctx = TRUE; From 3455cf823ef78aad5c3c192626405d140403db91 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 16 Dec 2010 19:06:04 +0000 Subject: [PATCH 62/93] Set ImageRuntimeVersion based on mscorlib version when available --- mcs/mcs/driver.cs | 2 +- mcs/mcs/ikvm.cs | 41 ++++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs index c039fe2a9a36..891209bc4d6e 100644 --- a/mcs/mcs/driver.cs +++ b/mcs/mcs/driver.cs @@ -1486,7 +1486,7 @@ public bool Compile () ShowTime ("Initializing predefined types"); - if (!assembly.Create (loader.Domain)) + if (!assembly.Create (loader)) return false; // System.Object was not loaded, use compiled assembly as corlib diff --git a/mcs/mcs/ikvm.cs b/mcs/mcs/ikvm.cs index 14ea40b52a86..d38be0b70c56 100644 --- a/mcs/mcs/ikvm.cs +++ b/mcs/mcs/ikvm.cs @@ -129,29 +129,32 @@ public AssemblyDefinitionStatic (ModuleContainer module, string name, string fil // // Initializes the code generator // - public bool Create (Universe domain) + public bool Create (StaticLoader loader) { ResolveAssemblySecurityAttributes (); var an = CreateAssemblyName (); - Builder = domain.DefineDynamicAssembly (an, AssemblyBuilderAccess.Save, Path.GetDirectoryName (file_name)); - - // Sets output file metadata version, this makes sense for mscorlib - // compilation only but won't restrict that for now - switch (RootContext.StdLibRuntimeVersion){ - case RuntimeVersion.v4: - Builder.__SetImageRuntimeVersion ("v4.0.30319", 0x20000); - break; - case RuntimeVersion.v2: - Builder.__SetImageRuntimeVersion ("v2.0.50727", 0x20000); - break; - case RuntimeVersion.v1: - // Compiler does not do any checks whether the produced metadata - // are valid in the context of 1.0 stream version - Builder.__SetImageRuntimeVersion ("v1.1.4322", 0x10000); - break; - default: - throw new NotImplementedException (); + Builder = loader.Domain.DefineDynamicAssembly (an, AssemblyBuilderAccess.Save, Path.GetDirectoryName (file_name)); + + if (loader.Corlib != null) { + Builder.__SetImageRuntimeVersion (loader.Corlib.ImageRuntimeVersion, 0x20000); + } else { + // Sets output file metadata version when there is no mscorlib + switch (RootContext.StdLibRuntimeVersion) { + case RuntimeVersion.v4: + Builder.__SetImageRuntimeVersion ("v4.0.30319", 0x20000); + break; + case RuntimeVersion.v2: + Builder.__SetImageRuntimeVersion ("v2.0.50727", 0x20000); + break; + case RuntimeVersion.v1: + // Compiler does not do any checks whether the produced metadata + // are valid in the context of 1.0 stream version + Builder.__SetImageRuntimeVersion ("v1.1.4322", 0x10000); + break; + default: + throw new NotImplementedException (); + } } builder_extra = new AssemblyBuilderIKVM (Builder, Compiler); From bfb617e8636436f4243815d25772a0f42eda8e8c Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 16 Dec 2010 14:43:32 -0600 Subject: [PATCH 63/93] Move line inside if () to fix 2 tests. Broke by 9aa23d8ebec0f5c60ae66fee3df8a3c6c39cf191. --- .../Managed.Windows.Forms/System.Windows.Forms/TextBox.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs index fc63bd438082..d7c548ca0a2a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs @@ -356,8 +356,10 @@ internal override Color ChangeBackColor (Color backColor) if (backColor == Color.Empty) { if (!ReadOnly) backColor = SystemColors.Window; + + backcolor_set = false; } - backcolor_set = false; + return backColor; } From 8609775f13619f6b7a67442ccfd93b191e11de99 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 16 Dec 2010 22:26:00 +0100 Subject: [PATCH 64/93] Null out trace_ips after freeing it to avoid crashes. --- mono/mini/mini-exceptions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index 1709de8ee582..23f4b6cef325 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -1277,6 +1277,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, gpointer obj, gpoin MONO_OBJECT_SETREF (mono_ex, stack_trace, ves_icall_System_Exception_get_trace (mono_ex)); } g_list_free (trace_ips); + trace_ips = NULL; if (ji->from_llvm) { #ifdef MONO_CONTEXT_SET_LLVM_EXC_REG From b3dce5c637a30b3a18111264bbd2c61f5cb06763 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 16 Dec 2010 22:31:13 +0100 Subject: [PATCH 65/93] Don't put llvm type infos into the text segment, it is no longer needed. --- mono/mini/mini-llvm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 1df09e826bc7..46555e2eb048 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -2065,12 +2065,6 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMSetLinkage (type_info, LLVMPrivateLinkage); LLVMSetVisibility (type_info, LLVMHiddenVisibility); - /* - * Put this into the .text section so it needs less relocations/stubs, if - * the LSDA is in the .text section too. - */ - LLVMSetSection (type_info, "text"); - /* * Enabling this causes llc to crash: * http://llvm.org/bugs/show_bug.cgi?id=6102 From 0cf8705abf577b7daa2b248babc547a8e9a4793b Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 16 Dec 2010 16:29:56 -0500 Subject: [PATCH 66/93] Fix access policy when more than one scheme is present #659791 * ClientAccessPolicy.cs: Remove special case for scheme * ClientAccessPolicyParser.cs: Add scheme-only entries like full URI --- .../System.Net.Policy/ClientAccessPolicy.cs | 41 ++++++++++--------- .../ClientAccessPolicyParser.cs | 17 +------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicy.cs b/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicy.cs index ea98f9b0428b..ab6af6c6d3ad 100644 --- a/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicy.cs +++ b/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicy.cs @@ -153,7 +153,6 @@ public AllowFrom () { Domains = new List (); HttpRequestHeaders = new Headers (); - Scheme = String.Empty; } public bool AllowAnyDomain { get; set; } @@ -164,23 +163,8 @@ public AllowFrom () public bool AllowAnyMethod { get; set; } - public string Scheme { get; internal set; } - public bool IsAllowed (Uri uri, string method) { - // check scheme - if ((Scheme.Length > 0) && (Scheme == uri.Scheme)) { - switch (Scheme) { - case "http": - return (uri.Port == 80); - case "https": - return (uri.Port == 443); - case "file": - return true; - default: - return false; - } - } // check methods if (!AllowAnyMethod) { // if not all methods are allowed (*) then only GET and POST request are possible @@ -195,12 +179,16 @@ public bool IsAllowed (Uri uri, string method) if (AllowAnyDomain) return true; - if (Domains.All (domain => !CheckDomainUri (domain))) + if (Domains.All (domain => !CheckDomainUri (uri, domain))) return false; return true; } - static bool CheckDomainUri (string policy) + const string AllHttpScheme = "http://*"; + const string AllHttpsScheme = "https://*"; + const string AllFileScheme = "file:///"; + + static bool CheckDomainUri (Uri applicationUri, string policy) { Uri uri; if (Uri.TryCreate (policy, UriKind.Absolute, out uri)) { @@ -218,7 +206,22 @@ static bool CheckDomainUri (string policy) // check for matching protocol if (!policy.StartsWith (ApplicationUri.Scheme)) return false; - // check for the wirld card immediately after the scheme + + switch (ApplicationUri.Scheme) { + case "http": + if (policy == AllHttpScheme) + return (applicationUri.Port == 80); + break; + case "https": + if (policy == AllHttpsScheme) + return (applicationUri.Port == 443); + break; + case "file": + if (policy == AllFileScheme) + return true; + break; + } + if (policy.IndexOf ("://*.", ApplicationUri.Scheme.Length) != ApplicationUri.Scheme.Length) return false; // remove *. from uri diff --git a/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicyParser.cs b/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicyParser.cs index f1cd5edb4085..365cef284cd3 100644 --- a/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicyParser.cs +++ b/mcs/class/System.Net/System.Net.Policy/ClientAccessPolicyParser.cs @@ -191,23 +191,10 @@ static void ReadAllowFromElement (XmlReader reader, AccessPolicy policy) switch (reader.LocalName) { case "domain": var d = reader.GetAttribute ("uri"); - switch (d) { - case "*": + if (d == "*") v.AllowAnyDomain = true; - break; - case "http://*": - v.Scheme = "http"; - break; - case "https://*": - v.Scheme = "https"; - break; - case "file:///": - v.Scheme = "file"; - break; - default: + else v.Domains.Add (d); - break; - } reader.Skip (); break; default: From f7ad295d0509b1b23e39ef124c7dad2a0a2281f5 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 03:33:50 +0100 Subject: [PATCH 67/93] Reserve r7 on arm/darwin even if iphone_abi is disabled. --- mono/mini/mini-arm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index ccfb22238dbc..62f77b7bf3e8 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -43,10 +43,17 @@ static int thumb_supported = 0; * Whenever to use the ARM EABI */ static int eabi_supported = 0; + +/* + * Whenever we are on arm/darwin aka the iphone. + */ +static int darwin = 0; /* * Whenever to use the iphone ABI extensions: * http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/index.html * Basically, r7 is used as a frame pointer and it should point to the saved r7 + lr. + * This is required for debugging/profiling tools to work, but it has some overhead so it should + * only be turned on in debug builds. */ static int iphone_abi = 0; static int i8_align; @@ -507,6 +514,7 @@ mono_arch_cpu_optimizazions (guint32 *exclude_mask) #if __APPLE__ thumb_supported = TRUE; v5_supported = TRUE; + darwin = TRUE; iphone_abi = TRUE; #else char buf [512]; @@ -624,7 +632,7 @@ mono_arch_get_global_int_regs (MonoCompile *cfg) regs = g_list_prepend (regs, GUINT_TO_POINTER (ARMREG_V1)); regs = g_list_prepend (regs, GUINT_TO_POINTER (ARMREG_V2)); regs = g_list_prepend (regs, GUINT_TO_POINTER (ARMREG_V3)); - if (iphone_abi) + if (darwin) /* V4=R7 is used as a frame pointer, but V7=R10 is preserved */ regs = g_list_prepend (regs, GUINT_TO_POINTER (ARMREG_V7)); else @@ -4586,6 +4594,7 @@ mono_arch_emit_prolog (MonoCompile *cfg) * the frame, so we keep using our own frame pointer. * FIXME: Optimize this. */ + g_assert (darwin); ARM_PUSH (code, (1 << ARMREG_R7) | (1 << ARMREG_LR)); ARM_MOV_REG_REG (code, ARMREG_R7, ARMREG_SP); prev_sp_offset += 8; /* r7 and lr */ @@ -5788,6 +5797,7 @@ mono_arch_set_target (char *mtriple) if (strstr (mtriple, "darwin")) { v5_supported = TRUE; thumb_supported = TRUE; + darwin = TRUE; iphone_abi = TRUE; } if (strstr (mtriple, "gnueabi")) From 5b0a74c1c7ae758397dd1fcc705f1c8a26bbd89e Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 04:39:49 +0100 Subject: [PATCH 68/93] Send back an error instead of asserting when a breakpoint cannot be set at an il offset because it has no seq point. Fixes #620099. --- mono/mini/debugger-agent.c | 108 +++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 46 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 59cb24f58a16..db390ba7c679 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -72,6 +72,7 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD, #include #include #include +#include #include "debugger-agent.h" #include "mini.h" @@ -301,7 +302,8 @@ typedef enum { ERR_INVALID_ARGUMENT = 102, ERR_UNLOADED = 103, ERR_NO_INVOCATION = 104, - ERR_ABSENT_INFORMATION = 105 + ERR_ABSENT_INFORMATION = 105, + ERR_NO_SEQ_POINT_AT_IL_OFFSET = 106 } ErrorCode; typedef enum { @@ -3290,12 +3292,15 @@ breakpoints_init (void) * JI. */ static void -insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo *ji, MonoBreakpoint *bp) +insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo *ji, MonoBreakpoint *bp, MonoError *error) { int i, count; gint32 il_offset = -1, native_offset; BreakpointInstance *inst; + if (error) + mono_error_init (error); + native_offset = 0; for (i = 0; i < seq_points->len; ++i) { il_offset = seq_points->seq_points [i].il_offset; @@ -3306,8 +3311,15 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo } if (i == seq_points->len) { - /* Have to handle this somehow */ - g_error ("Unable to insert breakpoint at %s:%d, seq_points=%d\n", mono_method_full_name (ji->method, TRUE), bp->il_offset, seq_points->len); + char *s = g_strdup_printf ("Unable to insert breakpoint at %s:%d, seq_points=%d\n", mono_method_full_name (ji->method, TRUE), bp->il_offset, seq_points->len); + if (error) { + mono_error_set_error (error, MONO_ERROR_GENERIC, "%s", s); + g_free (s); + return; + } else { + g_error ("%s", s); + g_free (s); + } } inst = g_new0 (BreakpointInstance, 1); @@ -3406,7 +3418,7 @@ add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) continue; g_assert (seq_points); - insert_breakpoint (seq_points, domain, ji, bp); + insert_breakpoint (seq_points, domain, ji, bp, NULL); } } @@ -3414,11 +3426,14 @@ add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) } static void -set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_points, MonoBreakpoint *bp) +set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_points, MonoBreakpoint *bp, MonoError *error) { gpointer code; MonoJitInfo *ji; + if (error) + mono_error_init (error); + code = mono_jit_find_compiled_method_with_jit_info (domain, method, &ji); if (!code) { /* Might be AOTed code */ @@ -3429,42 +3444,11 @@ set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_ } g_assert (code); - insert_breakpoint (seq_points, domain, ji, bp); + insert_breakpoint (seq_points, domain, ji, bp, error); } -typedef struct -{ - MonoBreakpoint *bp; - MonoDomain *domain; -} SetBpUserData; - static void -set_bp_in_method_cb (gpointer key, gpointer value, gpointer user_data) -{ - MonoMethod *method = key; - MonoSeqPointInfo *seq_points = value; - SetBpUserData *ud = user_data; - MonoBreakpoint *bp = ud->bp; - MonoDomain *domain = ud->domain; - - if (bp_matches_method (bp, method)) - set_bp_in_method (domain, method, seq_points, bp); -} - -static void -set_bp_in_domain (gpointer key, gpointer value, gpointer user_data) -{ - MonoDomain *domain = key; - MonoBreakpoint *bp = user_data; - SetBpUserData ud; - - ud.bp = bp; - ud.domain = domain; - - mono_domain_lock (domain); - g_hash_table_foreach (domain_jit_info (domain)->seq_points, set_bp_in_method_cb, &ud); - mono_domain_unlock (domain); -} +clear_breakpoint (MonoBreakpoint *bp); /* * set_breakpoint: @@ -3473,11 +3457,20 @@ set_bp_in_domain (gpointer key, gpointer value, gpointer user_data) * METHOD can be NULL, in which case a breakpoint is placed in all methods. * METHOD can also be a generic method definition, in which case a breakpoint * is placed in all instances of the method. + * If ERROR is non-NULL, then it is set and NULL is returnd if some breakpoints couldn't be + * inserted. */ static MonoBreakpoint* -set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req) +set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError *error) { MonoBreakpoint *bp; + GHashTableIter iter, iter2; + MonoDomain *domain; + MonoMethod *m; + MonoSeqPointInfo *seq_points; + + if (error) + mono_error_init (error); // FIXME: // - suspend/resume the vm to prevent code patching problems @@ -3495,7 +3488,18 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req) mono_loader_lock (); - g_hash_table_foreach (domains, set_bp_in_domain, bp); + g_hash_table_iter_init (&iter, domains); + while (g_hash_table_iter_next (&iter, (void**)&domain, NULL)) { + mono_domain_lock (domain); + + g_hash_table_iter_init (&iter2, domain_jit_info (domain)->seq_points); + while (g_hash_table_iter_next (&iter2, (void**)&m, (void**)&seq_points)) { + if (bp_matches_method (bp, m)) + set_bp_in_method (domain, m, seq_points, bp, error); + } + + mono_domain_unlock (domain); + } mono_loader_unlock (); @@ -3503,6 +3507,11 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req) g_ptr_array_add (breakpoints, bp); mono_loader_unlock (); + if (error && !mono_error_ok (error)) { + clear_breakpoint (bp); + return NULL; + } + return bp; } @@ -4108,7 +4117,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointI * Implement single stepping using breakpoints if possible. */ if (step_to_catch) { - bp = set_breakpoint (method, sp->il_offset, ss_req->req); + bp = set_breakpoint (method, sp->il_offset, ss_req->req, NULL); ss_req->bps = g_slist_append (ss_req->bps, bp); } else if (ss_req->depth == STEP_DEPTH_OVER) { frame_index = 1; @@ -4133,7 +4142,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointI for (i = 0; i < sp->next_len; ++i) { next_sp = &info->seq_points [sp->next [i]]; - bp = set_breakpoint (method, next_sp->il_offset, ss_req->req); + bp = set_breakpoint (method, next_sp->il_offset, ss_req->req, NULL); ss_req->bps = g_slist_append (ss_req->bps, bp); } } @@ -5426,6 +5435,7 @@ static ErrorCode event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { int err; + MonoError error; switch (command) { case CMD_EVENT_REQUEST_SET: { @@ -5508,7 +5518,13 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (req->event_kind == EVENT_KIND_BREAKPOINT) { g_assert (method); - req->info = set_breakpoint (method, location, req); + req->info = set_breakpoint (method, location, req, &error); + if (!mono_error_ok (&error)) { + g_free (req); + DEBUG(1, fprintf (log_file, "[dbg] Failed to set breakpoint: %s\n", mono_error_get_message (&error))); + mono_error_cleanup (&error); + return ERR_NO_SEQ_POINT_AT_IL_OFFSET; + } } else if (req->event_kind == EVENT_KIND_STEP) { g_assert (step_thread_id); @@ -5524,9 +5540,9 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; } } else if (req->event_kind == EVENT_KIND_METHOD_ENTRY) { - req->info = set_breakpoint (NULL, METHOD_ENTRY_IL_OFFSET, req); + req->info = set_breakpoint (NULL, METHOD_ENTRY_IL_OFFSET, req, NULL); } else if (req->event_kind == EVENT_KIND_METHOD_EXIT) { - req->info = set_breakpoint (NULL, METHOD_EXIT_IL_OFFSET, req); + req->info = set_breakpoint (NULL, METHOD_EXIT_IL_OFFSET, req, NULL); } else if (req->event_kind == EVENT_KIND_EXCEPTION) { } else { if (req->nmodifiers) { From 01e4a7c9c21edb4258479ea18ddad50847f66e8a Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 04:45:09 +0100 Subject: [PATCH 69/93] Convert the new NO_SEQ_POINT_AT_IL_OFFSET sdb error code into an exception. --- mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs | 3 ++- .../Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs index 74f8c9f1581a..78028f2637be 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs @@ -276,7 +276,8 @@ public enum ErrorCode { INVALID_ARGUMENT = 102, ERR_UNLOADED = 103, ERR_NO_INVOCATION = 104, - ABSENT_INFORMATION = 105 + ABSENT_INFORMATION = 105, + NO_SEQ_POINT_AT_IL_OFFSET = 106 } public class ErrorHandlerEventArgs : EventArgs { diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs index 7900bdebc103..c105131e42fc 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs @@ -227,6 +227,8 @@ internal void ErrorHandler (object sender, ErrorHandlerEventArgs args) { throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee."); case ErrorCode.ABSENT_INFORMATION: throw new AbsentInformationException (); + case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET: + throw new ArgumentException ("Cannot set breakpoint on the specified IL offset."); default: throw new CommandException (args.ErrorCode); } From 9bc4f0d82f586200bd312009dd71fdd11a07be1e Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 16 Dec 2010 22:19:30 -0600 Subject: [PATCH 70/93] Fix some broken tests that check for assembly version 2.0.0.0 on the 4.0 profile. --- .../ConfigurationManagerTest.cs | 8 +++----- .../ConfigurationPermissionTest.cs | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs index dafab3623afb..038667dd84c2 100644 --- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs +++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs @@ -28,8 +28,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 - using System; using System.Collections; using System.Collections.Specialized; @@ -147,8 +145,10 @@ public void OpenExeConfiguration1_UserLevel_None () FileInfo fi = new FileInfo (config.FilePath); #if TARGET_JVM Assert.AreEqual ("nunit-console.jar.config", fi.Name); -#else +#elif NET_2_0 Assert.AreEqual ("System.Configuration_test_net_2_0.dll.config", fi.Name); +#else + Assert.AreEqual ("System.Configuration_test_net_4_0.dll.config", fi.Name); #endif } @@ -492,5 +492,3 @@ public string GetSettingValue (string key) } } } - -#endif diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationPermissionTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationPermissionTest.cs index 5f994463a28d..3ba5d9988746 100644 --- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationPermissionTest.cs +++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationPermissionTest.cs @@ -27,7 +27,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 using System; using System.Configuration; @@ -153,18 +152,28 @@ public void ToXml () { ConfigurationPermission p = new ConfigurationPermission (PermissionState.Unrestricted); +#if NET_4_0 Assert.AreEqual( - "\n", + "\n", p.ToString().Replace ("\r\n", "\n"), "A1"); - +#else + Assert.AreEqual ( + "\n", + p.ToString ().Replace ("\r\n", "\n"), "A1"); +#endif p = new ConfigurationPermission (PermissionState.None); +#if NET_4_0 Assert.AreEqual ( - "\n", + "\n", p.ToString().Replace ("\r\n", "\n"), "A2"); +#else + Assert.AreEqual ( + "\n", + p.ToString ().Replace ("\r\n", "\n"), "A2"); +#endif } } } -#endif From b5ba5bfb20a43ca20a811152059313f1fcb480d0 Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Fri, 17 Dec 2010 00:32:23 -0500 Subject: [PATCH 71/93] [ThreadPool] Reset the abort state when unloading a domain Properly reset the abort state of threadpool threads that processed domain unloading or were running in a domain that was being unloaded. Thanks go to Kumpera for finding this out. --- mono/metadata/threadpool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index bc3281600e4f..105ecf37dbb6 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -2018,6 +2018,8 @@ async_invoke_thread (gpointer data) mono_unhandled_exception (exc); exit (255); } + if (klass == mono_defaults.threadabortexception_class) + mono_thread_internal_reset_abort (thread); } if (is_socket && tp->is_io) { MonoSocketAsyncResult *state = (MonoSocketAsyncResult *) data; From 093d9ef44814f3320c8cc42c7e77faf35d9a7a51 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 09:05:21 +0000 Subject: [PATCH 72/93] [657601] Fixes parsing pragma warning when encounter eof --- mcs/mcs/cs-tokenizer.cs | 2 +- mcs/tests/test-802.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 mcs/tests/test-802.cs diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs index 5e4b2ebba7ce..4692fccda80b 100644 --- a/mcs/mcs/cs-tokenizer.cs +++ b/mcs/mcs/cs-tokenizer.cs @@ -2182,7 +2182,7 @@ void ParsePragmaDirective (string arg) Report.RegisterWarningRegion (loc).WarningEnable (loc, code, Report); } } - } while (code >= 0 && c != '\n'); + } while (code >= 0 && c != '\n' && c != -1); } return; diff --git a/mcs/tests/test-802.cs b/mcs/tests/test-802.cs new file mode 100644 index 000000000000..e232e30dd48e --- /dev/null +++ b/mcs/tests/test-802.cs @@ -0,0 +1,9 @@ +#pragma warning disable 1591 +public class C +{ + public static void Main () + { + // only to test tokenizer with eof + } +} +#pragma warning restore 1591 \ No newline at end of file From 510289542e9627d7897c583cfcaad67dd3ed46db Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 09:06:21 +0000 Subject: [PATCH 73/93] Add an error to obsolete attribute to get consistent compiler error code --- .../corlib/System.Security.Permissions/SecurityAction.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs b/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs index b35b957d4f29..8e9caf0026bd 100644 --- a/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs +++ b/mcs/class/corlib/System.Security.Permissions/SecurityAction.cs @@ -44,22 +44,22 @@ public enum SecurityAction { Demand = 2, Assert = 3, #if NET_4_0 - [Obsolete] + [Obsolete ("This requests should not be used")] #endif Deny = 4, PermitOnly = 5, LinkDemand = 6, InheritanceDemand = 7, #if NET_4_0 - [Obsolete] + [Obsolete ("This requests should not be used")] #endif RequestMinimum = 8, #if NET_4_0 - [Obsolete] + [Obsolete ("This requests should not be used")] #endif RequestOptional = 9, #if NET_4_0 - [Obsolete] + [Obsolete ("This requests should not be used")] #endif RequestRefuse = 10, } From 4029237c922195c905bfdce40162945e6cc0fdc8 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 09:35:19 +0000 Subject: [PATCH 74/93] Made SecurityAction predefined type --- mcs/mcs/assembly.cs | 7 +-- mcs/mcs/attribute.cs | 25 --------- mcs/mcs/typemanager.cs | 7 +++ mcs/tests/ver-il-dmcs.xml | 105 +++++++++++++++++++++++++++++++++++++- 4 files changed, 115 insertions(+), 29 deletions(-) diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index fb21b000c222..df1602b666d8 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -569,19 +569,20 @@ void ReadModulesAssemblyAttributes () public void Resolve () { - if (RootContext.Unsafe) { + if (RootContext.Unsafe && module.PredefinedTypes.SecurityAction.Define ()) { // // Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)] // when -unsafe option was specified // - Location loc = Location.Null; MemberAccess system_security_permissions = new MemberAccess (new MemberAccess ( new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc); + var req_min = (ConstSpec) module.PredefinedTypes.SecurityAction.GetField ("RequestMinimum", module.PredefinedTypes.SecurityAction.TypeSpec, loc); + Arguments pos = new Arguments (1); - pos.Add (new Argument (new MemberAccess (new MemberAccess (system_security_permissions, "SecurityAction", loc), "RequestMinimum"))); + pos.Add (new Argument (req_min.GetConstant (null))); Arguments named = new Arguments (1); named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (true, loc))); diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index 3b59a197d5c5..8aa4e32c09d4 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -1728,7 +1728,6 @@ public PredefinedAttributes (ModuleContainer module) public class PredefinedAttribute : PredefinedType { protected MethodSpec ctor; - List fields; List properties; public PredefinedAttribute (ModuleContainer module, string ns, string name) @@ -1834,30 +1833,6 @@ ConstructorInfo GetCtorMetaInfo () return (ConstructorInfo) ctor.GetMetaInfo (); } - public FieldSpec GetField (string name, TypeSpec memberType, Location loc) - { - FieldSpec spec; - if (fields != null) { - spec = fields.Find (l => l.Name == name); - } else { - spec = null; - } - - if (spec == null) { - spec = TypeManager.GetPredefinedField (type, name, loc, memberType); - - if (spec != null) { - if (fields == null) { - fields = new List (); - } - - fields.Add (spec); - } - } - - return spec; - } - public PropertySpec GetProperty (string name, TypeSpec memberType, Location loc) { PropertySpec spec; diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs index 7310eb884ef6..667ac192b06f 100644 --- a/mcs/mcs/typemanager.cs +++ b/mcs/mcs/typemanager.cs @@ -215,6 +215,7 @@ class PredefinedTypes public readonly PredefinedType NotSupportedException; public readonly PredefinedType RuntimeFieldHandle; public readonly PredefinedType RuntimeMethodHandle; + public readonly PredefinedType SecurityAction; // // C# 3.0 @@ -257,6 +258,7 @@ public PredefinedTypes (ModuleContainer module) NotSupportedException = new PredefinedType (module, MemberKind.Class, "System", "NotSupportedException"); RuntimeFieldHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeFieldHandle"); RuntimeMethodHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeMethodHandle"); + SecurityAction = new PredefinedType (module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction"); Expression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression"); ExpressionGeneric = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1); @@ -376,6 +378,11 @@ public bool Define () return true; } + public FieldSpec GetField (string name, TypeSpec memberType, Location loc) + { + return TypeManager.GetPredefinedField (type, name, loc, memberType); + } + public string GetSignatureForError () { return ns + "." + name; diff --git a/mcs/tests/ver-il-dmcs.xml b/mcs/tests/ver-il-dmcs.xml index 408c76a5d612..697171442bde 100644 --- a/mcs/tests/ver-il-dmcs.xml +++ b/mcs/tests/ver-il-dmcs.xml @@ -14115,6 +14115,29 @@ + + + + 7 + + + + + 17 + + + 7 + + + + + 26 + + + 7 + + + @@ -17624,7 +17647,7 @@ 1 - 212 + 246 @@ -17693,6 +17716,12 @@ 7 + + 8 + + + 36 + @@ -23270,6 +23299,27 @@ + + + + 1 + + + 44 + + + 1 + + + + + 14 + + + 7 + + + @@ -45914,6 +45964,16 @@ + + + + 1 + + + 7 + + + @@ -49941,6 +50001,28 @@ + + + + 47 + + + 47 + + + 8 + + + 1 + + + 1 + + + 42 + + + @@ -50592,6 +50674,27 @@ + + + + 39 + + + 7 + + + 7 + + + + + 22 + + + 7 + + + From c1d41511b8c4c126ead765b6440a810f6caa0fde Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 11:58:26 +0000 Subject: [PATCH 75/93] [660077] Setup class interfaces for defined types in same way as for imported types --- mcs/mcs/class.cs | 5 +++ mcs/mcs/statement.cs | 11 +++++- mcs/tests/gtest-417-lib.cs | 29 +++++++++++++++ mcs/tests/gtest-417.cs | 35 ++++++++++++++++++ mcs/tests/ver-il-gmcs.xml | 76 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 mcs/tests/gtest-417-lib.cs create mode 100644 mcs/tests/gtest-417.cs diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index f76c1ff3a303..b2383e08406d 100644 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -1524,6 +1524,11 @@ protected virtual bool DoDefineMembers () if (ct != null) ct.CheckConstraints (this); + if (base_type.Interfaces != null) { + foreach (var iface in base_type.Interfaces) + spec.AddInterface (iface); + } + var baseContainer = base_type.MemberDefinition as ClassOrStruct; if (baseContainer != null) { baseContainer.Define (); diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index 2700144ddd07..a639157ca423 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -5479,7 +5479,8 @@ MethodGroupExpr ResolveGetEnumerator (ResolveContext rc) // Option 2: Try to match using IEnumerable interfaces with preference of generic version // TypeSpec iface_candidate = null; - for (TypeSpec t = expr.Type; t != null && t != TypeManager.object_type; t = t.BaseType) { + var t = expr.Type; + do { var ifaces = t.Interfaces; if (ifaces != null) { foreach (var iface in ifaces) { @@ -5502,7 +5503,13 @@ MethodGroupExpr ResolveGetEnumerator (ResolveContext rc) } } } - } + + if (t.IsGenericParameter) + t = t.BaseType; + else + t = null; + + } while (t != null); if (iface_candidate == null) { rc.Report.Error (1579, loc, diff --git a/mcs/tests/gtest-417-lib.cs b/mcs/tests/gtest-417-lib.cs new file mode 100644 index 000000000000..0565f8258196 --- /dev/null +++ b/mcs/tests/gtest-417-lib.cs @@ -0,0 +1,29 @@ +// Compiler options: -t:library + +using System; +using System.Collections; +using System.Collections.Generic; + +public class GlobalMonitoredCharacterCollection : ReadonlyCollection +{ +} + +public class ReadonlyCollection : IReadonlyCollection +{ + protected List m_items; + protected ReadonlyCollection () { m_items = new List (); } + + IEnumerator IEnumerable.GetEnumerator () + { + return m_items.GetEnumerator (); + } + + IEnumerator IEnumerable.GetEnumerator () + { + return m_items.GetEnumerator (); + } +} + +public interface IReadonlyCollection : IEnumerable +{ +} diff --git a/mcs/tests/gtest-417.cs b/mcs/tests/gtest-417.cs new file mode 100644 index 000000000000..c91f9595627c --- /dev/null +++ b/mcs/tests/gtest-417.cs @@ -0,0 +1,35 @@ +// Compiler options: -r:gtest-417-lib.dll + +using System; +using System.Collections; + +class Indirect : Base +{ +} + +abstract class Base : IEnumerable +{ + IEnumerator IEnumerable.GetEnumerator () + { + return new int [0].GetEnumerator (); + } +} + +public class TestCase +{ + public static GlobalMonitoredCharacterCollection MonitoredCharacters; + + static int Main () + { + MonitoredCharacters = new GlobalMonitoredCharacterCollection(); + foreach (var character in MonitoredCharacters) + { + } + + foreach (var n in new Indirect ()) + { + } + + return 0; + } +} diff --git a/mcs/tests/ver-il-gmcs.xml b/mcs/tests/ver-il-gmcs.xml index 439de26d894d..2ac174bf0e4c 100644 --- a/mcs/tests/ver-il-gmcs.xml +++ b/mcs/tests/ver-il-gmcs.xml @@ -11057,6 +11057,29 @@ + + + + 7 + + + + + 12 + + + 7 + + + + + 125 + + + 7 + + + @@ -42883,6 +42906,16 @@ + + + + 1 + + + 7 + + + @@ -46910,6 +46943,28 @@ + + + + 47 + + + 47 + + + 8 + + + 1 + + + 1 + + + 42 + + + @@ -47561,6 +47616,27 @@ + + + + 39 + + + 7 + + + 7 + + + + + 22 + + + 7 + + + From fc940fba4a9152bb2fde3f6df176096aaa841cf4 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 15:58:31 +0000 Subject: [PATCH 76/93] Update mcs name for monolite build --- mcs/build/profiles/basic.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/build/profiles/basic.make b/mcs/build/profiles/basic.make index df858ae27dfb..6c1e9aff9aae 100644 --- a/mcs/build/profiles/basic.make +++ b/mcs/build/profiles/basic.make @@ -8,7 +8,7 @@ use_monolite := $(wildcard $(monolite_flag)) ifdef use_monolite PROFILE_RUNTIME = $(with_mono_path_monolite) $(RUNTIME) -BOOTSTRAP_MCS = $(PROFILE_RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/monolite/gmcs.exe +BOOTSTRAP_MCS = $(PROFILE_RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/monolite/mcs.exe else PROFILE_RUNTIME = $(EXTERNAL_RUNTIME) BOOTSTRAP_MCS = $(EXTERNAL_MCS) @@ -60,7 +60,7 @@ do-profile-check: $(depsdir)/.stamp $(MAKE) $(MAKE_Q) $(PROFILE_OUT) || ok=false; \ rm -f $(PROFILE_EXE) $(PROFILE_OUT); \ if $$ok; then :; else \ - if test -f $(topdir)/class/lib/monolite/gmcs.exe; then \ + if test -f $(topdir)/class/lib/monolite/mcs.exe; then \ $(MAKE) -s do-profile-check-monolite ; \ else \ echo "*** The compiler '$(BOOTSTRAP_MCS)' doesn't appear to be usable." 1>&2; \ From 82264df085188d39e5980217d51711e3bc3e3891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Fri, 17 Dec 2010 15:27:10 +0000 Subject: [PATCH 77/93] Remove a leftover debugging scwl --- .../corlib/System.Collections.Concurrent/SplitOrderedList.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs b/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs index 2d2d04832a5a..2774c33f0928 100644 --- a/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs +++ b/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs @@ -319,7 +319,6 @@ Node ListSearch (ulong key, TKey subKey, ref Node left, Node h) break; tNext = t.Next; - Console.WriteLine ("Check: " + (tNext.Key == key && !comparer.Equals (subKey, t.SubKey))); } while (tNext.Marked || t.Key < key || (tNext.Key == key && !comparer.Equals (subKey, t.SubKey))); rightNode = t; From e704c1eb9715c411672647229c3c063c553f23bb Mon Sep 17 00:00:00 2001 From: Andrew Jorgensen Date: Thu, 16 Dec 2010 14:52:29 -0700 Subject: [PATCH 78/93] get-monolite-latest now pulls a versioned archive In order to ensure that monolite actually works you need to ensure that the corlib in it has the same version as your runtime. Monolite archives are now versioned monolite-MONO_CORLIB_VERSION-DATE. --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c45f6ba032f5..339d38c8e8e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,8 @@ DISTCLEANFILES= mono-uninstalled.pc # building with monolite mcslib = $(mcs_topdir)/class/lib monolite = $(mcslib)/monolite -monolite_url = http://mono.ximian.com/daily/monolite-latest.tar.gz +mono_corlib_version = $(shell sed -n "s/\#define MONO_CORLIB_VERSION //p" $(srcdir)/mono/metadata/appdomain.c) +monolite_url = http://mono.ximian.com/daily/monolite-$(mono_corlib_version)-latest.tar.gz .PHONY: get-monolite-latest get-monolite-latest: -rm -fr $(mcslib)/monolite-* From 0df612b81360c6e485f837b17ef8acb36fae516f Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Fri, 17 Dec 2010 10:30:52 -0600 Subject: [PATCH 79/93] Reverse #elif check since 4.0 profile defines NET_2_0. Fixes broken test. --- .../Test/System.Configuration/ConfigurationManagerTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs index 038667dd84c2..abe9fdc8f409 100644 --- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs +++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs @@ -145,10 +145,10 @@ public void OpenExeConfiguration1_UserLevel_None () FileInfo fi = new FileInfo (config.FilePath); #if TARGET_JVM Assert.AreEqual ("nunit-console.jar.config", fi.Name); -#elif NET_2_0 - Assert.AreEqual ("System.Configuration_test_net_2_0.dll.config", fi.Name); -#else +#elif NET_4_0 Assert.AreEqual ("System.Configuration_test_net_4_0.dll.config", fi.Name); +#else + Assert.AreEqual ("System.Configuration_test_net_2_0.dll.config", fi.Name); #endif } From 66efe2cc38eee7ccb8a0715e8350396ff267d9a8 Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Fri, 17 Dec 2010 17:39:39 +0100 Subject: [PATCH 80/93] Log profiler: fix statistical mode on linux amd64. --- mono/profiler/proflog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mono/profiler/proflog.c b/mono/profiler/proflog.c index f624a8af2599..cb8d91695c34 100644 --- a/mono/profiler/proflog.c +++ b/mono/profiler/proflog.c @@ -1576,7 +1576,13 @@ perf_event_syscall (struct perf_event_attr *attr, pid_t pid, int cpu, int group_ { attr->size = PERF_ATTR_SIZE_VER0; //printf ("perf attr size: %d\n", attr->size); +#if defined(__x86_64__) + return syscall(/*__NR_perf_event_open*/ 298, attr, pid, cpu, group_fd, flags); +#elif defined(__i386__) return syscall(/*__NR_perf_event_open*/ 336, attr, pid, cpu, group_fd, flags); +#else + return -1; +#endif } static int From db5d050444932ab335316cadb1de338ef5cc46f0 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 17 Dec 2010 17:52:26 +0000 Subject: [PATCH 81/93] Add --with-moon-gc to select the gc to use with moon (boehm/sgen) --- configure.in | 26 +++++++++++++++++++++++--- mono/metadata/Makefile.am | 8 +++++--- mono/mini/Makefile.am | 29 ++++++++++++++++------------- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/configure.in b/configure.in index 0f0cd253308b..d1eaccaffa06 100644 --- a/configure.in +++ b/configure.in @@ -2593,11 +2593,28 @@ fi MOONLIGHT_DEFINES= AC_ARG_WITH(moonlight, [ --with-moonlight=yes|no|only If you want to build Mono for Moonlight (defaults to no)],[ - MOONLIGHT_DEFINES="-DMOONLIGHT -DDISABLE_ASSEMBLY_REMAPPING" + if test x$with_moonlight != xno; then + MOONLIGHT_DEFINES="-DMOONLIGHT -DDISABLE_ASSEMBLY_REMAPPING " + fi ], [with_moonlight=no]) -AC_SUBST(MOONLIGHT_DEFINES) +MOONLIGHT_GC=boehm +AC_ARG_WITH(moon_gc, [ --with-moon-gc=boehm,sgen Select the gc to use with Moonlight (defaults to boehm)],[ + case "x$with_moon_gc" in + xboehm) + MOONLIGHT_GC=boehm + MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $BOEHM_DEFINES" + ;; + xsgen) + MOONLIGHT_GC=sgen + MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $SGEN_DEFINES" + ;; + *) + AC_MSG_ERROR([Invalid argument to --with-moon-gc.]) ;; + esac +], [with_moon_gc=boehm]) +AC_SUBST(MOONLIGHT_DEFINES) AC_CHECK_HEADER([malloc.h], [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1], @@ -2625,6 +2642,9 @@ libmono_ldflags="$libmono_ldflags $LIBS" AM_CONDITIONAL(MOONLIGHT, [test "x$with_moonlight" != "xno"]) AM_CONDITIONAL(ONLY_MOONLIGHT, [test "x$with_moonlight" = "xonly"]) +AM_CONDITIONAL(MOONLIGHT_BOEHM, [test "x$with_moon_gc" = "xboehm"]) +AM_CONDITIONAL(MOONLIGHT_SGEN, [test "x$with_moon_gc" = "xsgen"]) + AM_CONDITIONAL(INSTALL_4_0, [test "x$with_profile4" = xyes]) AM_CONDITIONAL(INSTALL_MONODROID, [test "x$with_monodroid" = xyes]) AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" = xyes]) @@ -2977,7 +2997,7 @@ echo " LLVM Back End: $enable_llvm (dynamically loaded: $enable_loadedllvm) Libraries: - Moon Profile: $with_moonlight + Moon Profile: $with_moonlight ($with_moon_gc) MonoDroid: $with_monodroid MonoTouch: $with_monotouch JNI support: $jdk_headers_found diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 8187bca68cbc..c8f40e9840f8 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -214,12 +214,14 @@ libmonoruntime_la_SOURCES = \ libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) -libmonoruntimemoon_la_SOURCES = $(libmonoruntime_la_SOURCES) -libmonoruntimemoon_la_CFLAGS = $(MOONLIGHT_DEFINES) $(BOEHM_DEFINES) - libmonoruntimesgen_la_SOURCES = $(libmonoruntime_la_SOURCES) libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) +if MOONLIGHT +libmonoruntimemoon_la_SOURCES = $(libmonoruntime_la_SOURCES) +libmonoruntimemoon_la_CFLAGS = $(MOONLIGHT_DEFINES) +endif + libmonoruntime_static_la_SOURCES = $(libmonoruntime_la_SOURCES) libmonoruntime_static_la_LDFLAGS = -static libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES) diff --git a/mono/mini/Makefile.am b/mono/mini/Makefile.am index 5a2f2eba77cf..27b06f69e5a5 100644 --- a/mono/mini/Makefile.am +++ b/mono/mini/Makefile.am @@ -24,12 +24,16 @@ sgen_libs = \ $(monodir)/mono/utils/libmonoutils.la \ $(GLIB_LIBS) +if MOONLIGHT moon_libs = \ $(monodir)/mono/metadata/libmonoruntimemoon.la \ $(monodir)/mono/io-layer/libwapi.la \ $(monodir)/mono/utils/libmonoutils.la \ - $(GLIB_LIBS) \ - $(libgc_libs) + $(GLIB_LIBS) +if MOONLIGHT_BOEHM + moon_libs += $(libgc_libs) +endif +endif static_libs= \ $(monodir)/mono/metadata/libmonoruntime-static.la \ @@ -497,29 +501,34 @@ monobin_platform_ldflags=-framework CoreFoundation endif libmono_2_0_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources) -libmono_2_0_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS) +libmono_2_0_la_CFLAGS = $(mono_CFLAGS) +libmono_2_0_la_LIBADD = $(libs) $(LIBMONO_DTRACE_OBJECT) libmonosgen_2_0_la_SOURCES = $(libmono_2_0_la_SOURCES) -libmonosgen_2_0_la_CFLAGS = $(AM_CFLAGS) $(SGEN_DEFINES) +libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) +libmonosgen_2_0_la_LIBADD = $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) if MOONLIGHT libmono_moon_la_SOURCES = $(libmono_2_0_la_SOURCES) libmono_moon_la_CFLAGS = $(AM_CFLAGS) $(MOONLIGHT_DEFINES) +if MOONLIGHT_BOEHM +libmono_moon_la_CFLAGS += $(LIBGC_CFLAGS) +endif libmono_moon_la_LIBADD = $(moon_libs) $(LIBMONO_DTRACE_OBJECT) endif libmono_static_la_SOURCES = $(libmono_2_0_la_SOURCES) -libmono_static_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS) +libmono_static_la_CFLAGS = $(mono_CFLAGS) libmono_static_la_LDFLAGS = -static libmono_static_la_LIBADD = $(static_libs) $(MONO_DTRACE_OBJECT) libmonosgen_static_la_SOURCES = $(libmono_2_0_la_SOURCES) -libmonosgen_static_la_CFLAGS = $(AM_CFLAGS) $(SGEN_DEFINES) +libmonosgen_static_la_CFLAGS = $(mono_sgen_CFLAGS) libmonosgen_static_la_LDFLAGS = -static libmonosgen_static_la_LIBADD = $(sgenstatic_libs) $(MONO_DTRACE_OBJECT) nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES) -nodist_libmono_static_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS) +nodist_libmono_static_la_CFLAGS = $(mono_CFLAGS) BURGSRC= $(common_BURGSRC) $(arch_BURGSRC) @@ -527,12 +536,6 @@ libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit libmonoinclude_HEADERS = jit.h -libmono_2_0_la_LIBADD = \ - $(libs) $(LIBMONO_DTRACE_OBJECT) - -libmonosgen_2_0_la_LIBADD = \ - $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) - basic-simd.exe: basic-simd.cs $(MCS) -out:$@ $< -r:TestDriver.dll -r:Mono.Simd.dll From 68032088ce1a84d67c221e8a26ee041da233ba14 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 17 Dec 2010 18:27:11 +0000 Subject: [PATCH 82/93] Document the new --with-moon-gc flag on the README --- README | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README b/README index ccfd67d4cfd7..e16228e92383 100644 --- a/README +++ b/README @@ -305,6 +305,21 @@ This is Mono. System.dll, System.Code.dll and System.Xml.Core.dll) and turn on the LINQ extensions for the compiler. + --with-moon-gc=boehm,sgen + + Select the GC to use for Moonlight. + + boehm: + Selects the Boehm Garbage Collector, with the same flags + as the regular Mono build. This is the default. + + sgen: + Selects the new SGen Garbage Collector, which provides + Generational GC support, using the same flags as the + mono-sgen build. + + This defaults to `boehm'. + --with-libgdiplus=installed,sibling, This is used to configure where should Mono look for From 52aac691d9bfbe197add13cc2731f79f5b579e6f Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 17 Dec 2010 20:04:00 +0000 Subject: [PATCH 83/93] Fix moonlight build --- configure.in | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/configure.in b/configure.in index d1eaccaffa06..b7fb0bc7fa49 100644 --- a/configure.in +++ b/configure.in @@ -2599,21 +2599,22 @@ AC_ARG_WITH(moonlight, [ --with-moonlight=yes|no|only If you want to bu ], [with_moonlight=no]) MOONLIGHT_GC=boehm -AC_ARG_WITH(moon_gc, [ --with-moon-gc=boehm,sgen Select the gc to use with Moonlight (defaults to boehm)],[ - case "x$with_moon_gc" in - xboehm) - MOONLIGHT_GC=boehm - MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $BOEHM_DEFINES" - ;; - xsgen) - MOONLIGHT_GC=sgen - MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $SGEN_DEFINES" - ;; - *) - AC_MSG_ERROR([Invalid argument to --with-moon-gc.]) ;; - esac +AC_ARG_WITH(moon_gc, [ --with-moon-gc=boehm,sgen Select the gc to use with Moonlight (defaults to boehm)],[ ], [with_moon_gc=boehm]) +case "x$with_moon_gc" in + xboehm) + MOONLIGHT_GC=boehm + MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $BOEHM_DEFINES" + ;; + xsgen) + MOONLIGHT_GC=sgen + MOONLIGHT_DEFINES="$MOONLIGHT_DEFINES $SGEN_DEFINES" + ;; + *) + AC_MSG_ERROR([Invalid argument to --with-moon-gc.]) ;; +esac + AC_SUBST(MOONLIGHT_DEFINES) AC_CHECK_HEADER([malloc.h], From 44a043e5d1ab827950fb042ffa1b4f4b4ef06499 Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Fri, 17 Dec 2010 15:07:22 -0500 Subject: [PATCH 84/93] Mach uses wait_time not abs_time The time to wait is relative in the Mac functions. --- mono/utils/mono-semaphore.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mono/utils/mono-semaphore.c b/mono/utils/mono-semaphore.c index 4727430cbf08..d65170cd46db 100644 --- a/mono/utils/mono-semaphore.c +++ b/mono/utils/mono-semaphore.c @@ -48,7 +48,11 @@ mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms, gboolean alertable) if (timeout_ms == (guint32) 0xFFFFFFFF) return mono_sem_wait (sem, alertable); +#ifdef USE_MACH_SEMA + memset (&t, 0, sizeof (TIMESPEC)); +#else gettimeofday (&t, NULL); +#endif ts.tv_sec = timeout_ms / 1000 + t.tv_sec; ts.tv_nsec = (timeout_ms % 1000) * 1000000 + t.tv_usec * 1000; while (ts.tv_nsec > NSEC_PER_SEC) { @@ -73,7 +77,11 @@ mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms, gboolean alertable) struct timeval current; if (alertable) return -1; +#ifdef USE_MACH_SEMA + memset (¤t, 0, sizeof (TIMESPEC)); +#else gettimeofday (¤t, NULL); +#endif ts = copy; ts.tv_sec -= (current.tv_sec - t.tv_sec); ts.tv_nsec -= (current.tv_usec - t.tv_usec) * 1000; From f55bc7d06db776ab1d41b92b32c80b0c78dc44a3 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 21:47:38 +0100 Subject: [PATCH 85/93] Allow decomposition of some complex 64 bit opcodes on 32 bit platforms when running with llvm. --- mono/mini/decompose.c | 372 ++++++++++++++++++++++-------------------- mono/mini/ir-emit.h | 15 ++ mono/mini/mini-llvm.c | 9 + 3 files changed, 223 insertions(+), 173 deletions(-) diff --git a/mono/mini/decompose.c b/mono/mini/decompose.c index 89d17c3328c1..c1dc10f87b5c 100644 --- a/mono/mini/decompose.c +++ b/mono/mini/decompose.c @@ -20,165 +20,15 @@ MonoInst* mono_emit_native_call (MonoCompile *cfg, gconstpointer func, MonoMetho void mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native); void mini_emit_initobj (MonoCompile *cfg, MonoInst *dest, const guchar *ip, MonoClass *klass); -/* - * mono_decompose_opcode: - * - * Decompose complex opcodes into ones closer to opcodes supported by - * the given architecture. - * Returns a MonoInst which represents the result of the decomposition, and can - * be pushed on the IL stack. This is needed because the original instruction is - * nullified. - * Sets the cfg exception if an opcode is not supported. - */ -MonoInst* -mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) +/* Decompose complex long opcodes on 64 bit machines or when using LLVM */ +static gboolean +decompose_long_opcode (MonoCompile *cfg, MonoInst *ins, MonoInst **repl_ins) { MonoInst *repl = NULL; - int type = ins->type; - int dreg = ins->dreg; - - /* FIXME: Instead of = NOP, don't emit the original ins at all */ -#ifdef MONO_ARCH_HAVE_DECOMPOSE_OPTS - mono_arch_decompose_opts (cfg, ins); -#endif + *repl_ins = NULL; - /* - * The code below assumes that we are called immediately after emitting - * ins. This means we can emit code using the normal code generation - * macros. - */ switch (ins->opcode) { - /* this doesn't make sense on ppc and other architectures */ -#if !defined(MONO_ARCH_NO_IOV_CHECK) - case OP_IADD_OVF: - if (COMPILE_LLVM (cfg)) - break; - ins->opcode = OP_IADDCC; - MONO_EMIT_NEW_COND_EXC (cfg, IOV, "OverflowException"); - break; - case OP_IADD_OVF_UN: - if (COMPILE_LLVM (cfg)) - break; - ins->opcode = OP_IADDCC; - MONO_EMIT_NEW_COND_EXC (cfg, IC, "OverflowException"); - break; - case OP_ISUB_OVF: - if (COMPILE_LLVM (cfg)) - break; - ins->opcode = OP_ISUBCC; - MONO_EMIT_NEW_COND_EXC (cfg, IOV, "OverflowException"); - break; - case OP_ISUB_OVF_UN: - if (COMPILE_LLVM (cfg)) - break; - ins->opcode = OP_ISUBCC; - MONO_EMIT_NEW_COND_EXC (cfg, IC, "OverflowException"); - break; -#endif - case OP_ICONV_TO_OVF_I1: - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 127); - MONO_EMIT_NEW_COND_EXC (cfg, IGT, "OverflowException"); - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, -128); - MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); - MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, ins->dreg, ins->sreg1); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_I1_UN: - /* probe values between 0 to 127 */ - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 127); - MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); - MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, ins->dreg, ins->sreg1); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_U1: - case OP_ICONV_TO_OVF_U1_UN: - /* probe value to be within 0 to 255 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 255); - MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IAND_IMM, ins->dreg, ins->sreg1, 0xff); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_I2: - /* Probe value to be within -32768 and 32767 */ - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 32767); - MONO_EMIT_NEW_COND_EXC (cfg, IGT, "OverflowException"); - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, -32768); - MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); - MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, ins->dreg, ins->sreg1); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_I2_UN: - /* Convert uint value into short, value within 0 and 32767 */ - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 32767); - MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); - MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, ins->dreg, ins->sreg1); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_U2: - case OP_ICONV_TO_OVF_U2_UN: - /* Probe value to be within 0 and 65535 */ - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 0xffff); - MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IAND_IMM, ins->dreg, ins->sreg1, 0xffff); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_OVF_U4: - case OP_ICONV_TO_OVF_I4_UN: -#if SIZEOF_REGISTER == 4 - case OP_ICONV_TO_OVF_U: - case OP_ICONV_TO_OVF_I_UN: -#endif - MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 0); - MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); - MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); - NULLIFY_INS (ins); - break; - case OP_ICONV_TO_I4: - case OP_ICONV_TO_U4: - case OP_ICONV_TO_OVF_I4: - case OP_ICONV_TO_OVF_U4_UN: -#if SIZEOF_REGISTER == 4 - case OP_ICONV_TO_OVF_I: - case OP_ICONV_TO_OVF_U_UN: -#endif - ins->opcode = OP_MOVE; - break; - case OP_ICONV_TO_I: -#if SIZEOF_REGISTER == 8 - ins->opcode = OP_SEXT_I4; -#else - ins->opcode = OP_MOVE; -#endif - break; - case OP_ICONV_TO_U: -#if SIZEOF_REGISTER == 8 - ins->opcode = OP_ZEXT_I4; -#else - ins->opcode = OP_MOVE; -#endif - break; - - case OP_FCONV_TO_R8: - ins->opcode = OP_FMOVE; - break; - - case OP_FCONV_TO_OVF_I1_UN: - case OP_FCONV_TO_OVF_I2_UN: - case OP_FCONV_TO_OVF_I4_UN: - case OP_FCONV_TO_OVF_I8_UN: - case OP_FCONV_TO_OVF_U1_UN: - case OP_FCONV_TO_OVF_U2_UN: - case OP_FCONV_TO_OVF_U4_UN: - case OP_FCONV_TO_OVF_U8_UN: - case OP_FCONV_TO_OVF_I_UN: - case OP_FCONV_TO_OVF_U_UN: - cfg->exception_type = MONO_EXCEPTION_INVALID_PROGRAM; - cfg->exception_message = g_strdup_printf ("float conv.ovf.un opcodes not supported."); - break; - - /* Long opcodes on 64 bit machines */ -#if SIZEOF_REGISTER == 8 case OP_LCONV_TO_I4: MONO_EMIT_NEW_BIALU_IMM (cfg, OP_LSHR_IMM, ins->dreg, ins->sreg1, 0); NULLIFY_INS (ins); @@ -237,7 +87,7 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) break; case OP_ICONV_TO_OVF_U8: case OP_ICONV_TO_OVF_U: - MONO_EMIT_NEW_COMPARE_IMM (cfg,ins->sreg1, 0); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg,ins->sreg1, 0); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_ZEXT_I4, ins->dreg, ins->sreg1); NULLIFY_INS (ins); @@ -252,88 +102,93 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I1: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 127); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 127); MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException"); - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, -128); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -128); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_LCONV_TO_I1, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I1_UN: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 127); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 127); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_LCONV_TO_I1, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U1: /* probe value to be within 0 to 255 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 255); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 255); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, ins->dreg, ins->sreg1, 0xff); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U1_UN: /* probe value to be within 0 to 255 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 255); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 255); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, ins->dreg, ins->sreg1, 0xff); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I2: /* Probe value to be within -32768 and 32767 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 32767); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 32767); MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException"); - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, -32768); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -32768); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_LCONV_TO_I2, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I2_UN: /* Probe value to be within 0 and 32767 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 32767); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 32767); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_LCONV_TO_I2, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U2: /* Probe value to be within 0 and 65535 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0xffff); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0xffff); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, ins->dreg, ins->sreg1, 0xffff); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U2_UN: /* Probe value to be within 0 and 65535 */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0xffff); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0xffff); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, ins->dreg, ins->sreg1, 0xffff); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I4: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0x7fffffff); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0x7fffffff); MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException"); /* The int cast is needed for the VS compiler. See Compiler Warning (level 2) C4146. */ - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, ((int)-2147483648)); +#if SIZEOF_REGISTER == 8 + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, ((int)-2147483648)); +#else + g_assert (COMPILE_LLVM (cfg)); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -2147483648UL); +#endif MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_I4_UN: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0x7fffffff); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0x7fffffff); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U4: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0xffffffffUL); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0xffffffffUL); MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException"); - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, ins->sreg1, 0); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U4_UN: - MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 0xffffffff); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0xffffffff); MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); @@ -346,23 +201,194 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) break; case OP_LCONV_TO_OVF_I_UN: case OP_LCONV_TO_OVF_I8_UN: - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, ins->sreg1, 0); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; case OP_LCONV_TO_OVF_U8: case OP_LCONV_TO_OVF_U: - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, ins->sreg1, 0); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, 0); MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); NULLIFY_INS (ins); break; + default: + return FALSE; + } + + *repl_ins = repl; + return TRUE; +} + +/* + * mono_decompose_opcode: + * + * Decompose complex opcodes into ones closer to opcodes supported by + * the given architecture. + * Returns a MonoInst which represents the result of the decomposition, and can + * be pushed on the IL stack. This is needed because the original instruction is + * nullified. + * Sets the cfg exception if an opcode is not supported. + */ +MonoInst* +mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) +{ + MonoInst *repl = NULL; + int type = ins->type; + int dreg = ins->dreg; + + /* FIXME: Instead of = NOP, don't emit the original ins at all */ + +#ifdef MONO_ARCH_HAVE_DECOMPOSE_OPTS + mono_arch_decompose_opts (cfg, ins); #endif + /* + * The code below assumes that we are called immediately after emitting + * ins. This means we can emit code using the normal code generation + * macros. + */ + switch (ins->opcode) { + /* this doesn't make sense on ppc and other architectures */ +#if !defined(MONO_ARCH_NO_IOV_CHECK) + case OP_IADD_OVF: + if (COMPILE_LLVM (cfg)) + break; + ins->opcode = OP_IADDCC; + MONO_EMIT_NEW_COND_EXC (cfg, IOV, "OverflowException"); + break; + case OP_IADD_OVF_UN: + if (COMPILE_LLVM (cfg)) + break; + ins->opcode = OP_IADDCC; + MONO_EMIT_NEW_COND_EXC (cfg, IC, "OverflowException"); + break; + case OP_ISUB_OVF: + if (COMPILE_LLVM (cfg)) + break; + ins->opcode = OP_ISUBCC; + MONO_EMIT_NEW_COND_EXC (cfg, IOV, "OverflowException"); + break; + case OP_ISUB_OVF_UN: + if (COMPILE_LLVM (cfg)) + break; + ins->opcode = OP_ISUBCC; + MONO_EMIT_NEW_COND_EXC (cfg, IC, "OverflowException"); + break; +#endif + case OP_ICONV_TO_OVF_I1: + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 127); + MONO_EMIT_NEW_COND_EXC (cfg, IGT, "OverflowException"); + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, -128); + MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); + MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, ins->dreg, ins->sreg1); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_I1_UN: + /* probe values between 0 to 127 */ + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 127); + MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); + MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, ins->dreg, ins->sreg1); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_U1: + case OP_ICONV_TO_OVF_U1_UN: + /* probe value to be within 0 to 255 */ + MONO_EMIT_NEW_COMPARE_IMM (cfg, ins->sreg1, 255); + MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IAND_IMM, ins->dreg, ins->sreg1, 0xff); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_I2: + /* Probe value to be within -32768 and 32767 */ + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 32767); + MONO_EMIT_NEW_COND_EXC (cfg, IGT, "OverflowException"); + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, -32768); + MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); + MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, ins->dreg, ins->sreg1); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_I2_UN: + /* Convert uint value into short, value within 0 and 32767 */ + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 32767); + MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); + MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, ins->dreg, ins->sreg1); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_U2: + case OP_ICONV_TO_OVF_U2_UN: + /* Probe value to be within 0 and 65535 */ + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 0xffff); + MONO_EMIT_NEW_COND_EXC (cfg, IGT_UN, "OverflowException"); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IAND_IMM, ins->dreg, ins->sreg1, 0xffff); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_OVF_U4: + case OP_ICONV_TO_OVF_I4_UN: +#if SIZEOF_REGISTER == 4 + case OP_ICONV_TO_OVF_U: + case OP_ICONV_TO_OVF_I_UN: +#endif + MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 0); + MONO_EMIT_NEW_COND_EXC (cfg, ILT, "OverflowException"); + MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); + NULLIFY_INS (ins); + break; + case OP_ICONV_TO_I4: + case OP_ICONV_TO_U4: + case OP_ICONV_TO_OVF_I4: + case OP_ICONV_TO_OVF_U4_UN: +#if SIZEOF_REGISTER == 4 + case OP_ICONV_TO_OVF_I: + case OP_ICONV_TO_OVF_U_UN: +#endif + ins->opcode = OP_MOVE; + break; + case OP_ICONV_TO_I: +#if SIZEOF_REGISTER == 8 + ins->opcode = OP_SEXT_I4; +#else + ins->opcode = OP_MOVE; +#endif + break; + case OP_ICONV_TO_U: +#if SIZEOF_REGISTER == 8 + ins->opcode = OP_ZEXT_I4; +#else + ins->opcode = OP_MOVE; +#endif + break; + + case OP_FCONV_TO_R8: + ins->opcode = OP_FMOVE; + break; + + case OP_FCONV_TO_OVF_I1_UN: + case OP_FCONV_TO_OVF_I2_UN: + case OP_FCONV_TO_OVF_I4_UN: + case OP_FCONV_TO_OVF_I8_UN: + case OP_FCONV_TO_OVF_U1_UN: + case OP_FCONV_TO_OVF_U2_UN: + case OP_FCONV_TO_OVF_U4_UN: + case OP_FCONV_TO_OVF_U8_UN: + case OP_FCONV_TO_OVF_I_UN: + case OP_FCONV_TO_OVF_U_UN: + cfg->exception_type = MONO_EXCEPTION_INVALID_PROGRAM; + cfg->exception_message = g_strdup_printf ("float conv.ovf.un opcodes not supported."); + break; + default: { MonoJitICallInfo *info; +#if SIZEOF_REGISTER == 8 + if (decompose_long_opcode (cfg, ins, &repl)) + break; +#else + if (COMPILE_LLVM (cfg) && decompose_long_opcode (cfg, ins, &repl)) + break; +#endif + info = mono_find_jit_opcode_emulation (ins->opcode); if (info) { MonoInst **args; diff --git a/mono/mini/ir-emit.h b/mono/mini/ir-emit.h index 6505c2a3c88b..67a2efa3c59b 100755 --- a/mono/mini/ir-emit.h +++ b/mono/mini/ir-emit.h @@ -588,6 +588,21 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type) MONO_ADD_INS ((cfg)->cbb, inst); \ } while (0) +/* This is used on 32 bit machines too when running with LLVM */ +#define MONO_EMIT_NEW_LCOMPARE_IMM(cfg,sr1,imm) do { \ + MonoInst *inst; \ + MONO_INST_NEW ((cfg), (inst), (OP_LCOMPARE_IMM)); \ + inst->sreg1 = sr1; \ + if (SIZEOF_REGISTER == 4 && COMPILE_LLVM (cfg)) { \ + guint64 _l = (imm); \ + inst->inst_imm = _l & 0xffffffff; \ + inst->inst_offset = _l >> 32; \ + } else { \ + inst->inst_imm = (imm); \ + } \ + MONO_ADD_INS ((cfg)->cbb, inst); \ + } while (0) + #define MONO_EMIT_NEW_LOAD_MEMBASE_OP(cfg,op,dr,base,offset) do { \ MonoInst *inst; \ MONO_INST_NEW ((cfg), (inst), (op)); \ diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 46555e2eb048..e3706243f8d5 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -2304,6 +2304,15 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) cmp = LLVMBuildFCmp (builder, fpcond_to_llvm_cond [rel], convert (ctx, lhs, LLVMDoubleType ()), convert (ctx, rhs, LLVMDoubleType ()), ""); else if (ins->opcode == OP_COMPARE_IMM) cmp = LLVMBuildICmp (builder, cond_to_llvm_cond [rel], convert (ctx, lhs, IntPtrType ()), LLVMConstInt (IntPtrType (), ins->inst_imm, FALSE), ""); + else if (ins->opcode == OP_LCOMPARE_IMM) { + if (SIZEOF_REGISTER == 4 && COMPILE_LLVM (cfg)) { + /* The immediate is encoded in two fields */ + guint64 l = ((guint64)(guint32)ins->inst_offset << 32) | ((guint32)ins->inst_imm); + cmp = LLVMBuildICmp (builder, cond_to_llvm_cond [rel], convert (ctx, lhs, LLVMInt64Type ()), LLVMConstInt (LLVMInt64Type (), l, FALSE), ""); + } else { + cmp = LLVMBuildICmp (builder, cond_to_llvm_cond [rel], convert (ctx, lhs, LLVMInt64Type ()), LLVMConstInt (LLVMInt64Type (), ins->inst_imm, FALSE), ""); + } + } else if (ins->opcode == OP_COMPARE) cmp = LLVMBuildICmp (builder, cond_to_llvm_cond [rel], convert (ctx, lhs, IntPtrType ()), convert (ctx, rhs, IntPtrType ()), ""); else From 6cf2d8462291e081db3958b8c3930716e22bb79c Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 22:07:38 +0100 Subject: [PATCH 86/93] Fix OP_LCONV_TO_OVF_I4 under LLVM. Don't use the Mono LLVM calling convention for pinvoke calls. --- mono/mini/decompose.c | 2 +- mono/mini/mini-llvm.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mono/mini/decompose.c b/mono/mini/decompose.c index c1dc10f87b5c..4f1e1ac65fd4 100644 --- a/mono/mini/decompose.c +++ b/mono/mini/decompose.c @@ -167,7 +167,7 @@ decompose_long_opcode (MonoCompile *cfg, MonoInst *ins, MonoInst **repl_ins) MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, ((int)-2147483648)); #else g_assert (COMPILE_LLVM (cfg)); - MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -2147483648UL); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -2147483648LL); #endif MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException"); MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1); diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index e3706243f8d5..349e90b40e97 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -1941,7 +1941,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, #endif /* The two can't be used together, so use only one LLVM calling conv to pass them */ g_assert (!(call->rgctx_arg_reg && call->imt_arg_reg)); - LLVMSetInstructionCallConv (lcall, LLVMMono1CallConv); + if (!sig->pinvoke) + LLVMSetInstructionCallConv (lcall, LLVMMono1CallConv); if (call->rgctx_arg_reg) LLVMAddInstrAttribute (lcall, 1 + sinfo.rgctx_arg_pindex, LLVMInRegAttribute); From 43ff0aa5949f348a3a8b93a4268eab33827c9d06 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 22:29:15 +0100 Subject: [PATCH 87/93] Add support for OP_SETFRET to the llvm backend. --- mono/mini/mini-llvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 349e90b40e97..c459b388e1b0 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -2413,6 +2413,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_MOVE: case OP_LMOVE: case OP_XMOVE: + case OP_SETFRET: g_assert (lhs); values [ins->dreg] = lhs; break; From 01715c3d972b834469ecdd2dce8eebdfdfe54ec0 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 17 Dec 2010 23:06:18 +0100 Subject: [PATCH 88/93] Support methods returning vtypes by addr on arm/LLVM. --- mono/mini/mini-arm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index 62f77b7bf3e8..0935c6174f19 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -1444,7 +1444,11 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) * - we only pass/receive them in registers in some cases, and only * in 1 or 2 integer registers. */ - if (cinfo->ret.storage != RegTypeGeneral && cinfo->ret.storage != RegTypeNone && cinfo->ret.storage != RegTypeFP && cinfo->ret.storage != RegTypeIRegPair) { + if (cinfo->vtype_retaddr) { + /* Vtype returned using a hidden argument */ + linfo->ret.storage = LLVMArgVtypeRetAddr; + linfo->vret_arg_index = cinfo->vret_arg_index; + } else if (cinfo->ret.storage != RegTypeGeneral && cinfo->ret.storage != RegTypeNone && cinfo->ret.storage != RegTypeFP && cinfo->ret.storage != RegTypeIRegPair) { cfg->exception_message = g_strdup ("unknown ret conv"); cfg->disable_llvm = TRUE; return linfo; From 1b30134ae786fefa6620a55d8c2e9ef877b132f8 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 17 Dec 2010 22:53:43 +0000 Subject: [PATCH 89/93] Add more files to mcs dist --- mcs/mcs/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcs/mcs/Makefile b/mcs/mcs/Makefile index e7c27cfb32e8..1f962e2bb28f 100644 --- a/mcs/mcs/Makefile +++ b/mcs/mcs/Makefile @@ -6,11 +6,12 @@ EXTRA_DISTFILES = \ *mcs.csproj \ compiler.doc \ *mcs.sln \ - *cs-parser.jay \ + cs-parser.jay \ *.sources \ NOTES \ TODO \ - *mcs.exe.config + *mcs.exe.config \ + ikvm.cs ifeq (basic, $(PROFILE)) LOCAL_MCS_FLAGS += -d:STATIC From 256afe837495e19d7d5823260789e13591c33cf6 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sat, 18 Dec 2010 02:58:27 +0100 Subject: [PATCH 90/93] Support passing vtypes on llvm/arm. --- mono/mini/mini-arm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index 0935c6174f19..4bcc5089aaef 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -1465,6 +1465,20 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) case RegTypeBase: linfo->args [i].storage = LLVMArgInIReg; break; + case RegTypeStructByVal: + // FIXME: Passing entirely on the stack or split reg/stack + if (ainfo->vtsize == 0 && ainfo->size <= 2) { + linfo->args [i].storage = LLVMArgVtypeInReg; + linfo->args [i].pair_storage [0] = LLVMArgInIReg; + if (ainfo->size == 2) + linfo->args [i].pair_storage [1] = LLVMArgInIReg; + else + linfo->args [i].pair_storage [1] = LLVMArgNone; + } else { + cfg->exception_message = g_strdup_printf ("vtype-by-val on stack"); + cfg->disable_llvm = TRUE; + } + break; default: cfg->exception_message = g_strdup_printf ("ainfo->storage (%d)", ainfo->storage); cfg->disable_llvm = TRUE; From 69d5baed9f62c995082b04647a69db445520d7e2 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sat, 18 Dec 2010 03:39:35 +0100 Subject: [PATCH 91/93] Name the llvm methods using the debug symbol by default, instead of using the cryptic m_ name. --- mono/mini/aot-compiler.c | 39 +++++++++++++++++---------------------- mono/mini/mini-llvm.c | 23 ++++++++++------------- mono/mini/mini.h | 2 +- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 8fe73c81e27b..268f6cae1f81 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -493,6 +493,14 @@ arch_init (MonoAotCompile *acfg) acfg->llc_args = g_string_new (""); acfg->as_args = g_string_new (""); + /* + * The prefix LLVM likes to put in front of symbol names on darwin. + * The mach-os specs require this for globals, but LLVM puts them in front of all + * symbols. We need to handle this, since we need to refer to LLVM generated + * symbols. + */ + acfg->llvm_label_prefix = ""; + #ifdef TARGET_ARM if (acfg->aot_opts.mtriple && strstr (acfg->aot_opts.mtriple, "darwin")) { g_string_append (acfg->llc_args, "-mattr=+v6"); @@ -3149,7 +3157,7 @@ get_debug_sym (MonoMethod *method, const char *prefix, GHashTable *cache) { char *name1, *name2, *cached; int i, j, len, count; - + name1 = mono_method_full_name (method, TRUE); len = strlen (name1); name2 = malloc (strlen (prefix) + len + 16); @@ -4743,14 +4751,6 @@ mono_aot_get_got_offset (MonoJumpInfo *ji) char* mono_aot_get_method_name (MonoCompile *cfg) -{ - guint32 method_index = get_method_index (llvm_acfg, cfg->orig_method); - - return g_strdup_printf ("m_%x", method_index); -} - -char* -mono_aot_get_method_debug_name (MonoCompile *cfg) { return get_debug_sym (cfg->orig_method, "", llvm_acfg->method_label_hash); } @@ -6361,6 +6361,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) #endif acfg->num_trampolines [MONO_AOT_TRAMP_IMT_THUNK] = acfg->aot_opts.full_aot ? acfg->aot_opts.nimt_trampolines : 0; + acfg->temp_prefix = img_writer_get_temp_label_prefix (NULL); + + arch_init (acfg); + acfg->got_symbol_base = g_strdup_printf ("%smono_aot_%s_got", acfg->llvm_label_prefix, acfg->image->assembly->aname.name); acfg->plt_symbol = g_strdup_printf ("%smono_aot_%s_plt", acfg->llvm_label_prefix, acfg->image->assembly->aname.name); @@ -6374,18 +6378,6 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) *p = '_'; } - acfg->temp_prefix = img_writer_get_temp_label_prefix (NULL); - - /* - * The prefix LLVM likes to put in front of symbol names on darwin. - * The mach-os specs require this for globals, but LLVM puts them in front of all - * symbols. We need to handle this, since we need to refer to LLVM generated - * symbols. - */ - acfg->llvm_label_prefix = ""; - - arch_init (acfg); - acfg->method_index = 1; collect_methods (acfg); @@ -6501,7 +6493,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) MonoCompile *cfg = acfg->cfgs [i]; int method_index = get_method_index (acfg, cfg->orig_method); - cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index); + if (COMPILE_LLVM (cfg)) + cfg->asm_symbol = g_strdup_printf ("%s%s", acfg->llvm_label_prefix, cfg->llvm_method_name); + else + cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index); } } diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index c459b388e1b0..173fe550da2f 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -3738,8 +3738,8 @@ mono_llvm_emit_method (MonoCompile *cfg) MonoMethodSignature *sig; MonoBasicBlock *bb; LLVMTypeRef method_type; - LLVMValueRef method = NULL, debug_alias = NULL; - char *method_name, *debug_name = NULL; + LLVMValueRef method = NULL; + char *method_name; LLVMValueRef *values; int i, max_block_num, bb_index; gboolean last = FALSE; @@ -3792,12 +3792,11 @@ mono_llvm_emit_method (MonoCompile *cfg) if (cfg->compile_aot) { ctx->lmodule = &aot_module; method_name = mono_aot_get_method_name (cfg); - debug_name = mono_aot_get_method_debug_name (cfg); + cfg->llvm_method_name = g_strdup (method_name); } else { init_jit_module (); ctx->lmodule = &jit_module; method_name = mono_method_full_name (cfg->method, TRUE); - debug_name = NULL; } module = ctx->module = ctx->lmodule->module; @@ -3849,6 +3848,13 @@ mono_llvm_emit_method (MonoCompile *cfg) #endif LLVMSetLinkage (method, LLVMPrivateLinkage); + if (cfg->compile_aot) { + LLVMSetLinkage (method, LLVMInternalLinkage); + LLVMSetVisibility (method, LLVMHiddenVisibility); + } else { + LLVMSetLinkage (method, LLVMPrivateLinkage); + } + if (cfg->method->save_lmf) LLVM_FAILURE (ctx, "lmf"); @@ -4072,14 +4078,6 @@ mono_llvm_emit_method (MonoCompile *cfg) if (cfg->compile_aot) { /* Don't generate native code, keep the LLVM IR */ - - /* Can't delete the method if it has an alias, so only add it if successful */ - if (debug_name) { - debug_alias = LLVMAddAlias (module, LLVMTypeOf (method), method, debug_name); - LLVMSetLinkage (debug_alias, LLVMInternalLinkage); - LLVMSetVisibility (debug_alias, LLVMHiddenVisibility); - } - if (cfg->compile_aot && cfg->verbose_level) printf ("%s emitted as %s\n", mono_method_full_name (cfg->method, TRUE), method_name); @@ -4127,7 +4125,6 @@ mono_llvm_emit_method (MonoCompile *cfg) g_free (ctx->pindexes); g_free (ctx->is_dead); g_free (ctx->unreachable); - g_free (debug_name); g_ptr_array_free (phi_values, TRUE); g_free (ctx->bblocks); g_hash_table_destroy (ctx->region_to_handler); diff --git a/mono/mini/mini.h b/mono/mini/mini.h index de5105f736eb..e2880824a70f 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -1230,6 +1230,7 @@ typedef struct { guint32 got_offset, ex_info_offset, method_info_offset; /* Symbol used to refer to this method in generated assembly */ char *asm_symbol; + char *llvm_method_name; MonoJitExceptionInfo *llvm_ex_info; guint32 llvm_ex_info_len; @@ -1670,7 +1671,6 @@ MonoMethod* mono_aot_get_array_helper_from_wrapper (MonoMethod *method) MONO_INT guint32 mono_aot_get_got_offset (MonoJumpInfo *ji) MONO_LLVM_INTERNAL; char* mono_aot_get_method_name (MonoCompile *cfg) MONO_LLVM_INTERNAL; char* mono_aot_get_plt_symbol (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL; -char* mono_aot_get_method_debug_name (MonoCompile *cfg) MONO_LLVM_INTERNAL; MonoJumpInfo* mono_aot_patch_info_dup (MonoJumpInfo* ji) MONO_LLVM_INTERNAL; void mono_aot_set_make_unreadable (gboolean unreadable) MONO_INTERNAL; gboolean mono_aot_is_pagefault (void *ptr) MONO_INTERNAL; From 00706612686733a2f0aa45f3d2aab9d3a0a38916 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sat, 18 Dec 2010 03:51:20 +0100 Subject: [PATCH 92/93] Fix a buffer overflow in the aot compiler. --- mono/mini/aot-compiler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 268f6cae1f81..75dedbf19468 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -3026,7 +3026,7 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui MonoMethodHeader *header; gboolean skip, direct_call; guint32 got_slot; - char direct_call_target [128]; + char direct_call_target [1024]; if (method) { header = mono_method_get_header (method); @@ -3078,6 +3078,7 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui MonoCompile *callee_cfg = g_hash_table_lookup (acfg->method_to_cfg, patch_info->data.method); //printf ("DIRECT: %s %s\n", method ? mono_method_full_name (method, TRUE) : "", mono_method_full_name (callee_cfg->method, TRUE)); direct_call = TRUE; + g_assert (strlen (callee_cfg->asm_symbol) < 1000); sprintf (direct_call_target, "%s", callee_cfg->asm_symbol); patch_info->type = MONO_PATCH_INFO_NONE; acfg->stats.direct_calls ++; From 56c5f3c396189378070801e2cedaa6809eaaf749 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Sat, 18 Dec 2010 10:19:45 +0000 Subject: [PATCH 93/93] Add aot-compiler to dist list --- mcs/class/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index da5b9590392f..63bc061ad037 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -176,7 +176,7 @@ include ../build/rules.make SUBDIRS = $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) $(moonlight_dirs) $(mobile_dirs) $(net_4_0_dirs) -DIST_ONLY_SUBDIRS = dlr IKVM.Reflection +DIST_ONLY_SUBDIRS = dlr IKVM.Reflection aot-compiler # No new makefiles for: System.Messaging, System.Web.Mobile, # System.ServiceProcess