1. Patrick Mézard
  2. libphonenumber-csharp

Commits

Patrick Mézard  committed 62187f1

csharp: fix geocoding data naming scheme

It was previously impossible to instantiate PhoneNumberOfflineGeocoder
with non-test data.

  • Participants
  • Parent commits 00324a5
  • Branches csharp

Comments (0)

Files changed (265)

File csharp/PhoneNumbers.Test/TestPhoneNumberOfflineGeocoder.cs

View file
  • Ignore whitespace
         }
 
         [Test]
+        public void testInstantiationWithRegularData()
+        {
+            PhoneNumberUtil.ResetInstance();
+            geocoder = PhoneNumberOfflineGeocoder.GetInstance();
+        }
+
+        [Test]
         public void testGetDescriptionForNumberWithNoDataFile()
         {
             // No data file containing mappings for US numbers is available in Chinese for the unittests. As

File csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs

View file
  • Ignore whitespace
     public class PhoneNumberOfflineGeocoder
     {
         private static PhoneNumberOfflineGeocoder instance = null;
-        private const String MAPPING_DATA_DIRECTORY = "res.";
+        private const String MAPPING_DATA_DIRECTORY = "res.prod_";
         private static Object thisLock = new Object();
 
         private readonly PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
             {
                 var name = n.Substring(prefix.Length);
                 var pos = name.IndexOf("_");
-                var country = int.Parse(name.Substring(0, pos));
+                int country;
+                try
+                {
+                    country = int.Parse(name.Substring(0, pos));
+                }
+                catch(FormatException e)
+                {
+                    throw new Exception("Failed to parse geocoding file name: " + name);
+                }
                 var language = name.Substring(pos + 1);
                 if (!files.ContainsKey(country))
                     files[country] = new HashSet<String>();

File csharp/PhoneNumbers/PhoneNumbers.csproj

View file
  • Ignore whitespace
     <EmbeddedResource Include="PhoneNumberMetaDataForTesting.xml" />
   </ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="res\1_en" />
-    <EmbeddedResource Include="res\31_nl" />
-    <EmbeddedResource Include="res\34_es" />
-    <EmbeddedResource Include="res\43_de" />
-    <EmbeddedResource Include="res\46_sv" />
-    <EmbeddedResource Include="res\49_de" />
-    <EmbeddedResource Include="res\54_es" />
-    <EmbeddedResource Include="res\55_pt" />
-    <EmbeddedResource Include="res\56_es" />
-    <EmbeddedResource Include="res\82_en" />
-    <EmbeddedResource Include="res\82_ko" />
-    <EmbeddedResource Include="res\82_zh" />
-    <EmbeddedResource Include="res\82_zh_Hant" />
-    <EmbeddedResource Include="res\86_zh" />
     <EmbeddedResource Include="res\test_1_en" />
     <EmbeddedResource Include="res\test_82_en" />
     <EmbeddedResource Include="res\test_82_ko" />
   </ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="res\44_en" />
+    <EmbeddedResource Include="res\test_1_de" />
   </ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="res\33_fr" />
-    <EmbeddedResource Include="res\351_pt" />
-    <EmbeddedResource Include="res\39_en" />
-    <EmbeddedResource Include="res\39_it" />
-    <EmbeddedResource Include="res\41_de" />
-    <EmbeddedResource Include="res\41_en" />
-    <EmbeddedResource Include="res\41_fr" />
-    <EmbeddedResource Include="res\41_it" />
-    <EmbeddedResource Include="res\7_en" />
-    <EmbeddedResource Include="res\81_ja" />
-    <EmbeddedResource Include="res\886_en" />
-    <EmbeddedResource Include="res\886_zh" />
-    <EmbeddedResource Include="res\886_zh_Hant" />
-    <EmbeddedResource Include="res\90_en" />
-    <EmbeddedResource Include="res\90_tr" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\213_en" />
-    <EmbeddedResource Include="res\216_en" />
-    <EmbeddedResource Include="res\221_en" />
-    <EmbeddedResource Include="res\224_en" />
-    <EmbeddedResource Include="res\225_en" />
-    <EmbeddedResource Include="res\226_en" />
-    <EmbeddedResource Include="res\229_en" />
-    <EmbeddedResource Include="res\233_en" />
-    <EmbeddedResource Include="res\261_en" />
-    <EmbeddedResource Include="res\264_en" />
-    <EmbeddedResource Include="res\266_en" />
-    <EmbeddedResource Include="res\267_en" />
-    <EmbeddedResource Include="res\268_en" />
-    <EmbeddedResource Include="res\354_en" />
-    <EmbeddedResource Include="res\355_en" />
-    <EmbeddedResource Include="res\370_en" />
-    <EmbeddedResource Include="res\371_en" />
-    <EmbeddedResource Include="res\372_en" />
-    <EmbeddedResource Include="res\420_en" />
-    <EmbeddedResource Include="res\421_en" />
-    <EmbeddedResource Include="res\48_pl" />
-    <EmbeddedResource Include="res\51_en" />
-    <EmbeddedResource Include="res\84_en" />
-    <EmbeddedResource Include="res\84_vi" />
-    <EmbeddedResource Include="res\94_en" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\220_en" />
-    <EmbeddedResource Include="res\222_fr" />
-    <EmbeddedResource Include="res\232_en" />
-    <EmbeddedResource Include="res\242_fr" />
-    <EmbeddedResource Include="res\243_fr" />
-    <EmbeddedResource Include="res\244_pt" />
-    <EmbeddedResource Include="res\245_pt" />
-    <EmbeddedResource Include="res\249_en" />
-    <EmbeddedResource Include="res\251_en" />
-    <EmbeddedResource Include="res\254_en" />
-    <EmbeddedResource Include="res\263_en" />
-    <EmbeddedResource Include="res\27_en" />
-    <EmbeddedResource Include="res\290_en" />
-    <EmbeddedResource Include="res\290_fr" />
-    <EmbeddedResource Include="res\30_el" />
-    <EmbeddedResource Include="res\352_de" />
-    <EmbeddedResource Include="res\352_en" />
-    <EmbeddedResource Include="res\36_hu" />
-    <EmbeddedResource Include="res\373_en" />
-    <EmbeddedResource Include="res\373_ro" />
-    <EmbeddedResource Include="res\373_ru" />
-    <EmbeddedResource Include="res\374_en" />
-    <EmbeddedResource Include="res\58_en" />
-    <EmbeddedResource Include="res\58_es" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\228_en" />
-    <EmbeddedResource Include="res\228_es" />
-    <EmbeddedResource Include="res\228_fr" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\20_en" />
-    <EmbeddedResource Include="res\230_en" />
-    <EmbeddedResource Include="res\230_es" />
-    <EmbeddedResource Include="res\230_fr" />
-    <EmbeddedResource Include="res\239_pt" />
-    <EmbeddedResource Include="res\256_en" />
-    <EmbeddedResource Include="res\269_fr" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\212_en" />
-    <EmbeddedResource Include="res\212_fr" />
-    <EmbeddedResource Include="res\238_pt" />
-    <EmbeddedResource Include="res\247_en" />
-    <EmbeddedResource Include="res\252_en" />
-    <EmbeddedResource Include="res\258_pt" />
-    <EmbeddedResource Include="res\260_en" />
-    <EmbeddedResource Include="res\299_en" />
-    <EmbeddedResource Include="res\358_en" />
-    <EmbeddedResource Include="res\358_fi" />
-    <EmbeddedResource Include="res\358_se" />
-    <EmbeddedResource Include="res\53_en" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\381_sr" />
-    <EmbeddedResource Include="res\81_en" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\222_en" />
-    <EmbeddedResource Include="res\225_fr" />
-    <EmbeddedResource Include="res\229_fr" />
-    <EmbeddedResource Include="res\238_en" />
-    <EmbeddedResource Include="res\239_en" />
-    <EmbeddedResource Include="res\242_en" />
-    <EmbeddedResource Include="res\243_en" />
-    <EmbeddedResource Include="res\244_en" />
-    <EmbeddedResource Include="res\245_en" />
-    <EmbeddedResource Include="res\258_en" />
-    <EmbeddedResource Include="res\269_en" />
-    <EmbeddedResource Include="res\30_en" />
-    <EmbeddedResource Include="res\31_en" />
-    <EmbeddedResource Include="res\33_en" />
-    <EmbeddedResource Include="res\34_en" />
-    <EmbeddedResource Include="res\351_en" />
-    <EmbeddedResource Include="res\36_en" />
-    <EmbeddedResource Include="res\381_en" />
-    <EmbeddedResource Include="res\43_en" />
-    <EmbeddedResource Include="res\46_en" />
-    <EmbeddedResource Include="res\48_en" />
-    <EmbeddedResource Include="res\49_en" />
-    <EmbeddedResource Include="res\54_en" />
-    <EmbeddedResource Include="res\55_en" />
-    <EmbeddedResource Include="res\56_en" />
-    <EmbeddedResource Include="res\86_en" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="res\test_1_de" />
+    <EmbeddedResource Include="res\prod_1_en" />
+    <EmbeddedResource Include="res\prod_20_en" />
+    <EmbeddedResource Include="res\prod_212_en" />
+    <EmbeddedResource Include="res\prod_212_fr" />
+    <EmbeddedResource Include="res\prod_213_en" />
+    <EmbeddedResource Include="res\prod_216_en" />
+    <EmbeddedResource Include="res\prod_220_en" />
+    <EmbeddedResource Include="res\prod_221_en" />
+    <EmbeddedResource Include="res\prod_222_en" />
+    <EmbeddedResource Include="res\prod_222_fr" />
+    <EmbeddedResource Include="res\prod_224_en" />
+    <EmbeddedResource Include="res\prod_225_en" />
+    <EmbeddedResource Include="res\prod_225_fr" />
+    <EmbeddedResource Include="res\prod_226_en" />
+    <EmbeddedResource Include="res\prod_228_en" />
+    <EmbeddedResource Include="res\prod_228_es" />
+    <EmbeddedResource Include="res\prod_228_fr" />
+    <EmbeddedResource Include="res\prod_229_en" />
+    <EmbeddedResource Include="res\prod_229_fr" />
+    <EmbeddedResource Include="res\prod_230_en" />
+    <EmbeddedResource Include="res\prod_230_es" />
+    <EmbeddedResource Include="res\prod_230_fr" />
+    <EmbeddedResource Include="res\prod_232_en" />
+    <EmbeddedResource Include="res\prod_233_en" />
+    <EmbeddedResource Include="res\prod_238_en" />
+    <EmbeddedResource Include="res\prod_238_pt" />
+    <EmbeddedResource Include="res\prod_239_en" />
+    <EmbeddedResource Include="res\prod_239_pt" />
+    <EmbeddedResource Include="res\prod_242_en" />
+    <EmbeddedResource Include="res\prod_242_fr" />
+    <EmbeddedResource Include="res\prod_243_en" />
+    <EmbeddedResource Include="res\prod_243_fr" />
+    <EmbeddedResource Include="res\prod_244_en" />
+    <EmbeddedResource Include="res\prod_244_pt" />
+    <EmbeddedResource Include="res\prod_245_en" />
+    <EmbeddedResource Include="res\prod_245_pt" />
+    <EmbeddedResource Include="res\prod_247_en" />
+    <EmbeddedResource Include="res\prod_249_en" />
+    <EmbeddedResource Include="res\prod_251_en" />
+    <EmbeddedResource Include="res\prod_252_en" />
+    <EmbeddedResource Include="res\prod_254_en" />
+    <EmbeddedResource Include="res\prod_256_en" />
+    <EmbeddedResource Include="res\prod_258_en" />
+    <EmbeddedResource Include="res\prod_258_pt" />
+    <EmbeddedResource Include="res\prod_260_en" />
+    <EmbeddedResource Include="res\prod_261_en" />
+    <EmbeddedResource Include="res\prod_263_en" />
+    <EmbeddedResource Include="res\prod_264_en" />
+    <EmbeddedResource Include="res\prod_266_en" />
+    <EmbeddedResource Include="res\prod_267_en" />
+    <EmbeddedResource Include="res\prod_268_en" />
+    <EmbeddedResource Include="res\prod_269_en" />
+    <EmbeddedResource Include="res\prod_269_fr" />
+    <EmbeddedResource Include="res\prod_27_en" />
+    <EmbeddedResource Include="res\prod_290_en" />
+    <EmbeddedResource Include="res\prod_290_fr" />
+    <EmbeddedResource Include="res\prod_299_en" />
+    <EmbeddedResource Include="res\prod_30_el" />
+    <EmbeddedResource Include="res\prod_30_en" />
+    <EmbeddedResource Include="res\prod_31_en" />
+    <EmbeddedResource Include="res\prod_31_nl" />
+    <EmbeddedResource Include="res\prod_33_en" />
+    <EmbeddedResource Include="res\prod_33_fr" />
+    <EmbeddedResource Include="res\prod_34_en" />
+    <EmbeddedResource Include="res\prod_34_es" />
+    <EmbeddedResource Include="res\prod_351_en" />
+    <EmbeddedResource Include="res\prod_351_pt" />
+    <EmbeddedResource Include="res\prod_352_de" />
+    <EmbeddedResource Include="res\prod_352_en" />
+    <EmbeddedResource Include="res\prod_352_fr" />
+    <EmbeddedResource Include="res\prod_354_en" />
+    <EmbeddedResource Include="res\prod_355_en" />
+    <EmbeddedResource Include="res\prod_358_en" />
+    <EmbeddedResource Include="res\prod_358_fi" />
+    <EmbeddedResource Include="res\prod_358_se" />
+    <EmbeddedResource Include="res\prod_36_en" />
+    <EmbeddedResource Include="res\prod_36_hu" />
+    <EmbeddedResource Include="res\prod_370_en" />
+    <EmbeddedResource Include="res\prod_371_en" />
+    <EmbeddedResource Include="res\prod_372_en" />
+    <EmbeddedResource Include="res\prod_373_en" />
+    <EmbeddedResource Include="res\prod_373_ro" />
+    <EmbeddedResource Include="res\prod_373_ru" />
+    <EmbeddedResource Include="res\prod_374_en" />
+    <EmbeddedResource Include="res\prod_381_en" />
+    <EmbeddedResource Include="res\prod_381_sr" />
+    <EmbeddedResource Include="res\prod_39_en" />
+    <EmbeddedResource Include="res\prod_39_it" />
+    <EmbeddedResource Include="res\prod_41_de" />
+    <EmbeddedResource Include="res\prod_41_en" />
+    <EmbeddedResource Include="res\prod_41_fr" />
+    <EmbeddedResource Include="res\prod_41_it" />
+    <EmbeddedResource Include="res\prod_420_en" />
+    <EmbeddedResource Include="res\prod_421_en" />
+    <EmbeddedResource Include="res\prod_43_de" />
+    <EmbeddedResource Include="res\prod_43_en" />
+    <EmbeddedResource Include="res\prod_44_en" />
+    <EmbeddedResource Include="res\prod_46_en" />
+    <EmbeddedResource Include="res\prod_46_sv" />
+    <EmbeddedResource Include="res\prod_48_en" />
+    <EmbeddedResource Include="res\prod_48_pl" />
+    <EmbeddedResource Include="res\prod_49_de" />
+    <EmbeddedResource Include="res\prod_49_en" />
+    <EmbeddedResource Include="res\prod_51_en" />
+    <EmbeddedResource Include="res\prod_53_en" />
+    <EmbeddedResource Include="res\prod_54_en" />
+    <EmbeddedResource Include="res\prod_54_es" />
+    <EmbeddedResource Include="res\prod_55_en" />
+    <EmbeddedResource Include="res\prod_55_pt" />
+    <EmbeddedResource Include="res\prod_56_en" />
+    <EmbeddedResource Include="res\prod_56_es" />
+    <EmbeddedResource Include="res\prod_58_en" />
+    <EmbeddedResource Include="res\prod_58_es" />
+    <EmbeddedResource Include="res\prod_7_en" />
+    <EmbeddedResource Include="res\prod_81_en" />
+    <EmbeddedResource Include="res\prod_81_ja" />
+    <EmbeddedResource Include="res\prod_82_en" />
+    <EmbeddedResource Include="res\prod_82_ko" />
+    <EmbeddedResource Include="res\prod_82_zh" />
+    <EmbeddedResource Include="res\prod_82_zh_Hant" />
+    <EmbeddedResource Include="res\prod_84_en" />
+    <EmbeddedResource Include="res\prod_84_vi" />
+    <EmbeddedResource Include="res\prod_86_en" />
+    <EmbeddedResource Include="res\prod_86_zh" />
+    <EmbeddedResource Include="res\prod_886_en" />
+    <EmbeddedResource Include="res\prod_886_zh" />
+    <EmbeddedResource Include="res\prod_886_zh_Hant" />
+    <EmbeddedResource Include="res\prod_90_en" />
+    <EmbeddedResource Include="res\prod_90_tr" />
+    <EmbeddedResource Include="res\prod_94_en" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

File csharp/PhoneNumbers/Properties/AssemblyInfo.cs

View file
  • Ignore whitespace
 //
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("4.9.0.41")]
-[assembly: AssemblyVersion("4.9.0.41")]
-[assembly: AssemblyFileVersion("4.9.0.41")]
+// [assembly: AssemblyVersion("4.9.0.42")]
+[assembly: AssemblyVersion("4.9.0.42")]
+[assembly: AssemblyFileVersion("4.9.0.42")]