|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Framework.BuildException;
using Microsoft.Build.Internal;
namespace Microsoft.Build.BackEnd
{
internal static class SerializationContractInitializer
{
public static void Initialize()
{
RegisterExceptions();
// reserved for future usage - BuildEventArgs, etc.
}
private static void RegisterExceptions()
{
// Any exception not contained int this list will be transferred as a GenericBuildTransferredException
BuildExceptionSerializationHelper.InitializeSerializationContract(
new(typeof(GenericBuildTransferredException), (msg, inner) => new GenericBuildTransferredException(msg, inner)),
new(typeof(SdkResolverException), (msg, inner) => new SdkResolverException(msg, inner)),
new(typeof(SdkResolverServiceException), (msg, inner) => new SdkResolverServiceException(msg, inner)),
new(typeof(BuildAbortedException), BuildAbortedException.CreateFromRemote),
new(typeof(CircularDependencyException), (msg, inner) => new CircularDependencyException(msg, inner)),
new(typeof(InternalLoggerException), (msg, inner) => new InternalLoggerException(msg, inner)),
new(typeof(InvalidProjectFileException), (msg, inner) => new InvalidProjectFileException(msg, inner)),
new(typeof(InvalidToolsetDefinitionException), (msg, inner) => new InvalidToolsetDefinitionException(msg, inner)),
new(typeof(ProjectCache.ProjectCacheException), (msg, inner) => new ProjectCache.ProjectCacheException(msg, inner)),
#pragma warning disable CS0618 // Type or member is obsolete
// convert Exception type from Experimental namespace to the current namespace
new(typeof(Experimental.ProjectCache.ProjectCacheException), (msg, inner) => new ProjectCache.ProjectCacheException(msg, inner)),
#pragma warning restore CS0618 // Type or member is obsolete
new(typeof(InternalErrorException), InternalErrorException.CreateFromRemote),
new(typeof(LoggerException), (msg, inner) => new LoggerException(msg, inner)),
new(typeof(NodeFailedToLaunchException), (msg, inner) => new NodeFailedToLaunchException(msg, inner)),
new(typeof(SchedulerCircularDependencyException), (msg, inner) => new SchedulerCircularDependencyException(msg, inner)),
new(typeof(RegistryException), (msg, inner) => new RegistryException(msg, inner)),
new(typeof(HostObjectException), (msg, inner) => new HostObjectException(msg, inner)),
new(typeof(UnbuildableProjectTypeException), (msg, inner) => new UnbuildableProjectTypeException(msg, inner)),
new(typeof(CriticalTaskException), (msg, inner) => new CriticalTaskException(msg, inner)));
}
}
}
|