Re: [Mono-dev] gmcs:compiler > "Cannot convert type `lambda expression' to `System.Action'"

2008-06-16 Thread M. David Peterson
Hi Casey,

On Mon, Jun 16, 2008 at 5:50 PM, Casey Marshall <
[EMAIL PROTECTED]> wrote:

>
> I filed this bug on this (or a similar) error:
>
> https://bugzilla.novell.com/show_bug.cgi?id=378189


Okay, so it looks like it's well covered in bugzilla, so I won't worry about
adding a new report.  Will *definitely* add my vote to your report to get
this one fixed. 


> I don't know if it's well understood or not, but it's definitely still
> an issue, and has been for a while.


What's interesting is that, in my particular case, due to [1] I can't run
various pieces of code[2] via 1.9.1 that have been compiled via 1.9.1 yet
*can* run that code if I compile with 1.9.1 yet run via SVN head.  In other
words, the workaround is to compile with 1.9.1 and run against SVN head.  A
pain in the a$$ yes, but there are worse things in life: Like starving
children, ridiculously high gas prices, a war that had should have never
been waged, and -- of course -- being forced to write code in Java. ;-)

Okay, sorry... That's not very funny in comparison to the others.  But yes,
life could be worse.

[1] https://bugzilla.novell.com/show_bug.cgi?id=392063
[2]
http://nuxleus.googlecode.com/svn/trunk/nuxleus/Source/Nuxleus.Extension.Aws/SimpleDB/SdbAction.cs

-- 
/M:D

M. David Peterson
Co-Founder & Chief Architect, 3rd & Urban, LLC
Email: [EMAIL PROTECTED] | [EMAIL PROTECTED]
Mobile: (206) 999-0588
http://3rdandUrban.com | http://amp.fm |
http://www.oreillynet.com/pub/au/2354
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] gmcs:compiler > "Cannot convert type `lambda expression' to `System.Action'"

2008-06-16 Thread Casey Marshall
On Mon, 2008-06-16 at 17:38 -0600, M. David Peterson wrote:
> Was about to report this to Novell:Bugzilla but after a quick
> search[1] it seems there may be plenty of related bugs, so thought it
> better to get a quick clarification first.
> 

I filed this bug on this (or a similar) error:

https://bugzilla.novell.com/show_bug.cgi?id=378189

I don't know if it's well understood or not, but it's definitely still
an issue, and has been for a while.

Thanks.

> Bug: "Cannot convert type `lambda expression' to `System.Action'"
> 
> ./Async.cs(143,29): error CS1502: The best overloaded method
> match for
> 
> `EeekSoft.Asynchronous.AsyncExtensions.Run(System.Collections.Generic.IEnumerator,
>  System.Action)' has some invalid arguments
> ./Async.cs(189,30): (Location of the symbol related to
> previous error)
> ./Async.cs(143,29): error CS1503: Argument 2: Cannot convert
> type `lambda expression' to `System.Action'
> 
> This bug makes itself known on recent SVN revisions but -- strangely
> -- compiles just fine on 1.9.1
> Compiles as expect on MS.NET
> 
> Steps to repro:  Using recent SVN revision,
> 
> svn co
> 
> http://nuxleus.googlecode.com/svn/trunk/nuxleus/Source/Nuxleus.Extension.Linq/
> co Nuxleus.Extension.Linq
> gmcs -t:library -recurse:*.cs -r:System.Xml -r:System.Xml.Linq
> -out:Nuxleus.Extension.Aws.dll
> 
> Expected results: As per release 1.9.1,
> 
> $ which mono
> /usr/bin/mono
> $ mono -V
> Mono JIT compiler version 1.9.1 (tarball)
> Copyright (C) 2002-2007 Novell, Inc and Contributors.
> www.mono-project.com
> TLS:   __thread
> GC:none
> SIGSEGV:   altstack
> Notifications: epoll
> Architecture:  amd64
> Disabled:  none
> $ gmcs -t:library -recurse:*.cs -r:System.Xml
> -r:/usr/lib/mono/3.5/System.Xml.Linq
> -out:Nuxleus.Extension.Aws.dll
> $
> 
> Actual results: As per SVN 105925 (tarbal)
> 
> $ which mono
> /usr/bin/mono
> $ mono -V
> Mono JIT compiler version 105925 (tarball)
> Copyright (C) 2002-2008 Novell, Inc and Contributors.
> www.mono-project.com
> TLS:   __thread
> GC:Included Boehm (with typed GC)
> SIGSEGV:   altstack
> Notifications: epoll
> Architecture:  amd64
> Disabled:  none
> $ gmcs -t:library -recurse:*.cs -r:System.Xml
> -r:System.Xml.Linq -out:Nuxleus.Extension.Aws.dll
> ./Async.cs(143,29): error CS1502: The best overloaded method
> match for
> 
> `EeekSoft.Asynchronous.AsyncExtensions.Run(System.Collections.Generic.IEnumerator,
>  System.Action)' has some invalid arguments
> ./Async.cs(189,30): (Location of the symbol related to
> previous error)
> ./Async.cs(143,29): error CS1503: Argument 2: Cannot convert
> type `lambda expression' to `System.Action'
> Compilation failed: 2 error(s), 0 warnings
> $
> 
> Should I go ahead and submit this as a new bug, or, as per link[1] is
> this a well understood issue?
> 
> [1]
> https://bugzilla.novell.com/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=Mono%3A+Compilers&content=%22Cannot+convert+type+%60lambda+expression%27+to+%60System.Action%27%22
> 
> -- 
> /M:D
> 
> M. David Peterson
> Co-Founder & Chief Architect, 3rd & Urban, LLC
> Email: [EMAIL PROTECTED] | [EMAIL PROTECTED]
> Mobile: (206) 999-0588
> http://3rdandUrban.com | http://amp.fm |
> http://www.oreillynet.com/pub/au/2354 
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] gmcs:compiler > "Cannot convert type `lambda expression' to `System.Action'"

2008-06-16 Thread M. David Peterson
Was about to report this to Novell:Bugzilla but after a quick search[1] it
seems there may be plenty of related bugs, so thought it better to get a
quick clarification first.

Bug: "Cannot convert type `lambda expression' to `System.Action'"

./Async.cs(143,29): error CS1502: The best overloaded method match for
> `EeekSoft.Asynchronous.AsyncExtensions.Run(System.Collections.Generic.IEnumerator,
> System.Action)' has some invalid arguments
> ./Async.cs(189,30): (Location of the symbol related to previous error)
> ./Async.cs(143,29): error CS1503: Argument 2: Cannot convert type `lambda
> expression' to `System.Action'
>

This bug makes itself known on recent SVN revisions but -- strangely --
compiles just fine on 1.9.1
Compiles as expect on MS.NET

Steps to repro:  Using recent SVN revision,

svn co
> http://nuxleus.googlecode.com/svn/trunk/nuxleus/Source/Nuxleus.Extension.Linq/
> co Nuxleus.Extension.Linq
> gmcs -t:library -recurse:*.cs -r:System.Xml -r:System.Xml.Linq
> -out:Nuxleus.Extension.Aws.dll
>

Expected results: As per release 1.9.1,

$ which mono
> /usr/bin/mono
> $ mono -V
> Mono JIT compiler version 1.9.1 (tarball)
> Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
> TLS:   __thread
> GC:none
> SIGSEGV:   altstack
> Notifications: epoll
> Architecture:  amd64
> Disabled:  none
> $ gmcs -t:library -recurse:*.cs -r:System.Xml
> -r:/usr/lib/mono/3.5/System.Xml.Linq -out:Nuxleus.Extension.Aws.dll
> $
>

Actual results: As per SVN 105925 (tarbal)

$ which mono
> /usr/bin/mono
> $ mono -V
> Mono JIT compiler version 105925 (tarball)
> Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
> TLS:   __thread
> GC:Included Boehm (with typed GC)
> SIGSEGV:   altstack
> Notifications: epoll
> Architecture:  amd64
> Disabled:  none
> $ gmcs -t:library -recurse:*.cs -r:System.Xml -r:System.Xml.Linq
> -out:Nuxleus.Extension.Aws.dll
> ./Async.cs(143,29): error CS1502: The best overloaded method match for
> `EeekSoft.Asynchronous.AsyncExtensions.Run(System.Collections.Generic.IEnumerator,
> System.Action)' has some invalid arguments
> ./Async.cs(189,30): (Location of the symbol related to previous error)
> ./Async.cs(143,29): error CS1503: Argument 2: Cannot convert type `lambda
> expression' to `System.Action'
> Compilation failed: 2 error(s), 0 warnings
> $
>

Should I go ahead and submit this as a new bug, or, as per link[1] is this a
well understood issue?

[1]
https://bugzilla.novell.com/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=Mono%3A+Compilers&content=%22Cannot+convert+type+%60lambda+expression%27+to+%60System.Action%27%22

-- 
/M:D

M. David Peterson
Co-Founder & Chief Architect, 3rd & Urban, LLC
Email: [EMAIL PROTECTED] | [EMAIL PROTECTED]
Mobile: (206) 999-0588
http://3rdandUrban.com | http://amp.fm |
http://www.oreillynet.com/pub/au/2354
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] [PATCH] Implement support for mixed-mode assemblies on Windows x64 as well

2008-06-16 Thread Kornél Pál

Hi,

The attached patch makes some modifications to enable mixed-mode 
assembly support on Windows x64 as well.


I already update mixed-mode tests to support x64 and are working with 
this patch.


domain.c: Avoid system error message boxes.

assembly.c: Use __ImageBase instead of mono_module_handle that is 
defined by the linker; no initialization required.


image.c: mono_image_open_from_module_handle: Replace ref_count argument 
with has_entry_point. Handle do_mono_image_load fauilre correctly.


mono_image_open_full, mono_image_close: Use has_entry_point instead of 
coff_attributes.


coree.c: _CorValidateImage: Convert platform independent PE32 images to 
PE32+ on 64-bit Windows that makes the OS able to load CIL images as 
modules.


MonoFixupCorEE: Export Address Table RVAs are 32-bit unsigned integers 
so memory has to be allocated for trampolines (x64) or procedure labels 
(IA64) up to 4 GB away from image base address. IA64 version is not 
tested but was very easy to implement and should work if we ever need it.


Also contains some work to make MonoFixupCorEE reversible when unloading 
mono.dll but that's not implemented yet.


Please test the attached patch and if you like it, please approve it.

Kornél
Index: mono/mono/metadata/domain.c
===
--- mono/mono/metadata/domain.c (revision 105942)
+++ mono/mono/metadata/domain.c (working copy)
@@ -1203,7 +1203,10 @@
if (domain)
g_assert_not_reached ();
 
-#if defined(PLATFORM_WIN32) && !defined(_WIN64)
+#ifdef PLATFORM_WIN32
+   /* Avoid system error message boxes. */
+   SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+
mono_load_coree (exe_filename);
 #endif
 
Index: mono/mono/metadata/assembly.c
===
--- mono/mono/metadata/assembly.c   (revision 105942)
+++ mono/mono/metadata/assembly.c   (working copy)
@@ -551,7 +551,7 @@
 #ifdef PLATFORM_WIN32
gchar *bindir, *installdir, *root, *name, *config;
 
-   name = mono_get_module_file_name (mono_module_handle);
+   name = mono_get_module_file_name ((HMODULE) &__ImageBase);
bindir = g_path_get_dirname (name);
installdir = g_path_get_dirname (bindir);
root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
Index: mono/mono/metadata/image.c
===
--- mono/mono/metadata/image.c  (revision 105942)
+++ mono/mono/metadata/image.c  (working copy)
@@ -1080,7 +1080,7 @@
 #ifdef PLATFORM_WIN32
 /* fname is not duplicated. */
 MonoImage*
-mono_image_open_from_module_handle (HMODULE module_handle, char* fname, int 
ref_count, MonoImageOpenStatus* status)
+mono_image_open_from_module_handle (HMODULE module_handle, char* fname, 
gboolean has_entry_point, MonoImageOpenStatus* status)
 {
MonoImage* image;
MonoCLIImageInfo* iinfo;
@@ -1091,9 +1091,13 @@
iinfo = g_new0 (MonoCLIImageInfo, 1);
image->image_info = iinfo;
image->name = fname;
-   image->ref_count = ref_count;
+   image->ref_count = has_entry_point ? 0 : 1;
+   image->has_entry_point = has_entry_point;
 
image = do_mono_image_load (image, status, TRUE);
+   if (image == NULL)
+   return NULL;
+
return register_image (image);
 }
 #endif
@@ -1122,15 +1126,11 @@
image = g_hash_table_lookup (loaded_images_hash, absfname);
if (image) {
g_assert (image->is_module_handle);
-   if (image->ref_count == 0) {
-   MonoCLIImageInfo *iinfo = image->image_info;
-
-   if (iinfo->cli_header.coff.coff_attributes & 
COFF_ATTRIBUTE_LIBRARY_IMAGE) {
-   /* Increment reference count on images 
loaded outside of the runtime. */
-   fname_utf16 = g_utf8_to_utf16 
(absfname, -1, NULL, NULL, NULL);
-   module_handle = LoadLibrary 
(fname_utf16);
-   g_assert (module_handle != NULL);
-   }
+   if (image->has_entry_point && image->ref_count == 0) {
+   /* Increment reference count on images loaded 
outside of the runtime. */
+   fname_utf16 = g_utf8_to_utf16 (absfname, -1, 
NULL, NULL, NULL);
+   module_handle = LoadLibrary (fname_utf16);
+   g_assert (module_handle != NULL);
}
mono_image_addref (image);
mono_images_unlock ();
@@ -1167,11 +1167,12 @@
 
if (image) {
g_assert (image->is_module_handle);
+   g_assert (image->has_entry_point);
   

Re: [Mono-dev] DataColumn.DefaultValue fixes

2008-06-16 Thread Atsushi Eno
Hey Kosta,

Thanks, that's a good point. I don't think reflection is a soluton
there for performance wise, so I made another fix to replace
Activator.CreateInstance().

Atsushi Eno

Konstantin Triger wrote:
> Hey Eno,
> 
> Yep, I agree it's a corner case, that can be postponed. Yet I think it's 
> worth mentioning in a MonoInternalNoteAttribute, just to not forget.
> 
> In addition, there can be a performance issue related to 
> Activator.CreateInstance() call, that can be solved in the same time.
> 
> On Fri, Jun 13, 2008 at 5:32 PM, Atsushi Eno <[EMAIL PROTECTED] 
> > wrote:
> 
> Hi Kosta,
> 
> Thanks for digging it. It sounds interesting, though I'm not sure how
> it is significant. INullable is in System.Data.SqlTypes namespace,
> so I'd expect that it is mostly for internal use.
> 
> The fix I made for SqlXxx type support as null value is rather
> to make Sys.Data classes to not premise DBNull than picking every
> possible supported types.
> 
> Of course, changing relevant to support INullable is better than
> now I think.
> 
> Atsushi Eno
> 
> 
> 
> Konstantin Triger wrote:
> 
> Hello all,
> 
> It was strange to me that MS perform a special check for SqlXXX
> types, so I started looking what is common to them. I saw that
> all of them derive from INullable. It looked interesting, so I
> created my type that derived from INullable. When I tried to set
> it as a DataColumn type, I got an exception stating that I must
> have a static property or field named "Null". When I added it, I
> got its value for DataColumn.DefaultValue.
> 
> Regards,
> Kosta
> 
> 
> 
> 
> 
> -- 
> Regards,
> Konstantin Triger
> RSS: http://feeds.feedburner.com/ktriger

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] DataSet / DataTable xsd fix wrt Locale and UseCurrentLocale

2008-06-16 Thread Atsushi Eno
Hi again,

I have another set of sys.data changes to fix xsd output on
msdata:Locale and msdata.UseCurrentCulture. In .NET 2.0 (possibly
SP1), it should not reflect implicit Locale value but should
reflect explicit Locale value (which is, I mean, assigned explicitly).
In those implicit cases, it outputs msdata:UseCurrentCulture, not
msdata:Locale.

On reading either a schema or xml instance (i.e. as schema inference),
en-US culture seems filled (regardless of current culture; if you
change my patch for XmlDataInferenceLoader or XmlSchemaDataImporter
to fill CurrentCulture, you'll see some tests failing).

(And I did some code unification in DataTable.WriteXmlSchema methods.)

The changes reside all over the related classes:

XmlSchemaWriter.cs
DataSet.cs
XmlTableWriter.cs
XmlDataInferenceLoader.cs
XmlSchemaDataImporter.cs
DataTable.cs

If it looks good, I'll commit the fix later.

Atsushi Eno
Index: System.Data/XmlSchemaWriter.cs
===
--- System.Data/XmlSchemaWriter.cs  (revision 105755)
+++ System.Data/XmlSchemaWriter.cs  (working copy)
@@ -63,9 +63,10 @@
internal static void WriteXmlSchema (XmlWriter writer, 
DataTable[] tables,
 DataRelation[] relations,
 string mainDataTable,
-string dataSetName)
+string dataSetName,
+CultureInfo locale)
{
-   new XmlSchemaWriter (writer, tables, relations, 
mainDataTable, dataSetName).WriteSchema ();
+   new XmlSchemaWriter (writer, tables, relations, 
mainDataTable, dataSetName, locale).WriteSchema ();
}
 
public XmlSchemaWriter (DataSet dataset,
@@ -74,7 +75,11 @@
{
dataSetName = dataset.DataSetName;
dataSetNamespace = dataset.Namespace;
+#if NET_2_0
+   dataSetLocale = dataset.LocaleSpecified ? 
dataset.Locale : null;
+#else
dataSetLocale = dataset.Locale;
+#endif
dataSetProperties = dataset.ExtendedProperties;
w = writer;
if (tables != null) {
@@ -91,20 +96,26 @@
DataTable[] tables,
DataRelation[] relations,
string mainDataTable,
-   string dataSetName)
+   string dataSetName,
+   CultureInfo locale)
{
w = writer;
this.tables = tables;
this.relations = relations;
this.mainDataTable = mainDataTable;
this.dataSetName = dataSetName;
+   this.dataSetLocale = locale;
this.dataSetProperties = new PropertyCollection();
if (tables[0].DataSet != null) {
dataSetNamespace = tables[0].DataSet.Namespace;
+#if !NET_2_0
dataSetLocale = tables[0].DataSet.Locale;
+#endif
} else {
dataSetNamespace = tables[0].Namespace;
+#if !NET_2_0
dataSetLocale = tables[0].Locale;
+#endif
}
}
 
@@ -217,29 +228,35 @@
"IsDataSet", XmlConstants.MsdataNamespace,
"true");
 
+#if NET_2_0
+   bool useCurrentLocale = (dataSetLocale == null);
+
+   if (!useCurrentLocale)
+#endif
+   {
+   w.WriteAttributeString (
+   XmlConstants.MsdataPrefix,
+   "Locale",
+   XmlConstants.MsdataNamespace,
+   dataSetLocale.Name);
+   }
+
+#if NET_2_0
if(mainDataTable != null && mainDataTable != "")
w.WriteAttributeString (
XmlConstants.MsdataPrefix,
"MainDataTable",
XmlConstants.MsdataNamespace,
mainDataTable);
-#if NET_2_0
-   if (dataSetLocale == CultureInfo.CurrentCulture) {
+
+   if (useCurrentLocale) {
w.WriteAttributeString (
XmlConstants.MsdataPrefix,
"UseCurrentLocale",
XmlConstan

Re: [Mono-dev] [Patch] Small optimization to String.Replace and StringBuilder.Replace

2008-06-16 Thread Andreas Nahr
Did you time/measure this change?

-   const int maxValue = 200; // Allocate 800 byte
maximum
+   // Allocate 800 byte maximum
+   int maxValue = Math.Min ((length + oldValue.Length -
1) / oldValue.Length, 200);
int* dat = stackalloc int[maxValue];
fixed (char* source = this, replace = newValue) {
int i = 0, count = 0;
@@ -1661,6 +1654,9 @@
}
i = found + oldValue.length;
}
+   if (count == 0)
+   return this;
+
int nlen = this.length + ((newValue.length -
oldValue.length) * count);
String tmp = InternalAllocateStr (nlen);

My assumption is that for small (common) cases this may produce a noticable
slowdown.
I'm fine with the count == 0 shortcut, but the exact calculation will
probably hurt performance.
Maybe a compromise would be
int maxValue = Math.Min (length, 200);

Happy Hacking
Andreas

> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED] [mailto:mono-devel-list-
> [EMAIL PROTECTED] Im Auftrag von Juraj Skripsky
> Gesendet: Montag, 16. Juni 2008 16:38
> An: mono-devel
> Betreff: [Mono-dev] [Patch] Small optimization to String.Replace and
> StringBuilder.Replace
> 
> Hello,
> 
> Attached you'll find a patch which reduces the number of allocations
> done in String.Replace and StringBuilder.Replace.
> 
> All unit tests pass.
> Please review.
> 
> - Juraj

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Question about Mono.Security.X509

2008-06-16 Thread David Wolinsky
Many apologies for the mistakes!  I appreciate the thoroughness and have 
hopefully not looked over any issues in this patch.


Regards,
David

Sebastien Pouliot wrote:

Hello David,

General note: Please review the Mono coding guidelines.
http://www.mono-project.com/Coding_Guidelines

E.g. use tabs not spaces, add a space before '('

  


diff -urN mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security_test.dll.sources mono-1.9.1/mcs/class/Mono.Security/Mono.Security_test.dll.sources
--- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security_test.dll.sources	2007-11-08 17:34:20.0 -0500
+++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security_test.dll.sources	2008-06-13 01:58:07.0 -0400
@@ -40,3 +40,4 @@
 Mono.Security.X509.Extensions/KeyUsageExtensionTest.cs
 Mono.Security.X509.Extensions/ExtendedKeyUsageExtensionTest.cs
 Mono.Security.X509.Extensions/BasicConstraintsExtensionTest.cs
+Mono.Security.X509.Extensions/SubjectAltNameTest.cs
diff -urN mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog
--- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog	2007-11-08 17:34:18.0 -0500
+++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog	2008-06-16 12:47:03.0 -0400
@@ -1,3 +1,8 @@
+2008-06-13  David Wolinsky  <[EMAIL PROTECTED]>
+
+	* X509CertificateBuilder.cs: Extensions is now writable so that it
+	can be added unto during run time.
+
 2007-05-09  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
 	* PKCS12.cs: Adds SecretBag support. Patch by Jay Miller.
diff -urN mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateBuilder.cs mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateBuilder.cs
--- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateBuilder.cs	2007-11-08 17:34:18.0 -0500
+++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateBuilder.cs	2008-06-16 12:45:25.0 -0400
@@ -136,6 +136,7 @@
 
 		public X509ExtensionCollection Extensions {
 			get { return extensions; }
+			set { extensions = value; }
 		}
 
 
diff -urN mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog
--- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog	2008-01-29 17:05:09.0 -0500
+++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog	2008-06-16 12:48:09.0 -0400
@@ -1,3 +1,9 @@
+2008-06-13  David Wolinsky  <[EMAIL PROTECTED]>
+	* SubjectAltName.cs: IP Addresses are handled and now this class
+	can be generated via the constructor from arrays.
+	* GeneralNames.cs: Added support to generate GeneralNames from
+	an arrays of strings.
+
 2007-12-14  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
 	* AuthorityKeyIdentifierExtension.cs: Don't throw on what we don't
diff -urN mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
--- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs	2007-11-08 17:34:17.0 -0500
+++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs	2008-06-16 12:51:08.0 -0400
@@ -72,11 +72,55 @@
 		private ArrayList directoryNames;
 		private ArrayList uris;
 		private ArrayList ipAddr;
+		private ASN1 asn;
 
 		public GeneralNames ()
 		{
 		}
 
+		public GeneralNames (string[] rfc822s, string[] dnsNames, string[] ipAddresses, string[] uris)
+		{
+			// This is an extension
+			asn = new ASN1 (0x30);
+
+			if (rfc822s != null) {
+rfc822Name = new ArrayList ();
+foreach (string rfc822 in rfc822s) {
+	asn.Add (new ASN1 (0x81, Encoding.ASCII.GetBytes (rfc822)));
+	rfc822Name.Add (rfc822s);
+}
+			}
+
+			if (dnsNames != null) {
+dnsName = new ArrayList ();
+foreach (string dnsname in dnsNames) {
+	asn.Add (new ASN1 (0x82, Encoding.ASCII.GetBytes (dnsname)));
+	dnsName.Add(dnsname);
+}
+			}
+
+			if (ipAddresses != null) {
+ipAddr = new ArrayList ();
+foreach (string ipaddress in ipAddresses) {
+	string[] parts = ipaddress.Split ('.', ':');
+	byte[] bytes = new byte[parts.Length];
+	for (int i = 0; i < parts.Length; i++) {
+		bytes[i] = Byte.Parse (parts[i]);
+	}
+	asn.Add (new ASN1 (0x87, bytes));
+	ipAddr.Add (ipaddress);
+}
+			}
+
+			if (uris != null) {
+this.uris = new ArrayList();
+foreach (string uri in uris) {
+	asn.Add (new ASN1 (0x86, Encoding.ASCII.GetBytes (uri)));
+	this.uris.Add (uri);
+}
+			}
+		}
+
 		public GeneralNames (ASN1 sequence)
 		{
 			for (int i = 0; i < sequence.Count; i++) {
@@ -105,7 +149,17 @@
 case 0x87: // iPAddress[7] OCTET STRING
 	if (ipAddr == null)
 		ipAddr = new ArrayList ();
-	// TODO - Must find sample

[Mono-dev] [Patch] Small optimization to String.Replace and StringBuilder.Replace

2008-06-16 Thread Juraj Skripsky
Hello,

Attached you'll find a patch which reduces the number of allocations
done in String.Replace and StringBuilder.Replace.

All unit tests pass.
Please review.

- Juraj
Index: System/ChangeLog
===
--- System/ChangeLog	(revision 105881)
+++ System/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-06-16  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* String.cs (ReplaceUnchecked): Don't stackalloc more than necessary. Return
+	"this" if it does not contain oldValue.
+	(Compare): Use Math.Min. 
+
 2008-06-14  Zoltan Varga  <[EMAIL PROTECTED]>
 
 	* Environment.cs: Bump corlib version.
Index: System/String.cs
===
--- System/String.cs	(revision 105881)
+++ System/String.cs	(working copy)
@@ -568,17 +568,9 @@
 			// CompareInfo.Compare will insist that length
 			// <= (string.Length - offset)
 
-			int len1 = length;
-			int len2 = length;
+			int len1 = Math.Min (length, strA.Length - indexA);
+			int len2 = Math.Min (length, strB.Length - indexB); 
 			
-			if (length > (strA.Length - indexA)) {
-len1 = strA.Length - indexA;
-			}
-
-			if (length > (strB.Length - indexB)) {
-len2 = strB.Length - indexB;
-			}
-
 			// ENHANCE: Might call internal_compare_switch directly instead of doing all checks twice
 			return culture.CompareInfo.Compare (strA, indexA, len1, strB, indexB, len2, compopts);
 		}
@@ -1645,7 +1637,8 @@
 // because the length of the result would be this.length and length calculation unneccesary
 			}
 
-			const int maxValue = 200; // Allocate 800 byte maximum
+			// Allocate 800 byte maximum
+			int maxValue = Math.Min ((length + oldValue.Length - 1) / oldValue.Length, 200);
 			int* dat = stackalloc int[maxValue];
 			fixed (char* source = this, replace = newValue) {
 int i = 0, count = 0;
@@ -1661,6 +1654,9 @@
 	}
 	i = found + oldValue.length;
 }
+if (count == 0)
+	return this;
+
 int nlen = this.length + ((newValue.length - oldValue.length) * count);
 String tmp = InternalAllocateStr (nlen);
 
Index: System.Text/StringBuilder.cs
===
--- System.Text/StringBuilder.cs	(revision 105881)
+++ System.Text/StringBuilder.cs	(working copy)
@@ -310,14 +310,19 @@
 throw new ArgumentException ("The old value cannot be zero length.");
 
 			// TODO: OPTIMIZE!
-			string replace = _str.Substring(startIndex, count).Replace(oldValue, newValue);
+			string substr = _str.Substring(startIndex, count);
+			string replace = substr.Replace(oldValue, newValue);
+			if ((object) replace == (object) substr)
+return this;
 
 			InternalEnsureCapacity (replace.Length + (_length - count));
 
-			string end = _str.Substring (startIndex + count, _length - startIndex - count );
-
+			if (replace.Length < count)
+String.CharCopy (_str, startIndex + replace.Length, _str, startIndex + count, _length - startIndex  - count);
+			else if (replace.Length > count)
+String.CharCopyReverse (_str, startIndex + replace.Length, _str, startIndex + count, _length - startIndex  - count);
+
 			String.CharCopy (_str, startIndex, replace, 0, replace.Length);
-			String.CharCopy (_str, startIndex + replace.Length, end, 0, end.Length);
 			
 			_length = replace.Length + (_length - count);
 
Index: System.Text/ChangeLog
===
--- System.Text/ChangeLog	(revision 105881)
+++ System.Text/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2008-06-16  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* StringBuilder.cs (Replace): Do nothing if we don't contain oldValue.
+	Do the moving of the string end in-place.
+
 2008-06-01  Juraj Skripsky  <[EMAIL PROTECTED]>
 
 	* StringBuilder.cs (ToString): Use String.SubstringUnchecked instead
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Question about Mono.Security.X509

2008-06-16 Thread Sebastien Pouliot
Hello David,

General note: Please review the Mono coding guidelines.
http://www.mono-project.com/Coding_Guidelines

E.g. use tabs not spaces, add a space before '('

> diff -urpN 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security_test.dll.sources 
> mono-1.9.1/mcs/class/Mono.Security/Mono.Security_test.dll.sources
> --- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security_test.dll.sources 
>   2007-11-08 17:34:20.0 -0500
> +++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security_test.dll.sources   
> 2008-06-13 01:58:07.0 -0400
> @@ -40,3 +40,4 @@ Mono.Security.X509/X520AttributesTest.cs
>  Mono.Security.X509.Extensions/KeyUsageExtensionTest.cs
>  Mono.Security.X509.Extensions/ExtendedKeyUsageExtensionTest.cs
>  Mono.Security.X509.Extensions/BasicConstraintsExtensionTest.cs
> +Mono.Security.X509.Extensions/SubjectAltNameTest.cs
> diff -urpN 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog 
> mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog
> --- mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog 
> 2007-11-08 17:34:18.0 -0500
> +++ mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog 
> 2008-06-13 02:02:37.0 -0400
> @@ -1,3 +1,8 @@
> +2008-06-13  David Wolinsky  <[EMAIL PROTECTED]>
> +
> +  * X509CertificateBuilder.cs: Extensions is now writable so that it
> +   can be added unto during run time.
> +
>  2007-05-09  Sebastien Pouliot  <[EMAIL PROTECTED]>
>  
> * PKCS12.cs: Adds SecretBag support. Patch by Jay Miller.
> diff -urpN 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog
>  mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog
> --- 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog
>   2008-01-29 17:05:09.0 -0500
> +++ 
> mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/ChangeLog  
> 2008-06-13 02:01:27.0 -0400
> @@ -1,3 +1,9 @@
> +2008-06-13  David Wolinsky  <[EMAIL PROTECTED]>
> +  * SubjectAltName.cs: IP Addresses are handled and now this class
> +   can be generated via the constructor from arrays.
> +   * GeneralNames.cs: Added support to generate GeneralNames from
> +   an arrays of strings.
> +
>  2007-12-14  Sebastien Pouliot  <[EMAIL PROTECTED]>
>  
> * AuthorityKeyIdentifierExtension.cs: Don't throw on what we don't
> diff -urpN 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
>  
> mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
> --- 
> mono-1.9.1-old/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
> 2007-11-08 17:34:17.0 -0500
> +++ 
> mono-1.9.1/mcs/class/Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
> 2008-06-13 01:58:52.0 -0400
> @@ -72,11 +72,52 @@ namespace Mono.Security.X509.Extensions 
> private ArrayList directoryNames;
> private ArrayList uris;
> private ArrayList ipAddr;
> +private ASN1 asn;
> +
>  
> public GeneralNames ()
> {
> }
>  
> +public GeneralNames(ArrayList rfc822s, ArrayList dnsNames, ArrayList 
> ipAddresses, ArrayList uris)

let's change the ArrayList into string[]...

> +{
> +  // This is an extension
> +  asn = new ASN1 ( 0x30);
> +
> +  if(rfc822s != null) {
> +foreach(string rfc822 in rfc822s) {
> +  asn.Add( new ASN1 (0x81, Encoding.ASCII.GetBytes (rfc822)));
> +}
> +rfc822Name = rfc822s;

... since it fix the problem here, i.e. this is a reference, not a copy
(that the caller could change after the call making the internal state
inconsistent).

> +  }
> +
> +  if(dnsNames != null) {

the easy fix is to:

dnsName = new ArrayList ();

> +foreach(string dnsname in dnsNames) {
> +  asn.Add( new ASN1 (0x82, Encoding.ASCII.GetBytes (dnsname)));

dnsName.Add (dnsname);

> +}
> +dnsName = dnsNames;

(and here)

> +  }
> +
> +  if(ipAddresses != null) {
> +foreach(string ipaddress in ipAddresses) {
> +  string[] parts = ipaddress.Split('.', ':');
> +  byte[] bytes = new byte[parts.Length];
> +  for(int i = 0; i < parts.Length; i++) {
> +bytes[i] = Byte.Parse(parts[i]);
> +  }
> +  asn.Add( new ASN1 (0x87, bytes));
> +}
> +ipAddr = ipAddresses;

(and here)

> +  }
> +
> +  if(uris != null) {
> +foreach(string uri in uris) {
> +  asn.Add( new ASN1 (0x86, Encoding.ASCII.GetBytes (uri)));
> +}
> +this.uris = uris;

(and here)

> +  }
> +}
> +
> public GeneralNames (ASN1 sequence)
> {
> for (int i = 0; i < sequence.Count; i++) {
> @@ -103,9 +144,16 @@ namespace Mono.Security.X50