Commit 50a89c1c authored by csharptest's avatar csharptest Committed by rogerk

Fixed removal of all '_' from names, Added unit test.

parent c7b23c17
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<WorkingDirectories Include="$(BuildTempDirectory)" /> <WorkingDirectories Include="$(BuildTempDirectory)" />
<WorkingDirectories Include="$(BuildOutputDirectory)" /> <WorkingDirectories Include="$(BuildOutputDirectory)" />
<Protos Include="$(ProtosDirectory)\extest\unittest_issues.proto" />
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_full.proto" /> <Protos Include="$(ProtosDirectory)\extest\unittest_extras_full.proto" />
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_lite.proto" /> <Protos Include="$(ProtosDirectory)\extest\unittest_extras_lite.proto" />
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_xmltest.proto" /> <Protos Include="$(ProtosDirectory)\extest\unittest_extras_xmltest.proto" />
...@@ -71,6 +72,9 @@ ...@@ -71,6 +72,9 @@
<TargetDirectory>$(SourceDirectory)\AddressBook</TargetDirectory> <TargetDirectory>$(SourceDirectory)\AddressBook</TargetDirectory>
</GeneratedSource> </GeneratedSource>
<!-- Unit test --> <!-- Unit test -->
<GeneratedSource Include="$(BuildTempDirectory)\UnitTestExtrasIssuesProtoFile.cs">
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
</GeneratedSource>
<GeneratedSource Include="$(BuildTempDirectory)\UnitTestXmlSerializerTestProtoFile.cs"> <GeneratedSource Include="$(BuildTempDirectory)\UnitTestXmlSerializerTestProtoFile.cs">
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> <TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
</GeneratedSource> </GeneratedSource>
......
// These proto descriptors have at one time been reported as an issue or defect.
// They are kept here to replicate the issue, and continue to verify the fix.
import "google/protobuf/csharp_options.proto";
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
option (google.protobuf.csharp_file_options).namespace = "UnitTest.Issues.TestProtos";
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasIssuesProtoFile";
package unittest_issues;
option optimize_for = SPEED;
// The following is a representative set of features
/*
enum EnumOptions {
ONE = 0;
TWO = 1;
THREE = 2;
}
message TestBasicChild
{
repeated EnumOptions options = 3;
optional bytes binary = 4;
}
message TestBasicNoFields {
}
message TestBasicRescursive {
optional TestBasicRescursive child = 1;
}
message TestBasicMessage {
optional int64 number = 6;
repeated int32 numbers = 2;
optional string text = 3;
repeated string textlines = 700;
optional bool valid = 5;
optional TestBasicChild child = 1;
repeated group Children = 401
{
repeated EnumOptions options = 3;
optional bytes binary = 4;
}
extensions 100 to 199;
}
message TestBasicExtension {
required int32 number = 1;
}
extend TestBasicMessage {
optional EnumOptions extension_enum = 101;
optional string extension_text = 102;
repeated int32 extension_number = 103 [packed = true];
optional TestBasicExtension extension_message = 199;
}
// Issue for non-qualified type reference in new services generation
option (google.protobuf.csharp_file_options).service_generator_type = IRPCDISPATCH;
service TestGenericService {
rpc Foo(TestBasicNoFields) returns (TestBasicMessage);
rpc Bar(TestBasicNoFields) returns (TestBasicMessage);
}
*/
// Issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
message A {
optional int32 _A = 1;
}
message B {
optional int32 B_ = 1;
}
message AB {
optional int32 a_b = 1;
}
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<Compile Include="TestProtos\UnitTestCustomOptionsProtoFile.cs" /> <Compile Include="TestProtos\UnitTestCustomOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestEmbedOptimizeForProtoFile.cs" /> <Compile Include="TestProtos\UnitTestEmbedOptimizeForProtoFile.cs" />
<Compile Include="TestProtos\UnitTestEmptyProtoFile.cs" /> <Compile Include="TestProtos\UnitTestEmptyProtoFile.cs" />
<Compile Include="TestProtos\UnitTestExtrasIssuesProtoFile.cs" />
<Compile Include="TestProtos\UnitTestGenericServices.cs" /> <Compile Include="TestProtos\UnitTestGenericServices.cs" />
<Compile Include="TestProtos\UnitTestGoogleSizeProtoFile.cs" /> <Compile Include="TestProtos\UnitTestGoogleSizeProtoFile.cs" />
<Compile Include="TestProtos\UnitTestGoogleSpeedProtoFile.cs" /> <Compile Include="TestProtos\UnitTestGoogleSpeedProtoFile.cs" />
......
...@@ -102,12 +102,12 @@ namespace Google.ProtocolBuffers ...@@ -102,12 +102,12 @@ namespace Google.ProtocolBuffers
/// <summary> /// <summary>
/// Similar to UnderlineToCamel, but also matches the first character if it is lower-case /// Similar to UnderlineToCamel, but also matches the first character if it is lower-case
/// </summary> /// </summary>
private static Regex UnderlineToPascal = new Regex(@"(?:^|[0-9_])[a-z]"); private static Regex UnderlineToPascal = new Regex(@"(?:(?:^|[0-9_])[a-z])|_");
/// <summary> /// <summary>
/// Matches lower-case character that follow either an underscore, or a number /// Matches lower-case character that follow either an underscore, or a number
/// </summary> /// </summary>
private static Regex UnderlineToCamel = new Regex(@"[0-9_][a-z]"); private static Regex UnderlineToCamel = new Regex(@"(?:[0-9_][a-z])|_");
/// <summary> /// <summary>
/// Used for text-template transformation where a regex match is replaced in the input string. /// Used for text-template transformation where a regex match is replaced in the input string.
......
...@@ -23,6 +23,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unittest", "unittest", "{C8 ...@@ -23,6 +23,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unittest", "unittest", "{C8
..\protos\extest\unittest_generic_services.proto = ..\protos\extest\unittest_generic_services.proto ..\protos\extest\unittest_generic_services.proto = ..\protos\extest\unittest_generic_services.proto
..\protos\google\protobuf\unittest_import.proto = ..\protos\google\protobuf\unittest_import.proto ..\protos\google\protobuf\unittest_import.proto = ..\protos\google\protobuf\unittest_import.proto
..\protos\google\protobuf\unittest_import_lite.proto = ..\protos\google\protobuf\unittest_import_lite.proto ..\protos\google\protobuf\unittest_import_lite.proto = ..\protos\google\protobuf\unittest_import_lite.proto
..\protos\extest\unittest_issues.proto = ..\protos\extest\unittest_issues.proto
..\protos\google\protobuf\unittest_lite.proto = ..\protos\google\protobuf\unittest_lite.proto ..\protos\google\protobuf\unittest_lite.proto = ..\protos\google\protobuf\unittest_lite.proto
..\protos\google\protobuf\unittest_lite_imports_nonlite.proto = ..\protos\google\protobuf\unittest_lite_imports_nonlite.proto ..\protos\google\protobuf\unittest_lite_imports_nonlite.proto = ..\protos\google\protobuf\unittest_lite_imports_nonlite.proto
..\protos\google\protobuf\unittest_mset.proto = ..\protos\google\protobuf\unittest_mset.proto ..\protos\google\protobuf\unittest_mset.proto = ..\protos\google\protobuf\unittest_mset.proto
...@@ -67,7 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{66ED1950 ...@@ -67,7 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{66ED1950
..\build\RunBenchmarks.bat = ..\build\RunBenchmarks.bat ..\build\RunBenchmarks.bat = ..\build\RunBenchmarks.bat
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Serialization", "ProtocolBuffers.Serialization\ProtocolBuffers.Serialization.csproj", "{231391AF-449C-4a39-986C-AD7F270F4750}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Serialization", "ProtocolBuffers.Serialization\ProtocolBuffers.Serialization.csproj", "{231391AF-449C-4A39-986C-AD7F270F4750}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -147,14 +148,10 @@ Global ...@@ -147,14 +148,10 @@ Global
{EEFFED24-3750-4567-9A23-1DB676A15610}.Release_Silverlight2|Any CPU.ActiveCfg = Release|Any CPU {EEFFED24-3750-4567-9A23-1DB676A15610}.Release_Silverlight2|Any CPU.ActiveCfg = Release|Any CPU
{EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU {EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU {EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Debug_Silverlight2|Any CPU.ActiveCfg = Debug_Silverlight2|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Debug_Silverlight2|Any CPU.ActiveCfg = Debug_Silverlight2|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Debug_Silverlight2|Any CPU.Build.0 = Debug_Silverlight2|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Release_Silverlight2|Any CPU.ActiveCfg = Release_Silverlight2|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Debug|Any CPU.Build.0 = Debug|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Release|Any CPU.ActiveCfg = Release|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Release_Silverlight2|Any CPU.ActiveCfg = Release_Silverlight2|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Release_Silverlight2|Any CPU.Build.0 = Release_Silverlight2|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Release|Any CPU.ActiveCfg = Release|Any CPU
{231391AF-449C-4a39-986C-AD7F270F4750}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment