diff --git a/src/ProtocolBuffers.Serialization/AbstractReader.cs b/src/ProtocolBuffers.Serialization/AbstractReader.cs index a46125fc45..c8dfd2b48f 100644 --- a/src/ProtocolBuffers.Serialization/AbstractReader.cs +++ b/src/ProtocolBuffers.Serialization/AbstractReader.cs @@ -698,28 +698,5 @@ namespace Google.ProtocolBuffers.Serialization } #endregion - - internal static bool TryParseInt32(string text, out int number) - { - return TryParseInt32(text, NumberStyles.Any, CultureInfo.InvariantCulture, out number); - } - - internal static bool TryParseInt32(string text, NumberStyles style, IFormatProvider format, out int number) - { -#if COMPACT_FRAMEWORK - try - { - number = int.Parse(text, NumberStyles.Integer, CultureInfo.InvariantCulture); - return true; - } - catch - { - number = 0; - return false; - } -#else - return int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out number); -#endif - } } } \ No newline at end of file diff --git a/src/ProtocolBuffers.Serialization/AbstractTextReader.cs b/src/ProtocolBuffers.Serialization/AbstractTextReader.cs index 3f8a0c0589..b40a560aa6 100644 --- a/src/ProtocolBuffers.Serialization/AbstractTextReader.cs +++ b/src/ProtocolBuffers.Serialization/AbstractTextReader.cs @@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers.Serialization if (ReadAsText(ref text, typeof(Enum))) { int number; - if (TryParseInt32(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out number)) + if (FrameworkPortability.TryParseInt32(text, NumberStyles.Integer, FrameworkPortability.InvariantCulture, out number)) { value = number; return true; diff --git a/src/ProtocolBuffers.Serialization/AbstractWriter.cs b/src/ProtocolBuffers.Serialization/AbstractWriter.cs index 1e087ec676..2dc6b88743 100644 --- a/src/ProtocolBuffers.Serialization/AbstractWriter.cs +++ b/src/ProtocolBuffers.Serialization/AbstractWriter.cs @@ -157,8 +157,8 @@ namespace Google.ProtocolBuffers.Serialization } else if (value is IConvertible) { - WriteEnum(field, ((IConvertible) value).ToInt32(CultureInfo.InvariantCulture), - ((IConvertible) value).ToString(CultureInfo.InvariantCulture)); + WriteEnum(field, ((IConvertible)value).ToInt32(FrameworkPortability.InvariantCulture), + ((IConvertible)value).ToString(FrameworkPortability.InvariantCulture)); } else { diff --git a/src/ProtocolBuffers.Serialization/DictionaryReader.cs b/src/ProtocolBuffers.Serialization/DictionaryReader.cs index ac7d2b6f84..c460523c24 100644 --- a/src/ProtocolBuffers.Serialization/DictionaryReader.cs +++ b/src/ProtocolBuffers.Serialization/DictionaryReader.cs @@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers.Serialization { if (obj is IConvertible) { - value = (T) Convert.ChangeType(obj, typeof(T), CultureInfo.InvariantCulture); + value = (T)Convert.ChangeType(obj, typeof(T), FrameworkPortability.InvariantCulture); } else { diff --git a/src/ProtocolBuffers.Serialization/JsonTextCursor.cs b/src/ProtocolBuffers.Serialization/JsonTextCursor.cs index 1a7988096e..19c45af753 100644 --- a/src/ProtocolBuffers.Serialization/JsonTextCursor.cs +++ b/src/ProtocolBuffers.Serialization/JsonTextCursor.cs @@ -195,7 +195,7 @@ namespace Google.ProtocolBuffers.Serialization if (!cond) { throw new FormatException( - String.Format(CultureInfo.InvariantCulture, + String.Format(FrameworkPortability.InvariantCulture, "({0}:{1}) error: Unexpected token {2}, expected: {3}.", _lineNo, _linePos, CharDisplay(_next), @@ -210,7 +210,7 @@ namespace Google.ProtocolBuffers.Serialization if (!cond) { throw new FormatException( - String.Format(CultureInfo.InvariantCulture, + String.Format(FrameworkPortability.InvariantCulture, "({0},{1}) error: {2}", _lineNo, _linePos, message)); } } @@ -225,7 +225,7 @@ namespace Google.ProtocolBuffers.Serialization format = String.Format(format, args); } throw new FormatException( - String.Format(CultureInfo.InvariantCulture, + String.Format(FrameworkPortability.InvariantCulture, "({0},{1}) error: {2}", _lineNo, _linePos, format)); } } @@ -322,7 +322,7 @@ namespace Google.ProtocolBuffers.Serialization string hex = new string(new char[] {ReadChar(), ReadChar(), ReadChar(), ReadChar()}); int result; Assert( - AbstractTextReader.TryParseInt32(hex, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, + FrameworkPortability.TryParseInt32(hex, NumberStyles.AllowHexSpecifier, FrameworkPortability.InvariantCulture, out result), "Expected a 4-character hex specifier."); sb.Add((char) result); diff --git a/src/ProtocolBuffers.Serialization/XmlFormatReader.cs b/src/ProtocolBuffers.Serialization/XmlFormatReader.cs index 71ede7d24f..a4f111d4d1 100644 --- a/src/ProtocolBuffers.Serialization/XmlFormatReader.cs +++ b/src/ProtocolBuffers.Serialization/XmlFormatReader.cs @@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers.Serialization { int number; string temp; - if (null != (temp = _input.GetAttribute("value")) && TryParseInt32(temp, out number)) + if (null != (temp = _input.GetAttribute("value")) && FrameworkPortability.TryParseInt32(temp, out number)) { Skip(); value = number; diff --git a/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 2da0080ec9..4f4e13d879 100644 --- a/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -575,7 +575,7 @@ namespace Google.ProtocolBuffers case FieldType.Enum: if (value is Enum) { - return ComputeEnumSize(fieldNumber, ((IConvertible) value).ToInt32(CultureInfo.InvariantCulture)); + return ComputeEnumSize(fieldNumber, ((IConvertible)value).ToInt32(FrameworkPortability.InvariantCulture)); } else { @@ -631,7 +631,7 @@ namespace Google.ProtocolBuffers case FieldType.Enum: if (value is Enum) { - return ComputeEnumSizeNoTag(((IConvertible) value).ToInt32(CultureInfo.InvariantCulture)); + return ComputeEnumSizeNoTag(((IConvertible)value).ToInt32(FrameworkPortability.InvariantCulture)); } else { diff --git a/src/ProtocolBuffers/Delegates.cs b/src/ProtocolBuffers/Delegates.cs index 0a7dec078d..3b62bc0cb2 100644 --- a/src/ProtocolBuffers/Delegates.cs +++ b/src/ProtocolBuffers/Delegates.cs @@ -50,11 +50,5 @@ namespace Google.ProtocolBuffers internal delegate TResult Func(T1 arg1, T2 arg2); - internal delegate TResult Func(T1 arg1, T2 arg2, T3 arg3); - - internal delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4); - - internal delegate void Action(); - internal delegate void Action(T1 arg1, T2 arg2); } \ No newline at end of file diff --git a/src/ProtocolBuffers/GeneratedMessageLite.cs b/src/ProtocolBuffers/GeneratedMessageLite.cs index aecba7d6f3..0dfc976bb9 100644 --- a/src/ProtocolBuffers/GeneratedMessageLite.cs +++ b/src/ProtocolBuffers/GeneratedMessageLite.cs @@ -111,7 +111,7 @@ namespace Google.ProtocolBuffers } else { - writer.WriteLine("{0}: {1}", name, ((IConvertible) value).ToString(CultureInfo.InvariantCulture)); + writer.WriteLine("{0}: {1}", name, ((IConvertible)value).ToString(FrameworkPortability.InvariantCulture)); } } diff --git a/src/ProtocolBuffers/TextFormat.cs b/src/ProtocolBuffers/TextFormat.cs index bbc76186d5..c0f4a5f65e 100644 --- a/src/ProtocolBuffers/TextFormat.cs +++ b/src/ProtocolBuffers/TextFormat.cs @@ -170,10 +170,10 @@ namespace Google.ProtocolBuffers // the double to/from string will trim the precision to 6 places. As with other numeric formats // below, always use the invariant culture so it's predictable. case FieldType.Float: - generator.Print(((float) value).ToString("r", CultureInfo.InvariantCulture)); + generator.Print(((float)value).ToString("r", FrameworkPortability.InvariantCulture)); break; case FieldType.Double: - generator.Print(((double) value).ToString("r", CultureInfo.InvariantCulture)); + generator.Print(((double)value).ToString("r", FrameworkPortability.InvariantCulture)); break; case FieldType.Int32: @@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers case FieldType.Fixed64: // The simple Object.ToString converts using the current culture. // We want to always use the invariant culture so it's predictable. - generator.Print(((IConvertible) value).ToString(CultureInfo.InvariantCulture)); + generator.Print(((IConvertible)value).ToString(FrameworkPortability.InvariantCulture)); break; case FieldType.Bool: // Explicitly use the Java true/false @@ -314,7 +314,7 @@ namespace Google.ProtocolBuffers case "nanf": return float.NaN; default: - return float.Parse(text, CultureInfo.InvariantCulture); + return float.Parse(text, FrameworkPortability.InvariantCulture); } } @@ -331,7 +331,7 @@ namespace Google.ProtocolBuffers case "nan": return double.NaN; default: - return double.Parse(text, CultureInfo.InvariantCulture); + return double.Parse(text, FrameworkPortability.InvariantCulture); } } @@ -708,7 +708,7 @@ namespace Google.ProtocolBuffers { // Explicitly specify the invariant culture so that this code does not break when // executing in Turkey. - String lowerName = name.ToLower(CultureInfo.InvariantCulture); + String lowerName = name.ToLower(FrameworkPortability.InvariantCulture); field = type.FindDescriptor(lowerName); // If the case-insensitive match worked but the field is NOT a group, // TODO(jonskeet): What? Java comment ends here! diff --git a/src/ProtocolBuffers/TextTokenizer.cs b/src/ProtocolBuffers/TextTokenizer.cs index 7fdbd1d6e8..90774bc267 100644 --- a/src/ProtocolBuffers/TextTokenizer.cs +++ b/src/ProtocolBuffers/TextTokenizer.cs @@ -346,7 +346,7 @@ namespace Google.ProtocolBuffers try { - double result = double.Parse(currentToken, CultureInfo.InvariantCulture); + double result = double.Parse(currentToken, FrameworkPortability.InvariantCulture); NextToken(); return result; } @@ -387,7 +387,7 @@ namespace Google.ProtocolBuffers try { - float result = float.Parse(currentToken, CultureInfo.InvariantCulture); + float result = float.Parse(currentToken, FrameworkPortability.InvariantCulture); NextToken(); return result; }