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

Feature Query API #9665

Merged
merged 25 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
49bed0e
implement CheckFeatureAvailability
surayya-MS Jan 18, 2024
28297c6
add command line support for feature availability
surayya-MS Jan 19, 2024
14e7a32
Update src/Framework/FeatureAvailabilityChecker.cs
surayya-MS Jan 22, 2024
d018cc0
change NotFound to 0 in FeatureStatus
surayya-MS Jan 23, 2024
d896fa8
support ask for multiple features displayed in json format
surayya-MS Jan 23, 2024
d00b86e
do not show logo if featureavailability switch is set
surayya-MS Jan 23, 2024
c9d4b4f
add featureavailability switch unit test
surayya-MS Jan 23, 2024
b9f85c6
support property function
surayya-MS Jan 24, 2024
7d30eb4
small fix
surayya-MS Jan 24, 2024
a5511f9
Update src/MSBuild/Resources/Strings.resx
surayya-MS Jan 30, 2024
a66e4bc
rename class
surayya-MS Jan 30, 2024
7367226
small fix
surayya-MS Jan 30, 2024
27a27e4
add comment for NumberOfParameterlessSwitches and NumberOfParameteriz…
surayya-MS Jan 30, 2024
c356250
fix MissingFeatureAvailabilityError text
surayya-MS Jan 30, 2024
aee5520
rename file
surayya-MS Jan 30, 2024
5b52a0a
update strings
surayya-MS Jan 30, 2024
fd217d1
update comment for Features class
surayya-MS Jan 30, 2024
0ede528
add Preview status
surayya-MS Jan 31, 2024
68ff297
make _featureStatusMap readonly
surayya-MS Feb 1, 2024
c0fdfce
Update src/Framework/Features.cs
surayya-MS Feb 1, 2024
b61ca22
remove features from the _featureStatusMap
surayya-MS Feb 1, 2024
c915554
Merge branch 'queryAPI' of https://github.com/surayya-MS/msbuild into…
surayya-MS Feb 1, 2024
63034eb
fix test
surayya-MS Feb 1, 2024
4ce6e30
use Undefined instead of NotFound status
surayya-MS Feb 1, 2024
2852cd6
rename variable
surayya-MS Feb 5, 2024
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
60 changes: 60 additions & 0 deletions src/Framework/FeatureAvailabilityChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Build.Framework
{
/// <summary>
/// The status of a feature.
/// </summary>
public enum FeatureStatus
{
/// <summary>
/// The feature is available.
/// </summary>
Available,
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// The feature is not available.
/// </summary>
NotAvailable,

/// <summary>
/// The feature is not found.
/// </summary>
NotFound,

// TODO: Add more status if needed
// Preview,
// Deprecated,
}

/// <summary>
/// This class is used to check if a feature is available or not.
/// </summary>
public static class FeatureAvailabilityChecker
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
{
private static Dictionary<string, FeatureStatus> _featureStatusMap = new Dictionary<string, FeatureStatus>
{
// TODO: Fill in the dictionary with the features and their status
{ "Feature1", FeatureStatus.Available },
{ "Feature2", FeatureStatus.NotAvailable },
};

/// <summary>
/// Checks if a feature is available or not.
/// </summary>
/// <param name="featureName">The name of the feature.</param>
/// <returns>A feature status <see cref="FeatureStatus"/>.</returns>
public static FeatureStatus CheckFeatureAvailability(string featureName)
{
return _featureStatusMap.ContainsKey(featureName) ?
_featureStatusMap[featureName] : FeatureStatus.NotFound;
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
5 changes: 4 additions & 1 deletion src/MSBuild/CommandLineSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ internal enum ParameterlessSwitch
#if DEBUG
WaitForDebugger,
#endif
NumberOfParameterlessSwitches
NumberOfParameterlessSwitches,
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
FeautureAvailability
}

/// <summary>
Expand Down Expand Up @@ -115,6 +116,7 @@ internal enum ParameterizedSwitch
GetProperty,
GetItem,
GetTargetResult,
FeatureAvailability,
NumberOfParameterizedSwitches,
}

Expand Down Expand Up @@ -280,6 +282,7 @@ internal ParameterizedSwitchInfo(
new ParameterizedSwitchInfo( new string[] { "getProperty" }, ParameterizedSwitch.GetProperty, null, true, "MissingGetPropertyError", true, false),
new ParameterizedSwitchInfo( new string[] { "getItem" }, ParameterizedSwitch.GetItem, null, true, "MissingGetItemError", true, false),
new ParameterizedSwitchInfo( new string[] { "getTargetResult" }, ParameterizedSwitch.GetTargetResult, null, true, "MissingGetTargetResultError", true, false),
new ParameterizedSwitchInfo( new string[] { "featureavailability", "fa" }, ParameterizedSwitch.FeatureAvailability, "DuplicateFeatureAvailability", false, "MissingFeatureAvailabilityError", true, false),
};

/// <summary>
Expand Down
14 changes: 13 additions & 1 deletion src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,14 @@
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized.
</comment>
</data>
<data name="MissingFeatureAvailabilityError" UESanitized="true" Visibility="Public">
<value>MSBUILD : error MSB1067: Must provide a property name for the featureavailability switch.</value>
<comment>
{StrBegin="MSBUILD : error MSB1067: "}UE: This happens if the user does something like "msbuild.exe -featureavailability". The user must pass in an actual property name
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
following the switch, as in "msbuild.exe -featureavailability:blah".
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized.
</comment>
</data>
<data name="MissingGetItemError" UESanitized="true" Visibility="Public">
<value>MSBUILD : error MSB1014: Must provide an item name for the getItem switch.</value>
<comment>
Expand Down Expand Up @@ -1397,6 +1405,10 @@
<value>MSBUILD : error MSB1058: Only one output results cache can be specified.</value>
<comment>{StrBegin="MSBUILD : error MSB1058: "}</comment>
</data>
<data name="DuplicateFeatureAvailability" UESanitized="true" Visibility="Public">
<value>MSBUILD : error MSB1068: Only one feature availability can be specified.</value>
<comment>{StrBegin="MSBUILD : error MSB1068: "}</comment>
</data>
<data name="OptionalLoggerCreationMessage" UESanitized="true" Visibility="Public">
<value>The specified logger "{0}" could not be created and will not be used. {1}</value>
<comment>
Expand Down Expand Up @@ -1559,7 +1571,7 @@
<!--
The command line message bucket is: MSB1001 - MSB1999

Next error code should be MSB1067.
Next error code should be MSB1069.

Don't forget to update this comment after using the new code.
-->
Expand Down
14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading