Skip to content

Commit

Permalink
Merge pull request #18471 from kkm000/kkm/17884-protobuf-list-casing
Browse files Browse the repository at this point in the history
C# Tooling: change the case to 'Protobuf' consistently
  • Loading branch information
jtattermusch committed Mar 22, 2019
2 parents b250241 + c07a74d commit cfa0d22
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/csharp/Grpc.Tools.Tests/ProtoCompileBasicTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void SetUp()
};
}

[TestCase("ProtoBuf")]
[TestCase("Protobuf")]
[TestCase("Generator")]
[TestCase("OutputDir")]
[Description("We trust MSBuild to initialize these properties.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public new void SetUp()
{
_task.Generator = "csharp";
_task.OutputDir = "outdir";
_task.ProtoBuf = Utils.MakeSimpleItems("a.proto");
_task.Protobuf = Utils.MakeSimpleItems("a.proto");
}

void ExecuteExpectSuccess()
Expand All @@ -55,7 +55,7 @@ public void MinimalCompile()
[Test]
public void CompileTwoFiles()
{
_task.ProtoBuf = Utils.MakeSimpleItems("a.proto", "foo/b.proto");
_task.Protobuf = Utils.MakeSimpleItems("a.proto", "foo/b.proto");
ExecuteExpectSuccess();
Assert.That(_task.LastResponseFile, Is.EqualTo(new[] {
"--csharp_out=outdir", "--error_format=msvs", "a.proto", "foo/b.proto" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public new void SetUp()
{
_task.Generator = "csharp";
_task.OutputDir = "outdir";
_task.ProtoBuf = Utils.MakeSimpleItems("a.proto");
_task.Protobuf = Utils.MakeSimpleItems("a.proto");

_mockEngine
.Setup(me => me.LogMessageEvent(It.IsAny<BuildMessageEventArgs>()))
Expand Down
2 changes: 1 addition & 1 deletion src/csharp/Grpc.Tools/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static class Metadata
{
// On output dependency lists.
public static string Source = "Source";
// On ProtoBuf items.
// On Protobuf items.
public static string ProtoRoot = "ProtoRoot";
public static string OutputDir = "OutputDir";
public static string GrpcServices = "GrpcServices";
Expand Down
2 changes: 1 addition & 1 deletion src/csharp/Grpc.Tools/GeneratorServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ string GetRelativeDir(string root, string proto)
protoDir = EndWithSlash(protoDir);
if (!protoDir.StartsWith(rootDir))
{
Log.LogWarning("ProtoBuf item '{0}' has the ProtoRoot metadata '{1}' " +
Log.LogWarning("Protobuf item '{0}' has the ProtoRoot metadata '{1}' " +
"which is not prefix to its path. Cannot compute relative path.",
proto, root);
return "";
Expand Down
8 changes: 4 additions & 4 deletions src/csharp/Grpc.Tools/ProtoCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class ProtoCompile : ToolTask
/// Protobuf files to compile.
/// </summary>
[Required]
public ITaskItem[] ProtoBuf { get; set; }
public ITaskItem[] Protobuf { get; set; }

/// <summary>
/// Directory where protoc dependency files are cached. If provided, dependency
Expand Down Expand Up @@ -237,7 +237,7 @@ protected override bool ValidateParameters()
Log.LogError("Properties ProtoDepDir and DependencyOut may not be both specified");
}

if (ProtoBuf.Length > 1 && (ProtoDepDir != null || DependencyOut != null))
if (Protobuf.Length > 1 && (ProtoDepDir != null || DependencyOut != null))
{
Log.LogError("Proto compiler currently allows only one input when " +
"--dependency_out is specified (via ProtoDepDir or DependencyOut). " +
Expand All @@ -247,7 +247,7 @@ protected override bool ValidateParameters()
// Use ProtoDepDir to autogenerate DependencyOut
if (ProtoDepDir != null)
{
DependencyOut = DepFileUtil.GetDepFilenameForProto(ProtoDepDir, ProtoBuf[0].ItemSpec);
DependencyOut = DepFileUtil.GetDepFilenameForProto(ProtoDepDir, Protobuf[0].ItemSpec);
}

if (GrpcPluginExe == null)
Expand Down Expand Up @@ -319,7 +319,7 @@ protected override string GenerateResponseFileCommands()
}
cmd.AddSwitchMaybe("dependency_out", DependencyOut);
cmd.AddSwitchMaybe("error_format", "msvs");
foreach (var proto in ProtoBuf)
foreach (var proto in Protobuf)
{
cmd.AddArg(proto.ItemSpec);
}
Expand Down
4 changes: 2 additions & 2 deletions src/csharp/Grpc.Tools/ProtoCompilerOutputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ProtoCompilerOutputs : Task
/// files actually produced by the compiler.
/// </summary>
[Required]
public ITaskItem[] ProtoBuf { get; set; }
public ITaskItem[] Protobuf { get; set; }

/// <summary>
/// Output items per each potential output. We do not look at existing
Expand Down Expand Up @@ -68,7 +68,7 @@ public override bool Execute()
// Get language-specific possible output. The generator expects certain
// metadata be set on the proto item.
var possible = new List<ITaskItem>();
foreach (var proto in ProtoBuf)
foreach (var proto in Protobuf)
{
var outputs = generator.GetPossibleOutputs(proto);
foreach (string output in outputs)
Expand Down
4 changes: 2 additions & 2 deletions src/csharp/Grpc.Tools/ProtoReadDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ProtoReadDependencies : Task
/// of proto files cached under ProtoDepDir.
/// </summary>
[Required]
public ITaskItem[] ProtoBuf { get; set; }
public ITaskItem[] Protobuf { get; set; }

/// <summary>
/// Directory where protoc dependency files are cached.
Expand All @@ -55,7 +55,7 @@ public override bool Execute()
if (ProtoDepDir != null)
{
var dependencies = new List<ITaskItem>();
foreach (var proto in ProtoBuf)
foreach (var proto in Protobuf)
{
string[] deps = DepFileUtil.ReadDependencyInputs(ProtoDepDir, proto.ItemSpec, Log);
foreach (string dep in deps)
Expand Down
6 changes: 3 additions & 3 deletions src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties">
<Rule Name="ProtoBuf"
<Rule Name="Protobuf"
DisplayName="File Properties"
PageTemplate="generic"
Description="File Properties"
OverrideMode="Extend">
<Rule.DataSource>
<DataSource Persistence="ProjectFile" Label="Configuration" ItemType="ProtoBuf"
<DataSource Persistence="ProjectFile" Label="Configuration" ItemType="Protobuf"
HasConfigurationCondition="false" SourceOfDefaultValue="AfterContext" />
</Rule.DataSource>

Expand All @@ -21,7 +21,7 @@
<EnumValue Name="Server" DisplayName="Server only" />
<EnumValue Name="None" DisplayName="Do not generate" />
<EnumProperty.DataSource>
<DataSource ItemType="ProtoBuf" SourceOfDefaultValue="AfterContext"
<DataSource ItemType="Protobuf" SourceOfDefaultValue="AfterContext"
PersistenceStyle="Attribute" />
</EnumProperty.DataSource>
</EnumProperty>
Expand Down
6 changes: 3 additions & 3 deletions src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</ItemGroup>

<ItemDefinitionGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' ">
<ProtoBuf>
<GrpcServices Condition=" '%(ProtoBuf.GrpcServices)' == '' ">Both</GrpcServices>
</ProtoBuf>
<Protobuf>
<GrpcServices Condition=" '%(Protobuf.GrpcServices)' == '' ">Both</GrpcServices>
</Protobuf>
</ItemDefinitionGroup>

<!-- This target is invoked in a C# project, or can be called in a customized project. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<!-- NET SDK projects only: include proto files by default. Other project
types are not setting or using $(EnableDefaultItems).
Note that MSBuild evaluates all ItemGroups and their conditions in the
final pass over the build script, so properties like EnableDefaultProtoBufItems
final pass over the build script, so properties like EnableDefaultProtobufItems
here can be changed later in the project. -->
<ItemGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' ">
<ProtoBuf Include="**/*.proto"
Condition=" '$(EnableDefaultItems)' == 'true' and '$(EnableDefaultProtoBufItems)' == 'true' " />
<Protobuf Include="**/*.proto"
Condition=" '$(EnableDefaultItems)' == 'true' and '$(EnableDefaultProtobufItems)' == 'true' " />
</ItemGroup>
</Project>
38 changes: 19 additions & 19 deletions src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
</PropertyGroup>

<ItemDefinitionGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' ">
<ProtoBuf>
<Access Condition="'%(ProtoBuf.Access)' == '' ">Public</Access>
<ProtoCompile Condition="'%(ProtoBuf.ProtoCompile)' == '' ">True</ProtoCompile>
<ProtoRoot Condition="'%(ProtoBuf.ProtoRoot)' == '' " />
<CompileOutputs Condition="'%(ProtoBuf.CompileOutputs)' == ''">True</CompileOutputs>
<OutputDir Condition="'%(ProtoBuf.OutputDir)' == '' ">$(Protobuf_OutputPath)</OutputDir>
</ProtoBuf>
<Protobuf>
<Access Condition="'%(Protobuf.Access)' == '' ">Public</Access>
<ProtoCompile Condition="'%(Protobuf.ProtoCompile)' == '' ">True</ProtoCompile>
<ProtoRoot Condition="'%(Protobuf.ProtoRoot)' == '' " />
<CompileOutputs Condition="'%(Protobuf.CompileOutputs)' == ''">True</CompileOutputs>
<OutputDir Condition="'%(Protobuf.OutputDir)' == '' ">$(Protobuf_OutputPath)</OutputDir>
</Protobuf>
</ItemDefinitionGroup>

<ItemGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' ">
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Protobuf.CSharp.xml">
<Context>File;BrowseObject</Context>
</PropertyPageSchema>
<AvailableItemName Include="ProtoBuf" />
<AvailableItemName Include="Protobuf" />
</ItemGroup>

<PropertyGroup>
<!-- NET SDK: by default, do not include proto files in the directory.
Current Microsoft's recommendation is against globbing:
https://docs.microsoft.com/en-us/dotnet/core/tools/csproj#recommendation -->
<EnableDefaultProtoBufItems Condition=" '$(EnableDefaultProtoBufItems)' == '' ">false</EnableDefaultProtoBufItems>
<EnableDefaultProtobufItems Condition=" '$(EnableDefaultProtobufItems)' == '' ">false</EnableDefaultProtobufItems>
</PropertyGroup>

<!-- Check configuration sanity before build. -->
Expand Down Expand Up @@ -96,7 +96,7 @@
<!-- Main compile sequence. Certain steps are gated by the value $(DisableProtobufDesignTimeBuild),
so the sequence is good for either design time or build time. -->
<Target Name="Protobuf_Compile"
Condition=" '@(ProtoBuf)' != '' "
Condition=" '@(Protobuf)' != '' "
DependsOnTargets=" Protobuf_BeforeCompile;
Protobuf_ResolvePlatform;
_Protobuf_SelectFiles;
Expand All @@ -120,13 +120,13 @@
to "." for the project's directory, as it is the current when compiling; for the
files outside of project directory, use each .proto file's directory as the root. -->
<FindUnderPath Path="$(MSBuildProjectDirectory)"
Files="@(ProtoBuf->WithMetadataValue('ProtoRoot',''))">
Files="@(Protobuf->WithMetadataValue('ProtoRoot',''))">
<Output TaskParameter="InPath" ItemName="_Protobuf_NoRootInProject"/>
<Output TaskParameter="OutOfPath" ItemName="_Protobuf_NoRootElsewhere"/>
</FindUnderPath>
<ItemGroup>
<!-- Files with explicit metadata. -->
<Protobuf_Compile Include="@(ProtoBuf->HasMetadata('ProtoRoot'))" />
<Protobuf_Compile Include="@(Protobuf->HasMetadata('ProtoRoot'))" />
<!-- In-project files will have ProtoRoot='.'. -->
<Protobuf_Compile Include="@(_Protobuf_NoRootInProject)">
<ProtoRoot>.</ProtoRoot>
Expand Down Expand Up @@ -154,13 +154,13 @@
<Target Name="Protobuf_PrepareCompile" Condition=" '@(Protobuf_Compile)' != '' ">
<!-- Predict expected names. -->
<ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' "
ProtoBuf="@(Protobuf_Compile)"
Protobuf="@(Protobuf_Compile)"
Generator="$(Protobuf_Generator)">
<Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" />
</ProtoCompilerOutputs>
<!-- Read any dependency files from previous compiles. -->
<ProtoReadDependencies Condition=" '$(Protobuf_DepFilesPath)' != '' and '$(DisableProtobufDesignTimeBuild)' != 'true' "
ProtoBuf="@(Protobuf_Compile)"
Protobuf="@(Protobuf_Compile)"
ProtoDepDir="$(Protobuf_DepFilesPath)" >
<Output TaskParameter="Dependencies" ItemName="Protobuf_Dependencies" />
</ProtoReadDependencies>
Expand Down Expand Up @@ -263,7 +263,7 @@
<ProtoCompile Condition=" '@(_Protobuf_OutOfDateProto)' != '' "
ToolExe="$(Protobuf_ProtocFullPath)"
Generator="$(Protobuf_Generator)"
ProtoBuf="%(_Protobuf_OutOfDateProto.Source)"
Protobuf="%(_Protobuf_OutOfDateProto.Source)"
ProtoPath="%(_Protobuf_OutOfDateProto.AdditionalImportDirs);$(Protobuf_StandardImportsPath);%(_Protobuf_OutOfDateProto.ProtoRoot)"
ProtoDepDir="$(Protobuf_DepFilesPath)"
OutputDir="%(_Protobuf_OutOfDateProto.OutputDir)"
Expand Down Expand Up @@ -327,7 +327,7 @@

<!-- Main cleanup sequence. -->
<Target Name="Protobuf_Clean"
Condition=" '@(ProtoBuf)' != '' "
Condition=" '@(Protobuf)' != '' "
DependsOnTargets=" Protobuf_BeforeClean;
Protobuf_PrepareClean;
_Protobuf_CoreClean;
Expand All @@ -354,7 +354,7 @@
<Target Name="Protobuf_PrepareClean" Condition=" '@(Protobuf)' != '' ">
<!-- Predict expected names. -->
<ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' "
ProtoBuf="@(Protobuf)"
Protobuf="@(Protobuf)"
Generator="$(Protobuf_Generator)">
<Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" />
</ProtoCompilerOutputs>
Expand All @@ -376,9 +376,9 @@
* The Pack target includes .proto files into the source package. -->
<Target Name="_Protobuf_SourceFilesProjectOutputGroup"
BeforeTargets="SourceFilesProjectOutputGroup"
Condition=" '@(ProtoBuf)' != '' " >
Condition=" '@(Protobuf)' != '' " >
<ItemGroup>
<SourceFilesProjectOutputGroupOutput Include="@(ProtoBuf->'%(FullPath)')" />
<SourceFilesProjectOutputGroupOutput Include="@(Protobuf->'%(FullPath)')" />
</ItemGroup>
</Target>
</Project>
18 changes: 9 additions & 9 deletions src/csharp/Grpc.Tools/build/_protobuf/Protobuf.CSharp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

<ContentType Name="ProtoFile"
DisplayName="Protocol buffer definitions file"
ItemType="ProtoBuf" />
ItemType="Protobuf" />

<ItemType Name="ProtoBuf"
<ItemType Name="Protobuf"
DisplayName="Protobuf compiler" />

<Rule Name="ProtoBuf"
<Rule Name="Protobuf"
DisplayName="File Properties"
PageTemplate="generic"
Description="File Properties"
OverrideMode="Extend">
<Rule.DataSource>
<DataSource Persistence="ProjectFile" Label="Configuration" ItemType="ProtoBuf"
<DataSource Persistence="ProjectFile" Label="Configuration" ItemType="Protobuf"
HasConfigurationCondition="false" SourceOfDefaultValue="AfterContext" />
</Rule.DataSource>

Expand All @@ -31,7 +31,7 @@

<StringProperty Name="Identity" Visible="false" ReadOnly="true">
<StringProperty.DataSource>
<DataSource Persistence="Intrinsic" ItemType="ProtoBuf"
<DataSource Persistence="Intrinsic" ItemType="Protobuf"
PersistedName="Identity" SourceOfDefaultValue="AfterContext" />
</StringProperty.DataSource>
</StringProperty>
Expand All @@ -42,7 +42,7 @@
Category="Misc"
Description="Location of the file.">
<StringProperty.DataSource>
<DataSource Persistence="Intrinsic" ItemType="ProtoBuf"
<DataSource Persistence="Intrinsic" ItemType="Protobuf"
PersistedName="FullPath" SourceOfDefaultValue="AfterContext" />
</StringProperty.DataSource>
</StringProperty>
Expand All @@ -53,7 +53,7 @@
Category="Misc"
Description="Name of the file or folder.">
<StringProperty.DataSource>
<DataSource Persistence="Intrinsic" ItemType="ProtoBuf"
<DataSource Persistence="Intrinsic" ItemType="Protobuf"
PersistedName="FileNameAndExtension" SourceOfDefaultValue="AfterContext" />
</StringProperty.DataSource>
</StringProperty>
Expand Down Expand Up @@ -81,7 +81,7 @@
<EnumValue Name="Public" DisplayName="Public" IsDefault="true" />
<EnumValue Name="Internal" DisplayName="Internal" />
<EnumProperty.DataSource>
<DataSource ItemType="ProtoBuf" SourceOfDefaultValue="AfterContext"
<DataSource ItemType="Protobuf" SourceOfDefaultValue="AfterContext"
PersistenceStyle="Attribute" />
</EnumProperty.DataSource>
</EnumProperty>
Expand All @@ -90,7 +90,7 @@
Category="Protobuf" Default="true"
Description="Specifies if this file is compiled or only imported by other files.">
<BoolProperty.DataSource>
<DataSource ItemType="ProtoBuf" SourceOfDefaultValue="AfterContext"
<DataSource ItemType="Protobuf" SourceOfDefaultValue="AfterContext"
PersistenceStyle="Attribute" />
</BoolProperty.DataSource>
</BoolProperty>
Expand Down

0 comments on commit cfa0d22

Please sign in to comment.