diff options
author | Jon Skeet <skeet@pobox.com> | 2010-12-14 20:41:54 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2010-12-14 20:41:54 +0000 |
commit | ec79ca13415cc921feb9151efa88e7691da45c1e (patch) | |
tree | 45a6e6ccd2a6870051d2463c35405f40530ce8ac /src/ProtocolBuffers | |
parent | f82a09da05e0650a1d532f42567686d4ba5a6106 (diff) | |
download | protobuf-ec79ca13415cc921feb9151efa88e7691da45c1e.tar.gz protobuf-ec79ca13415cc921feb9151efa88e7691da45c1e.tar.bz2 protobuf-ec79ca13415cc921feb9151efa88e7691da45c1e.zip |
Fixed build for lite runtime
Diffstat (limited to 'src/ProtocolBuffers')
-rw-r--r-- | src/ProtocolBuffers/EnumLite.cs | 10 | ||||
-rw-r--r-- | src/ProtocolBuffers/ProtocolBuffers.csproj | 19 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/ProtocolBuffers/EnumLite.cs b/src/ProtocolBuffers/EnumLite.cs index 12497d8e..3776297f 100644 --- a/src/ProtocolBuffers/EnumLite.cs +++ b/src/ProtocolBuffers/EnumLite.cs @@ -35,6 +35,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Reflection; using System.Text; namespace Google.ProtocolBuffers { @@ -86,8 +87,17 @@ namespace Google.ProtocolBuffers { public EnumLiteMap() { items = new SortedList<int, IEnumLite>(); +#if SILVERLIGHT2 + // Silverlight doesn't support Enum.GetValues + // TODO(jonskeet): Validate that this reflection is permitted, e.g. in Windows Phone 7 + foreach (FieldInfo fi in typeof(TEnum).GetFields(BindingFlags.Static | BindingFlags.Public)) { + TEnum evalue = (TEnum) fi.GetValue(null); + items.Add(Convert.ToInt32(evalue), new EnumValue(evalue)); + } +#else foreach (TEnum evalue in Enum.GetValues(typeof(TEnum))) items.Add(Convert.ToInt32(evalue), new EnumValue(evalue)); +#endif } IEnumLite IEnumLiteMap.FindValueByNumber(int number) { diff --git a/src/ProtocolBuffers/ProtocolBuffers.csproj b/src/ProtocolBuffers/ProtocolBuffers.csproj index 715afe87..8da01c9a 100644 --- a/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -68,19 +68,18 @@ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_Silverlight2|AnyCPU'"> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release_Silverlight2\</OutputPath> - <DefineConstants>TRACE;SILVERLIGHT2</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <NoStdLib>true</NoStdLib> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release_Silverlight2\</OutputPath> + <DefineConstants>TRACE;SILVERLIGHT2</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <NoStdLib>true</NoStdLib> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <ItemGroup> <Reference Include="mscorlib" /> <Reference Include="System" /> - <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> @@ -199,7 +198,7 @@ <Install>true</Install> </BootstrapperPackage> </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' == 'Debug' " /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' == 'Debug' " /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' == 'Release' " /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" Condition=" '$(Configuration)' == 'Debug_Silverlight2' " /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" Condition=" '$(Configuration)' == 'Release_Silverlight2' " /> |