Skip to content

Commit 0668d5f

Browse files
author
Hovsep
authored
Added Generated Sync method and License Header check on Build. (Azure#11)
* Added Generated Sync method and License Header check on Build. * Fixed License Headers for existing files.
1 parent 64ca428 commit 0668d5f

File tree

3 files changed

+41
-256
lines changed

3 files changed

+41
-256
lines changed

CheckSourceFiles.ps1

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
function Check-SyncMethods()
3+
{
4+
$retValue = $false
5+
6+
$TextPattern=[regex]'\/\/\/ <summary>*([\r\n][ \t]+\/\/\/.*)+[\r\n][ \t]+public static.*\)[\r\n][ \t]+\{[\r\n].*\.GetAwaiter\(\)\.GetResult\(\);[\r\n][ \t]+\}[\r\n][\r\n][ \t]+'
7+
8+
Get-ChildItem -Recurse -Filter "*.cs" | Where-Object { $_.Attributes -ne "Directory"} | ForEach-Object {
9+
$text = (Get-Content $_.FullName) -join "`n"
10+
11+
if($text -match $TextPattern) {
12+
Write-Host "[ERROR]: Found Sync Method in file: $($_.FullName)"
13+
$retValue = $true
14+
}
15+
}
16+
return $retValue;
17+
}
18+
19+
function Check-LicenseHeader()
20+
{
21+
$retValue = $false
22+
$licenseHeader = "// Copyright (c) Microsoft Corporation. All rights reserved."
23+
$licenseHeaderAutoGen = "// <auto-generated> // Copyright (c) Microsoft Corporation. All rights reserved."
24+
25+
Get-ChildItem -Recurse -Filter "*.cs" | Where-Object { $_.Attributes -ne "Directory"} | ForEach-Object {
26+
$text = (Get-Content $_.FullName -First 2) -join " "
27+
28+
if((-Not $text.StartsWith($licenseHeader)) -And (-Not $text.StartsWith($licenseHeaderAutoGen))) {
29+
Write-Host "[ERROR]: File does not contain valid License Header: $($_.FullName)"
30+
$retValue = $true
31+
}
32+
}
33+
return $retValue;
34+
}
35+
36+
if(Check-SyncMethods | Check-LicenseHeader) {
37+
exit(-1)
38+
}
39+
exit(0)

Tests/Fluent.Tests/Dns/DnsRecordSetTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Azure.Tests;
2-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
32
// Licensed under the MIT License. See License.txt in the project root for license information.
43

4+
using Azure.Tests;
55
using Fluent.Tests.Common;
66
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
77
using Microsoft.Rest.Azure;

src/ResourceManagement/Compute/DataDiskImpl.cs

-254
This file was deleted.

0 commit comments

Comments
 (0)