From b2c233c0864f2c2fc8f3f52608d62777f7408aa6 Mon Sep 17 00:00:00 2001 From: Jan Krivanek Date: Sun, 11 Aug 2024 12:45:43 +0200 Subject: [PATCH 1/2] Rename - fix casing of IMSBuildElementLocation --- src/Build/BuildCheck/Infrastructure/CheckScopeClassifier.cs | 2 +- .../BuildCheck/Infrastructure/InternalOM/PropertyReadInfo.cs | 2 +- .../BuildCheck/Infrastructure/InternalOM/PropertyWriteInfo.cs | 2 +- src/Build/BuildCheck/OM/PropertyReadData.cs | 4 ++-- src/Build/BuildCheck/OM/PropertyWriteData.cs | 4 ++-- src/Shared/IElementLocation.cs | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Build/BuildCheck/Infrastructure/CheckScopeClassifier.cs b/src/Build/BuildCheck/Infrastructure/CheckScopeClassifier.cs index fdd3e04ebcc..58002c5a2e9 100644 --- a/src/Build/BuildCheck/Infrastructure/CheckScopeClassifier.cs +++ b/src/Build/BuildCheck/Infrastructure/CheckScopeClassifier.cs @@ -19,7 +19,7 @@ internal static class CheckScopeClassifier /// internal static bool IsActionInObservedScope( EvaluationCheckScope scope, - IMsBuildElementLocation? location, + IMSBuildElementLocation? location, string projectFileFullPath) => IsActionInObservedScope(scope, location?.File, projectFileFullPath); diff --git a/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyReadInfo.cs b/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyReadInfo.cs index 7b04208bc25..9fa2029535a 100644 --- a/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyReadInfo.cs +++ b/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyReadInfo.cs @@ -19,6 +19,6 @@ internal readonly record struct PropertyReadInfo( string PropertyName, int StartIndex, int EndIndex, - IMsBuildElementLocation ElementLocation, + IMSBuildElementLocation ElementLocation, bool IsUninitialized, PropertyReadContext PropertyReadContext); diff --git a/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyWriteInfo.cs b/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyWriteInfo.cs index 96046f59eae..b93e256dac6 100644 --- a/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyWriteInfo.cs +++ b/src/Build/BuildCheck/Infrastructure/InternalOM/PropertyWriteInfo.cs @@ -14,4 +14,4 @@ namespace Microsoft.Build.Experimental.BuildCheck.Infrastructure; internal readonly record struct PropertyWriteInfo( string PropertyName, bool IsEmpty, - IMsBuildElementLocation? ElementLocation); + IMSBuildElementLocation? ElementLocation); diff --git a/src/Build/BuildCheck/OM/PropertyReadData.cs b/src/Build/BuildCheck/OM/PropertyReadData.cs index 1dda8388419..3599b381a5d 100644 --- a/src/Build/BuildCheck/OM/PropertyReadData.cs +++ b/src/Build/BuildCheck/OM/PropertyReadData.cs @@ -15,7 +15,7 @@ internal class PropertyReadData( string projectFilePath, int? projectConfigurationId, string propertyName, - IMsBuildElementLocation elementLocation, + IMSBuildElementLocation elementLocation, bool isUninitialized, PropertyReadContext propertyReadContext) : CheckData(projectFilePath, projectConfigurationId) @@ -40,7 +40,7 @@ public PropertyReadData( /// /// Location of the property access. /// - public IMsBuildElementLocation ElementLocation { get; } = elementLocation; + public IMSBuildElementLocation ElementLocation { get; } = elementLocation; /// /// Indicates whether the property was accessed before being initialized. diff --git a/src/Build/BuildCheck/OM/PropertyWriteData.cs b/src/Build/BuildCheck/OM/PropertyWriteData.cs index ec5745ac791..c15ac695031 100644 --- a/src/Build/BuildCheck/OM/PropertyWriteData.cs +++ b/src/Build/BuildCheck/OM/PropertyWriteData.cs @@ -15,7 +15,7 @@ internal class PropertyWriteData( string projectFilePath, int? projectConfigurationId, string propertyName, - IMsBuildElementLocation? elementLocation, + IMSBuildElementLocation? elementLocation, bool isEmpty) : CheckData(projectFilePath, projectConfigurationId) { @@ -37,7 +37,7 @@ public PropertyWriteData(string projectFilePath, int? projectConfigurationId, Pr /// If the location is null, it means that the property doesn't come from xml, but rather other sources /// (environment variable, global property, toolset properties etc.). /// - public IMsBuildElementLocation? ElementLocation { get; } = elementLocation; + public IMSBuildElementLocation? ElementLocation { get; } = elementLocation; /// /// Was any value written? (E.g. if we set propA with value propB, while propB is undefined - the isEmpty will be true). diff --git a/src/Shared/IElementLocation.cs b/src/Shared/IElementLocation.cs index 1623d1582eb..b85a483a2e5 100644 --- a/src/Shared/IElementLocation.cs +++ b/src/Shared/IElementLocation.cs @@ -7,7 +7,7 @@ namespace Microsoft.Build.Shared { - internal interface IElementLocation : IMsBuildElementLocation, ITranslatable { } + internal interface IElementLocation : IMSBuildElementLocation, ITranslatable { } /// /// Represents the location information for error reporting purposes. This is normally used to @@ -20,7 +20,7 @@ internal interface IElementLocation : IMsBuildElementLocation, ITranslatable { } /// This is currently internal - but it is prepared to be made public once it will be needed by other public BuildCheck OM /// (e.g. by property read/write OM) /// - public interface IMsBuildElementLocation + public interface IMSBuildElementLocation { /// /// The file from which this particular element originated. It may From 304ec6d0b37f024cd22bc78bc247346e1113df17 Mon Sep 17 00:00:00 2001 From: Jan Krivanek Date: Sun, 11 Aug 2024 12:54:17 +0200 Subject: [PATCH 2/2] Rename round 2 --- src/Build/BuildCheck/API/BuildCheckResult.cs | 6 +++--- .../BuildCheck/Checks/PropertiesUsageCheck.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Build/BuildCheck/API/BuildCheckResult.cs b/src/Build/BuildCheck/API/BuildCheckResult.cs index 37203165c79..f9184127aa7 100644 --- a/src/Build/BuildCheck/API/BuildCheckResult.cs +++ b/src/Build/BuildCheck/API/BuildCheckResult.cs @@ -17,12 +17,12 @@ namespace Microsoft.Build.Experimental.BuildCheck; /// public sealed class BuildCheckResult : IBuildCheckResult { - public static BuildCheckResult Create(CheckRule rule, IMsBuildElementLocation location, params string[] messageArgs) + public static BuildCheckResult Create(CheckRule rule, IMSBuildElementLocation location, params string[] messageArgs) { return new BuildCheckResult(rule, location, messageArgs); } - public BuildCheckResult(CheckRule checkConfig, IMsBuildElementLocation location, string[] messageArgs) + public BuildCheckResult(CheckRule checkConfig, IMSBuildElementLocation location, string[] messageArgs) { CheckRule = checkConfig; Location = location; @@ -43,7 +43,7 @@ internal BuildEventArgs ToEventArgs(CheckResultSeverity severity) /// /// Optional location of the finding (in near future we might need to support multiple locations). /// - public IMsBuildElementLocation Location { get; } + public IMSBuildElementLocation Location { get; } public string LocationString => Location.LocationString; diff --git a/src/Build/BuildCheck/Checks/PropertiesUsageCheck.cs b/src/Build/BuildCheck/Checks/PropertiesUsageCheck.cs index 5af02c861ee..f2e7d2fc37a 100644 --- a/src/Build/BuildCheck/Checks/PropertiesUsageCheck.cs +++ b/src/Build/BuildCheck/Checks/PropertiesUsageCheck.cs @@ -118,13 +118,13 @@ public override void RegisterInternalActions(IInternalCheckRegistrationContext r } } - private Dictionary _writenProperties = new(MSBuildNameIgnoreCaseComparer.Default); + private Dictionary _writenProperties = new(MSBuildNameIgnoreCaseComparer.Default); private HashSet _readProperties = new(MSBuildNameIgnoreCaseComparer.Default); // For the 'Property Initialized after used' check - we are interested in cases where: // 1. Property is read anywhere and then initialized in the checked scope. // 2. Property is read in the checked scope and then initialized anywhere. - private Dictionary _uninitializedReadsInScope = new(MSBuildNameIgnoreCaseComparer.Default); - private Dictionary _uninitializedReadsOutOfScope = new(MSBuildNameIgnoreCaseComparer.Default); + private Dictionary _uninitializedReadsInScope = new(MSBuildNameIgnoreCaseComparer.Default); + private Dictionary _uninitializedReadsOutOfScope = new(MSBuildNameIgnoreCaseComparer.Default); private void ProcessPropertyWrite(BuildCheckDataContext context) { @@ -142,7 +142,7 @@ private void ProcessPropertyWrite(BuildCheckDataContext conte // For initialized after used check - we can remove the read from dictionary after hitting write - because // once the property is written it should no more be uninitialized (so shouldn't be added again). - if (_uninitializedReadsInScope.TryGetValue(writeData.PropertyName, out IMsBuildElementLocation? uninitInScopeReadLocation)) + if (_uninitializedReadsInScope.TryGetValue(writeData.PropertyName, out IMSBuildElementLocation? uninitInScopeReadLocation)) { _uninitializedReadsInScope.Remove(writeData.PropertyName); @@ -154,7 +154,7 @@ private void ProcessPropertyWrite(BuildCheckDataContext conte if (CheckScopeClassifier.IsActionInObservedScope(_initializedAfterUseScope, writeData.ElementLocation, writeData.ProjectFilePath) && - _uninitializedReadsOutOfScope.TryGetValue(writeData.PropertyName, out IMsBuildElementLocation? uninitOutScopeReadLocation)) + _uninitializedReadsOutOfScope.TryGetValue(writeData.PropertyName, out IMSBuildElementLocation? uninitOutScopeReadLocation)) { _uninitializedReadsOutOfScope.Remove(writeData.PropertyName); @@ -236,7 +236,7 @@ private void DoneWithProject(BuildCheckDataContext(MSBuildNameIgnoreCaseComparer.Default); - _writenProperties = new Dictionary(MSBuildNameIgnoreCaseComparer.Default); - _uninitializedReadsInScope = new Dictionary(MSBuildNameIgnoreCaseComparer.Default); + _writenProperties = new Dictionary(MSBuildNameIgnoreCaseComparer.Default); + _uninitializedReadsInScope = new Dictionary(MSBuildNameIgnoreCaseComparer.Default); } }