commit
d886f6c9b9
272
build.ps1
272
build.ps1
|
@ -1,3 +1,8 @@
|
|||
# reference to System.*
|
||||
$SysDirectory = [System.IO.Directory]
|
||||
$SysPath = [System.IO.Path]
|
||||
$SysFile = [System.IO.File]
|
||||
|
||||
# Default to Debug
|
||||
$Configuration = 'Debug'
|
||||
|
||||
|
@ -30,42 +35,83 @@ else
|
|||
exit
|
||||
}
|
||||
|
||||
$Build = 'build'
|
||||
if ($args -contains 'rebuild')
|
||||
{
|
||||
$Build = 'rebuild'
|
||||
}
|
||||
|
||||
$PROGRAMFILESX86 = [Environment]::GetFolderPath("ProgramFilesX86")
|
||||
$env:ENLISTMENT_ROOT = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$ENLISTMENT_ROOT = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$LOGDIR = $ENLISTMENT_ROOT + "\bin"
|
||||
|
||||
# Default to use Visual Studio 2017
|
||||
$VS15MSBUILD=$PROGRAMFILESX86 + "\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
$VSTEST = $PROGRAMFILESX86 + "\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
|
||||
$SN = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\sn.exe"
|
||||
$SNx64 = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\sn.exe"
|
||||
|
||||
|
||||
# Figure out the directory and path for SN.exe
|
||||
$SN = $null
|
||||
$SNx64 = $null
|
||||
$SNVersions = @()
|
||||
ForEach ($directory in $SysDirectory::EnumerateDirectories($PROGRAMFILESX86 + "\Microsoft SDKs\Windows", "*A"))
|
||||
{
|
||||
# remove the first char 'v'
|
||||
$directoryName = $SysPath::GetFileName($directory).substring(1)
|
||||
|
||||
# remove the last char 'A'
|
||||
$directoryName = $directoryName.substring(0, $directoryName.LastIndexOf('A'))
|
||||
|
||||
# parse to double "10.0"
|
||||
$versionNo = [System.Double]::Parse($directoryName)
|
||||
|
||||
$fileobject = $null
|
||||
$fileobject = New-Object System.Object
|
||||
$fileobject | Add-Member -type NoteProperty -Name version -Value $versionNo
|
||||
$fileobject | Add-Member -type NoteProperty -Name directory -Value $directory
|
||||
|
||||
$SNVersions += $fileobject
|
||||
}
|
||||
|
||||
# using the latest version
|
||||
$SNVersions = $SNVersions | Sort-Object -Property version -Descending
|
||||
|
||||
ForEach ($ver in $SNVersions)
|
||||
{
|
||||
# only care about the folder has "bin" subfolder
|
||||
$snBinDirectory = $ver.directory + "\bin"
|
||||
if(!$SysDirectory::Exists($snBinDirectory))
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
if($SysFile::Exists($snBinDirectory + "\sn.exe") -and $SysFile::Exists($snBinDirectory + "\x64\sn.exe"))
|
||||
{
|
||||
$SN = $snBinDirectory + "\sn.exe"
|
||||
$SNx64 = $snBinDirectory + "\x64\sn.exe"
|
||||
break
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEach ($netFxDirectory in $SysDirectory::EnumerateDirectories($snBinDirectory, "NETFX * Tools") | Sort -Descending)
|
||||
{
|
||||
# currently, sorting descending for the NETFX version looks good.
|
||||
if($SysFile::Exists($netFxDirectory + "\sn.exe") -and $SysFile::Exists($netFxDirectory + "\x64\sn.exe"))
|
||||
{
|
||||
$SN = $netFxDirectory + "\sn.exe"
|
||||
$SNx64 = $netFxDirectory + "\x64\sn.exe"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($SN -ne $null -and $SNx64 -ne $null)
|
||||
{
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# Other variables
|
||||
$FXCOP = $FXCOPDIR + "\FxCopCmd.exe"
|
||||
$BUILDLOG = $LOGDIR + "\msbuild.log"
|
||||
$TESTLOG = $LOGDIR + "\mstest.log"
|
||||
$TESTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\Test\net461"
|
||||
$PRODUCTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\net461"
|
||||
$NUGETEXE = $PROGRAMFILESX86 + "\Microsoft Visual Studio\2017\Enterprise\MSBuild\ReadyRoll\OctoPack\build\NuGet.exe"
|
||||
$NUGETPACK = $ENLISTMENT_ROOT + "\packages"
|
||||
$ProductProj = $ENLISTMENT_ROOT + "\src\Microsoft.OpenAPI.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj"
|
||||
$TESTProj = $ENLISTMENT_ROOT + "\test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenApi.OData.Reader.Tests.csproj"
|
||||
|
||||
$TESTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\Test\net472"
|
||||
$PRODUCTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\net472"
|
||||
|
||||
$ProductDlls = "Microsoft.OpenApi.OData.Reader.dll"
|
||||
|
||||
$XUnitTestDlls = "Microsoft.OpenApi.OData.Reader.Tests.dll"
|
||||
|
||||
$AllTestSuite = @()
|
||||
ForEach($dll in $XUnitTestDlls)
|
||||
{
|
||||
$AllTestSuite += $TESTDIR + "\" + $dll
|
||||
}
|
||||
|
||||
Function GetDlls
|
||||
{
|
||||
$dlls = @()
|
||||
|
@ -85,20 +131,17 @@ Function GetDlls
|
|||
|
||||
Function SkipStrongName
|
||||
{
|
||||
$SnLog = $LOGDIR + "\SkipStrongName.log"
|
||||
Out-File $SnLog
|
||||
|
||||
Write-Host 'Skip strong name validations for Microsoft.OpenApi.OData assemblies...'
|
||||
|
||||
$dlls = GetDlls
|
||||
ForEach ($dll in $dlls)
|
||||
{
|
||||
& $SN /Vr $dll | Out-File $SnLog -Append
|
||||
& $SN /Vr $dll
|
||||
}
|
||||
|
||||
ForEach ($dll in $dlls)
|
||||
{
|
||||
& $SNx64 /Vr $dll | Out-File $SnLog -Append
|
||||
& $SNx64 /Vr $dll
|
||||
}
|
||||
|
||||
Write-Host "SkipStrongName Done" -ForegroundColor $Success
|
||||
|
@ -137,180 +180,40 @@ Function CleanBeforeScorch
|
|||
Write-Host "Clean Done" -ForegroundColor $Success
|
||||
}
|
||||
|
||||
# Incremental build and rebuild
|
||||
Function RunBuild ($sln)
|
||||
{
|
||||
Write-Host "*** Building $sln ***"
|
||||
$slnpath = $ENLISTMENT_ROOT + "\$sln"
|
||||
$Conf = "/p:Configuration=" + "$Configuration"
|
||||
|
||||
# Default to VS2017
|
||||
$MSBUILD = $VS15MSBUILD
|
||||
|
||||
& $MSBUILD $slnpath /t:$Build /m /nr:false /fl "/p:Platform=Any CPU" $Conf /p:Desktop=true `
|
||||
/flp:LogFile=$LOGDIR/msbuild.log /flp:Verbosity=Normal 1>$null 2>$null
|
||||
|
||||
if($LASTEXITCODE -eq 0)
|
||||
{
|
||||
Write-Host "Build $sln SUCCESS" -ForegroundColor $Success
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Build $sln FAILED" -ForegroundColor $Err
|
||||
Write-Host "For more information, please open the following test result files:"
|
||||
Write-Host "$LOGDIR\msbuild.log"
|
||||
Cleanup
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
Function NugetRestoreSolution
|
||||
{
|
||||
Write-Host '**********Pull NuGet Packages*********'
|
||||
& $NUGETEXE "restore" ($ENLISTMENT_ROOT + "\Microsoft.OpenApi.OData.sln")
|
||||
}
|
||||
|
||||
Function BuildProcess
|
||||
{
|
||||
Write-Host '**********Start To Build The Project*********'
|
||||
|
||||
$script:BUILD_START_TIME = Get-Date
|
||||
if (Test-Path $BUILDLOG)
|
||||
{
|
||||
rm $BUILDLOG
|
||||
}
|
||||
|
||||
RunBuild ('Microsoft.OpenApi.OData.sln')
|
||||
|
||||
|
||||
Write-Host "Build Product ..."
|
||||
|
||||
& dotnet.exe build $ProductProj -c $Configuration
|
||||
|
||||
Write-Host "Build Test ..."
|
||||
|
||||
& dotnet.exe build $TESTProj -c $Configuration
|
||||
|
||||
Write-Host "Build Done" -ForegroundColor $Success
|
||||
$script:BUILD_END_TIME = Get-Date
|
||||
}
|
||||
|
||||
Function TestSummary
|
||||
{
|
||||
Write-Host 'Collecting test results ...'
|
||||
|
||||
$file = Get-Content -Path $TESTLOG
|
||||
$pass = 0
|
||||
$skipped = 0
|
||||
$fail = 0
|
||||
$trxfile = New-Object -TypeName System.Collections.ArrayList
|
||||
$failedtest1 = New-Object -TypeName System.Collections.ArrayList
|
||||
$failedtest2 = New-Object -TypeName System.Collections.ArrayList
|
||||
$part = 1
|
||||
foreach ($line in $file)
|
||||
{
|
||||
# Consolidate logic for retrieving number of passed and skipped tests. Failed tests is separate due to the way
|
||||
# VSTest and DotNet (for .NET Core tests) report results differently.
|
||||
if ($line -match "^Total tests: .*")
|
||||
{
|
||||
# The line is in this format:
|
||||
# Total tests: 5735. Passed: 5735. Failed: 0. Skipped: 0.
|
||||
# We want to extract the total passed and total skipped.
|
||||
|
||||
# Extract total passed by taking the substring between "Passed: " and "."
|
||||
# The regex first extracts the string after the hardcoded "Passed: " (i.e. "#. Failed: #. Skipped: #.")
|
||||
# Then we tokenize by "." and retrieve the first token which is the number for passed.
|
||||
$pattern = "Passed: (.*)"
|
||||
$extractedNumber = [regex]::match($line, $pattern).Groups[1].Value.Split(".")[0]
|
||||
$pass += $extractedNumber
|
||||
|
||||
# Extract total failed by taking the substring between "Failed: " and "."
|
||||
# The regex first extracts the string after the hardcoded "Failed: " (i.e. "#.")
|
||||
# Then we tokenize by "." and retrieve the first token which is the number for skipped.
|
||||
$pattern = "Failed: (.*)"
|
||||
$extractedNumber = [regex]::match($line, $pattern).Groups[1].Value.Split(".")[0]
|
||||
$fail += $extractedNumber
|
||||
|
||||
# Extract total skipped by taking the substring between "Skipped: " and "."
|
||||
# The regex first extracts the string after the hardcoded "Skipped: " (i.e. "#.")
|
||||
# Then we tokenize by "." and retrieve the first token which is the number for skipped.
|
||||
$pattern = "Skipped: (.*)"
|
||||
$extractedNumber = [regex]::match($line, $pattern).Groups[1].Value.Split(".")[0]
|
||||
$skipped += $extractedNumber
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Test summary:" -ForegroundColor $Success
|
||||
Write-Host "Passed :`t$pass" -ForegroundColor $Success
|
||||
|
||||
if ($skipped -ne 0)
|
||||
{
|
||||
Write-Host "Skipped:`t$skipped" -ForegroundColor $Warning
|
||||
}
|
||||
|
||||
$color = $Success
|
||||
if ($fail -ne 0)
|
||||
{
|
||||
$color = $Err
|
||||
}
|
||||
Write-Host "Failed :`t$fail" -ForegroundColor $color
|
||||
Write-Host "----------------------" -ForegroundColor $Success
|
||||
Write-Host "Total :`t$($pass + $fail)" -ForegroundColor $Success
|
||||
if ($fail -ne 0)
|
||||
{
|
||||
Write-Host "Find failed test information at:" $TESTLOG -ForegroundColor $Err
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Congratulation! All of the tests passed!" -ForegroundColor $Success
|
||||
}
|
||||
}
|
||||
|
||||
Function RunTest($title, $testdir)
|
||||
{
|
||||
Write-Host "**********Running $title***********"
|
||||
|
||||
& $VSTEST $testdir >> $TESTLOG
|
||||
|
||||
if($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Run $title FAILED" -ForegroundColor $Err
|
||||
}
|
||||
}
|
||||
|
||||
Function TestProcess
|
||||
{
|
||||
Write-Host '**********Start To Run The Test*********'
|
||||
if (Test-Path $TESTLOG)
|
||||
{
|
||||
rm $TESTLOG
|
||||
}
|
||||
|
||||
$script:TEST_START_TIME = Get-Date
|
||||
cd $TESTDIR
|
||||
if ($TestType -eq 'All')
|
||||
{
|
||||
RunTest -title 'All Tests' -testdir $AllTestSuite
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host 'Error : TestType' -ForegroundColor $Err
|
||||
Cleanup
|
||||
exit
|
||||
}
|
||||
|
||||
& dotnet test $TESTProj -c $Configuration
|
||||
|
||||
Write-Host "Test Done" -ForegroundColor $Success
|
||||
$script:TEST_END_TIME = Get-Date
|
||||
TestSummary
|
||||
cd $ENLISTMENT_ROOT
|
||||
}
|
||||
|
||||
Function FxCopProcess
|
||||
{
|
||||
# TODO:
|
||||
}
|
||||
|
||||
# Main Process
|
||||
|
||||
if (! (Test-Path $LOGDIR))
|
||||
{
|
||||
mkdir $LOGDIR 1>$null
|
||||
}
|
||||
|
||||
if ($TestType -eq 'EnableSkipStrongName')
|
||||
{
|
||||
CleanBeforeScorch
|
||||
NugetRestoreSolution
|
||||
BuildProcess
|
||||
SkipStrongName
|
||||
Exit
|
||||
|
@ -318,18 +221,15 @@ if ($TestType -eq 'EnableSkipStrongName')
|
|||
elseif ($TestType -eq 'DisableSkipStrongName')
|
||||
{
|
||||
CleanBeforeScorch
|
||||
NugetRestoreSolution
|
||||
BuildProcess
|
||||
DisableSkipStrongName
|
||||
Exit
|
||||
}
|
||||
|
||||
CleanBeforeScorch
|
||||
NugetRestoreSolution
|
||||
BuildProcess
|
||||
SkipStrongName
|
||||
TestProcess
|
||||
FxCopProcess
|
||||
Cleanup
|
||||
|
||||
$buildTime = New-TimeSpan $script:BUILD_START_TIME -end $script:BUILD_END_TIME
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -195,7 +195,7 @@ namespace Microsoft.OpenApi.OData.Edm
|
|||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
return value.ToList();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -294,24 +294,47 @@ namespace Microsoft.OpenApi.OData.Edm
|
|||
{
|
||||
continue;
|
||||
}
|
||||
IEdmEntityType bindingEntityType = bindingType.AsEntity().EntityDefinition();
|
||||
|
||||
// 1. Search for corresponding navigation source path
|
||||
if (AppendBoundOperationOnNavigationSourcePath(edmOperation, isCollection, bindingEntityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var firstEntityType = bindingType.AsEntity().EntityDefinition();
|
||||
var allEntitiesForOperation= new List<IEdmEntityType>(){ firstEntityType };
|
||||
|
||||
// 2. Search for generated navigation property
|
||||
if (AppendBoundOperationOnNavigationPropertyPath(edmOperation, isCollection, bindingEntityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
System.Func<IEdmNavigationSource, bool> filter = (z) =>
|
||||
z.EntityType() != firstEntityType &&
|
||||
z.EntityType().FindAllBaseTypes().Contains(firstEntityType);
|
||||
|
||||
// 3. Search for derived
|
||||
if (AppendBoundOperationOnDerived(edmOperation, isCollection, bindingEntityType))
|
||||
//Search all EntitySets
|
||||
allEntitiesForOperation.AddRange(
|
||||
_model.EntityContainer.EntitySets()
|
||||
.Where(filter).Select(x => x.EntityType())
|
||||
);
|
||||
|
||||
//Search all singletons
|
||||
allEntitiesForOperation.AddRange(
|
||||
_model.EntityContainer.Singletons()
|
||||
.Where(filter).Select(x => x.EntityType())
|
||||
);
|
||||
|
||||
allEntitiesForOperation = allEntitiesForOperation.Distinct().ToList();
|
||||
|
||||
foreach (var bindingEntityType in allEntitiesForOperation)
|
||||
{
|
||||
continue;
|
||||
// 1. Search for corresponding navigation source path
|
||||
if (AppendBoundOperationOnNavigationSourcePath(edmOperation, isCollection, bindingEntityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. Search for generated navigation property
|
||||
if (AppendBoundOperationOnNavigationPropertyPath(edmOperation, isCollection, bindingEntityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. Search for derived
|
||||
if (AppendBoundOperationOnDerived(edmOperation, isCollection, bindingEntityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="$ProductRoot$\net461\Microsoft.OpenApi.OData.Reader.dll" target="lib\net461" />
|
||||
<file src="$ProductRoot$\net461\Microsoft.OpenApi.OData.Reader.pdb" target="lib\net461" />
|
||||
<file src="$ProductRoot$\net472\Microsoft.OpenApi.OData.Reader.dll" target="lib\net472" />
|
||||
<file src="$ProductRoot$\net472\Microsoft.OpenApi.OData.Reader.pdb" target="lib\net472" />
|
||||
<file src="$ProductRoot$\netstandard2.0\Microsoft.OpenApi.OData.Reader.dll" target="lib\netstandard2.0" />
|
||||
<file src="$ProductRoot$\netstandard2.0\Microsoft.OpenApi.OData.Reader.pdb" target="lib\netstandard2.0" />
|
||||
</files>
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="$ProductRoot$\net461\Microsoft.OpenApi.OData.Reader.dll" target="lib\net461" />
|
||||
<file src="$ProductRoot$\net461\Microsoft.OpenApi.OData.Reader.pdb" target="lib\net461" />
|
||||
<file src="$ProductRoot$\net472\Microsoft.OpenApi.OData.Reader.dll" target="lib\net472" />
|
||||
<file src="$ProductRoot$\net472\Microsoft.OpenApi.OData.Reader.pdb" target="lib\net472" />
|
||||
<file src="$ProductRoot$\netstandard2.0\Microsoft.OpenApi.OData.Reader.dll" target="lib\netstandard2.0" />
|
||||
<file src="$ProductRoot$\netstandard2.0\Microsoft.OpenApi.OData.Reader.pdb" target="lib\netstandard2.0" />
|
||||
</files>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
|
||||
<RootNamespace>Microsoft.OpenApi.OData</RootNamespace>
|
||||
<TargetFrameworks>net461; netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472; netstandard2.0</TargetFrameworks>
|
||||
<PackageId>Microsoft.OpenApi.OData.Reader</PackageId>
|
||||
<LangVersion Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">latest</LangVersion>
|
||||
<LangVersion Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">latest</LangVersion>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>OoasGui</RootNamespace>
|
||||
<AssemblyName>OoasGui</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
public static IEdmModel CompositeKeyModel { get; }
|
||||
|
||||
public static IEdmModel TripServiceModel { get; }
|
||||
public static IEdmModel ContractServiceModel { get; }
|
||||
|
||||
public static IEdmModel GraphBetaModel { get; }
|
||||
|
||||
|
@ -42,6 +43,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
BasicEdmModel = CreateEdmModel();
|
||||
CompositeKeyModel = CreateCompositeKeyModel();
|
||||
TripServiceModel = LoadEdmModel("TripService.OData.xml");
|
||||
ContractServiceModel = LoadEdmModel("Contract.OData.xml");
|
||||
GraphBetaModel = LoadEdmModel("Graph.Beta.OData.xml");
|
||||
MultipleSchemasEdmModel = LoadEdmModel("Multiple.Schema.OData.xml");
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.OpenApi.OData.Edm.Tests
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(paths);
|
||||
Assert.Equal(4399, paths.Count());
|
||||
Assert.Equal(4481, paths.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -66,5 +66,30 @@ namespace Microsoft.OpenApi.OData.Generator.Tests
|
|||
Assert.Contains("/CountryOrRegion/{Name}", paths.Keys);
|
||||
Assert.Contains("/Me", paths.Keys);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreatePathsReturnsForContractModelWithHierarhicalClass()
|
||||
{
|
||||
// Arrange
|
||||
IEdmModel model = EdmModelHelper.ContractServiceModel;
|
||||
OpenApiConvertSettings settings = new OpenApiConvertSettings
|
||||
{
|
||||
EnableKeyAsSegment = true,
|
||||
EnableUnqualifiedCall = true
|
||||
};
|
||||
ODataContext context = new ODataContext(model, settings);
|
||||
|
||||
// Act
|
||||
var paths = context.CreatePaths();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(paths);
|
||||
Assert.Equal(4, paths.Count);
|
||||
|
||||
Assert.Contains("/Accounts", paths.Keys);
|
||||
Assert.Contains("/Accounts/{id}", paths.Keys);
|
||||
Assert.Contains("/Accounts/{id}/Attachments()", paths.Keys);
|
||||
Assert.Contains("/Accounts/{id}/AttachmentsAdd", paths.Keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<AssemblyName>Microsoft.OpenApi.OData.Reader.Tests</AssemblyName>
|
||||
<RootNamespace>Microsoft.OpenApi.OData.Reader.Tests</RootNamespace>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\tool\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>true</DelaySign>
|
||||
|
@ -57,6 +57,7 @@
|
|||
<EmbeddedResource Include="Resources\TripService.OpenApi.V2.yaml" />
|
||||
<EmbeddedResource Include="Resources\YamlWriterTest.yaml.txt" />
|
||||
<EmbeddedResource Include="Resources\JsonWriterTest.json.txt" />
|
||||
<EmbeddedResource Include="Resources\Contract.OData.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -52,6 +52,42 @@ namespace Microsoft.OpenApi.OData.Operation.Tests
|
|||
Assert.Equal(new string[] { "204", "default" }, operation.Responses.Select(e => e.Key));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateOperationForEdmActionReturnsCorrectOperationHierarhicalClass()
|
||||
{
|
||||
// Arrange
|
||||
IEdmModel model = EdmModelHelper.ContractServiceModel;
|
||||
ODataContext context = new ODataContext(model);
|
||||
const string entitySetName = "Accounts";
|
||||
const string actionName = "AttachmentsAdd";
|
||||
IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet(entitySetName);
|
||||
Assert.NotNull(entitySet);
|
||||
|
||||
IEdmAction action = model.SchemaElements.OfType<IEdmAction>().First(f => f.Name == actionName);
|
||||
Assert.NotNull(action);
|
||||
ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataOperationSegment(action));
|
||||
|
||||
// Act
|
||||
var operation = _operationHandler.CreateOperation(context, path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(operation);
|
||||
Assert.Equal($"Invoke action {actionName}", operation.Summary);
|
||||
Assert.NotNull(operation.Tags);
|
||||
var tag = Assert.Single(operation.Tags);
|
||||
Assert.Equal($"{entitySetName}.Actions", tag.Name);
|
||||
|
||||
Assert.NotNull(operation.Parameters);
|
||||
Assert.Equal(1, operation.Parameters.Count);
|
||||
Assert.Equal(new string[] { "id" }, operation.Parameters.Select(p => p.Name));
|
||||
|
||||
Assert.NotNull(operation.RequestBody);
|
||||
Assert.Equal("Action parameters", operation.RequestBody.Description);
|
||||
|
||||
Assert.Equal(2, operation.Responses.Count);
|
||||
Assert.Equal(new string[] { "204", "default" }, operation.Responses.Select(e => e.Key));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
|
|
|
@ -52,6 +52,42 @@ namespace Microsoft.OpenApi.OData.Operation.Tests
|
|||
Assert.Equal(new string[] { "200", "default" }, operation.Responses.Select(e => e.Key));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateOperationForEdmFunctionReturnsCorrectOperationHierarhicalClass()
|
||||
{
|
||||
// Arrange
|
||||
IEdmModel model = EdmModelHelper.ContractServiceModel;
|
||||
ODataContext context = new ODataContext(model);
|
||||
const string entitySetName = "Accounts";
|
||||
const string functionName = "Attachments";
|
||||
IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet(entitySetName);
|
||||
Assert.NotNull(entitySet);
|
||||
|
||||
IEdmFunction function = model.SchemaElements.OfType<IEdmFunction>().First(f => f.Name == functionName);
|
||||
Assert.NotNull(function);
|
||||
|
||||
ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataOperationSegment(function));
|
||||
|
||||
// Act
|
||||
var operation = _operationHandler.CreateOperation(context, path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(operation);
|
||||
Assert.Equal($"Invoke function {functionName}", operation.Summary);
|
||||
Assert.NotNull(operation.Tags);
|
||||
var tag = Assert.Single(operation.Tags);
|
||||
Assert.Equal($"{entitySetName}.Functions", tag.Name);
|
||||
|
||||
Assert.NotNull(operation.Parameters);
|
||||
Assert.Equal(1, operation.Parameters.Count);
|
||||
Assert.Equal(new string[] { "id" }, operation.Parameters.Select(p => p.Name));
|
||||
|
||||
Assert.Null(operation.RequestBody);
|
||||
|
||||
Assert.Equal(2, operation.Responses.Count);
|
||||
Assert.Equal(new string[] { "200", "default" }, operation.Responses.Select(e => e.Key));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
|
||||
<edmx:DataServices>
|
||||
<Schema Namespace="Microsoft.OData.Service.Sample.Contract" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||
<EntityType Name="BaseEntityApiModel" Abstract="true">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Edm.Int64" Nullable="false" />
|
||||
<Property Name="name" Type="Edm.String" />
|
||||
<Property Name="description" Type="Edm.String" />
|
||||
</EntityType>
|
||||
<ComplexType Name="AttachmentApiModel" BaseType="System.Object">
|
||||
<Property Name="id" Type="Edm.Int64" />
|
||||
<Property Name="name" Type="Edm.String" />
|
||||
<Property Name="objId" Type="Edm.Int64" />
|
||||
<Property Name="mime" Type="Edm.String" />
|
||||
<Property Name="extension" Type="Edm.String" />
|
||||
<Property Name="size" Type="Edm.Int64" />
|
||||
<Property Name="type" Type="Edm.String" />
|
||||
<Property Name="date" Type="Edm.DateTimeOffset" />
|
||||
<Property Name="comment" Type="Edm.String" />
|
||||
</ComplexType>
|
||||
<EntityType Name="AccountApiModel" BaseType="Microsoft.OData.Service.Sample.Contract.BaseEntityApiModel">
|
||||
<Property Name="priority" Type="Edm.Int32" />
|
||||
<Property Name="numberFilial" Type="Edm.String" />
|
||||
<Property Name="numberCustomer" Type="Edm.String" />
|
||||
<Property Name="calculateVar" Type="Edm.Boolean" />
|
||||
<Property Name="lastCloseDate" Type="Edm.DateTimeOffset" />
|
||||
</EntityType>
|
||||
</Schema>
|
||||
<Schema Namespace="Default" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||
<Function Name="Attachments" IsBound="true">
|
||||
<Parameter Name="bindingParameter" Type="Microsoft.OData.Service.Sample.Contract.BaseEntityApiModel" />
|
||||
<ReturnType Type="Collection(Microsoft.OData.Service.Sample.Contract.AttachmentApiModel)" />
|
||||
</Function>
|
||||
<Action Name="AttachmentsAdd" IsBound="true">
|
||||
<Parameter Name="bindingParameter" Type="Microsoft.OData.Service.Sample.Contract.BaseEntityApiModel"/>
|
||||
<Parameter Name="comment" Type="Edm.String"/>
|
||||
<Parameter Name="file" Type="Edm.String"/>
|
||||
</Action>
|
||||
<EntityContainer Name="Container">
|
||||
<EntitySet Name="Accounts" EntityType="Microsoft.OData.Service.Sample.Contract.AccountApiModel">
|
||||
</EntitySet>
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:DataServices>
|
||||
</edmx:Edmx>
|
|
@ -2050,7 +2050,7 @@
|
|||
<Property Name="businessPhones" Type="Collection(Edm.String)" Nullable="false" Unicode="false" />
|
||||
<Property Name="city" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="companyName" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="country" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="countryOrRegion" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="department" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="deviceKeys" Type="Collection(microsoft.graph.deviceKey)" Nullable="false" />
|
||||
<Property Name="displayName" Type="Edm.String" Unicode="false" />
|
||||
|
@ -2724,7 +2724,7 @@
|
|||
<Property Name="assignedPlans" Type="Collection(microsoft.graph.assignedPlan)" Nullable="false" />
|
||||
<Property Name="businessPhones" Type="Collection(Edm.String)" Nullable="false" Unicode="false" />
|
||||
<Property Name="city" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="country" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="countryOrRegion" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="countryLetterCode" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="displayName" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="isMultipleDataLocationsForServicesEnabled" Type="Edm.Boolean" />
|
||||
|
@ -2918,7 +2918,7 @@
|
|||
<Property Name="businessPhones" Type="Collection(Edm.String)" Nullable="false" Unicode="false" />
|
||||
<Property Name="city" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="companyName" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="country" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="countryOrRegion" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="department" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="displayName" Type="Edm.String" Unicode="false" />
|
||||
<Property Name="givenName" Type="Edm.String" Unicode="false" />
|
||||
|
@ -20381,22 +20381,22 @@
|
|||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block auto fill." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlocked">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from using the Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from using the Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeCookiePolicy">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates which cookies to block in the Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates which cookies to block in the Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockDeveloperTools">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block developer tools in the Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block developer tools in the Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockSendingDoNotTrackHeader">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from sending the do not track header." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockExtensions">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block extensions in the Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block extensions in the Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockInPrivateBrowsing">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block InPrivate browsing on corporate networks, in the Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to block InPrivate browsing on corporate networks, in the Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockJavaScript">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from using JavaScript." />
|
||||
|
@ -20414,7 +20414,7 @@
|
|||
<Annotation Term="Org.OData.Core.V1.Description" String="Clear browsing data on exiting Microsoft Edge." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeAllowStartPagesModification">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Allow users to change Start pages on Edge. Use the EdgeHomepageUrls to specify the Start pages that the user would see by default when they open Edge." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Allow users to change Start pages on Microsoft Edge. Use the EdgeHomepageUrls to specify the Start pages that the user would see by default when they open Microsoft Edge." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeDisableFirstRunPage">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Block the Microsoft web page that opens on the first use of Microsoft Edge. This policy allows enterprises, like those enrolled in zero emissions configurations, to block this page." />
|
||||
|
@ -20633,7 +20633,7 @@
|
|||
<Annotation Term="Org.OData.Core.V1.Description" String="Enabling this policy hides the user tile from appearing in the start menu." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/startMenuLayoutEdgeAssetsXml">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="This policy setting allows you to import Edge assets to be used with startMenuLayoutXml policy. Start layout can contain secondary tile from Edge app which looks for Edge local asset file. Edge local asset would not exist and cause Edge secondary tile to appear empty in this case. This policy only gets applied when startMenuLayoutXml policy is modified. The value should be a UTF-8 Base64 encoded byte array." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="This policy setting allows you to import Microsoft Edge assets to be used with startMenuLayoutXml policy. Start layout can contain secondary tile from Microsoft Edge app which looks for Microsoft Edge local asset file. Microsoft Edge local asset would not exist and cause Microsoft Edge secondary tile to appear empty in this case. This policy only gets applied when startMenuLayoutXml policy is modified. The value should be a UTF-8 Base64 encoded byte array." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/startMenuLayoutXml">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Allows admins to override the default Start menu layout and prevents the user from changing it. The layout is modified by specifying an XML file based on a layout modification schema. XML needs to be in a UTF8 encoded byte array format." />
|
||||
|
@ -20792,7 +20792,7 @@
|
|||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from using the search suggestions in the address bar." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockSendingIntranetTrafficToInternetExplorer">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from sending Intranet traffic to Internet Explorer from Edge." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Block the user from sending Intranet traffic to Internet Explorer from Microsoft Edge." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeRequireSmartScreen">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to Require the user to use the smart screen filter." />
|
||||
|
@ -20801,16 +20801,16 @@
|
|||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates the enterprise mode site list location. Could be a local file, local network or http location." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeFirstRunUrl">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="The first run URL for when Edge browser is opened for the first time." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="The first run URL for when Microsoft Edge browser is opened for the first time." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeSearchEngine">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Allows IT admins to set a default search engine for MDM-Controlled devices. Users can override this and change their default search engine provided the AllowSearchEngineCustomization policy is not set." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeHomepageUrls">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="The list of URLs for homepages shodwn on MDM-enrolled devices on Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="The list of URLs for homepages shodwn on MDM-enrolled devices on Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/edgeBlockAccessToAboutFlags">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to prevent access to about flags on Edge browser." />
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not to prevent access to about flags on Microsoft Edge browser." />
|
||||
</Annotations>
|
||||
<Annotations Target="microsoft.graph.windows10GeneralConfiguration/smartScreenBlockPromptOverride">
|
||||
<Annotation Term="Org.OData.Core.V1.Description" String="Indicates whether or not users can override SmartScreen Filter warnings about potentially malicious websites." />
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@
|
|||
<!-- Setup the EnlistmentRoot, without the last '\' -->
|
||||
<EnlistmentRoot Condition="'$(EnlistmentRoot)'==''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))</EnlistmentRoot>
|
||||
|
||||
<EnlistToolPath Condition=" '$(EnlistToolPath)'=='' ">$(EnlistmentRoot)\tool</EnlistToolPath>
|
||||
<EnlistToolPath Condition="'$(EnlistToolPath)'==''">$(EnlistmentRoot)\tool</EnlistToolPath>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="WebStack.versions.settings.targets" />
|
||||
<Import Project="versioning.props" />
|
||||
<PropertyGroup>
|
||||
<VersionNugetNightlyBuild>$([System.DateTime]::Now.ToString("yyyyMMddHHmm"))</VersionNugetNightlyBuild>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!-- Set the version number: major, minor, build and release (i.e. alpha, beta or blank for RTM)-->
|
||||
<PropertyGroup>
|
||||
<VersionMajor Condition="'$(VersionMajor)' == ''">1</VersionMajor>
|
||||
<VersionMinor Condition="'$(VersionMinor)' == ''">0</VersionMinor>
|
||||
<VersionBuild Condition="'$(VersionBuild)' == ''">1</VersionBuild>
|
||||
<VersionRelease Condition="'$(VersionRelease)' == ''"></VersionRelease>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- For NuGet Package Dependencies -->
|
||||
<PropertyGroup>
|
||||
<OpenApiCorePackageDependency>[1.1.4, 2.0.0)</OpenApiCorePackageDependency>
|
||||
<ODataEdmPackageDependency>[7.6.1, 8.0.0)</ODataEdmPackageDependency>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
Revision number is a date code. Note that this only work for 6 years before the year part (year minus 2017)
|
||||
overflows the Int16. The system convert below will throw errors when this happens.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2017</VersionStartYear>
|
||||
<VersionDateCode>$([System.Convert]::ToInt16('$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))'))</VersionDateCode>
|
||||
<VersionRevision Condition="'$(VersionRevision)' == '' OR '$(VersionRevision)' == '0'">$([System.Convert]::ToString($(VersionDateCode)))</VersionRevision>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Product Version -->
|
||||
<PropertyGroup>
|
||||
<VersionFullSemantic>$(VersionMajor).$(VersionMinor).$(VersionBuild)</VersionFullSemantic>
|
||||
<VersionFull>$(VersionFullSemantic).$(VersionRevision)</VersionFull>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- For NuGet Packages -->
|
||||
<PropertyGroup>
|
||||
<VersionNuGetSemantic>$(VersionFullSemantic)</VersionNuGetSemantic>
|
||||
<VersionNuGetSemantic Condition="'$(VersionRelease)'!=''">$(VersionFullSemantic)-$(VersionRelease)</VersionNuGetSemantic>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
==================================================================================================
|
||||
Property Groups to define version information. Do not modify this section.
|
||||
================================================================================================== -->
|
||||
<PropertyGroup>
|
||||
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == '' AND '$(MSBuildProjectExtension)' == '.csproj'">true</VersionFileGenerationEnabled>
|
||||
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == ''">false</VersionFileGenerationEnabled>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2017</VersionStartYear>
|
||||
<VersionMajor Condition="'$(VersionMajor)' == '0'">INVALID_VersionMajor</VersionMajor>
|
||||
<VersionMajor Condition="'$(VersionMajor)' == ''">INVALID_VersionMajor</VersionMajor>
|
||||
<VersionMinor Condition="'$(VersionMinor)' == ''">INVALID_VersionMinor</VersionMinor>
|
||||
<VersionBuild Condition="'$(VersionBuild)' == ''">INVALID_VersionBuild</VersionBuild>
|
||||
<VersionRevision Condition="'$(VersionRevision)' == '' OR '$(VersionRevision)' == '0'">$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))</VersionRevision>
|
||||
<VersionRevision Condition="'$(VersionRevision)' == ''">0</VersionRevision>
|
||||
<VersionRelease Condition="'$(VersionRelease)' == ''"></VersionRelease>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</AssemblyVersion>
|
||||
<AssemblyFileVersion>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</AssemblyFileVersion>
|
||||
<AssemblyInfoVersion>$(AssemblyFileVersion)</AssemblyInfoVersion>
|
||||
<AssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).version.cs</AssemblyVersionFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
|
||||
<Compile Include="$(AssemblyVersionFile)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Clean Include="$(AssemblyVersionFile)" Condition="'$(MSBuildProjectExtension)' == '.csproj'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyCompany>Microsoft Corporation.</AssemblyCompany>
|
||||
<AssemblyCopyright>© Microsoft Corporation. All rights reserved.</AssemblyCopyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- GenerateVersionFile target: generates assembly attributes into a source file that is included -->
|
||||
<Target Name="GenerateVersionFileCore" Condition="'$(ShouldGenerateVersionFile)' == 'true'">
|
||||
<ItemGroup>
|
||||
<LinesToWrite Include="// $(SourceFileCopyright)" Condition="'$(SourceFileCopyright)' != ''"/>
|
||||
<LinesToWrite Include="// <auto-generated>" />
|
||||
<LinesToWrite Include="// This code was generated by a tool." />
|
||||
<LinesToWrite Include="// </auto-generated>" />
|
||||
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCompany("$(AssemblyCompany)")]" Condition="'$(AssemblyCompany)' != ''"/>
|
||||
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCopyright("$(AssemblyCopyright)")]" Condition="'$(AssemblyCopyright)' != ''"/>
|
||||
<LinesToWrite Include="[assembly: System.Reflection.AssemblyVersion("$(AssemblyVersion)")]" Condition="'$(AssemblyVersion)' != ''"/>
|
||||
<LinesToWrite Include="[assembly: System.Reflection.AssemblyFileVersion("$(AssemblyFileVersion)")]" Condition="'$(AssemblyFileVersion)' != ''"/>
|
||||
<LinesToWrite Include="[assembly: System.Reflection.AssemblyInformationalVersion("$(AssemblyInfoVersion)")]" Condition="'$(AssemblyInfoVersion)' != ''" />
|
||||
<LinesToWrite Include="[assembly: System.Resources.SatelliteContractVersionAttribute("$(SatelliteContractVersion)")]" Condition="'$(SatelliteContractVersion)' != ''"/>
|
||||
<LinesToWrite Include="@(VersionFileAttribute)" Condition="'@(VersionFileAttribute)' != ''" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile File="$(AssemblyVersionFile)" Lines="@(LinesToWrite)" Overwrite="true" Encoding="Unicode"/>
|
||||
<Message Text="Assembly Version File: $(AssemblyVersionFile)" />
|
||||
</Target>
|
||||
|
||||
<!-- ShouldGenerateVersionFile target: determines whether a version needs to be generated. -->
|
||||
<Target Name="ShouldGenerateVersionFile">
|
||||
<ReadLinesFromFile File="$(AssemblyVersionFile)" Condition="Exists('$(AssemblyVersionFile)')">
|
||||
<Output ItemName="VersionText" TaskParameter="Lines"/>
|
||||
</ReadLinesFromFile>
|
||||
<PropertyGroup>
|
||||
<VersionText>@(VersionText)</VersionText>
|
||||
<ShouldGenerateVersionFile>!$(VersionText.Contains('$(AssemblyFileVersion)'))</ShouldGenerateVersionFile>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="ValidateVersionValues">
|
||||
<!-- Throw if any of the version values is not int16 -->
|
||||
<PropertyGroup>
|
||||
<VersionMajor>$([System.Convert]::ToInt16('$(VersionMajor)'))</VersionMajor>
|
||||
<VersionMinor>$([System.Convert]::ToInt16('$(VersionMinor)'))</VersionMinor>
|
||||
<VersionBuild>$([System.Convert]::ToUInt16('$(VersionBuild)'))</VersionBuild>
|
||||
<VersionRevision>$([System.Convert]::ToInt16('$(VersionRevision)'))</VersionRevision>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<PropertyGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
|
||||
<BeforeCompileDependsOn>ValidateVersionValues;ShouldGenerateVersionFile;GenerateVersionFileCore</BeforeCompileDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="BeforeCompile" DependsOnTargets="$(BeforeCompileDependsOn)" />
|
||||
</Project>
|
|
@ -25,11 +25,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
Revision number is a date code. Note that this only work for 6 years before the year part (year minus 2017)
|
||||
Revision number is a date code. Note that this only work for 6 years before the year part (year minus 2020)
|
||||
overflows the Int16. The system convert below will throw errors when this happens.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2019</VersionStartYear>
|
||||
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2020</VersionStartYear>
|
||||
|
||||
<!-- { Now.Year - 2019 + 1}{MM}{DD} -->
|
||||
<VersionDateCode>$([System.Convert]::ToInt16('$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))'))</VersionDateCode>
|
||||
|
|
Loading…
Reference in a new issue