diff --git a/README.md b/README.md index 0a214ba7e..80f35affc 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,6 @@ C# port of Google's [libphonenumber library](https://github.com/googlei18n/libph * port read/write source xml data to binary for better performance and smaller .nupkg size (WIP) * update / add / port new unit tests and logging from java source -## Building - * This library targets several frameworks. As such to build the solution as is `.NET Portable Library targeting pack` and `.NET Framework 3.5 development tools` must be installed and finally copy the portable files to the dotnet sdk: `xcopy "C:\Program Files (x86)\MSBuild\Microsoft\Portable" "C:\Program Files\dotnet\sdk\$(dotnet --version)\Microsoft\Portable\" /S /E` - * Alternately to avoid these dependencies the PhoneNumbers.csproj can be edited to exclude unneeded frameworks. - ## How to unfold automatic generated files * Install Jetbrains - Resharper for Visual Studio * File by file, right click and "Cleanup code" diff --git a/csharp/README.txt b/csharp/README.txt index 2ef1d5b22..7d619cc94 100644 --- a/csharp/README.txt +++ b/csharp/README.txt @@ -4,11 +4,10 @@ PhoneNumbers C# Library This is a C# port of libphonenumber, originally from: http://code.google.com/p/libphonenumber/. -Original Java code is Copyright (C) 2009-2020 Google Inc. +Original Java code is Copyright (C) 2009-2022 Google Inc. lib/ - NUnit, Google.ProtoBuffersLite binaries and various conversion - scripts. + update script PhoneNumbers/ Port of libphonenumber Java library @@ -17,12 +16,6 @@ PhoneNumbers.Test/ Port of libphonenumber Java tests in xunit format. -Building --------- - -Open csharp/PhoneNumbers.sln VS2019 solution file to get an overview -of the code. "Build All" should put the libraries at the usual places. - Known Issues ------------ diff --git a/csharp/lib/cleanprotobuf.py b/csharp/lib/cleanprotobuf.py deleted file mode 100644 index a5dd4ebd9..000000000 --- a/csharp/lib/cleanprotobuf.py +++ /dev/null @@ -1,56 +0,0 @@ -"""\ -cleanprotobuf reads a C# file generated by ProtoGen.exe and fixes/removes -all references to protobuf-csharp assemblies to avoid unnecessary dependencies. -As of now, phone metadata is read from the source XML file and not from -the protocol buffers files. -""" -import sys, os, re - -replacements = [ - # Remove using directives - (r'\nusing .*?Google.ProtocolBuffers.*?;', '', re.S), - # Remove RegisterAllExtensions - (r'#region Extension registration.*?#endregion', '', re.S), - # Remove GeneratedMessageLite inheritance - (r'\s*:\s*pb::[a-zA-Z0-9]+<[^>]+>', '', re.S), - # Remove WriteTo() - (r'\n public override void WriteTo.*?\n }', '', re.S), - # Remove SerializedSize - (r'\n public override int SerializedSize.*?\n }', '', re.S), - # Remove ParseFrom - (r'\n public static \w+ ParseFrom.*?\n }', '', re.S), - # Remove ParseFrom - (r'\n public static \w+ ParseDelimitedFrom.*?\n }', '', re.S), - (r'\n public override Builder MergeFrom\(pb\:\:.*?\n }', '', re.S), - (r'\n public override void PrintTo.*?\n }', '', re.S), - (r'pbc::PopsicleList<([^>]+)>', r'scg::List<\1>', None), - (r'pbc::IPopsicleList<([^>]+)>', r'scg::IList<\1>', None), - (r'pb::ThrowHelper.ThrowIfNull\(([^,]+), ([^\)]+)\);', - r'if(\1 == null) throw new global::System.ArgumentNullException(\2);', - None), - - (r'(public|protected|private)\s+override\s+(?!.*(?:GetHashCode|Equals))', r'\1 ', None), - (r'public sealed partial class', 'public partial class', None), - (r'\n(\s+)public\s+(\S+)\s+BuildPartial\(\)', - r'\n\1public \2 Build() { return BuildPartial(); }\n\1public \2 BuildPartial()', - re.S), - - (r'pbc::Lists.AsReadOnly\(([^\)]+)\)', r'\1', None), - - (r'\n\s*result[^\n]+MakeReadOnly\(\);', '\n', re.S), - (r'base\.AddRange\(([^,]+),([^\)]+)\);', r'\2.AddRange(\1);', None), - (r'private int memoizedSerializedSize = -1;', '', None), -] - - -def cleanlines(data): - for pattern, repl, reopts in replacements: - r = re.compile(pattern, reopts or 0) - data = r.sub(repl, data) - return data - -if __name__ == '__main__': - input, output = sys.argv[1:3] - data = file(input, 'r').read() - data = cleanlines(data) - file(output, 'w').write(data) diff --git a/csharp/lib/fixcs.py b/csharp/lib/fixcs.py deleted file mode 100644 index 64b27cb80..000000000 --- a/csharp/lib/fixcs.py +++ /dev/null @@ -1,38 +0,0 @@ -import re, sys - -replacements = [ - ('.length()', '.Length'), - ('.containsKey(', '.ContainsKey('), - ('.substring(', '.Substring('), - ('.setCountryCode(', '.SetCountryCode('), - ('.setNationalNumber(', '.SetNationalNumber('), - ('assertEquals(', 'Assert.AreEqual('), - ('assertFalse(', 'Assert.False('), - ('assertTrue(', 'Assert.True('), - ('.getDescriptionForNumber(', '.GetDescriptionForNumber('), - ('.hasAttribute(', '.HasAttribute('), - ('.getAttribute(', '.GetAttribute('), - ('.equals(', '.Equals('), - ('.getNationalPrefixForParsing()', '.NationalPrefixForParsing'), - ('.getFormat()', '.Format'), -] - -regexps = [ - (r'public\s+void\s+test(\S+)\(\)(?:\s+throws\s+\S+)?\s*{', - r'[Test]\npublic void Test\1()\n{', - re.S), -] - -def fixcsharp(path): - data = file(path, 'rb').read() - for match, sub in replacements: - data = data.replace(match, sub) - for match, sub, opts in regexps: - regex = re.compile(match, opts) - data = regex.sub(sub, data) - data = data.replace('\r\n', '\n') - file(path, 'wb').write(data) - -if __name__ == '__main__': - for path in sys.argv[1:]: - fixcsharp(path) diff --git a/csharp/lib/makeprotobuf.bat b/csharp/lib/makeprotobuf.bat deleted file mode 100644 index c28214ff8..000000000 --- a/csharp/lib/makeprotobuf.bat +++ /dev/null @@ -1,9 +0,0 @@ -REM This script is used to generate Phonemetadata.cs and Phonenumber.cs -REM from their protocol buffers definitions. -REM Pythonscript depends on Python v2.7 - -protogen -namespace=PhoneNumbers -cls_compliance=false --proto_path=..\..\resources ..\..\resources\phonemetadata.proto ..\..\resources\phonenumber.proto -python cleanprotobuf.py PhoneMetadata.cs ..\PhoneNumbers\PhoneMetadata.cs -python cleanprotobuf.py PhoneNumber.cs ..\PhoneNumbers\PhoneNumber.cs -del PhoneMetadata.cs -del PhoneNumber.cs \ No newline at end of file diff --git a/csharp/lib/protobuf-license.txt b/csharp/lib/protobuf-license.txt deleted file mode 100644 index 2715f7b89..000000000 --- a/csharp/lib/protobuf-license.txt +++ /dev/null @@ -1,31 +0,0 @@ -Protocol Buffers - Google's data interchange format -Copyright 2008-2010 Google Inc. All rights reserved. -http://github.com/jskeet/dotnet-protobufs/ -Original C++/Java/Python code: -http://code.google.com/p/protobuf/ - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.