Просмотр исходного кода

增加google protobuf支持,对.proto文件使用自定义工具CmdTool即可自动生成.pb.cs文件
使用方法
1. CmdTool.exe使用前需要在命令行运行CmdTool.exe Register注册
2.CSharp/Tools目录加到环境变量,Protobuf库ProtoGen.exe的目录加到环境变量
3.右键点击项目中的.proto文件,自定义工具使用CmdTool工具

tanghai 14 лет назад
Родитель
Сommit
ab1b3803f2

+ 0 - 13
CSharp/CSharp.sln

@@ -5,8 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor", "Editor\Editor.csp
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Login", "Modules\LoginModule\Login.csproj", "{7CC7BF9C-13BE-470E-BC35-6A1944767899}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeCanvas", "Modules\TreeCanvas\TreeCanvas.csproj", "{6CD185D1-08E0-4729-A999-2D5B57BA8193}"
@@ -33,16 +31,6 @@ Global
 		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|Mixed Platforms.Build.0 = Release|x86
 		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|x86.ActiveCfg = Release|x86
 		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|x86.Build.0 = Release|x86
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Any CPU.Build.0 = Release|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|x86.ActiveCfg = Release|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -68,7 +56,6 @@ Global
 		HideSolutionNode = FALSE
 	EndGlobalSection
 	GlobalSection(NestedProjects) = preSolution
-		{7CC7BF9C-13BE-470E-BC35-6A1944767899} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
 		{6CD185D1-08E0-4729-A999-2D5B57BA8193} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
 	EndGlobalSection
 EndGlobal

+ 1 - 3
CSharp/Editor/Bootstrapper.cs

@@ -1,10 +1,9 @@
 using System.ComponentModel.Composition.Hosting;
 using System.Windows;
 using Microsoft.Practices.Prism.MefExtensions;
-using Module.Login;
 using Infrastructure;
 using Microsoft.Practices.Prism.Regions;
-using Module.TreeCanvas;
+using TreeCanvas;
 
 namespace Editor
 {
@@ -14,7 +13,6 @@ namespace Editor
 		{
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ViewExportAttribute).Assembly));
-			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(LoginModule).Assembly));
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(TreeCanvasModule).Assembly));
 		}
 

+ 0 - 4
CSharp/Editor/Editor.csproj

@@ -98,10 +98,6 @@
       <Project>{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}</Project>
       <Name>Infrastructure</Name>
     </ProjectReference>
-    <ProjectReference Include="..\Modules\LoginModule\Login.csproj">
-      <Project>{7CC7BF9C-13BE-470E-BC35-6A1944767899}</Project>
-      <Name>Login</Name>
-    </ProjectReference>
     <ProjectReference Include="..\Modules\TreeCanvas\TreeCanvas.csproj">
       <Project>{6CD185D1-08E0-4729-A999-2D5B57BA8193}</Project>
       <Name>TreeCanvas</Name>

+ 0 - 108
CSharp/Modules/LoginModule/Login.csproj

@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{7CC7BF9C-13BE-470E-BC35-6A1944767899}</ProjectGuid>
-    <OutputType>library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Module.Login</RootNamespace>
-    <AssemblyName>Module.Login</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
-    <FileAlignment>512</FileAlignment>
-    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="AsyncCtpLibrary">
-      <HintPath>..\..\Packages\AsynCtp\AsyncCtpLibrary.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Practices.Prism">
-      <HintPath>..\..\Packages\Prism.4.0.0.0\lib\NET40\Microsoft.Practices.Prism.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Practices.Prism.Interactivity">
-      <HintPath>..\..\Packages\Prism.4.0.0.0\lib\NET40\Microsoft.Practices.Prism.Interactivity.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Practices.Prism.MefExtensions">
-      <HintPath>..\..\Packages\Prism.MEFExtensions.4.0.0.0\lib\NET40\Microsoft.Practices.Prism.MefExtensions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Practices.ServiceLocation">
-      <HintPath>..\..\Packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
-    </Reference>
-    <Reference Include="NLog">
-      <HintPath>..\..\Packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.ComponentModel.Composition" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Xaml">
-      <RequiredTargetFramework>4.0</RequiredTargetFramework>
-    </Reference>
-    <Reference Include="WindowsBase" />
-    <Reference Include="PresentationCore" />
-    <Reference Include="PresentationFramework" />
-  </ItemGroup>
-  <ItemGroup>
-    <Page Include="LoginView.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
-    <Compile Include="LoginModule.cs" />
-    <Compile Include="LoginView.xaml.cs">
-      <DependentUpon>LoginView.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="LoginViewModel.cs" />
-    <AppDesigner Include="Properties\" />
-  </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties\" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\Infrastructure\Infrastructure.csproj">
-      <Project>{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}</Project>
-      <Name>Infrastructure</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="Packages.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PreBuildEvent>$(SolutionDir)\Tools\Nuget.exe install $(ProjectDir)Packages.config -o $(SolutionDir)Packages</PreBuildEvent>
-  </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 0 - 13
CSharp/Modules/LoginModule/LoginModule.cs

@@ -1,13 +0,0 @@
-using Microsoft.Practices.Prism.MefExtensions.Modularity;
-using Microsoft.Practices.Prism.Modularity;
-
-namespace Module.Login
-{
-	[ModuleExport(typeof(LoginModule))]
-	public class LoginModule : IModule
-	{
-		public void Initialize()
-		{
-		}
-	}
-}

+ 0 - 22
CSharp/Modules/LoginModule/LoginView.xaml

@@ -1,22 +0,0 @@
-<UserControl x:Class="Module.Login.LoginView"
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-		mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="360">
-	<Grid>
-		<Grid.RowDefinitions>
-			<RowDefinition Height="*"/>
-			<RowDefinition Height="*"/>
-		</Grid.RowDefinitions>
-		<StackPanel Grid.Row="0"  Orientation="Horizontal">
-			<Label Content="用户名: " Height="25"></Label>
-			<TextBox Name="tbUsername"  Text="{Binding Username}"  Width="100" Height="25"></TextBox>
-			<Label Content="密码: " Height="25"></Label>
-			<PasswordBox Name="pbPassword"  Width="100" Height="25"></PasswordBox>
-			<Button Name="btnLogin"  Content="登录" Width="50" Height="25" Click="btnLogin_Click"></Button>
-		</StackPanel>
-		<TextBox Grid.Row="1" Height="100"  Name="tbLogInfo" Text="{Binding LogInfo}" 
-				VerticalScrollBarVisibility="Visible" TextChanged="tbLogInfo_TextChanged"></TextBox>
-	</Grid>
-</UserControl>

+ 0 - 55
CSharp/Modules/LoginModule/LoginView.xaml.cs

@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using System.ComponentModel.Composition;
-using Infrastructure;
-
-namespace Module.Login
-{
-	/// <summary>
-	/// LoginView.xaml 的交互逻辑
-	/// </summary>
-	[ViewExport(RegionName = "MainRegion")]
-	[PartCreationPolicy(CreationPolicy.NonShared)]
-	public partial class LoginView : UserControl
-	{
-		public LoginView()
-		{
-			InitializeComponent();
-		}
-
-		[Import]
-		LoginViewModel ViewModel
-		{
-			get
-			{
-				return this.DataContext as LoginViewModel;
-			}
-			set
-			{
-				this.DataContext = value;
-			}
-		}
-
-		private void btnLogin_Click(object sender, RoutedEventArgs e)
-		{
-			this.ViewModel.Password = pbPassword.Password;
-			this.ViewModel.Login();
-		}
-
-		private void tbLogInfo_TextChanged(object sender, TextChangedEventArgs e)
-		{
-			tbLogInfo.ScrollToEnd();
-		}
-	}
-}

+ 0 - 123
CSharp/Modules/LoginModule/LoginViewModel.cs

@@ -1,123 +0,0 @@
-using System.ComponentModel.Composition;
-using Microsoft.Practices.Prism.ViewModel;
-using System.Threading.Tasks;
-using System.Net.Sockets;
-using System.Security.Cryptography;
-using System;
-using NLog;
-
-namespace Module.Login
-{
-	enum RealmLoginState : byte
-	{
-		RealmAuthLoginChallenge = 0,
-		RealmAuthLonginProof = 1,
-		AuthReconnectChallenge = 2,
-		AuthReconnectProof = 3,
-		AuthLoginPermit = 4,
-		RealmList = 10,
-		Surver = 48,
-	}
-
-	[Export(typeof(LoginViewModel))]
-	[PartCreationPolicy(CreationPolicy.NonShared)]
-	public class LoginViewModel : NotificationObject
-	{
-		private string username = "";
-		private string password = "";
-		private string logInfo = "";
-		private Logger logger = LogManager.GetCurrentClassLogger();
-
-		public LoginViewModel()
-		{
-		}
-
-		public string Username
-		{
-			get
-			{
-				return username;
-			}
-			set
-			{
-				if (username == value)
-				{
-					return;
-				}
-				username = value;
-				RaisePropertyChanged("Username");
-			}
-		}
-
-		public string Password
-		{
-			get
-			{
-				return password;
-			}
-			set
-			{
-				if (password == value)
-				{
-					return;
-				}
-				password = value;
-				RaisePropertyChanged("Password");
-			}
-		}
-
-		public string LogInfo
-		{
-			get
-			{
-				return logInfo;
-			}
-			set
-			{
-				if (logInfo == value)
-				{
-					return;
-				}
-				logInfo = value;
-				RaisePropertyChanged("LogInfo");
-			}
-		}
-
-		public async void Login()
-		{
-			using (TcpClient tcpClient = new TcpClient())
-			{
-				// 异步连接
-				await tcpClient.ConnectAsync("192.168.10.246", 19000);
-				var stream = tcpClient.GetStream();
-
-				// 验证通行证
-				await LoginPermit(stream);
-			}
-		}
-
-		public async Task LoginPermit(NetworkStream stream)
-		{
-			byte[] opcodeBuffer = new byte[1] { (byte)RealmLoginState.AuthLoginPermit };
-			await stream.WriteAsync(opcodeBuffer, 0, opcodeBuffer.Length);
-
-			string username = Username + new string(' ', 128 - Username.Length);
-			byte[] usernameBuffer = System.Text.Encoding.Default.GetBytes(username);
-			await stream.WriteAsync(usernameBuffer, 0, usernameBuffer.Length);
-
-			MD5 md5 = new MD5CryptoServiceProvider();
-			byte[] password = System.Text.Encoding.Default.GetBytes(Password);
-			byte[] passMD5Buffer = md5.ComputeHash(password);
-
-			string passMD5 = BitConverter.ToString(passMD5Buffer);
-			passMD5 = passMD5.Replace("-", "");
-			passMD5 = passMD5.ToLower();
-
-			passMD5Buffer = System.Text.Encoding.Default.GetBytes(passMD5);
-			await stream.WriteAsync(passMD5Buffer, 0, passMD5Buffer.Length);
-
-			LogInfo += "username: " + username.Trim() + " password md5: " + passMD5 + Environment.NewLine;
-			logger.Debug("11111111111");
-		}
-	}
-}

+ 0 - 7
CSharp/Modules/LoginModule/Packages.config

@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-	<package id="CommonServiceLocator" version="1.0" />
-	<package id="NLog" version="2.0.0.2000" />
-	<package id="Prism" version="4.0.0.0" />
-	<package id="Prism.MEFExtensions" version="4.0.0.0" />
-</packages>

+ 1 - 1
CSharp/Modules/TreeCanvas/Arrow.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	class Arrow
 	{

+ 1 - 1
CSharp/Modules/TreeCanvas/Connector.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	class Connector
 	{

+ 1 - 1
CSharp/Modules/TreeCanvas/Node.cs

@@ -4,7 +4,7 @@ using System.Linq;
 using System.Text;
 using System.Windows;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	class Node
 	{

+ 7 - 6
CSharp/Modules/TreeCanvas/Packages.config

@@ -1,7 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-	<package id="CommonServiceLocator" version="1.0" />
-	<package id="NLog" version="2.0.0.2000" />
-	<package id="Prism" version="4.0.0.0" />
-	<package id="Prism.MEFExtensions" version="4.0.0.0" />
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="CommonServiceLocator" version="1.0" />
+  <package id="Google.ProtocolBuffers" version="2.4.1.473" />
+  <package id="NLog" version="2.0.0.2000" />
+  <package id="Prism" version="4.0.0.0" />
+  <package id="Prism.MEFExtensions" version="4.0.0.0" />
 </packages>

+ 8 - 0
CSharp/Modules/TreeCanvas/Person.proto

@@ -0,0 +1,8 @@
+package Egametang;
+
+import "google/protobuf/csharp_options.proto";
+
+message Person
+{
+	required int32 num = 1;
+};

+ 20 - 0
CSharp/Modules/TreeCanvas/TreeCanvas.csproj

@@ -33,6 +33,12 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Google.ProtocolBuffers, Version=2.4.1.473, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.ProtocolBuffers.Serialization, Version=2.4.1.473, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.Expression.Drawing" />
     <Reference Include="Microsoft.Expression.Interactions" />
     <Reference Include="Microsoft.Practices.Prism">
@@ -65,6 +71,11 @@
     <Compile Include="Arrow.cs" />
     <Compile Include="Connector.cs" />
     <Compile Include="Node.cs" />
+    <Compile Include="Person.pb.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Person.proto</DependentUpon>
+    </Compile>
     <Compile Include="TreeCanvasModule.cs" />
     <Compile Include="TreeCanvasView.xaml.cs">
       <DependentUpon>TreeCanvasView.xaml</DependentUpon>
@@ -87,7 +98,16 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
+    <None Include="google\protobuf\csharp_options.proto" />
+    <None Include="google\protobuf\descriptor.proto" />
     <None Include="Packages.config" />
+    <None Include="Person.proto">
+      <Generator>CmdTool</Generator>
+      <LastGenOutput>Person.pb.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="CHANGES.txt" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>

+ 1 - 1
CSharp/Modules/TreeCanvas/TreeCanvasModule.cs

@@ -1,7 +1,7 @@
 using Microsoft.Practices.Prism.MefExtensions.Modularity;
 using Microsoft.Practices.Prism.Modularity;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	[ModuleExport(typeof(TreeCanvasModule))]
 	public class TreeCanvasModule : IModule

+ 1 - 1
CSharp/Modules/TreeCanvas/TreeCanvasView.xaml

@@ -6,7 +6,7 @@
 		xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" 
 		xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
 		xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
-		x:Class="Module.TreeCanvas.TreeCanvasView" 
+		x:Class="TreeCanvas.TreeCanvasView" 
 		mc:Ignorable="d" 
 		d:DesignHeight="600" d:DesignWidth="800">
 

+ 1 - 1
CSharp/Modules/TreeCanvas/TreeCanvasView.xaml.cs

@@ -14,7 +14,7 @@ using System.Windows.Shapes;
 using System.ComponentModel.Composition;
 using Infrastructure;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	/// <summary>
 	/// TreeCanvasView.xaml 的交互逻辑

+ 36 - 27
CSharp/Modules/TreeCanvas/TreeCanvasViewModel.cs

@@ -1,46 +1,55 @@
 using System.ComponentModel.Composition;
 using Microsoft.Practices.Prism.ViewModel;
-using NLog;
+using NLog;
 using System.Windows.Input;
-using Microsoft.Practices.Prism.Commands;
-using System.Collections.ObjectModel;
+using Microsoft.Practices.Prism.Commands;
+using System.Collections.ObjectModel;
 using System.Windows;
+using Google.ProtocolBuffers;
 
-namespace Module.TreeCanvas
+namespace TreeCanvas
 {
 	[Export(typeof(TreeCanvasViewModel))]
 	[PartCreationPolicy(CreationPolicy.NonShared)]
 	class TreeCanvasViewModel : NotificationObject
 	{
-		private Logger logger = LogManager.GetCurrentClassLogger();
-
-		private ObservableCollection<Node> nodes = new ObservableCollection<Node>();
+		private Logger logger = LogManager.GetCurrentClassLogger();
+
+		private ObservableCollection<Node> nodes = new ObservableCollection<Node>();
 		private ObservableCollection<Arrow> arrows = new ObservableCollection<Arrow>();
 				
 		public TreeCanvasViewModel()
-		{
+		{
 			logger.Debug("TreeCanvasViewModel");
 		}
 
-		public ObservableCollection<Node> Nodes
-		{
-			get
-			{
-				return nodes;
-			}
-		}
-
-		public ObservableCollection<Arrow> Arrows
-		{
-			get
-			{
-				return arrows;
-			}
-		}
-
-		public void NewNode(Point point)
-		{
-			Nodes.Add(new Node(point));
+		public ObservableCollection<Node> Nodes
+		{
+			get
+			{
+				return nodes;
+			}
+		}
+
+		public ObservableCollection<Arrow> Arrows
+		{
+			get
+			{
+				return arrows;
+			}
+		}
+
+		public void NewNode(Point point)
+		{
+			Nodes.Add(new Node(point));
+			Person.Builder personBuilder = Person.CreateBuilder();
+			personBuilder.SetNum(1);
+			Person person = personBuilder.Build();
+			string s = TextFormat.PrintToString(person);
+			logger.Debug(s);
+
+			TextFormat.Merge("num: 2", personBuilder);
+			Person person2 = personBuilder.Build();
 		}
 	}
 }

+ 111 - 0
CSharp/Modules/TreeCanvas/google/protobuf/csharp_options.proto

@@ -0,0 +1,111 @@
+// Extra options for C# generator
+
+import "google/protobuf/descriptor.proto";
+
+package google.protobuf;
+
+message CSharpFileOptions {
+
+  // Namespace for generated classes; defaults to the package.
+  optional string namespace = 1;
+  
+  // Name of the "umbrella" class used for metadata about all
+  // the messages within this file. Default is based on the name
+  // of the file.
+  optional string umbrella_classname = 2;
+  
+  // Whether classes should be public (true) or internal (false)
+  optional bool public_classes = 3 [default = true];
+
+  // Whether to generate a single file for everything within the
+  // .proto file (false), or one file per message (true).
+  // This option is not currently honored; please log a feature
+  // request if you really want it.
+  optional bool multiple_files = 4;
+
+  // Whether to nest messages within a single umbrella class (true)
+  // or create the umbrella class as a peer, with messages as
+  // top-level classes in the namespace (false)
+  optional bool nest_classes = 5;
+  
+  // Generate appropriate support for Code Contracts
+  // (Ongoing; support should improve over time)
+  optional bool code_contracts = 6;
+  
+  // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
+  // would generate files within [output directory]/Foo/Bar
+  optional bool expand_namespace_directories = 7;
+
+  // Generate attributes indicating non-CLS-compliance
+  optional bool cls_compliance = 8 [default = true];
+  
+  // Generate messages/builders with the [Serializable] attribute
+  optional bool add_serializable = 9 [default = false];
+  
+  // Generates a private ctor for Message types
+  optional bool generate_private_ctor = 10 [default = true];
+
+  // The extension that should be appended to the umbrella_classname when creating files.
+  optional string file_extension = 221 [default = ".cs"];
+  
+  // A nested namespace for the umbrella class.  Helpful for name collisions caused by 
+  // umbrella_classname conflicting with an existing type.  This will be automatically
+  // set to 'Proto' if a collision is detected with types being generated.  This value
+  // is ignored when nest_classes == true
+  optional string umbrella_namespace = 222;
+  
+  // The output path for the source file(s) generated
+  optional string output_directory = 223 [default = "."];
+
+  // Will ignore the type generations and remove dependencies for the descriptor proto
+  // files that declare their package to be "google.protobuf"
+  optional bool ignore_google_protobuf = 224 [default = false];
+
+  // Controls how services are generated, GENERIC is the deprecated original implementation
+  // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and 
+  // implementations using the included Windows RPC interop libarary.
+  optional CSharpServiceType service_generator_type = 225 [default = NONE];
+}
+
+enum CSharpServiceType {
+  // Services are ignored by the generator
+  NONE = 0;
+  // Generates the original Java generic service implementations
+  GENERIC = 1;
+  // Generates an interface for the service and nothing else
+  INTERFACE = 2;
+  // Generates an interface for the service and client/server wrappers for the interface
+  IRPCDISPATCH = 3;
+}
+
+extend FileOptions {
+  optional CSharpFileOptions csharp_file_options = 1000;
+}
+
+extend FieldOptions {
+  optional CSharpFieldOptions csharp_field_options = 1000;
+}
+
+message CSharpFieldOptions {
+  // Provides the ability to override the name of the property
+  // generated for this field. This is applied to all properties
+  // and methods to do with this field, including HasFoo, FooCount,
+  // FooList etc.
+  optional string property_name = 1;
+}
+
+message CSharpServiceOptions {
+  optional string interface_id = 1;
+}
+
+extend ServiceOptions {
+  optional CSharpServiceOptions csharp_service_options = 1000;
+}
+
+message CSharpMethodOptions {
+  optional int32 dispatch_id = 1;
+}
+
+extend MethodOptions {
+  optional CSharpMethodOptions csharp_method_options = 1000;
+}

+ 533 - 0
CSharp/Modules/TreeCanvas/google/protobuf/descriptor.proto

@@ -0,0 +1,533 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// 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.
+
+// Author: kenton@google.com (Kenton Varda)
+//  Based on original Protocol Buffers design by
+//  Sanjay Ghemawat, Jeff Dean, and others.
+//
+// The messages in this file describe the definitions found in .proto files.
+// A valid .proto file can be translated directly to a FileDescriptorProto
+// without any other information (e.g. without reading its imports).
+
+
+
+package google.protobuf;
+option java_package = "com.google.protobuf";
+option java_outer_classname = "DescriptorProtos";
+
+// descriptor.proto must be optimized for speed because reflection-based
+// algorithms don't work during bootstrapping.
+option optimize_for = SPEED;
+
+// The protocol compiler can output a FileDescriptorSet containing the .proto
+// files it parses.
+message FileDescriptorSet {
+  repeated FileDescriptorProto file = 1;
+}
+
+// Describes a complete .proto file.
+message FileDescriptorProto {
+  optional string name = 1;       // file name, relative to root of source tree
+  optional string package = 2;    // e.g. "foo", "foo.bar", etc.
+
+  // Names of files imported by this file.
+  repeated string dependency = 3;
+
+  // All top-level definitions in this file.
+  repeated DescriptorProto message_type = 4;
+  repeated EnumDescriptorProto enum_type = 5;
+  repeated ServiceDescriptorProto service = 6;
+  repeated FieldDescriptorProto extension = 7;
+
+  optional FileOptions options = 8;
+
+  // This field contains optional information about the original source code.
+  // You may safely remove this entire field whithout harming runtime
+  // functionality of the descriptors -- the information is needed only by
+  // development tools.
+  optional SourceCodeInfo source_code_info = 9;
+}
+
+// Describes a message type.
+message DescriptorProto {
+  optional string name = 1;
+
+  repeated FieldDescriptorProto field = 2;
+  repeated FieldDescriptorProto extension = 6;
+
+  repeated DescriptorProto nested_type = 3;
+  repeated EnumDescriptorProto enum_type = 4;
+
+  message ExtensionRange {
+    optional int32 start = 1;
+    optional int32 end = 2;
+  }
+  repeated ExtensionRange extension_range = 5;
+
+  optional MessageOptions options = 7;
+}
+
+// Describes a field within a message.
+message FieldDescriptorProto {
+  enum Type {
+    // 0 is reserved for errors.
+    // Order is weird for historical reasons.
+    TYPE_DOUBLE         = 1;
+    TYPE_FLOAT          = 2;
+    TYPE_INT64          = 3;   // Not ZigZag encoded.  Negative numbers
+                               // take 10 bytes.  Use TYPE_SINT64 if negative
+                               // values are likely.
+    TYPE_UINT64         = 4;
+    TYPE_INT32          = 5;   // Not ZigZag encoded.  Negative numbers
+                               // take 10 bytes.  Use TYPE_SINT32 if negative
+                               // values are likely.
+    TYPE_FIXED64        = 6;
+    TYPE_FIXED32        = 7;
+    TYPE_BOOL           = 8;
+    TYPE_STRING         = 9;
+    TYPE_GROUP          = 10;  // Tag-delimited aggregate.
+    TYPE_MESSAGE        = 11;  // Length-delimited aggregate.
+
+    // New in version 2.
+    TYPE_BYTES          = 12;
+    TYPE_UINT32         = 13;
+    TYPE_ENUM           = 14;
+    TYPE_SFIXED32       = 15;
+    TYPE_SFIXED64       = 16;
+    TYPE_SINT32         = 17;  // Uses ZigZag encoding.
+    TYPE_SINT64         = 18;  // Uses ZigZag encoding.
+  };
+
+  enum Label {
+    // 0 is reserved for errors
+    LABEL_OPTIONAL      = 1;
+    LABEL_REQUIRED      = 2;
+    LABEL_REPEATED      = 3;
+    // TODO(sanjay): Should we add LABEL_MAP?
+  };
+
+  optional string name = 1;
+  optional int32 number = 3;
+  optional Label label = 4;
+
+  // If type_name is set, this need not be set.  If both this and type_name
+  // are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
+  optional Type type = 5;
+
+  // For message and enum types, this is the name of the type.  If the name
+  // starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
+  // rules are used to find the type (i.e. first the nested types within this
+  // message are searched, then within the parent, on up to the root
+  // namespace).
+  optional string type_name = 6;
+
+  // For extensions, this is the name of the type being extended.  It is
+  // resolved in the same manner as type_name.
+  optional string extendee = 2;
+
+  // For numeric types, contains the original text representation of the value.
+  // For booleans, "true" or "false".
+  // For strings, contains the default text contents (not escaped in any way).
+  // For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
+  // TODO(kenton):  Base-64 encode?
+  optional string default_value = 7;
+
+  optional FieldOptions options = 8;
+}
+
+// Describes an enum type.
+message EnumDescriptorProto {
+  optional string name = 1;
+
+  repeated EnumValueDescriptorProto value = 2;
+
+  optional EnumOptions options = 3;
+}
+
+// Describes a value within an enum.
+message EnumValueDescriptorProto {
+  optional string name = 1;
+  optional int32 number = 2;
+
+  optional EnumValueOptions options = 3;
+}
+
+// Describes a service.
+message ServiceDescriptorProto {
+  optional string name = 1;
+  repeated MethodDescriptorProto method = 2;
+
+  optional ServiceOptions options = 3;
+}
+
+// Describes a method of a service.
+message MethodDescriptorProto {
+  optional string name = 1;
+
+  // Input and output type names.  These are resolved in the same way as
+  // FieldDescriptorProto.type_name, but must refer to a message type.
+  optional string input_type = 2;
+  optional string output_type = 3;
+
+  optional MethodOptions options = 4;
+}
+
+// ===================================================================
+// Options
+
+// Each of the definitions above may have "options" attached.  These are
+// just annotations which may cause code to be generated slightly differently
+// or may contain hints for code that manipulates protocol messages.
+//
+// Clients may define custom options as extensions of the *Options messages.
+// These extensions may not yet be known at parsing time, so the parser cannot
+// store the values in them.  Instead it stores them in a field in the *Options
+// message called uninterpreted_option. This field must have the same name
+// across all *Options messages. We then use this field to populate the
+// extensions when we build a descriptor, at which point all protos have been
+// parsed and so all extensions are known.
+//
+// Extension numbers for custom options may be chosen as follows:
+// * For options which will only be used within a single application or
+//   organization, or for experimental options, use field numbers 50000
+//   through 99999.  It is up to you to ensure that you do not use the
+//   same number for multiple options.
+// * For options which will be published and used publicly by multiple
+//   independent entities, e-mail kenton@google.com to reserve extension
+//   numbers.  Simply tell me how many you need and I'll send you back a
+//   set of numbers to use -- there's no need to explain how you intend to
+//   use them.  If this turns out to be popular, a web service will be set up
+//   to automatically assign option numbers.
+
+
+message FileOptions {
+
+  // Sets the Java package where classes generated from this .proto will be
+  // placed.  By default, the proto package is used, but this is often
+  // inappropriate because proto packages do not normally start with backwards
+  // domain names.
+  optional string java_package = 1;
+
+
+  // If set, all the classes from the .proto file are wrapped in a single
+  // outer class with the given name.  This applies to both Proto1
+  // (equivalent to the old "--one_java_file" option) and Proto2 (where
+  // a .proto always translates to a single class, but you may want to
+  // explicitly choose the class name).
+  optional string java_outer_classname = 8;
+
+  // If set true, then the Java code generator will generate a separate .java
+  // file for each top-level message, enum, and service defined in the .proto
+  // file.  Thus, these types will *not* be nested inside the outer class
+  // named by java_outer_classname.  However, the outer class will still be
+  // generated to contain the file's getDescriptor() method as well as any
+  // top-level extensions defined in the file.
+  optional bool java_multiple_files = 10 [default=false];
+
+  // If set true, then the Java code generator will generate equals() and
+  // hashCode() methods for all messages defined in the .proto file. This is
+  // purely a speed optimization, as the AbstractMessage base class includes
+  // reflection-based implementations of these methods.
+  optional bool java_generate_equals_and_hash = 20 [default=false];
+
+  // Generated classes can be optimized for speed or code size.
+  enum OptimizeMode {
+    SPEED = 1;        // Generate complete code for parsing, serialization,
+                      // etc.
+    CODE_SIZE = 2;    // Use ReflectionOps to implement these methods.
+    LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
+  }
+  optional OptimizeMode optimize_for = 9 [default=SPEED];
+
+
+
+
+  // Should generic services be generated in each language?  "Generic" services
+  // are not specific to any particular RPC system.  They are generated by the
+  // main code generators in each language (without additional plugins).
+  // Generic services were the only kind of service generation supported by
+  // early versions of proto2.
+  //
+  // Generic services are now considered deprecated in favor of using plugins
+  // that generate code specific to your particular RPC system.  Therefore,
+  // these default to false.  Old code which depends on generic services should
+  // explicitly set them to true.
+  optional bool cc_generic_services = 16 [default=false];
+  optional bool java_generic_services = 17 [default=false];
+  optional bool py_generic_services = 18 [default=false];
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message MessageOptions {
+  // Set true to use the old proto1 MessageSet wire format for extensions.
+  // This is provided for backwards-compatibility with the MessageSet wire
+  // format.  You should not use this for any other reason:  It's less
+  // efficient, has fewer features, and is more complicated.
+  //
+  // The message must be defined exactly as follows:
+  //   message Foo {
+  //     option message_set_wire_format = true;
+  //     extensions 4 to max;
+  //   }
+  // Note that the message cannot have any defined fields; MessageSets only
+  // have extensions.
+  //
+  // All extensions of your type must be singular messages; e.g. they cannot
+  // be int32s, enums, or repeated messages.
+  //
+  // Because this is an option, the above two restrictions are not enforced by
+  // the protocol compiler.
+  optional bool message_set_wire_format = 1 [default=false];
+
+  // Disables the generation of the standard "descriptor()" accessor, which can
+  // conflict with a field of the same name.  This is meant to make migration
+  // from proto1 easier; new code should avoid fields named "descriptor".
+  optional bool no_standard_descriptor_accessor = 2 [default=false];
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message FieldOptions {
+  // The ctype option instructs the C++ code generator to use a different
+  // representation of the field than it normally would.  See the specific
+  // options below.  This option is not yet implemented in the open source
+  // release -- sorry, we'll try to include it in a future version!
+  optional CType ctype = 1 [default = STRING];
+  enum CType {
+    // Default mode.
+    STRING = 0;
+
+    CORD = 1;
+
+    STRING_PIECE = 2;
+  }
+  // The packed option can be enabled for repeated primitive fields to enable
+  // a more efficient representation on the wire. Rather than repeatedly
+  // writing the tag and type for each element, the entire array is encoded as
+  // a single length-delimited blob.
+  optional bool packed = 2;
+
+
+  // Is this field deprecated?
+  // Depending on the target platform, this can emit Deprecated annotations
+  // for accessors, or it will be completely ignored; in the very least, this
+  // is a formalization for deprecating fields.
+  optional bool deprecated = 3 [default=false];
+
+  // EXPERIMENTAL.  DO NOT USE.
+  // For "map" fields, the name of the field in the enclosed type that
+  // is the key for this map.  For example, suppose we have:
+  //   message Item {
+  //     required string name = 1;
+  //     required string value = 2;
+  //   }
+  //   message Config {
+  //     repeated Item items = 1 [experimental_map_key="name"];
+  //   }
+  // In this situation, the map key for Item will be set to "name".
+  // TODO: Fully-implement this, then remove the "experimental_" prefix.
+  optional string experimental_map_key = 9;
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message EnumOptions {
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message EnumValueOptions {
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message ServiceOptions {
+
+  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC
+  //   framework.  We apologize for hoarding these numbers to ourselves, but
+  //   we were already using them long before we decided to release Protocol
+  //   Buffers.
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+message MethodOptions {
+
+  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC
+  //   framework.  We apologize for hoarding these numbers to ourselves, but
+  //   we were already using them long before we decided to release Protocol
+  //   Buffers.
+
+  // The parser stores options it doesn't recognize here. See above.
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  // Clients can define custom options in extensions of this message. See above.
+  extensions 1000 to max;
+}
+
+// A message representing a option the parser does not recognize. This only
+// appears in options protos created by the compiler::Parser class.
+// DescriptorPool resolves these when building Descriptor objects. Therefore,
+// options protos in descriptor objects (e.g. returned by Descriptor::options(),
+// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
+// in them.
+message UninterpretedOption {
+  // The name of the uninterpreted option.  Each string represents a segment in
+  // a dot-separated name.  is_extension is true iff a segment represents an
+  // extension (denoted with parentheses in options specs in .proto files).
+  // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+  // "foo.(bar.baz).qux".
+  message NamePart {
+    required string name_part = 1;
+    required bool is_extension = 2;
+  }
+  repeated NamePart name = 2;
+
+  // The value of the uninterpreted option, in whatever type the tokenizer
+  // identified it as during parsing. Exactly one of these should be set.
+  optional string identifier_value = 3;
+  optional uint64 positive_int_value = 4;
+  optional int64 negative_int_value = 5;
+  optional double double_value = 6;
+  optional bytes string_value = 7;
+  optional string aggregate_value = 8;
+}
+
+// ===================================================================
+// Optional source code info
+
+// Encapsulates information about the original source file from which a
+// FileDescriptorProto was generated.
+message SourceCodeInfo {
+  // A Location identifies a piece of source code in a .proto file which
+  // corresponds to a particular definition.  This information is intended
+  // to be useful to IDEs, code indexers, documentation generators, and similar
+  // tools.
+  //
+  // For example, say we have a file like:
+  //   message Foo {
+  //     optional string foo = 1;
+  //   }
+  // Let's look at just the field definition:
+  //   optional string foo = 1;
+  //   ^       ^^     ^^  ^  ^^^
+  //   a       bc     de  f  ghi
+  // We have the following locations:
+  //   span   path               represents
+  //   [a,i)  [ 4, 0, 2, 0 ]     The whole field definition.
+  //   [a,b)  [ 4, 0, 2, 0, 4 ]  The label (optional).
+  //   [c,d)  [ 4, 0, 2, 0, 5 ]  The type (string).
+  //   [e,f)  [ 4, 0, 2, 0, 1 ]  The name (foo).
+  //   [g,h)  [ 4, 0, 2, 0, 3 ]  The number (1).
+  //
+  // Notes:
+  // - A location may refer to a repeated field itself (i.e. not to any
+  //   particular index within it).  This is used whenever a set of elements are
+  //   logically enclosed in a single code segment.  For example, an entire
+  //   extend block (possibly containing multiple extension definitions) will
+  //   have an outer location whose path refers to the "extensions" repeated
+  //   field without an index.
+  // - Multiple locations may have the same path.  This happens when a single
+  //   logical declaration is spread out across multiple places.  The most
+  //   obvious example is the "extend" block again -- there may be multiple
+  //   extend blocks in the same scope, each of which will have the same path.
+  // - A location's span is not always a subset of its parent's span.  For
+  //   example, the "extendee" of an extension declaration appears at the
+  //   beginning of the "extend" block and is shared by all extensions within
+  //   the block.
+  // - Just because a location's span is a subset of some other location's span
+  //   does not mean that it is a descendent.  For example, a "group" defines
+  //   both a type and a field in a single declaration.  Thus, the locations
+  //   corresponding to the type and field and their components will overlap.
+  // - Code which tries to interpret locations should probably be designed to
+  //   ignore those that it doesn't understand, as more types of locations could
+  //   be recorded in the future.
+  repeated Location location = 1;
+  message Location {
+    // Identifies which part of the FileDescriptorProto was defined at this
+    // location.
+    //
+    // Each element is a field number or an index.  They form a path from
+    // the root FileDescriptorProto to the place where the definition.  For
+    // example, this path:
+    //   [ 4, 3, 2, 7, 1 ]
+    // refers to:
+    //   file.message_type(3)  // 4, 3
+    //       .field(7)         // 2, 7
+    //       .name()           // 1
+    // This is because FileDescriptorProto.message_type has field number 4:
+    //   repeated DescriptorProto message_type = 4;
+    // and DescriptorProto.field has field number 2:
+    //   repeated FieldDescriptorProto field = 2;
+    // and FieldDescriptorProto.name has field number 1:
+    //   optional string name = 1;
+    //
+    // Thus, the above path gives the location of a field name.  If we removed
+    // the last element:
+    //   [ 4, 3, 2, 7 ]
+    // this path refers to the whole field declaration (from the beginning
+    // of the label to the terminating semicolon).
+    repeated int32 path = 1 [packed=true];
+
+    // Always has exactly three or four elements: start line, start column,
+    // end line (optional, otherwise assumed same as start line), end column.
+    // These are packed into a single field for efficiency.  Note that line
+    // and column numbers are zero-based -- typically you will want to add
+    // 1 to each before displaying to a user.
+    repeated int32 span = 2 [packed=true];
+
+    // TODO(kenton):  Record comments appearing before and after the
+    // declaration.
+  }
+}

BIN
CSharp/Tools/CmdTool.exe


+ 25 - 0
CSharp/Tools/CmdTool.exe.config

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+	<configSections>
+		<section name="CmdTool" type="CSharpTest.Net.CustomTool.Config, CmdTool"/>
+	</configSections>
+	<CmdTool xsi:noNamespaceSchemaLocation="CmdTool.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+		<match filespec="*.proto">
+			<generator debug="true">
+				<execute exe="ProtoGen.exe" />
+				<!-- protoc.exe arguments -->
+				<arg value="--proto_path=$(InputDir)\"/>
+				<arg value="--include_imports"/>
+				<arg value="$(InputPath)"/>
+				<!-- protogen.exe arguments -->
+				<arg value="-file_extension=.pb.cs"/>
+				<arg value="-namespace=$(Namespace)"/>
+				<arg value="-output_directory=$(InputDir)\"/>
+				<arg value="-ignore_google_protobuf=true"/>
+				<arg value="-cls_compliance=false"/>
+				<arg value="-nest_classes=false"/>
+				<output extension=".pb.cs"/>
+			</generator>
+		</match>
+	</CmdTool>
+</configuration>

+ 81 - 0
CSharp/Tools/CmdTool.xsd

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="CmdTool" nillable="true" type="CmdToolConfig" />
+  <xs:complexType name="CmdToolConfig">
+    <xs:sequence>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="match" type="FileMatch" />
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="FileMatch">
+    <xs:sequence>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="applies-to" type="MatchAppliesTo" />
+      <xs:element minOccurs="1" maxOccurs="unbounded" name="generator" type="GeneratorConfig" />
+    </xs:sequence>
+    <xs:attribute name="filespec" type="FileMatchPattern" use="required" />
+  </xs:complexType>
+  <xs:complexType name="MatchAppliesTo">
+    <xs:attribute name="folder" type="FilePathPattern" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="GeneratorConfig">
+    <xs:sequence>
+      <xs:choice minOccurs="1" maxOccurs="1">
+        <xs:element minOccurs="1" maxOccurs="1" name="script" type="GeneratorScript" />
+        <xs:element minOccurs="1" maxOccurs="1" name="execute" type="GeneratorExec" />
+      </xs:choice>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="arg" type="GeneratorArgument" />
+      <xs:element minOccurs="0" maxOccurs="1" name="std-input" type="GeneratorInput" />
+      <xs:element minOccurs="0" maxOccurs="1" name="std-output" type="GeneratorOutput" />
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="output" type="GeneratorOutput" />
+    </xs:sequence>
+    <xs:attribute name="debug" type="xs:boolean" default="false" use="optional" />
+  </xs:complexType>
+  <xs:complexType name="GeneratorScript">
+    <xs:simpleContent>
+      <xs:extension base="xs:string">
+        <xs:attribute name="type" type="GeneratorScriptType" use="required"/>
+        <xs:attribute name="src" type="FilePathPattern" use="optional"/>
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:complexType name="GeneratorExec">
+    <xs:simpleContent>
+      <xs:extension base="xs:string">
+        <xs:attribute name="exe" type="FilePathPattern" use="required"/>
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:complexType name="GeneratorArgument">
+    <xs:attribute name="value" type="xs:string" use="required" />
+  </xs:complexType>
+  <xs:complexType name="GeneratorInput">
+    <xs:attribute name="redirect" type="xs:boolean" use="required" />
+  </xs:complexType>
+  <xs:complexType name="GeneratorOutput">
+    <xs:attribute name="extension" type="xs:string" use="required" />
+  </xs:complexType>
+  <xs:simpleType name="FilePathPattern">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="^[^*?&quot;|&lt;&gt;]+$" />
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="FileMatchPattern">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="^[^\\/:&quot;|&lt;&gt;]+$" />
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="FileExtensionPattern">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="^.[^\\/:*?&quot;|&lt;&gt;]*$" />
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="GeneratorScriptType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="JScript"/>
+      <xs:enumeration value="VBScript"/>
+      <xs:enumeration value="Cmd"/>
+      <xs:enumeration value="PowerShell"/>
+      <xs:enumeration value="CSharp"/>
+      <xs:enumeration value="VBNet"/>
+    </xs:restriction>
+  </xs:simpleType>
+</xs:schema>