I have a custom view marked as obsolete with
[Obsolete("AccordionButton is deprecated, please use HeaderButton instead.")]
by adding this attribute to the *.xaml.cs file. Now I'm getting a warning in the xaml.g.cs file on compilation, because it is a partial class (consisting of *.xaml and *.xaml.cs code behind file).
I don't understand why I'm getting the warning, the view isn't used anywhere else. Yes, I could delete the file, but out of curiosity why doesn't he check that this is a partial class? How can I get rid of the warning and keeping the Obsolete
attribute at the same time?
Edit:
Here is the 'full' code:
AccordionButton.xaml.cs
using MyProject.Common.CustomRenderers;
using System;
using Xamarin.Forms;
namespace MyProject.Views
{
#pragma warning disable 618
[Obsolete("AccordionButton is deprecated, please use HeaderButton instead.")]
public partial class AccordionButton : MultiLineButton
{
private bool expand = false;
public bool Expand
{
get{ return this.expand;}
set{ this.expand = value;}
}
public ContentView AssociatedContent { get; set; }
public AccordionButton()
{
}
}
#pragma warning restore 618
}
AccordionButton.xaml
<?xml version="1.0" encoding="utf-8" ?>
<customViews:MultiLineButton xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyProject.Views.AccordionButton"
xmlns:customViews="clr-namespace:MyProject.Views;assembly=MyProject">
</customViews:MultiLineButton>
AccordionButton.xaml.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("MyProject.Views.AccordionButton.xaml", "Views/AccordionButton.xaml", typeof(global::MyProject.Views.AccordionButton))]
namespace MyProject.Views {
[global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Views\\AccordionButton.xaml")]
public partial class AccordionButton : global::MyProject.Views.MultiLineButton {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(AccordionButton));
}
}
}
If I double click the warning he marks this part global::MyProject.Views.AccordionButton
. The warning only appears after compiling ...
When I compare this to a test project (where everything is working fine) the AccordionButton.xaml.g.cs looks like this
[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("TestObsolete.Views.AccordionButton.xaml", "Views/AccordionButton.xaml", null)]
So there is something in my project which is different, but I haven't figured out what and why.