Home Bug Reports

slice2cs 3.4.1 omits map types

adv12adv12 Member Andrew VardemanOrganization: Iowa State UniversityProject: USDA agricultural survey
Hi. I'm using Ice 3.4.1 on Windows XP with Visual Studio 2010. slice2cs doesn't seem to be generating C# classes for my maps. Running slice2cs on the following code produces the output included below. I just installed 3.4.1 (upgrading from 3.2.1), and I uninstalled 3.2.1 in case slice2cs 3.4.1 was somehow loading DLLs from 3.2.1 or something like that. Any ideas what I might be doing wrong?

// ********************************************************
// Test Ice file.
// ********************************************************

#ifndef SLICE_TEST_ICE
#define SLICE_TEST_ICE

module SliceTest {
dictionary<string, string> StringMap;
};

#endif


// ******
// Output
// ******

// **********************************************************************
//
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

// Ice version 3.4.1

// <auto-generated>
//
// Generated from file `SliceTest.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>


using _System = global::System;
using _Microsoft = global::Microsoft;

#pragma warning disable 1591

namespace SliceTest
{
}

namespace SliceTest
{
[_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.4.1")]
public sealed class StringMapHelper
{
public static void write(IceInternal.BasicStream os__,
_System.Collections.Generic.Dictionary<string, string> v__)
{
if(v__ == null)
{
os__.writeSize(0);
}
else
{
os__.writeSize(v__.Count);
foreach(_System.Collections.Generic.KeyValuePair<string, string> e__ in v__)
{
os__.writeString(e__.Key);
os__.writeString(e__.Value);
}
}
}

public static _System.Collections.Generic.Dictionary<string, string> read(IceInternal.BasicStream is__)
{
int sz__ = is__.readSize();
_System.Collections.Generic.Dictionary<string, string> r__ = new _System.Collections.Generic.Dictionary<string, string>();
for(int i__ = 0; i__ < sz__; ++i__)
{
string k__;
k__ = is__.readString();
string v__;
v__ = is__.readString();
r__[k__] = v__;
}
return r__;
}
}
}

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Andrew,

    The mapping for dictionaries has changed since Ice 3.2. Now your dictionary maps to the following type by default:

    System.Collections.Generic.Dictionary<string, string>

    This means that the Slice compiler doesn't need to generate a class representing the dictionary because it can reuse the .NET Dictionary class.

    This page describes the mapping in more detail.

    Regards,
    Mark
  • adv12adv12 Member Andrew VardemanOrganization: Iowa State UniversityProject: USDA agricultural survey
    Oh.

    Mark,

    Thanks for the link. Next time I'll read up more on the changes before posting.

    Andrew
  • adv12adv12 Member Andrew VardemanOrganization: Iowa State UniversityProject: USDA agricultural survey
    documentation tweak

    Incidentally, while reading this:

    http://www.zeroc.com/doc/Ice-3.4.1-IceTouch/manual/Csharp.15.7.html

    I noticed a couple typos:

    "By default, he Slice-to-C# compiler maps the dictionary to the following type:
    System.Collections.Generic.Dictionary<Employee>"

    I think this should be:

    By default, the Slice-to-C# compiler maps the dictionary to the following type:
    System.Collections.Generic.Dictionary<int, Employee>
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    I noticed those too, and actually the mapped type should be

    System.Collections.Generic.Dictionary<long, Employee>

    Thanks,
    Mark
Sign In or Register to comment.