This is an automated email from the ASF dual-hosted git repository. blachniet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/avro.git
commit 539d746274a01011cffe6a863d7373d3a38d4c78 Author: Brian Lachniet <[email protected]> AuthorDate: Sun Aug 18 11:47:10 2019 -0400 AVRO-2454: Fix CA1305 - Specify IFormatProvider --- lang/csharp/Avro.ruleset | 1 - lang/csharp/src/apache/main/CodeGen/CodeGen.cs | 11 ++++++----- lang/csharp/src/apache/main/File/DataFileReader.cs | 17 +++++++++++------ lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs | 8 +++++--- .../src/apache/main/Reflect/ReflectDefaultReader.cs | 7 +++++-- .../src/apache/main/Schema/SchemaNormalization.cs | 9 ++++++--- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset index e3a8405..79f3a94 100644 --- a/lang/csharp/Avro.ruleset +++ b/lang/csharp/Avro.ruleset @@ -25,7 +25,6 @@ We disabled these rules initially to get the code analyzers installed in the project. --> <Rule Id="CA1062" Action="Info" /> - <Rule Id="CA1305" Action="Info" /> <Rule Id="CA1307" Action="Info" /> <Rule Id="CA1507" Action="Info" /> <Rule Id="CA1707" Action="Info" /> diff --git a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs index c3d1ef3..be33321 100644 --- a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs +++ b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs @@ -16,14 +16,14 @@ * limitations under the License. */ using System; +using System.CodeDom; +using System.CodeDom.Compiler; using System.Collections.Generic; -using System.Linq; +using System.Globalization; +using System.IO; using System.Reflection; using System.Text; -using System.CodeDom; -using System.CodeDom.Compiler; using Microsoft.CSharp; -using System.IO; namespace Avro { @@ -836,7 +836,8 @@ namespace Avro /// <returns>CodeCommentStatement object</returns> protected virtual CodeCommentStatement createDocComment(string comment) { - string text = string.Format("<summary>\r\n {0}\r\n </summary>", comment); + string text = string.Format(CultureInfo.InvariantCulture, + "<summary>\r\n {0}\r\n </summary>", comment); return new CodeCommentStatement(text, true); } diff --git a/lang/csharp/src/apache/main/File/DataFileReader.cs b/lang/csharp/src/apache/main/File/DataFileReader.cs index e93d8b1..784bf10 100644 --- a/lang/csharp/src/apache/main/File/DataFileReader.cs +++ b/lang/csharp/src/apache/main/File/DataFileReader.cs @@ -17,8 +17,9 @@ */ using System; using System.Collections.Generic; -using System.Linq; +using System.Globalization; using System.IO; +using System.Linq; using Avro.Generic; using Avro.IO; using Avro.Specific; @@ -165,7 +166,7 @@ namespace Avro.File /// <inheritdoc/> public long GetMetaLong(string key) { - return long.Parse(GetMetaString(key)); + return long.Parse(GetMetaString(key), CultureInfo.InvariantCulture); } /// <inheritdoc/> @@ -182,7 +183,8 @@ namespace Avro.File } catch (Exception e) { - throw new AvroRuntimeException(string.Format("Error fetching meta data for key: {0}", key), e); + throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture, + "Error fetching meta data for key: {0}", key), e); } } @@ -285,7 +287,8 @@ namespace Avro.File } catch (Exception e) { - throw new AvroRuntimeException(string.Format("Error fetching next object from block: {0}", e)); + throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture, + "Error fetching next object from block: {0}", e)); } } @@ -402,7 +405,8 @@ namespace Avro.File } catch (Exception e) { - throw new AvroRuntimeException(string.Format("Error fetching next object from block: {0}", e)); + throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture, + "Error fetching next object from block: {0}", e)); } } @@ -471,7 +475,8 @@ namespace Avro.File } catch (Exception e) { - throw new AvroRuntimeException(string.Format("Error ascertaining if data has next block: {0}", e), e); + throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture, + "Error ascertaining if data has next block: {0}", e), e); } } diff --git a/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs b/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs index 6725cf7..b077bfd 100644 --- a/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs +++ b/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs @@ -17,6 +17,7 @@ */ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; namespace Avro.IO @@ -50,7 +51,8 @@ namespace Avro.IO int remainingCheck = buffer.Read(b, off, (int) remaining); if(remainingCheck != remaining) - throw new InvalidDataException(string.Format("remainingCheck [{0}] and remaining[{1}] are different.", + throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture, + "remainingCheck [{0}] and remaining[{1}] are different.", remainingCheck, remaining)); return (int)remaining; } @@ -58,8 +60,8 @@ namespace Avro.IO int lenCheck = buffer.Read(b, off, len); if (lenCheck != len) - throw new InvalidDataException(string.Format("lenCheck [{0}] and len[{1}] are different.", - lenCheck, len)); + throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture, + "lenCheck [{0}] and len[{1}] are different.", lenCheck, len)); return len; } diff --git a/lang/csharp/src/apache/main/Reflect/ReflectDefaultReader.cs b/lang/csharp/src/apache/main/Reflect/ReflectDefaultReader.cs index 9e6e09c..32a626b 100644 --- a/lang/csharp/src/apache/main/Reflect/ReflectDefaultReader.cs +++ b/lang/csharp/src/apache/main/Reflect/ReflectDefaultReader.cs @@ -19,6 +19,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using Avro.IO; using Avro.Specific; using Newtonsoft.Json.Linq; @@ -120,7 +121,8 @@ namespace Avro.Reflect enumType = EnumCache.GetEnumeration(namedSchema); if (enumType == null) { - throw new Exception(string.Format("Couldn't find type matching enum name {0}", namedSchema.Fullname)); + throw new Exception(string.Format(CultureInfo.InvariantCulture, + "Couldn't find type matching enum name {0}", namedSchema.Fullname)); } if (nullable) @@ -144,7 +146,8 @@ namespace Avro.Reflect recordtype = _classCache.GetClass(recordSchema).GetClassType(); if (recordtype == null) { - throw new Exception(string.Format("Couldn't find type matching schema name {0}", recordSchema.Fullname)); + throw new Exception(string.Format(CultureInfo.InvariantCulture, + "Couldn't find type matching schema name {0}", recordSchema.Fullname)); } return recordtype; diff --git a/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs b/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs index c7ea9d6..eb7a4b4 100644 --- a/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs +++ b/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs @@ -16,9 +16,10 @@ * limitations under the License. */ +using System; using System.Collections.Generic; +using System.Globalization; using System.Text; -using System; namespace Avro { @@ -99,7 +100,8 @@ namespace Avro var sha256 = System.Security.Cryptography.SHA256.Create(); return sha256.ComputeHash(data); default: - throw new ArgumentException(string.Format("Unsupported fingerprint computation algorithm ({0})", fpName)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, + "Unsupported fingerprint computation algorithm ({0})", fpName)); } } @@ -214,7 +216,8 @@ namespace Avro else if (st == Schema.Type.Fixed) { FixedSchema fixedSchema = s as FixedSchema; - o.Append(",\"size\":").Append(fixedSchema.Size.ToString()); + o.Append(",\"size\":") + .Append(fixedSchema.Size.ToString(CultureInfo.InvariantCulture)); } else // st == Schema.Type.Record {
