Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatting fix according to IDE0055 #10922

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void SetById()
</Project>
";

using ProjectRootElementFromString projectRootElementFromString = new(content);
using ProjectRootElementFromString projectRootElementFromString = new(content);
ProjectRootElement project = projectRootElementFromString.Project;
ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children);

Expand All @@ -192,7 +192,7 @@ public void SetByIdWhereItAlreadyExists()
</Project>
";

using ProjectRootElementFromString projectRootElementFromString = new(content);
using ProjectRootElementFromString projectRootElementFromString = new(content);
ProjectRootElement project = projectRootElementFromString.Project;
ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children);

Expand All @@ -211,7 +211,7 @@ private static ProjectExtensionsElement GetEmptyProjectExtensions()
</Project>
";

using ProjectRootElementFromString projectRootElementFromString = new(content);
using ProjectRootElementFromString projectRootElementFromString = new(content);
ProjectRootElement project = projectRootElementFromString.Project;
ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children);
return extensions;
Expand Down
7 changes: 6 additions & 1 deletion src/Build.UnitTests/BackEnd/BinaryTranslator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ public static IEnumerable<object[]> GetBuildExceptionsAsTestData()
[MemberData(nameof(GetBuildExceptionsAsTestData))]
public void TestSerializationOfBuildExceptions(Type exceptionType)
{
Exception e = (Exception)Activator.CreateInstance(exceptionType, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance, null, new object[]{"msg", new GenericBuildTransferredException() }, System.Globalization.CultureInfo.CurrentCulture);
Exception e = (Exception)Activator.CreateInstance(
exceptionType,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance,
null,
new object[] { "msg", new GenericBuildTransferredException() },
System.Globalization.CultureInfo.CurrentCulture);
Exception remote;
try
{
Expand Down
9 changes: 5 additions & 4 deletions src/Build.UnitTests/BackEnd/EventSourceTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
}
}

public override void Dispose() {
if (_eventSources != null)
public override void Dispose()
{
if (_eventSources != null)
{
DisableEvents(_eventSources);
}

base.Dispose();
}

Expand All @@ -79,7 +80,7 @@ internal List<EventWrittenEventArgs> GetEvents()
resultList = new List<EventWrittenEventArgs>(emittedEvents);
emittedEvents.Clear();
}

return resultList;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/IntrinsicTask_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,8 @@ public void ItemGroupWithConditionOnGroup()
logger.AssertLogDoesntContain("[a1][b1]");
logger.ClearLog();

content = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
content = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<ItemGroup Condition='true'>
<i1 Include='a1'/>
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BackEnd/MockHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public IBuildComponent GetComponent(BuildComponentType type)
}

public TComponent GetComponent<TComponent>(BuildComponentType type) where TComponent : IBuildComponent
=> (TComponent) GetComponent(type);
=> (TComponent)GetComponent(type);

/// <summary>
/// Register a new build component factory with the host.
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/TargetBuilder_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ public void TestAfterTargetsEmpty()

TargetBuilder builder = (TargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder);
IConfigCache cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);
(string name, TargetBuiltReason reason)[] target = { ("Build", TargetBuiltReason.None) }
; BuildRequestEntry entry = new BuildRequestEntry(CreateNewBuildRequest(1, target), cache[1]);
(string name, TargetBuiltReason reason)[] target = { ("Build", TargetBuiltReason.None) };
BuildRequestEntry entry = new BuildRequestEntry(CreateNewBuildRequest(1, target), cache[1]);

BuildResult result = builder.BuildTargets(GetProjectLoggingContext(entry), entry, this, target, CreateStandardLookup(project), CancellationToken.None).Result;
AssertTaskExecutionOrder(new string[] { "BuildTask" });
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BackEnd/TaskHost_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void TestLogExtendedCustomErrorNotSerializableMP()
_mockHost.BuildParameters.MaxNodeCount = 4;

// Log the custom event args. (Pretend that the task actually did this.)
_taskHost.LogErrorEvent(new ExtendedBuildErrorEventArgs("testExtCustomBuildError", null, null, null, 0, 0, 0, 0,"ext err message", null, null));
_taskHost.LogErrorEvent(new ExtendedBuildErrorEventArgs("testExtCustomBuildError", null, null, null, 0, 0, 0, 0, "ext err message", null, null));

// Make sure our custom logger received the actual custom event and not some fake.
Assert.True(_customLogger.LastError is ExtendedBuildErrorEventArgs); // "Expected custom build Event"
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BinaryLogger_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void UnusedEnvironmentVariablesDoNotAppearInBinaryLog()
</Project>";
TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);

RunnerUtilities.ExecMSBuild($"{projectFile.Path} -bl:{_logFile}", out bool success);
success.ShouldBeTrue();

Expand Down Expand Up @@ -411,7 +411,7 @@ private void AssemblyLoadsDuringTaskRun(string additionalEventText)
""";
TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);

env.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1");
RunnerUtilities.ExecMSBuild($"{projectFile.Path} -nr:False -bl:{_logFile} -flp1:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile2.log")};verbosity=normal", out bool success);
success.ShouldBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BuildEventArgsDataEnumeration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void SampleFilteredItemsEnumeration()
results = args.EnumerateItemsOfType("Key2").ToList();

results.Count.ShouldBe(2);

results[0].Type.ShouldBe("Key2");
results[0].EvaluatedInclude.ShouldBe("spec");
metadata = results[0].EnumerateMetadata().ToList();
Expand Down
12 changes: 6 additions & 6 deletions src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ public void RoundtripExtendedWarningEventArgs_SerializedAsWarning(bool withOptio
"SenderName",
DateTime.Parse("9/1/2021 12:02:07 PM"),
withOptionalData ? new object[] { "argument0" } : null)
{
ExtendedData = withOptionalData ? "{'long-json':'mostly-strings'}" : null,
ExtendedMetadata = withOptionalData ? new Dictionary<string, string> { { "m1", "v1" }, { "m2", "v2" } } : null,
BuildEventContext = withOptionalData ? new BuildEventContext(1, 2, 3, 4, 5, 6, 7) : null,
};
{
ExtendedData = withOptionalData ? "{'long-json':'mostly-strings'}" : null,
ExtendedMetadata = withOptionalData ? new Dictionary<string, string> { { "m1", "v1" }, { "m2", "v2" } } : null,
BuildEventContext = withOptionalData ? new BuildEventContext(1, 2, 3, 4, 5, 6, 7) : null,
};

Roundtrip(args,
e => e.Code,
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public void ForwardCompatibleRead_HandleUnknownEvent()
memoryStream.Position = 0;

// some future type that is not known in current version
BinaryLogRecordKind unknownType = (BinaryLogRecordKind) Enum.GetValues(typeof(BinaryLogRecordKind)).Cast<BinaryLogRecordKind>().Select(e => (int)e).Max() + 2;
BinaryLogRecordKind unknownType = (BinaryLogRecordKind)Enum.GetValues(typeof(BinaryLogRecordKind)).Cast<BinaryLogRecordKind>().Select(e => (int)e).Max() + 2;
Microsoft.Build.Shared.BinaryWriterExtensions.Write7BitEncodedInt(binaryWriter, (int)unknownType);
memoryStream.Position.ShouldBe(eventSizePos, "The event type need to be overwritten in place - without overwriting any bytes after the type info");
memoryStream.Position = positionAfterFirstEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Definition/ProjectHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static class ProjectHelpers
/// <returns>A project instance.</returns>
internal static ProjectInstance CreateEmptyProjectInstance()
{
using ProjectFromString projectFromString = new( @"<Project>
using ProjectFromString projectFromString = new(@"<Project>
<Target Name='foo'/>
</Project>");
Project project = projectFromString.Project;
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/ExpanderFunction_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void TryConvertToLongGivenDoubleWithLongMaxValueFramework()
{
const long longMaxValue = long.MaxValue;
bool result = Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong((double)longMaxValue, out long actual);

// Because of loss of precision, long.MaxValue will not 'round trip' from long to double to long.
result.ShouldBeFalse();
actual.ShouldBe(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void MSBuildAddIntegerGreaterThanMax()
</PropertyGroup>
</Project>";

string expected = ((long.MaxValue +1D) + 1).ToString();
string expected = ((long.MaxValue + 1D) + 1).ToString();

using TestEnvironment env = TestEnvironment.Create();

Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/Preprocessor_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public void ProjectMetadata()
</ItemGroup>
</Project>");

using ProjectRootElementFromString projectRootElementFromString = new(content);
using ProjectRootElementFromString projectRootElementFromString = new(content);
ProjectRootElement xml = projectRootElementFromString.Project;
Project project = new Project(xml);

Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/BuildManager/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,15 @@ public ProjectInstance GetProjectInstanceForBuild(Project project)
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if StartBuild has not been called or if EndBuild has been called.</exception>
public BuildSubmission PendBuildRequest(BuildRequestData requestData)
=> (BuildSubmission) PendBuildRequest<BuildRequestData, BuildResult>(requestData);
=> (BuildSubmission)PendBuildRequest<BuildRequestData, BuildResult>(requestData);

/// <summary>
/// Submits a graph build request to the current build but does not start it immediately. Allows the user to
/// perform asynchronous execution or access the submission ID prior to executing the request.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if StartBuild has not been called or if EndBuild has been called.</exception>
public GraphBuildSubmission PendBuildRequest(GraphBuildRequestData requestData)
=> (GraphBuildSubmission) PendBuildRequest<GraphBuildRequestData, GraphBuildResult>(requestData);
=> (GraphBuildSubmission)PendBuildRequest<GraphBuildRequestData, GraphBuildResult>(requestData);

/// <summary>
/// Submits a build request to the current build but does not start it immediately. Allows the user to
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/Caching/ResultsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private static bool AreBuildResultFlagsCompatible(BuildRequest buildRequest, Bui
}

BuildRequestDataFlags buildRequestDataFlags = buildRequest.BuildRequestDataFlags;
BuildRequestDataFlags buildResultDataFlags = (BuildRequestDataFlags) buildResult.BuildRequestDataFlags;
BuildRequestDataFlags buildResultDataFlags = (BuildRequestDataFlags)buildResult.BuildRequestDataFlags;

if ((buildRequestDataFlags & FlagsAffectingBuildResults) != (buildResultDataFlags & FlagsAffectingBuildResults))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public IDictionary<int, ISet<string>> WarningsAsMessagesByProject
/// This property is ignored by this event sink and relies on the receiver to keep track of whether or not any errors have been logged.
/// </summary>
public ISet<int> BuildSubmissionIdsThatHaveLoggedErrors { get; } = null;

#endregion
#region IBuildEventSink Methods

Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/Logging/EventSourceSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void Consume(BuildEventArgs buildEvent)
RaiseEvent(buildMessageEvent, args => MessageRaised?.Invoke(null, args), RaiseAnyEvent);
break;
case TaskStartedEventArgs taskStartedEvent:
ArgsHandler<TaskStartedEventArgs> taskStartedFollowUp = args => RaiseEvent(args, args=> StatusEventRaised?.Invoke(null, args), RaiseAnyEvent);
ArgsHandler<TaskStartedEventArgs> taskStartedFollowUp = args => RaiseEvent(args, args => StatusEventRaised?.Invoke(null, args), RaiseAnyEvent);
RaiseEvent(taskStartedEvent, args => TaskStarted?.Invoke(null, args), taskStartedFollowUp);
break;
case TaskFinishedEventArgs taskFinishedEvent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void LogBuildFinished(bool success)
/// <inheritdoc />
public void LogBuildCanceled()
{
string message = ResourceUtilities.GetResourceString("AbortingBuild");
string message = ResourceUtilities.GetResourceString("AbortingBuild");
BuildCanceledEventArgs buildEvent = new BuildCanceledEventArgs(message);

ProcessLoggingEvent(buildEvent);
Expand Down
34 changes: 17 additions & 17 deletions src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,23 @@ await pluginInstance.BeginBuildAsync(
}

#if FEATURE_REPORTFILEACCESSES
FileAccessManager.HandlerRegistration? handlerRegistration = null;
if (_componentHost.BuildParameters.ReportFileAccesses)
{
handlerRegistration = _fileAccessManager.RegisterHandlers(
(buildRequest, fileAccessData) =>
{
// TODO: Filter out projects which do not configure this plugin
FileAccessContext fileAccessContext = GetFileAccessContext(buildRequest);
pluginInstance.HandleFileAccess(fileAccessContext, fileAccessData);
},
(buildRequest, processData) =>
{
// TODO: Filter out projects which do not configure this plugin
FileAccessContext fileAccessContext = GetFileAccessContext(buildRequest);
pluginInstance.HandleProcess(fileAccessContext, processData);
});
}
FileAccessManager.HandlerRegistration? handlerRegistration = null;
if (_componentHost.BuildParameters.ReportFileAccesses)
{
handlerRegistration = _fileAccessManager.RegisterHandlers(
(buildRequest, fileAccessData) =>
{
// TODO: Filter out projects which do not configure this plugin
FileAccessContext fileAccessContext = GetFileAccessContext(buildRequest);
pluginInstance.HandleFileAccess(fileAccessContext, fileAccessData);
},
(buildRequest, processData) =>
{
// TODO: Filter out projects which do not configure this plugin
FileAccessContext fileAccessContext = GetFileAccessContext(buildRequest);
pluginInstance.HandleProcess(fileAccessContext, processData);
});
}
#endif

return new ProjectCachePlugin(
Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void Reacquire()
}
}

#endregion
#endregion

#region IBuildEngine Members

Expand Down Expand Up @@ -957,7 +957,7 @@ public void ReportFileAccess(FileAccessData fileAccessData)

public EngineServices EngineServices { get; }

#endregion
#endregion

/// <summary>
/// Called by the internal MSBuild task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal virtual IReadOnlyList<SdkResolver> LoadAllResolvers(ElementLocation loc
new List<SdkResolver> { new DefaultSdkResolver() }
: new List<SdkResolver>();
try
{
{
var potentialResolvers = FindPotentialSdkResolvers(
Path.Combine(BuildEnvironmentHelper.Instance.MSBuildToolsDirectory32, "SdkResolvers"), location);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public virtual void ClearCaches()
/// <inheritdoc cref="ISdkResolverService.ResolveSdk"/>
public virtual SdkResult ResolveSdk(int submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, string solutionPath, string projectPath, bool interactive, bool isRunningInVisualStudio, bool failOnUnresolvedSdk)
{
// If we are running in .NET core, we ask the built-in default resolver first.
// If we are running in .NET core, we ask the built-in default resolver first.
// - It is a perf optimization (no need to discover and load any of the plug-in assemblies to resolve an "in-box" Sdk).
// - It brings `dotnet build` to parity with `MSBuild.exe` functionally, as the Framework build of Microsoft.DotNet.MSBuildSdkResolver
// contains the same logic and it is the first resolver in priority order.
Expand Down
3 changes: 2 additions & 1 deletion src/Build/BuildCheck/API/CheckConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class CheckConfiguration
/// If all rules within the check are not enabled, it will not be run.
/// If some rules are enabled and some are not, the check will be run and reports will be post-filtered.
/// </summary>
public bool? IsEnabled {
public bool? IsEnabled
{
get
{
// Do not consider Default as enabled, because the default severity of the rule could be set to None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void HandleBuildFinishedEvent(BuildFinishedEventArgs eventArgs)

private void LogCheckStats(ICheckContext checkContext)
{
Dictionary<string, TimeSpan> infraStats = _tracingData.InfrastructureTracingData;
Dictionary<string, TimeSpan> infraStats = _tracingData.InfrastructureTracingData;
// Stats are per rule, while runtime is per check - and check can have multiple rules.
// In case of multi-rule check, the runtime stats are duplicated for each rule.
Dictionary<string, TimeSpan> checkStats = _tracingData.ExtractCheckStats();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void DispatchBuildEvent(BuildEventArgs buildEvent)

public void DispatchAsComment(MessageImportance importance, string messageResourceName, params object?[] messageArgs)
{
ErrorUtilities.VerifyThrowInternalLength(messageResourceName,nameof(messageResourceName));
ErrorUtilities.VerifyThrowInternalLength(messageResourceName, nameof(messageResourceName));

DispatchAsCommentFromText(_eventContext, importance, ResourceUtilities.GetResourceString(messageResourceName), messageArgs);
}
Expand Down
Loading
Loading