Skip to content

Commit

Permalink
Project experimental attribute (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
manodasanW authored Aug 16, 2022
1 parent d2b8054 commit 38c0133
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Tests/TestComponentCSharp/CustomExperimentClass.cpp
Original file line number Diff line number Diff line change
@@ -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()
{
}
}
20 changes: 20 additions & 0 deletions src/Tests/TestComponentCSharp/CustomExperimentClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "CustomExperimentClass.g.h"

namespace winrt::TestComponentCSharp::implementation
{
struct CustomExperimentClass : CustomExperimentClassT<CustomExperimentClass>
{
CustomExperimentClass() = default;

int32_t Value();
void Value(int32_t value);
void f();
};
}
namespace winrt::TestComponentCSharp::factory_implementation
{
struct CustomExperimentClass : CustomExperimentClassT<CustomExperimentClass, implementation::CustomExperimentClass>
{
};
}
9 changes: 9 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<ItemGroup>
<ClInclude Include="ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.h" />
<ClInclude Include="AnotherAssembly.SetPropertyClass.h" />
<ClInclude Include="CustomExperimentClass.h" />
<ClInclude Include="CustomEquals.h" />
<ClInclude Include="ManualProjectionTestClasses.h" />
<ClInclude Include="pch.h" />
Expand All @@ -97,6 +98,7 @@
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.cpp" />
<ClCompile Include="AnotherAssembly.SetPropertyClass.cpp" />
<ClCompile Include="CustomExperimentClass.cpp" />
<ClCompile Include="CustomEquals.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ClCompile Include="ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.cpp" />
<ClCompile Include="AnotherAssembly.SetPropertyClass.cpp" />
<ClCompile Include="CustomEquals.cpp" />
<ClCompile Include="CustomExperimentClass.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand All @@ -33,6 +34,7 @@
<ClInclude Include="ABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVQXYZabcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.h" />
<ClInclude Include="AnotherAssembly.SetPropertyClass.h" />
<ClInclude Include="CustomEquals.h" />
<ClInclude Include="CustomExperimentClass.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="TestComponentCSharp.idl" />
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
3 changes: 2 additions & 1 deletion src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 38c0133

Please sign in to comment.