LEFT | RIGHT |
1 using System; | 1 /* |
2 using System.Collections.Generic; | 2 Copyright 2013 Google Inc |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 */ |
| 16 |
| 17 using System; |
3 using System.Diagnostics; | 18 using System.Diagnostics; |
4 using System.IO; | 19 using System.IO; |
5 using System.Linq; | 20 using System.Linq; |
6 using System.Text; | |
7 using System.Threading.Tasks; | |
8 | 21 |
9 using Microsoft.Build.Evaluation; | 22 using Microsoft.Build.Evaluation; |
10 | 23 |
11 using Google.Apis.Utils; | 24 using Google.Apis.Utils; |
| 25 using Google.Apis.Utils.Trace; |
12 | 26 |
13 namespace Google.Apis.Release | 27 namespace Google.Apis.Release |
14 { | 28 { |
15 /// <summary>Project extensions.</summary> | 29 /// <summary> |
16 static class ProjectExtenstions | 30 /// Extension methods for the Project class.· |
| 31 /// Add support in getting the short name of the project and also in replaci
ng the current library version with· |
| 32 /// the new version (<see cref="ReplaceVersion"/>). |
| 33 /// </summary> |
| 34 internal static class ProjectExtenstions |
17 { | 35 { |
18 static readonly TraceSource TraceSource = new TraceSource("Google.Apis")
; | 36 static readonly TraceSource TraceSource = new TraceSource("Google.Apis")
; |
19 | 37 |
20 /// <summary>Gets the name of the project.</summary> | 38 /// <summary>Gets the name of the project.</summary> |
21 public static string GetName(this Project project) | 39 public static string GetName(this Project project) |
22 { | 40 { |
23 return project.DirectoryPath.Substring(project.DirectoryPath.LastInd
exOf(Path.DirectorySeparatorChar) + 1); | 41 return project.DirectoryPath.Substring(project.DirectoryPath.LastInd
exOf(Path.DirectorySeparatorChar) + 1); |
24 } | 42 } |
25 | 43 |
26 /// <summary>Replaces Assembly version number with the given one.</summa
ry> | 44 /// <summary>Replaces Assembly version number with the given one.</summa
ry> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 private static string ReplaceVersionInLine(string line, string assemblyV
ersionPrefix, string newVersion) | 76 private static string ReplaceVersionInLine(string line, string assemblyV
ersionPrefix, string newVersion) |
59 { | 77 { |
60 var startVersion = assemblyVersionPrefix.Length; | 78 var startVersion = assemblyVersionPrefix.Length; |
61 // '.*' ends the old version number (e.g 1.2.* or 1.2.0.*) | 79 // '.*' ends the old version number (e.g 1.2.* or 1.2.0.*) |
62 var endVersion = line.IndexOf(".*", startVersion); | 80 var endVersion = line.IndexOf(".*", startVersion); |
63 var oldVersion = line.Substring(startVersion, endVersion - startVers
ion); | 81 var oldVersion = line.Substring(startVersion, endVersion - startVers
ion); |
64 return line.Replace(assemblyVersionPrefix + oldVersion, assemblyVers
ionPrefix + newVersion); | 82 return line.Replace(assemblyVersionPrefix + oldVersion, assemblyVers
ionPrefix + newVersion); |
65 } | 83 } |
66 } | 84 } |
67 } | 85 } |
LEFT | RIGHT |