Repository: googleapis/api-linter (go)

Issue:
C# namespace capitalization for versions is incorrect
The linter just complained about this option:

```proto
option csharp_namespace = "Google.Cloud.SecurityCenter.V1P1Beta1";
````

it thinks it should be:

```proto
option csharp_namespace = "Google.Cloud.SecurityCenter.V1p1Beta1";
````

... which is actually the bug I was trying to fix. In general, the PascalCasing of C# names considers numbers to be word separators, so we'd have `Http2Request` for example, rather than `Http2request`.

Pull request description:
[AIP-191] Handle point versions correctly in C#.
Fixes #557.

Patch:
diff --git a/rules/aip0191/csharp_namespace.go b/rules/aip0191/csharp_namespace.go
index 1f10b90..436e062 100644
--- a/rules/aip0191/csharp_namespace.go
+++ b/rules/aip0191/csharp_namespace.go
@@ -44,7 +44,11 @@ var csharpNamespace = &lint.FileRule{
 				wantSegment := csharpVersionRegexp.ReplaceAllStringFunc(
 					strcase.UpperCamelCase(segment),
 					func(s string) string {
-						stability := csharpVersionRegexp.FindStringSubmatch(s)[1]
+						point := csharpVersionRegexp.FindStringSubmatch(s)[1]
+						if point != "" {
+							s = strings.ReplaceAll(s, point, strings.ToUpper(point))
+						}
+						stability := csharpVersionRegexp.FindStringSubmatch(s)[2]
 						return strings.ReplaceAll(s, stability, strings.Title(stability))
 					},
 				)
@@ -64,4 +68,4 @@ var csharpNamespace = &lint.FileRule{
 }
 
 var csharpValidChars = regexp.MustCompile("^[A-Za-z0-9.]+$")
-var csharpVersionRegexp = regexp.MustCompile("[0-9]+(alpha|beta)")
+var csharpVersionRegexp = regexp.MustCompile("[0-9]+(p[0-9]+)?(alpha|beta)")


Test patch:
diff --git a/rules/aip0191/csharp_namespace_test.go b/rules/aip0191/csharp_namespace_test.go
index a24ee3c..016b0b4 100644
--- a/rules/aip0191/csharp_namespace_test.go
+++ b/rules/aip0191/csharp_namespace_test.go
@@ -27,8 +27,9 @@ func TestCsharpNamespace(t *testing.T) {
 		CsharpNamespace string
 		problems        testutils.Problems
 	}{
-		{"Valid", "Google.Example.V1", testutils.Problems{}},
-		{"ValidBeta", "Google.Example.V1Beta1", testutils.Problems{}},
+		{"Valid", "Google.Example.V1", nil},
+		{"ValidBeta", "Google.Example.V1Beta1", nil},
+		{"ValidPointBeta", "Google.Example.V1P1Beta1", nil},
 		{"InvalidBadChars", "Google:Example:V1", testutils.Problems{{Message: "Invalid characters"}}},
 		{"Invalid", "google.example.v1", testutils.Problems{{
 			Suggestion: fmt.Sprintf("option csharp_namespace = %q;", "Google.Example.V1"),
@@ -39,6 +40,9 @@ func TestCsharpNamespace(t *testing.T) {
 		{"InvalidBeta", "Google.Example.V1beta1", testutils.Problems{{
 			Suggestion: fmt.Sprintf("option csharp_namespace = %q;", "Google.Example.V1Beta1"),
 		}}},
+		{"InvalidPointBeta", "Google.Example.V1p1beta1", testutils.Problems{{
+			Suggestion: fmt.Sprintf("option csharp_namespace = %q;", "Google.Example.V1P1Beta1"),
+		}}},
 	} {
 		t.Run(test.name, func(t *testing.T) {
 			f := testutils.ParseProto3Tmpl(t, `