From 38c013380338fa9901bb5ed3488d8d5c43a94acc Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Tue, 16 Aug 2022 10:13:07 -0700 Subject: [PATCH] Project experimental attribute (#1244) --- .../CustomExperimentClass.cpp | 17 ++++++++++++++++ .../CustomExperimentClass.h | 20 +++++++++++++++++++ .../TestComponentCSharp.idl | 9 +++++++++ .../TestComponentCSharp.vcxproj | 2 ++ .../TestComponentCSharp.vcxproj.filters | 2 ++ .../UnitTest/TestComponentCSharp_Tests.cs | 7 +++++++ src/cswinrt/code_writers.h | 3 ++- 7 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/Tests/TestComponentCSharp/CustomExperimentClass.cpp create mode 100644 src/Tests/TestComponentCSharp/CustomExperimentClass.h diff --git a/src/Tests/TestComponentCSharp/CustomExperimentClass.cpp b/src/Tests/TestComponentCSharp/CustomExperimentClass.cpp new file mode 100644 index 000000000..4527c67d6 --- /dev/null +++ b/src/Tests/TestComponentCSharp/CustomExperimentClass.cpp @@ -0,0 +1,17 @@ +#include "pch.h" +#include "CustomExperimentClass.h" +#include "CustomExperimentClass.g.cpp" + +namespace winrt::TestComponentCSharp::implementation +{ + int32_t CustomExperimentClass::Value() + { + return 4; + } + void CustomExperimentClass::Value(int32_t value) + { + } + void CustomExperimentClass::f() + { + } +} diff --git a/src/Tests/TestComponentCSharp/CustomExperimentClass.h b/src/Tests/TestComponentCSharp/CustomExperimentClass.h new file mode 100644 index 000000000..6dfe2d15f --- /dev/null +++ b/src/Tests/TestComponentCSharp/CustomExperimentClass.h @@ -0,0 +1,20 @@ +#pragma once +#include "CustomExperimentClass.g.h" + +namespace winrt::TestComponentCSharp::implementation +{ + struct CustomExperimentClass : CustomExperimentClassT + { + CustomExperimentClass() = default; + + int32_t Value(); + void Value(int32_t value); + void f(); + }; +} +namespace winrt::TestComponentCSharp::factory_implementation +{ + struct CustomExperimentClass : CustomExperimentClassT + { + }; +} \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.idl b/src/Tests/TestComponentCSharp/TestComponentCSharp.idl index 2f44d0827..17af1636b 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.idl +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.idl @@ -590,6 +590,15 @@ And this is another one" Boolean Equals(UnSealedCustomEquals other); } + [default_interface] + [experimental] + runtimeclass CustomExperimentClass + { + CustomExperimentClass(); + Int32 Value{ get; set; }; + void f(); + } + // Compile time test for sub windows namespace namespace Windows { diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj index d014d2c83..cbbd048ac 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj @@ -80,6 +80,7 @@ + @@ -97,6 +98,7 @@ + Create diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters index e71b1a1c7..f87e12554 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters @@ -20,6 +20,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs index 2c21387e4..6badd330a 100644 --- a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs +++ b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs @@ -2905,5 +2905,12 @@ public void TestObjectFunctions() Assert.True(eighth.Equals(seventh)); Assert.False(seventh.Equals(eighth)); } + + // Manually verify warning for experimental. + private void TestExperimentAttribute() + { + CustomExperimentClass custom = new CustomExperimentClass(); + custom.f(); + } } } diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h index 5d8b5b025..26bc84faf 100644 --- a/src/cswinrt/code_writers.h +++ b/src/cswinrt/code_writers.h @@ -1697,7 +1697,8 @@ remove => %; allow_multiple = true; } if (attribute_name != "DefaultOverload" && attribute_name != "Overload" && - attribute_name != "AttributeUsage" && attribute_name != "ContractVersion") + attribute_name != "AttributeUsage" && attribute_name != "ContractVersion" && + attribute_name != "Experimental") { continue; }