[Mono-list] Indexer mcs compilation failure on Mono 0.29/Fedora Core 1

Roelof Blom roelof@blombrothers.com
Wed, 17 Dec 2003 08:51:10 +0100


This is a multi-part message in MIME format.
--------------030103010502000509050509
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

In the attached file (part of the ConfigurationManagement Application
Block supplied by Microsoft), mcs fails to compile the following indexer:

~        public string this [ string key, params object[] par ]
~        {
~            get
~            {
~                return string.Format( CultureInfo.CurrentUICulture,
_resourceManager.GetString( key, CultureInfo.CurrentCulture ), par );
~            }
~        }

It fails with this error:
Unhandled Exception: System.NullReferenceException: A null value was
found where an object instance was required
in <0x00695> Mono.CSharp.Indexer:Define (Mono.CSharp.TypeContainer)
in <0x002cc> Mono.CSharp.TypeContainer:DefineIndexers ()
in <0x00768> Mono.CSharp.TypeContainer:DefineMembers
(Mono.CSharp.TypeContainer)in <0x00353>
Mono.CSharp.RootContext:PopulateTypes ()
in <0x007cf> Mono.CSharp.Driver:MainDriver (string[])
in <0x0001b> Mono.CSharp.Driver:Main (string[])

Is this a known bug? If so, does it have a workaround?

Regards,
Roelof.



--------------030103010502000509050509
Content-Type: text/plain;
 name="Resource.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Resource.cs"

// ===============================================================================
// Microsoft Configuration Management Application Block for .NET
// http://msdn.microsoft.com/library/en-us/dnbda/html/cmab.asp
//
// Resource.cs
//
// Wrapper to make the use of resources easy on the code.
//
// For more information see the Configuration Management Application Block Implementation Overview. 
// 
// ===============================================================================
// Copyright (C) 2000-2001 Microsoft Corporation
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
// ==============================================================================

using System;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Reflection; 

namespace Microsoft.ApplicationBlocks.ConfigurationManagement
{
    /// <summary>
    /// Helper class used to manage application resources
    /// </summary>
    internal sealed class Resource
    {
        #region Static part

        private static readonly Resource _resource;

		//  static constructor private by nature.  Initialize our read-only member _resourceManager here, 
		//  there will only ever be one copy.
		static Resource()
		{
			_resource = new Resource();
		}


		//  return the singleton instance of Resource
        public static Resource ResourceManager
        {
            get
            {
                return _resource;
            }
        }
        
		
		#endregion
		
        #region Instance part
        
		//  this is the ACTUAL resource manager, for which this class is just a convenience wrapper
		private ResourceManager _resourceManager = null;

		//  make constructor private so no one can directly create an instance of Resource, only use the Static Property ResourceManager
        private Resource()
        {
            _resourceManager = new ResourceManager(this.GetType().Namespace + ".ConfigurationManagerText", Assembly.GetExecutingAssembly());
        }


		//  a convenience Indexer that access the internal resource manager
        public string this [ string key ]
        {
            get
            {
                return _resourceManager.GetString( key, CultureInfo.CurrentCulture );
            }
        }


		public string this [ string key, params object[] par ]
		{
			get
			{
				return string.Format( CultureInfo.CurrentUICulture, _resourceManager.GetString( key, CultureInfo.CurrentCulture ), par );
			}
		}

		public Stream GetStream( string name )
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream( name );
		}
		#endregion
    }
}


--------------030103010502000509050509--