Skip to content

Commit b03c550

Browse files
Copilotanupriya13
andcommitted
Remove deprecated autolink functionality to copy useWinUI3 flags from react-native.config.js
Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
1 parent 509c7a1 commit b03c550

File tree

3 files changed

+2
-140
lines changed

3 files changed

+2
-140
lines changed

packages/@react-native-windows/cli/src/commands/autolinkWindows/autolinkWindows.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ export class AutoLinkWindows {
712712

713713
public async ensureXAMLDialect() {
714714
let changesNeeded = false;
715-
const useWinUI3FromConfig = this.getWindowsConfig().useWinUI3;
716715
const experimentalFeatures = this.getExperimentalFeaturesPropsXml();
717716
if (experimentalFeatures) {
718717
const useWinUI3FromExperimentalFeatures =
@@ -729,30 +728,12 @@ export class AutoLinkWindows {
729728
experimentalFeatures.content,
730729
'WinUI3Version',
731730
);
732-
// Use the UseWinUI3 value in react-native.config.js, or if not present, the value from ExperimentalFeatures.props
731+
// Use the UseWinUI3 value from ExperimentalFeatures.props
733732
changesNeeded = await this.updatePackagesConfigXAMLDialect(
734-
useWinUI3FromConfig !== undefined
735-
? useWinUI3FromConfig
736-
: useWinUI3FromExperimentalFeatures,
733+
useWinUI3FromExperimentalFeatures,
737734
targetWinUI2xVersion,
738735
targetWinUI3xVersion,
739736
);
740-
if (useWinUI3FromConfig !== undefined) {
741-
// Make sure ExperimentalFeatures.props matches the value that comes from react-native.config.js
742-
const node =
743-
experimentalFeatures.content.getElementsByTagName('UseWinUI3');
744-
const newValue = useWinUI3FromConfig ? 'true' : 'false';
745-
changesNeeded = node.item(0)?.textContent !== newValue || changesNeeded;
746-
if (!this.options.check && changesNeeded) {
747-
node.item(0)!.textContent = newValue;
748-
const experimentalFeaturesOutput =
749-
new XMLSerializer().serializeToString(experimentalFeatures.content);
750-
await this.updateFile(
751-
experimentalFeatures.path,
752-
experimentalFeaturesOutput,
753-
);
754-
}
755-
}
756737
}
757738
return changesNeeded;
758739
}

packages/@react-native-windows/cli/src/e2etest/autolink.test.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -249,81 +249,7 @@ test('one valid cs autolink dependency', () => {
249249
);
250250
});
251251

252-
test('ensureXAMLDialect - useWinUI3=true in react-native.config.js, useWinUI3=false in ExperimentalFeatures.props', async () => {
253-
const folder = path.resolve('src/e2etest/projects/WithWinUI3');
254-
255-
// Create project with UseWinUI3 == false in ExperimentalFeatures.props
256-
await ensureCppAppProject(folder, 'WithWinUI3', false, false, false);
257-
258-
const rnc = require(path.join(folder, 'react-native.config.js'));
259-
260-
const config = projectConfigWindows(folder, rnc.project.windows)!;
261-
// Set useWinUI3=true in react-native.config.js
262-
config.useWinUI3 = true;
263-
264-
const al = new AutoLinkTest(
265-
{windows: config},
266-
{},
267-
{
268-
check: false,
269-
logging: false,
270-
},
271-
);
272-
al.experimentalFeaturesProps = `<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3></PropertyGroup></Project>`;
273-
al.packagesConfig = `<packages><package id="SuperPkg" version="42"/></packages>`;
274-
275-
const exd = await al.ensureXAMLDialect();
276-
expect(exd).toBeTruthy();
277-
278-
const expectedExperimentalFeatures =
279-
'<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3></PropertyGroup></Project>';
280-
expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
281-
282-
// example packages.config:
283-
// <packages>
284-
// <package id="SuperPkg" version="42"/>
285-
// <package id="Microsoft.WindowsAppSDK" version="1.0.0" targetFramework="native"/>
286-
// </packages>
287-
//
288-
expect(al.packagesConfig).toContain('Microsoft.WindowsAppSDK');
289-
expect(al.packagesConfig).toContain('<package id="SuperPkg" version="42"/>');
290-
expect(al.packagesConfig).not.toContain('Microsoft.UI.Xaml');
291-
});
292-
293-
test('ensureXAMLDialect - useWinUI3=false in react-native.config.js, useWinUI3=true in ExperimentalFeatures.props', async () => {
294-
const folder = path.resolve('src/e2etest/projects/WithWinUI3');
295-
const rnc = require(path.join(folder, 'react-native.config.js'));
296-
297-
const config = projectConfigWindows(folder, rnc.project.windows)!;
298-
config.useWinUI3 = false;
299-
const al = new AutoLinkTest(
300-
{windows: config},
301-
{},
302-
{
303-
check: false,
304-
logging: false,
305-
},
306-
);
307-
al.experimentalFeaturesProps = `<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3></PropertyGroup></Project>`;
308-
al.packagesConfig = `<packages><package id="SuperPkg" version="42"/></packages>`;
309252

310-
const exd = await al.ensureXAMLDialect();
311-
expect(exd).toBeTruthy();
312-
313-
const expectedExperimentalFeatures =
314-
'<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3></PropertyGroup></Project>';
315-
expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
316-
317-
// example packages.config:
318-
// <packages>
319-
// <package id="SuperPkg" version="42"/>
320-
// <package id="Microsoft.WindowsAppSDK" version="1.0.0" targetFramework="native"/>
321-
// </packages>
322-
//
323-
expect(al.packagesConfig).not.toContain('Microsoft.WindowsAppSDK');
324-
expect(al.packagesConfig).toContain('<package id="SuperPkg" version="42"/>');
325-
expect(al.packagesConfig).toContain('Microsoft.UI.Xaml');
326-
});
327253

328254
test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=true in ExperimentalFeatures.props', async () => {
329255
const folder = path.resolve('src/e2etest/projects/WithWinUI3');

packages/@react-native-windows/cli/src/e2etest/projectConfig.test.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -119,48 +119,3 @@ test.each(projects)(
119119
}
120120
},
121121
);
122-
123-
// Skipping this test as the feature is broken and needs to be removed, see https://github.com/microsoft/react-native-windows/issues/14601
124-
test.skip('useWinUI3=true in react-native.config.js, UseWinUI3=false in ExperimentalFeatures.props', async () => {
125-
const folder = path.resolve('src/e2etest/projects/WithWinUI3');
126-
127-
// Create project with UseWinUI3 == false in ExperimentalFeatures.props
128-
await ensureCppAppProject(folder, 'WithWinUI3', false, false, false);
129-
130-
const rnc = require(path.join(folder, 'react-native.config.js'));
131-
132-
const config = projectConfigWindows(folder, rnc.project.windows)!;
133-
// Set useWinUI3=true in react-native.config.js
134-
config.useWinUI3 = true;
135-
136-
const experimentalFeaturesPropsFile = path.join(
137-
folder,
138-
'windows/ExperimentalFeatures.props',
139-
);
140-
141-
// Verify starting props file
142-
const startingExperimentalFeatures = (
143-
await fs.readFile(experimentalFeaturesPropsFile)
144-
).toString();
145-
expect(startingExperimentalFeatures.replace(/\r/g, '')).toMatchSnapshot();
146-
147-
// Run Autolink to sync the files
148-
const al = new AutoLinkWindows(
149-
{windows: config},
150-
{},
151-
{
152-
check: false,
153-
logging: false,
154-
},
155-
);
156-
157-
const exd = await al.ensureXAMLDialect();
158-
expect(exd).toBeTruthy();
159-
160-
// Verify ending props file
161-
const finalExperimentalFeatures = (
162-
await fs.readFile(experimentalFeaturesPropsFile)
163-
).toString();
164-
165-
expect(finalExperimentalFeatures.replace(/\r/g, '')).toMatchSnapshot();
166-
});

0 commit comments

Comments
 (0)