Skip to content

Add mapping from ContractVersion attrib to SupportedOSPlatform attrib for VS compat assistance - #557

Merged
Scott Jones (Scottj1s) merged 12 commits into
masterfrom
scottj1s/SupportedOSPlatform
Jan 14, 2021
Merged

Scott Jones (Scottj1s) merged 12 commits into
masterfrom
scottj1s/SupportedOSPlatform

Conversation

@Scottj1s

@Scottj1s Scott Jones (Scottj1s) commented Nov 2, 2020 •

Copy link
Copy Markdown
Member

For details on how SupportedOSPlatform works, see:
Platform compatibility analyzer
OS version in TFMs
Annotating APIs as unsupported on specific platforms
CA1416: Validate platform compatibility

Note that the SupportedOSPlatform attribute is documented as only valid on:
assembly, module, class, struct, enum, constructor, method, property, indexer, field, event
By experiment, attributes are also supported.
interface, delegate, contract are NOT supported.

fixes #411

Comment thread cswinrt/code_writers.h Resolved
Comment thread cswinrt/code_writers.h Resolved
@Scottj1s
Scott Jones (Scottj1s) force-pushed the scottj1s/SupportedOSPlatform branch from 839f4b5 to d53416b Compare January 11, 2021 01:34
@Scottj1s
Scott Jones (Scottj1s) force-pushed the scottj1s/SupportedOSPlatform branch from d53416b to 490ecb5 Compare January 11, 2021 01:35
@manodasanW

Copy link
Copy Markdown
Member

APICompat run on Windows SDK projection:

microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFile)' does not exist in the implementation but it does exist in the contract.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFolder, System.String)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFile)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFolder, System.String, Windows.Storage.CreationCollisionOption)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelFeatureDescriptor' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelFeatureValue' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelOperatorProvider' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ImageFeatureDescriptor' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ActivatableAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.DualApiPartitionAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.MarshalingBehaviorAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.StaticAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ThreadingAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.

The first three might be issues? I wonder if the others really have a API compat issue?

@Scottj1s

Scott Jones (Scottj1s) commented Jan 14, 2021 •

Copy link
Copy Markdown
Member Author

APICompat run on Windows SDK projection:

microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFile)' does not exist in the implementation but it does exist in the contract.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFolder, System.String)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFile)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : MembersMustExist : Member 'public System.Threading.Tasks.Task<System.IO.Stream> System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFolder, System.String, Windows.Storage.CreationCollisionOption)' does not exist in the implementation but it does exist in the contract. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelFeatureDescriptor' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelFeatureValue' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ILearningModelOperatorProvider' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.ImageFeatureDescriptor' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ActivatableAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ContractVersionAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.DualApiPartitionAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.MarshalingBehaviorAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.StaticAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation. 
microsoft.dotnet.apicompat\5.0.0-beta.20560.3\build\Microsoft.DotNet.ApiCompat.targets(82,5): error : CannotRemoveAttribute : Attribute 'Windows.Foundation.Metadata.ThreadingAttribute' exists on 'Windows.AI.MachineLearning.LearningModelDevice' in the contract but not the implementation.

The first three might be issues? I wonder if the others really have a API compat issue?

I removed the metadata attributes because they seemed completely unnecessary at the projection layer (and because some of them were generating CA1416 noise). It's possible someone might be reflecting on them, which would make this a breaking change, but I can't imagine for what purpose.

The first 4 are resolved with reverting the WindowsRuntimeStorageExtensions Net5 factoring.

@Scottj1s
Scott Jones (Scottj1s) merged commit 86895f6 into master Jan 14, 2021
@Scottj1s
Scott Jones (Scottj1s) deleted the scottj1s/SupportedOSPlatform branch January 14, 2021 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project supported OS version attribute information as SupportedOSPlatform attributes

2 participants