Build s/ latest MSBuild / Visual Studio installed

- #12
- find `MSBuild.exe` and `Microsoft.Build.Tasks.*.dll` for v14.0 before v12.0
- avoid code analysis warnings (about `static`) the latest compiler detects
- correct suppression check ids
- suppress MW1201 FxCop rule for `UriExtensions.TryReadQueryAs()` to avoid #16

nits:
- add solution for tools
- ignore .vs directory
This commit is contained in:
Doug Bunting 2016-08-08 21:20:21 -07:00
Родитель 1a987f82d6
Коммит ddf07644e0
11 изменённых файлов: 45 добавлений и 15 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -15,4 +15,5 @@ _[Ss]cripts
*.vsp
*.psess
*.orig
*.sln.ide
*.sln.ide
.vs/

22
Tools.sln Normal file
Просмотреть файл

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Web.FxCop", "tools\src\Microsoft.Web.FxCop\Microsoft.Web.FxCop.csproj", "{F439D4E6-3FAC-4C30-9585-6D258133A2BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F439D4E6-3FAC-4C30-9585-6D258133A2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F439D4E6-3FAC-4C30-9585-6D258133A2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F439D4E6-3FAC-4C30-9585-6D258133A2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F439D4E6-3FAC-4C30-9585-6D258133A2BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -10,7 +10,9 @@ mkdir bin
REM Find the most recent 32bit MSBuild.exe on the system. Require v12.0 (installed with VS2013) or later since .NET 4.0
REM is not supported. Also handle x86 operating systems, where %ProgramFiles(x86)% is not defined. Always quote the
REM %MSBuild% value when setting the variable and never quote %MSBuild% references.
set MSBuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
set MSBuild="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %MSBuild% @set MSBuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
if "%1" == "" goto BuildDefaults

Просмотреть файл

@ -39,7 +39,7 @@ namespace System.Threading.Tasks
/// Attempts to get the result value for the given task. If the task ran to completion, then
/// it will return true and set the result value; otherwise, it will return false.
/// </summary>
[SuppressMessage("Microsoft.Web.FxCop", "MW1201:DoNotCallProblematicMethodsOnTask", Justification = "The usages here are deemed safe, and provide the implementations that this rule relies upon.")]
[SuppressMessage("Microsoft.Web.FxCop", "MW1201", Justification = "The usages here are deemed safe, and provide the implementations that this rule relies upon.")]
internal static bool TryGetResult<TResult>(this Task<TResult> task, out TResult result)
{
if (task.Status == TaskStatus.RanToCompletion)

Просмотреть файл

@ -11,7 +11,7 @@ namespace System.Net.Http
/// Defines an exception type for signalling that a request's media type was not supported.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "This type is not meant to be serialized")]
[SuppressMessage("Microsoft.Usage", "CA2240:Implement ISerializable correctly", Justification = "This type is not meant to be serialized")]
[SuppressMessage("Microsoft.Usage", "CA2240:ImplementISerializableCorrectly", Justification = "This type is not meant to be serialized")]
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "UnsupportedMediaTypeException is only used to propagate the media type back to the server layer")]
public class UnsupportedMediaTypeException : Exception
{

Просмотреть файл

@ -70,6 +70,7 @@ namespace System.Net.Http
/// <param name="value">An object to be initialized with this instance or null if the conversion cannot be performed.</param>
/// <returns><c>true</c> if the query component can be read as the specified type; otherwise <c>false</c>.</returns>
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "This is the non-generic version.")]
[SuppressMessage("Microsoft.Web.FxCop", "MW1201", Justification = "Avoid an NRE in our custom rule (see AspNetWebStack#16). Occurs while handling JTokenReader.Dispose().")]
public static bool TryReadQueryAs(this Uri address, Type type, out object value)
{
if (address == null)

Просмотреть файл

@ -149,7 +149,7 @@ namespace System.Web.Http.SelfHost.Channels
byte[] buffer = stream.ToArray(out num);
ArraySegment<byte> messageData = new ArraySegment<byte>(buffer, 0, num - messageOffset);
// ToArray transfers full ownership of buffer to us, meaning we are responsible for returning it to BufferManager.
// ToArray transfers full ownership of buffer to us, meaning we are responsible for returning it to BufferManager.
// But we must delay that release until WCF has finished with the buffer we are returning from this method.
HttpMessageEncodingRequestContext requestContext = HttpMessageEncodingRequestContext.GetContextFromMessage(message);
Contract.Assert(requestContext != null);
@ -188,7 +188,10 @@ namespace System.Web.Http.SelfHost.Channels
}
}
private async Task WriteMessageCore(HttpResponseMessage response, Stream stream, HttpMessageEncodingRequestContext requestContext)
private static async Task WriteMessageCore(
HttpResponseMessage response,
Stream stream,
HttpMessageEncodingRequestContext requestContext)
{
try
{

Просмотреть файл

@ -37,7 +37,7 @@ namespace System.Web.Http.Validation.Validators
return ConvertResults(validatable.Validate(validationContext));
}
private IEnumerable<ModelValidationResult> ConvertResults(IEnumerable<ValidationResult> results)
private static IEnumerable<ModelValidationResult> ConvertResults(IEnumerable<ValidationResult> results)
{
foreach (ValidationResult result in results)
{

Просмотреть файл

@ -4,8 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Security.Principal;
using System.Threading;
using System.Web.Mvc.Filters;
using System.Web.Mvc.Routing;
@ -18,6 +16,7 @@ namespace System.Web.Mvc.Async
private static readonly object _invokeActionMethodTag = new object();
private static readonly object _invokeActionMethodWithFiltersTag = new object();
[SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", Justification = "FxCop unable to handle what new compiler generates.")]
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Refactoring to reduce coupling not currently justified.")]
public virtual IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)
{

Просмотреть файл

@ -42,7 +42,7 @@ namespace System.Web.Mvc
return ConvertResults(validatable.Validate(validationContext));
}
private IEnumerable<ModelValidationResult> ConvertResults(IEnumerable<ValidationResult> results)
private static IEnumerable<ModelValidationResult> ConvertResults(IEnumerable<ValidationResult> results)
{
foreach (ValidationResult result in results)
{

Просмотреть файл

@ -1,9 +1,11 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\tools\WebStack.tasks.targets"/>
<PropertyGroup>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '12.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' != '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskFactoryAssemblyFile>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' == '12.0' ">Microsoft.Build.Tasks.v12.0</BuildTaskAssemblyReference>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">Microsoft.Build.Tasks.Core</BuildTaskAssemblyReference>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' != '' ">Microsoft.Build.Tasks.v$(MSBuildToolsVersion)</BuildTaskAssemblyReference>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' ">Microsoft.Build.Tasks.v4.0</BuildTaskAssemblyReference>
</PropertyGroup>
<UsingTask TaskName="NuGetPack" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
@ -88,15 +90,15 @@
string extension = sourceFile.GetMetadata("Extension");
string destinationDirectory = Path.Combine(OutputPath, relativeDirectory);
string destinationFilePath = Path.Combine(destinationDirectory, fileName + extension);
DirectoryInfo dir = new DirectoryInfo(destinationDirectory);
if (!dir.Exists)
{
dir.Create();
}
string content = File.ReadAllText(sourceFilePath);
// Do the transformation for source code only
if (extension.StartsWith(".cs") || extension.StartsWith(".vb"))
{