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

Project experimental attribute #1244

Merged
merged 1 commit into from
Aug 16, 2022
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
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