Skip to content

Commit

Permalink
[Xamarin.Android.Build.Task] use global:: for GeneratedCodeAttribute (d…
Browse files Browse the repository at this point in the history
…otnet#4170)

Fixes http://work.azdo.io/1057222

We had the global:: namespace prefix on ALL namespaces
in the Resource.Designer.cs file EXCEPT GeneratedCodeAttribute :facepalm.
So users can get errors like

	The type or namespace name 'CodeDom' does not exist in the namespace Foo.Bar.System

If they use `System` in their defualt namespace for the project.
This commit adds it, so users who use `System` in their
assembly namespaces will not be hit by this in the future.
  • Loading branch information
dellis1972 authored Jan 27, 2020
1 parent 1bee4ad commit 656085a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ public void CheckProjectReferenceAlias ()
}
}

[Test]
public void BuildAppWithSystemNamespace ()
{
var path = Path.Combine (Root, "temp", TestName);
var library = new XamarinAndroidLibraryProject () {
ProjectName = "Library1.System",
};
var proj = new XamarinAndroidApplicationProject () {
References = {
new BuildItem.ProjectReference (Path.Combine("..", library.ProjectName, Path.GetFileName (library.ProjectFilePath)), "Library1.System") {
},
},
};
using (var builder = CreateDllBuilder (Path.Combine (path, library.ProjectName), cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
builder.ThrowOnBuildFailure = false;
Assert.IsTrue (builder.Build (library), "Library should have built.");
using (var b = CreateApkBuilder (Path.Combine (path, proj.ProjectName), cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
b.ThrowOnBuildFailure = false;
Assert.IsTrue (b.Build (proj), "Project should have built.");
}
}
}

[Test]
public void RepetitiveBuild ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Foo.Foo
{


[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Foo.Foo
{


[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Foo.Foo
{


[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public JavaResourceParser ()
};
var asm = Assembly.GetExecutingAssembly().GetName();
var codeAttrDecl =
new CodeAttributeDeclaration("System.CodeDom.Compiler.GeneratedCodeAttribute",
new CodeAttributeDeclaration(new CodeTypeReference ("System.CodeDom.Compiler.GeneratedCodeAttribute", CodeTypeReferenceOptions.GlobalReference),
new CodeAttributeArgument(
new CodePrimitiveExpression(asm.Name)),
new CodeAttributeArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ CodeTypeDeclaration CreateResourceClass ()
};
var asm = Assembly.GetExecutingAssembly ().GetName ();
var codeAttrDecl =
new CodeAttributeDeclaration ("System.CodeDom.Compiler.GeneratedCodeAttribute",
new CodeAttributeDeclaration (new CodeTypeReference ("System.CodeDom.Compiler.GeneratedCodeAttribute", CodeTypeReferenceOptions.GlobalReference),
new CodeAttributeArgument (
new CodePrimitiveExpression (asm.Name)),
new CodeAttributeArgument (
Expand Down

0 comments on commit 656085a

Please sign in to comment.